Skip to contentSkip to conversation

epoll: fix compat syscall wire up of epoll_pwait2

PATCH In review Heiko Carstens 5 participants 8 messages Dec 20, 2020 – Dec 23, 2020

Subsystems (4)
lore
Share & tools
lore

Heiko Carstens

author maintainer
#0 lore raw

PATCH 1/1 epoll: fix compat syscall wire up of epoll_pwait2

Commit b0a0c2615f6f ("epoll: wire up syscall epoll_pwait2") wired up the 64 bit syscall instead of the compat variant in a couple of places.

Cc Willem de Bruijn <[email protected]>
Cc Al Viro <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc "David S. Miller" <[email protected]>
Fixes b0a0c2615f6f ("epoll: wire up syscall epoll_pwait2")
---
 arch/arm64/include/asm/unistd32.h         | 2 +-
 arch/mips/kernel/syscalls/syscall_n32.tbl | 2 +-
 arch/s390/kernel/syscalls/syscall.tbl     | 2 +-
 arch/sparc/kernel/syscalls/syscall.tbl    | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
arch/arm64/include/asm/unistd32.h +1 -1
index f4bca2b90218..cccfbbefbf95 100644
@@ -890,7 +890,7 @@ __SYSCALL(__NR_faccessat2, sys_faccessat2)
 #define __NR_process_madvise 440
 __SYSCALL(__NR_process_madvise, sys_process_madvise)
 #define __NR_epoll_pwait2 441
