All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/asm/64: do not clear high 32 bits of syscall number when CONFIG_X86_X32=y
@ 2017-09-12 22:57 Dmitry V. Levin
  2017-09-13 16:49 ` Oleg Nesterov
  2017-09-14 21:05 ` Andy Lutomirski
  0 siblings, 2 replies; 13+ messages in thread
From: Dmitry V. Levin @ 2017-09-12 22:57 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86
  Cc: Andy Lutomirski, Oleg Nesterov, Eugene Syromyatnikov,
	linux-kernel

Before this change, CONFIG_X86_X32=y fastpath behaviour was different
from slowpath:

$ gcc -xc -Wall -O2 - <<'EOF'
#include <unistd.h>
#include <asm/unistd.h>
int main(void) {
	unsigned long nr = ~0xffffffffUL | __NR_exit;
	return !!syscall(nr, 42, 1, 2, 3, 4, 5);
}
EOF
$ ./a.out; echo \$?=$?
$?=42
$ strace -enone ./a.out
syscall_18446744069414584380(0x2a, 0x1, 0x2, 0x3, 0x4, 0x5) = -1 (errno 38)
+++ exited with 1 +++

This change syncs CONFIG_X86_X32=y fastpath behaviour with the case
when CONFIG_X86_X32 is not enabled.

Fixes: fca460f95e92 ("x32: Handle the x32 system call flag")
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/x86/entry/entry_64.S | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 4916725..3bab6af 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -185,12 +185,10 @@ entry_SYSCALL_64_fastpath:
 	 */
 	TRACE_IRQS_ON
 	ENABLE_INTERRUPTS(CLBR_NONE)
-#if __SYSCALL_MASK == ~0
-	cmpq	$__NR_syscall_max, %rax
-#else
-	andl	$__SYSCALL_MASK, %eax
-	cmpl	$__NR_syscall_max, %eax
+#if __SYSCALL_MASK != ~0
+	andq	$__SYSCALL_MASK, %rax
 #endif
+	cmpq	$__NR_syscall_max, %rax
 	ja	1f				/* return -ENOSYS (already in pt_regs->ax) */
 	movq	%r10, %rcx
 
-- 
ldv

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-09-17 16:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-12 22:57 [PATCH] x86/asm/64: do not clear high 32 bits of syscall number when CONFIG_X86_X32=y Dmitry V. Levin
2017-09-13 16:49 ` Oleg Nesterov
2017-09-14 19:40   ` Eugene Syromyatnikov
2017-09-14 20:24     ` Dmitry V. Levin
2017-09-14 20:21   ` Dmitry V. Levin
2017-09-15 16:12     ` Oleg Nesterov
2017-09-14 21:05 ` Andy Lutomirski
2017-09-14 21:33   ` Dmitry V. Levin
2017-09-14 21:38     ` Andy Lutomirski
2017-09-15  5:31       ` Ingo Molnar
2017-09-15  5:46         ` hpa
2017-09-17 16:45           ` Dmitry V. Levin
2017-09-15  5:47         ` hpa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.