[PATCH] Revert "x86/syscalls: Make __X32_SYSCALL_BIT be unsigned long"

From: Andy Lutomirski
Date: Fri May 08 2020 - 20:25:39 EST


This reverts commit 45e29d119e9923ff14dfb840e3482bef1667bbfb and
adds a comment to discourage someone else from making the same
mistake again.

It turns out that some user code fails to compile if
__X32_SYSCALL_BIT is unsigned long. See, for example:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=954294

Reported-by: Thorsten Glaser <t.glaser@xxxxxxxxx>
Fixes: 45e29d119e99 ("x86/syscalls: Make __X32_SYSCALL_BIT be unsigned long")
Cc: stable@xxxxxxxxxx
Signed-off-by: Andy Lutomirski <luto@xxxxxxxxxx>
---
arch/x86/include/uapi/asm/unistd.h | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/uapi/asm/unistd.h b/arch/x86/include/uapi/asm/unistd.h
index 196fdd02b8b1..be5e2e747f50 100644
--- a/arch/x86/include/uapi/asm/unistd.h
+++ b/arch/x86/include/uapi/asm/unistd.h
@@ -2,8 +2,15 @@
#ifndef _UAPI_ASM_X86_UNISTD_H
#define _UAPI_ASM_X86_UNISTD_H

-/* x32 syscall flag bit */
-#define __X32_SYSCALL_BIT 0x40000000UL
+/*
+ * x32 syscall flag bit. Some user programs expect syscall NR macros
+ * and __X32_SYSCALL_BIT to have type int, even though syscall numbers
+ * are, for practical purposes, unsigned long.
+ *
+ * Fortunately, expressions like (nr & ~__X32_SYSCALL_BIT) do the right
+ * thing regardless.
+ */
+#define __X32_SYSCALL_BIT 0x40000000

#ifndef __KERNEL__
# ifdef __i386__
--
2.25.4