-__SYSCALL(__NR_epoll_pwait2, sys_epoll_pwait2)
+__SYSCALL(__NR_epoll_pwait2, compat_sys_epoll_pwait2)
 
 /*
  * Please add new compat syscalls above this comment and update
arch/mips/kernel/syscalls/syscall_n32.tbl +1 -1
index ad9c3dd0ab1f..0f03ad223f33 100644
@@ -379,4 +379,4 @@
 438	n32	pidfd_getfd			sys_pidfd_getfd
 439	n32	faccessat2			sys_faccessat2
 440	n32	process_madvise			sys_process_madvise
-441	n32	epoll_pwait2			sys_epoll_pwait2
+441	n32	epoll_pwait2			compat_sys_epoll_pwait2
arch/s390/kernel/syscalls/syscall.tbl +1 -1
index 14f6525886a8..d443423495e5 100644
@@ -443,4 +443,4 @@
 438  common	pidfd_getfd		sys_pidfd_getfd			sys_pidfd_getfd
 439  common	faccessat2		sys_faccessat2			sys_faccessat2
 440  common	process_madvise		sys_process_madvise		sys_process_madvise
-441  common	epoll_pwait2		sys_epoll_pwait2		sys_epoll_pwait2
+441  common	epoll_pwait2		sys_epoll_pwait2		compat_sys_epoll_pwait2
arch/sparc/kernel/syscalls/syscall.tbl +1 -1
index c7da4c3271e6..40d8c7cd8298 100644
@@ -486,4 +486,4 @@
 438	common	pidfd_getfd			sys_pidfd_getfd
 439	common	faccessat2			sys_faccessat2
 440	common	process_madvise			sys_process_madvise
-441	common	epoll_pwait2			sys_epoll_pwait2
+441	common	epoll_pwait2			sys_epoll_pwait2		compat_sys_epoll_pwait2
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Heiko Carstens

Commit b0a0c2615f6f ("epoll: wire up syscall epoll_pwait2") wired up the 64 bit syscall instead of the compat variant in a couple of places.

Cc Willem de Bruijn <[email protected]>
Cc Al Viro <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc "David S. Miller" <[email protected]>
Fixes b0a0c2615f6f ("epoll: wire up syscall epoll_pwait2")
Quoted 6 lines
---
 arch/arm64/include/asm/unistd32.h         | 2 +-
 arch/mips/kernel/syscalls/syscall_n32.tbl | 2 +-
 arch/s390/kernel/syscalls/syscall.tbl     | 2 +-
 arch/sparc/kernel/syscalls/syscall.tbl    | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

I double-checked all the entries to make sure you caught all the missing ones, looks good.

#2 lore raw
Quoted 25 lines · Arnd Bergmann
Quoted 16 lines · Heiko Carstens

Commit b0a0c2615f6f ("epoll: wire up syscall epoll_pwait2") wired up the 64 bit syscall instead of the compat variant in a couple of places.

Cc Willem de Bruijn <[email protected]>
Cc Al Viro <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc "David S. Miller" <[email protected]>
Fixes b0a0c2615f6f ("epoll: wire up syscall epoll_pwait2")
Quoted 6 lines
---
 arch/arm64/include/asm/unistd32.h         | 2 +-
 arch/mips/kernel/syscalls/syscall_n32.tbl | 2 +-
 arch/s390/kernel/syscalls/syscall.tbl     | 2 +-
 arch/sparc/kernel/syscalls/syscall.tbl    | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
Quoted 4 lines

I double-checked all the entries to make sure you caught all the missing ones, looks good.

Thanks a lot. I also arrived at the same list after comparing to epoll_pwait and signalfd (for sigset) and ppoll_time64 (for timespec64).

Slightly tangential, it's not immediately clear to me why in arch/x86/entry/syscalls/syscall_32.tbl epoll_pwait does not need a compat entry, unlike on other architectures and unlike signalfd.

#3 lore raw
Quoted 4 lines · Willem de Bruijn

Slightly tangential, it's not immediately clear to me why in arch/x86/entry/syscalls/syscall_32.tbl epoll_pwait does not need a compat entry, unlike on other architectures and unlike signalfd.

Hmm. Good question. That looks like a bug to me. Probably nobody noticed because it's so rarely used.

Or maybe I'm missing something too.

Adding x86 entry code people to the participants.

Linus

#4 lore raw
Quoted 8 lines · Linus Torvalds
Quoted 4 lines · Willem de Bruijn

Slightly tangential, it's not immediately clear to me why in arch/x86/entry/syscalls/syscall_32.tbl epoll_pwait does not need a compat entry, unlike on other architectures and unlike signalfd.

Quoted 6 lines

Hmm. Good question. That looks like a bug to me. Probably nobody noticed because it's so rarely used.

Or maybe I'm missing something too.

Adding x86 entry code people to the participants.

The sigset_t argument is actually compatible between x86-32 and x86-64 because

- The bits are in the same order on little-endian machines
- _NSIG is the same as _COMPAT_NSIG (unlike old sparc kernels)
- accessing a 64-bit with 32-bit alignment is always allowed on x86

All other architectures with compat mode support big-endian code at least as an option, so they have to use the compat version.

Arnd

#5 lore raw
Quoted 2 lines · Arnd Bergmann

The sigset_t argument is actually compatible between x86-32 and x86-64

Well, random high bits in size_t or the pointer value aren't. So it still looks a bit iffy to me.

But it might end up working almost by accident.

Linus

#6 lore raw
Quoted 9 lines · Linus Torvalds
Quoted 2 lines · Arnd Bergmann

The sigset_t argument is actually compatible between x86-32 and x86-64

Well, random high bits in size_t or the pointer value aren't. So it still looks a bit iffy to me.

But it might end up working almost by accident.

The direct syscall arguments all get the correct zero-extension with asm/syscall_wrapper.h, just like they do with any other syscall that is used in both native and compat mode, like epoll_wait().

It probably makes sense to change it just for consistency with the other architectures, but I would assume that it was intentional when this was added originally, as the compat handling for epoll_pwait() went through several iterations before it first worked correctly.

Arnd

maintainer Acked-by on v1 1/1
#7 lore raw
In reply to Heiko Carstens
Quoted 27 lines · Heiko Carstens

Commit b0a0c2615f6f ("epoll: wire up syscall epoll_pwait2") wired up the 64 bit syscall instead of the compat variant in a couple of places.

Cc Willem de Bruijn <[email protected]>
Cc Al Viro <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc "David S. Miller" <[email protected]>
Fixes b0a0c2615f6f ("epoll: wire up syscall epoll_pwait2")
---
 arch/arm64/include/asm/unistd32.h         | 2 +-
 arch/mips/kernel/syscalls/syscall_n32.tbl | 2 +-
 arch/s390/kernel/syscalls/syscall.tbl     | 2 +-
 arch/sparc/kernel/syscalls/syscall.tbl    | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
arch/arm64/include/asm/unistd32.h +0 -0
index f4bca2b90218..cccfbbefbf95 100644

arch/arm64/include/asm/unistd32.h __SYSCALL(__NR_faccessat2, sys_faccessat2) · line 893

Quoted 5 lines
arch/arm64/include/asm/unistd32.h +1 -1
@@ -890,7 +890,7 @@ __SYSCALL(__NR_faccessat2, sys_faccessat2)
 #define __NR_process_madvise 440
 __SYSCALL(__NR_process_madvise, sys_process_madvise)
 #define __NR_epoll_pwait2 441
-__SYSCALL(__NR_epoll_pwait2, sys_epoll_pwait2)
+__SYSCALL(__NR_epoll_pwait2, compat_sys_epoll_pwait2)

For this bit ^^

Will