aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRichard Palethorpe <rpalethorpe@suse.com>2024-01-10 15:01:22 +0200
committerThomas Gleixner <tglx@linutronix.de>2024-01-24 11:49:19 +0100
commit56062d60f117dccfb5281869e0ab61e090baf864 (patch)
tree340c12dcfc6bdda262a34f351a9b3a0855716c6d /include
parent090e3bec01763e415bccae445f5bfe3d0c61b629 (diff)
downloadlinux-56062d60f117dccfb5281869e0ab61e090baf864.tar.gz
x86/entry/ia32: Ensure s32 is sign extended to s64
Presently ia32 registers stored in ptregs are unconditionally cast to unsigned int by the ia32 stub. They are then cast to long when passed to __se_sys*, but will not be sign extended. This takes the sign of the syscall argument into account in the ia32 stub. It still casts to unsigned int to avoid implementation specific behavior. However then casts to int or unsigned int as necessary. So that the following cast to long sign extends the value. This fixes the io_pgetevents02 LTP test when compiled with -m32. Presently the systemcall io_pgetevents_time64() unexpectedly accepts -1 for the maximum number of events. It doesn't appear other systemcalls with signed arguments are effected because they all have compat variants defined and wired up. Fixes: ebeb8c82ffaf ("syscalls/x86: Use 'struct pt_regs' based syscall calling for IA32_EMULATION and x32") Suggested-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com> Signed-off-by: Nikolay Borisov <nik.borisov@suse.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20240110130122.3836513-1-nik.borisov@suse.com Link: https://lore.kernel.org/ltp/20210921130127.24131-1-rpalethorpe@suse.com/
Notes
Fixes: ebeb8c82ffaf ("syscalls/x86: Use 'struct pt_regs' based syscall calling for IA32_EMULATION and x32") # v4.17-rc1 Stable: de66d97add11 # v6.6.15 Stable: c02d3872c8dd # v6.1.76 Stable: fb6c8127dbe1 # v5.15.149 Stable: 4e806600eb14 # v5.10.210 Stable: 3cdbfac1068f # v5.4.269 Stable: d20c05fc2f18 # v4.19.307 Lore: https://lore.kernel.org/r/20210927161955.28494-1-rpalethorpe@suse.com # linux-api, linux-s390, lkml, ltp Lore: https://lore.kernel.org/r/20240110130122.3836513-1-nik.borisov@suse.com # linux-api, lkml Lore: https://lore.kernel.org/r/20240129170004.493220048@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/20240129170024.512138793@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/20240129170026.693449033@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/20240221125933.370602192@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/20240221125941.887545848@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/20240221125957.880384657@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/20240221130012.558262023@linuxfoundation.org # linux-patches, stable
Diffstat (limited to 'include')
-rw-r--r--include/linux/syscalls.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index cdba4d0c6d4a88..77eb9b0e768504 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -128,6 +128,7 @@ struct mnt_id_req;
#define __TYPE_IS_LL(t) (__TYPE_AS(t, 0LL) || __TYPE_AS(t, 0ULL))
#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
#define __SC_CAST(t, a) (__force t) a
+#define __SC_TYPE(t, a) t
#define __SC_ARGS(t, a) a
#define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))