compat: remove compat_alloc_user_space
Subsystems (14)
v5 cover compat: remove compat_alloc_user_space
From: Arnd Bergmann <[email protected]>
Going through compat_alloc_user_space() to convert indirect system call arguments tends to add complexity compared to handling the native and compat logic in the same code.
Out of the other remaining callers, the linux-media series went into v5.14, and the network ioctl handling is now fixed in net-next, so these are the last remaining users, and I now include the final patch to remove the definitions as well.
Since these patches are now all that remains, it would be nice to merge it all through Andrew's Linux-mm tree, which is already based on top of linux-next.
Arnd
---
Changes in v4:
- Rebase on top of net-next
- Split up and improve the kexec patch based on Christoph's suggestions
- Include final patch to remove compat_alloc_user_space
- Cc compat architecture maintainers
Changes in v3:
- fix whitespace as pointed out by Christoph Hellwig
- minor build fixes
- rebase to v5.13-rc1
Changes in v2:
- address review comments from Christoph Hellwig
- split syscall removal into a separate patch
- replace __X32_COND_SYSCALL() with individual macros for x32
Arnd Bergmann (6):
kexec: move locking into do_kexec_load
kexec: avoid compat_alloc_user_space
mm: simplify compat_sys_move_pages
mm: simplify compat numa syscalls
compat: remove some compat entry points
arch: remove compat_alloc_user_space
arch/arm64/include/asm/compat.h | 5 - arch/arm64/include/asm/uaccess.h | 11 -- arch/arm64/include/asm/unistd32.h | 10 +- arch/arm64/lib/Makefile | 2 +- arch/arm64/lib/copy_in_user.S | 77 --------- arch/mips/cavium-octeon/octeon-memcpy.S | 2 - arch/mips/include/asm/compat.h | 8 - arch/mips/include/asm/uaccess.h | 26 --- arch/mips/kernel/syscalls/syscall_n32.tbl | 10 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 10 +- arch/mips/lib/memcpy.S | 11 -- arch/parisc/include/asm/compat.h | 6 - arch/parisc/include/asm/uaccess.h | 2 - arch/parisc/kernel/syscalls/syscall.tbl | 8 +- arch/parisc/lib/memcpy.c | 9 - arch/powerpc/include/asm/compat.h | 16 -- arch/powerpc/kernel/syscalls/syscall.tbl | 10 +- arch/s390/include/asm/compat.h | 10 -- arch/s390/include/asm/uaccess.h | 3 - arch/s390/kernel/syscalls/syscall.tbl | 10 +- arch/s390/lib/uaccess.c | 63 ------- arch/sparc/include/asm/compat.h | 19 --- arch/sparc/kernel/process_64.c | 2 +- arch/sparc/kernel/signal32.c | 12 +- arch/sparc/kernel/signal_64.c | 8 +- arch/sparc/kernel/syscalls/syscall.tbl | 10 +- arch/x86/entry/syscalls/syscall_32.tbl | 4 +- arch/x86/entry/syscalls/syscall_64.tbl | 2 +- arch/x86/include/asm/compat.h | 13 -- arch/x86/include/asm/uaccess_64.h | 7 - include/linux/compat.h | 39 +---- include/linux/uaccess.h | 10 -- include/uapi/asm-generic/unistd.h | 10 +- kernel/compat.c | 21 --- kernel/kexec.c | 103 +++++------- kernel/sys_ni.c | 5 - mm/mempolicy.c | 196 +++++----------------- mm/migrate.c | 50 +++--- 38 files changed, 175 insertions(+), 645 deletions(-) delete mode 100644 arch/arm64/lib/copy_in_user.S
Signature · 34 lines
2.29.2 Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: Helge Deller <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: [email protected] Cc: "H. Peter Anvin" <[email protected]> Cc: Al Viro <[email protected]> Cc: Andrew Morton <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Feng Tang <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected]
PATCH v5 1/6 kexec: move locking into do_kexec_load
From: Arnd Bergmann <[email protected]>
The locking is the same between the native and compat version of sys_kexec_load(), so it can be done in the common implementation to reduce duplication.
--- kernel/kexec.c | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-)
kernel/kexec.c +16 -28
@@ -110,6 +110,17 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,unsigned long i;int ret; +/* +* Because we write directly to the reserved memory region when loading +* crash kernels we need a mutex here to prevent multiple crash kernels +* from attempting to load simultaneously, and to prevent a crash kernel +* from loading over the top of a in use crash kernel. +* +* KISS: always take the mutex. +*/ +if (!mutex_trylock (&kexec_mutex)) +return -EBUSY ; +if (flags &KEXEC_ON_CRASH ) { dest_image = &kexec_crash_image;if (kexec_crash_image)
@@ -121,7 +132,8 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,if (nr_segments ==0 ) {/* Uninstall image */ kimage_free (xchg (dest_image,NULL )); -return 0 ; + ret =0 ; + goto out_unlock; }if (flags &KEXEC_ON_CRASH ) {/*
@@ -134,7 +146,7 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments, ret =kimage_alloc_init (&image, entry, nr_segments, segments, flags);if (ret) -return ret; + goto out_unlock;if (flags &KEXEC_PRESERVE_CONTEXT ) image->preserve_context =1 ;
@@ -171,6 +183,8 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,arch_kexec_protect_crashkres ();kimage_free (image); +out_unlock: +mutex_unlock (&kexec_mutex);return ret; }
@@ -247,21 +261,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, ((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH_DEFAULT)) return -EINVAL; -/* Because we write directly to the reserved memory -* region when loading crash kernels we need a mutex here to -* prevent multiple crash kernels from attempting to load -* simultaneously, and to prevent a crash kernel from loading -* over the top of a in use crash kernel. -* -* KISS: always take the mutex. -*/ -if (!mutex_trylock (&kexec_mutex)) -return -EBUSY ; - result =do_kexec_load (entry, nr_segments, segments, flags); -mutex_unlock (&kexec_mutex); -return result; }
@@ -301,21 +302,8 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry, return -EFAULT; } -/* Because we write directly to the reserved memory -* region when loading crash kernels we need a mutex here to -* prevent multiple crash kernels from attempting to load -* simultaneously, and to prevent a crash kernel from loading -* over the top of a in use crash kernel. -* -* KISS: always take the mutex. -*/ -if (!mutex_trylock (&kexec_mutex)) -return -EBUSY ; - result =do_kexec_load (entry, nr_segments, ksegments, flags); -mutex_unlock (&kexec_mutex); -return result; }#endif
Signature · 1 line
2.29.2
Re: [PATCH v5 1/6] kexec: move locking into do_kexec_load
Quoted 5 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The locking is the same between the native and compat version of
sys_kexec_load(), so it can be done in the common implementation to reduce duplication.
Quoted 102 lines
Co-developed-by Eric Biederman <[email protected]>Co-developed-by Christoph Hellwig <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>--- kernel/kexec.c | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-)kernel/kexec.c +16
-28@@ -110,6 +110,17 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,unsigned long i;int ret; +/* +* Because we write directly to the reserved memory region when loading +* crash kernels we need a mutex here to prevent multiple crash kernels +* from attempting to load simultaneously, and to prevent a crash kernel +* from loading over the top of a in use crash kernel. +* +* KISS: always take the mutex. +*/ +if (!mutex_trylock (&kexec_mutex)) +return -EBUSY ; +if (flags &KEXEC_ON_CRASH ) { dest_image = &kexec_crash_image;if (kexec_crash_image)@@ -121,7 +132,8 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,if (nr_segments ==0 ) {/* Uninstall image */ kimage_free (xchg (dest_image,NULL )); -return 0 ; + ret =0 ; + goto out_unlock; }if (flags &KEXEC_ON_CRASH ) {/* @@ -134,7 +146,7 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments, ret =kimage_alloc_init (&image, entry, nr_segments, segments, flags);if (ret) -return ret; + goto out_unlock;if (flags &KEXEC_PRESERVE_CONTEXT ) image->preserve_context =1 ;@@ -171,6 +183,8 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,arch_kexec_protect_crashkres ();kimage_free (image); +out_unlock: +mutex_unlock (&kexec_mutex);return ret; }@@ -247,21 +261,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, ((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH_DEFAULT)) return -EINVAL; -/* Because we write directly to the reserved memory -* region when loading crash kernels we need a mutex here to -* prevent multiple crash kernels from attempting to load -* simultaneously, and to prevent a crash kernel from loading -* over the top of a in use crash kernel. -* -* KISS: always take the mutex. -*/ -if (!mutex_trylock (&kexec_mutex)) -return -EBUSY ; - result =do_kexec_load (entry, nr_segments, segments, flags); -mutex_unlock (&kexec_mutex); -return result; }@@ -301,21 +302,8 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry, return -EFAULT; } -/* Because we write directly to the reserved memory -* region when loading crash kernels we need a mutex here to -* prevent multiple crash kernels from attempting to load -* simultaneously, and to prevent a crash kernel from loading -* over the top of a in use crash kernel. -* -* KISS: always take the mutex. -*/ -if (!mutex_trylock (&kexec_mutex)) -return -EBUSY ; - result =do_kexec_load (entry, nr_segments, ksegments, flags); -mutex_unlock (&kexec_mutex); -return result; }#endif
PATCH v5 2/6 kexec: avoid compat_alloc_user_space
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
kimage_alloc_init() expects a __user pointer, so compat_sys_kexec_load() uses compat_alloc_user_space() to convert the layout and put it back onto the user space caller stack.
Moving the user space access into the syscall handler directly actually makes the code simpler, as the conversion for compat mode can now be done on kernel memory.
--- kernel/kexec.c | 61 +++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 36 deletions(-)
kernel/kexec.c +25 -36
@@ -19,26 +19,9 @@#include "kexec_internal.h" -static int copy_user_segment_list (struct kimage *image, -unsigned long nr_segments, -struct kexec_segment __user *segments) -{ -int ret; -size_t segment_bytes; - -/* Read in the segments */ - image->nr_segments = nr_segments; - segment_bytes = nr_segments *sizeof (*segments); - ret =copy_from_user (image->segment, segments, segment_bytes); -if (ret) - ret = -EFAULT ; - -return ret; -} -static int kimage_alloc_init (struct kimage **rimage,unsigned long entry,unsigned long nr_segments, -struct kexec_segment __user *segments, +struct kexec_segment *segments,unsigned long flags) {int ret;
@@ -58,10 +41,8 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry,return -ENOMEM ; image->start = entry; - - ret =copy_user_segment_list (image, nr_segments, segments); -if (ret) - goto out_free_image; + image->nr_segments = nr_segments; +memcpy (image->segment, segments, nr_segments *sizeof (*segments));if (kexec_on_panic) {/* Enable special crash kernel control page alloc policy. */
@@ -104,7 +85,7 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry, }static int do_kexec_load (unsigned long entry,unsigned long nr_segments, -struct kexec_segment __user *segments,unsigned long flags) +struct kexec_segment *segments,unsigned long flags) {struct kimage **dest_image, *image;unsigned long i;
@@ -250,7 +231,8 @@ static inline int kexec_load_check(unsigned long nr_segments, SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, struct kexec_segment __user *, segments, unsigned long, flags) { -int result; +struct kexec_segment *ksegments; +unsigned long result; result =kexec_load_check (nr_segments, flags);if (result)
@@ -261,7 +243,12 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, ((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH_DEFAULT)) return -EINVAL; - result =do_kexec_load (entry, nr_segments, segments, flags); + ksegments =memdup_user (segments, nr_segments *sizeof (ksegments[0 ])); +if (IS_ERR (ksegments)) +return PTR_ERR (ksegments); + + result =do_kexec_load (entry, nr_segments, ksegments, flags); +kfree (ksegments);return result; }
@@ -273,7 +260,7 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry, compat_ulong_t, flags) {struct compat_kexec_segment in; -struct kexec_segment out,__user *ksegments; +struct kexec_segment *ksegments;unsigned long i, result; result =kexec_load_check (nr_segments, flags);
@@ -286,24 +273,26 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,if ((flags &KEXEC_ARCH_MASK ) ==KEXEC_ARCH_DEFAULT )return -EINVAL ; - ksegments =compat_alloc_user_space (nr_segments *sizeof (out)); + ksegments =kmalloc_array (nr_segments,sizeof (ksegments[0 ]), +GFP_KERNEL ); +if (!ksegments) +return -ENOMEM ; +for (i =0 ; i < nr_segments; i++) { result =copy_from_user (&in, &segments[i],sizeof (in));if (result) -return -EFAULT ; + goto fail; - out.buf =compat_ptr (in.buf); - out.bufsz = in.bufsz; - out.mem = in.mem; - out.memsz = in.memsz; - - result =copy_to_user (&ksegments[i], &out,sizeof (out)); -if (result) -return -EFAULT ; + ksegments[i].buf =compat_ptr (in.buf); + ksegments[i].bufsz = in.bufsz; + ksegments[i].mem = in.mem; + ksegments[i].memsz = in.memsz; } result =do_kexec_load (entry, nr_segments, ksegments, flags); +fail: +kfree (ksegments); return result; }#endif
Signature · 1 line
2.29.2
Re: [PATCH v5 2/6] kexec: avoid compat_alloc_user_space
Quoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
kimage_alloc_init()expects a__userpointer, socompat_sys_kexec_load()usescompat_alloc_user_space()to convert the layout and put it back onto the user space caller stack.Moving the user space access into the syscall handler directly actually makes the code simpler, as the conversion for compat mode can now be done on kernel memory.
Quoted 134 lines
Co-developed-by Eric Biederman <[email protected]>Co-developed-by Christoph Hellwig <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>--- kernel/kexec.c | 61 +++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 36 deletions(-)kernel/kexec.c +25
-36@@ -19,26 +19,9 @@#include "kexec_internal.h" -static int copy_user_segment_list (struct kimage *image, -unsigned long nr_segments, -struct kexec_segment __user *segments) -{ -int ret; -size_t segment_bytes; - -/* Read in the segments */ - image->nr_segments = nr_segments; - segment_bytes = nr_segments *sizeof (*segments); - ret =copy_from_user (image->segment, segments, segment_bytes); -if (ret) - ret = -EFAULT ; - -return ret; -} -static int kimage_alloc_init (struct kimage **rimage,unsigned long entry,unsigned long nr_segments, -struct kexec_segment __user *segments, +struct kexec_segment *segments,unsigned long flags) {int ret;@@ -58,10 +41,8 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry,return -ENOMEM ; image->start = entry; - - ret =copy_user_segment_list (image, nr_segments, segments); -if (ret) - goto out_free_image; + image->nr_segments = nr_segments; +memcpy (image->segment, segments, nr_segments *sizeof (*segments));if (kexec_on_panic) {/* Enable special crash kernel control page alloc policy. */ @@ -104,7 +85,7 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry, }static int do_kexec_load (unsigned long entry,unsigned long nr_segments, -struct kexec_segment __user *segments,unsigned long flags) +struct kexec_segment *segments,unsigned long flags) {struct kimage **dest_image, *image;unsigned long i;@@ -250,7 +231,8 @@ static inline int kexec_load_check(unsigned long nr_segments, SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, struct kexec_segment __user *, segments, unsigned long, flags) { -int result; +struct kexec_segment *ksegments; +unsigned long result; result =kexec_load_check (nr_segments, flags);if (result)@@ -261,7 +243,12 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, ((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH_DEFAULT)) return -EINVAL; - result =do_kexec_load (entry, nr_segments, segments, flags); + ksegments =memdup_user (segments, nr_segments *sizeof (ksegments[0 ])); +if (IS_ERR (ksegments)) +return PTR_ERR (ksegments); + + result =do_kexec_load (entry, nr_segments, ksegments, flags); +kfree (ksegments);return result; }@@ -273,7 +260,7 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry, compat_ulong_t, flags) {struct compat_kexec_segment in; -struct kexec_segment out,__user *ksegments; +struct kexec_segment *ksegments;unsigned long i, result; result =kexec_load_check (nr_segments, flags);@@ -286,24 +273,26 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,if ((flags &KEXEC_ARCH_MASK ) ==KEXEC_ARCH_DEFAULT )return -EINVAL ; - ksegments =compat_alloc_user_space (nr_segments *sizeof (out)); + ksegments =kmalloc_array (nr_segments,sizeof (ksegments[0 ]), +GFP_KERNEL ); +if (!ksegments) +return -ENOMEM ; +for (i =0 ; i < nr_segments; i++) { result =copy_from_user (&in, &segments[i],sizeof (in));if (result) -return -EFAULT ; + goto fail; - out.buf =compat_ptr (in.buf); - out.bufsz = in.bufsz; - out.mem = in.mem; - out.memsz = in.memsz; - - result =copy_to_user (&ksegments[i], &out,sizeof (out)); -if (result) -return -EFAULT ; + ksegments[i].buf =compat_ptr (in.buf); + ksegments[i].bufsz = in.bufsz; + ksegments[i].mem = in.mem; + ksegments[i].memsz = in.memsz; } result =do_kexec_load (entry, nr_segments, ksegments, flags); +fail: +kfree (ksegments); return result; }#endif
PATCH v5 3/6 mm: simplify compat_sys_move_pages
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The compat move_pages() implementation uses compat_alloc_user_space() for converting the pointer array. Moving the compat handling into the function itself is a bit simpler and lets us avoid the compat_alloc_user_space() call.
--- mm/migrate.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-)
mm/migrate.c +30 -15
@@ -1820,6 +1820,23 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages,mmap_read_unlock (mm); } +static int get_compat_pages_array (const void __user *chunk_pages[], +const void __user *__user *pages, +unsigned long chunk_nr) +{ +compat_uptr_t __user *pages32 = (compat_uptr_t __user *)pages; +compat_uptr_t p; +int i; + +for (i =0 ; i < chunk_nr; i++) { +if (get_user (p, pages32 + i)) +return -EFAULT ; + chunk_pages[i] =compat_ptr (p); + } + +return 0 ; +} +/* * Determine the nodes of a user array of pages and store it in * a user array of status.
@@ -1839,8 +1856,15 @@ static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages,if (chunk_nr >DO_PAGES_STAT_CHUNK_NR ) chunk_nr =DO_PAGES_STAT_CHUNK_NR ; -if (copy_from_user (chunk_pages, pages, chunk_nr *sizeof (*chunk_pages))) -break ; +if (in_compat_syscall ()) { +if (get_compat_pages_array (chunk_pages, pages, + chunk_nr)) +break ; + }else { +if (copy_from_user (chunk_pages, pages, + chunk_nr *sizeof (*chunk_pages))) +break ; + }do_pages_stat_array (mm, chunk_nr, chunk_pages, chunk_status);
@@ -1945,23 +1969,14 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,#ifdef CONFIG_COMPAT COMPAT_SYSCALL_DEFINE6 (move_pages, pid_t, pid, compat_ulong_t, nr_pages, - compat_uptr_t __user *, pages32, + compat_uptr_t __user *, pages, const int __user *, nodes, int __user *, status, int, flags) { -const void __user *__user *pages; -int i; - - pages =compat_alloc_user_space (nr_pages *sizeof (void *)); -for (i =0 ; i < nr_pages; i++) { -compat_uptr_t p; - -if (get_user (p, pages32 + i) || -put_user (compat_ptr (p), pages + i)) -return -EFAULT ; - } -return kernel_move_pages (pid, nr_pages, pages, nodes, status, flags); +return kernel_move_pages (pid, nr_pages, + (const void __user *__user *)pages, + nodes, status, flags); }#endif /* CONFIG_COMPAT */
Signature · 1 line
2.29.2
PATCH v5 4/6 mm: simplify compat numa syscalls
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The compat implementations for mbind, get_mempolicy, set_mempolicy and migrate_pages are just there to handle the subtly different layout of bitmaps on 32-bit hosts.
The compat implementation however lacks some of the checks that are present in the native one, in particular for checking that the extra bits are all zero when user space has a larger mask size than the kernel. Worse, those extra bits do not get cleared when copying in or out of the kernel, which can lead to incorrect data as well.
Unify the implementation to handle the compat bitmap layout directly in the get_nodes() and copy_nodes_to_user() helpers. Splitting out the get_bitmap() helper from get_nodes() also helps readability of the native case.
On x86, two additional problems are addressed by this: compat tasks can pass a bitmap at the end of a mapping, causing a fault when reading across the page boundary for a 64-bit word. x32 tasks might also run into problems with get_mempolicy corrupting data when an odd number of 32-bit words gets passed.
On parisc the migrate_pages() system call apparently had the wrong calling convention, as big-endian architectures expect the words inside of a bitmap to be swapped. This is not a problem though since parisc has no NUMA support.
--- include/linux/compat.h | 17 ++-- mm/mempolicy.c | 175 +++++++++++++---------------------------- 2 files changed, 63 insertions(+), 129 deletions(-)
include/linux/compat.h +9 -8
@@ -395,14 +395,6 @@ struct compat_kexec_segment;struct compat_mq_attr ;struct compat_msgbuf ; -#define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t)) - -#define BITS_TO_COMPAT_LONGS (bits) DIV_ROUND_UP(bits, BITS_PER_COMPAT_LONG) - -long compat_get_bitmap (unsigned long *mask,const compat_ulong_t __user *umask, -unsigned long bitmap_size); -long compat_put_bitmap (compat_ulong_t __user *umask,unsigned long *mask, -unsigned long bitmap_size);void copy_siginfo_to_external32 (struct compat_siginfo *to,const struct kernel_siginfo *from); int copy_siginfo_from_user32(kernel_siginfo_t *to,
@@ -976,6 +968,15 @@ static inline bool in_compat_syscall(void) { return false; }#endif /* CONFIG_COMPAT */ +#define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t)) + +#define BITS_TO_COMPAT_LONGS (bits) DIV_ROUND_UP(bits, BITS_PER_COMPAT_LONG) + +long compat_get_bitmap (unsigned long *mask,const compat_ulong_t __user *umask, +unsigned long bitmap_size); +long compat_put_bitmap (compat_ulong_t __user *umask,unsigned long *mask, +unsigned long bitmap_size); +/* * Some legacy ABIs like the i386 one use less than natural alignment for 64-bit * types, and will need special compat treatment for that. Most architectures
mm/mempolicy.c +54 -121
235 lines not on this page · raw message
Signature · 1 line
2.29.2
Heiko Carstens
maintainerRe: [PATCH v5 4/6] mm: simplify compat numa syscalls
Quoted 4 lines · Arnd Bergmann
--- include/linux/compat.h | 17 ++-- mm/mempolicy.c | 175 +++++++++++++---------------------------- 2 files changed, 63 insertions(+), 129 deletions(-)
...
mm/mempolicy.c static long do_mbind(unsigned long start, unsigned long len, · line 1374
Quoted 10 lines
mm/mempolicy.c +10
-0+static int get_bitmap (unsigned long *mask,const unsigned long __user *nmask, +unsigned long maxnode) +{ +unsigned long nlongs =BITS_TO_LONGS (maxnode); +int ret; + +if (in_compat_syscall ()) + ret =compat_get_bitmap (mask, + (const compat_ulong_t __user *)nmask, + maxnode);
compat_ptr() conversion for e.g. nmask is missing with the next patch which removes the compat system calls.
Is that intended or am I missing something?
Re: [PATCH v5 4/6] mm: simplify compat numa syscalls
Quoted 7 lines · Heiko Carstens
Quoted 4 lines · Arnd Bergmann
--- include/linux/compat.h | 17 ++-- mm/mempolicy.c | 175 +++++++++++++---------------------------- 2 files changed, 63 insertions(+), 129 deletions(-)...
Quoted 14 lines
mm/mempolicy.c static long do_mbind(unsigned long start, unsigned long len, · line 1374
Quoted 10 lines
mm/mempolicy.c +10
-0+static int get_bitmap (unsigned long *mask,const unsigned long __user *nmask, +unsigned long maxnode) +{ +unsigned long nlongs =BITS_TO_LONGS (maxnode); +int ret; + +if (in_compat_syscall ()) + ret =compat_get_bitmap (mask, + (const compat_ulong_t __user *)nmask, + maxnode);
compat_ptr()conversion for e.g. nmask is missing with the next patch which removes the compat system calls.
Is that intended or am I missing something?
I don't think it's needed here, since the pointer comes from the system call argument, which has the compat_ptr() conversion applied in arch/s390/include/asm/syscall_wrapper.h, not from a compat_uptr_t that gets passed indirectly. The compat_get_bitmap() conversion is only needed for byte order adjustment, not for converting pointers.
It's also possible that I'm the one who's missing something.
Arnd
Heiko Carstens
maintainerRe: [PATCH v5 4/6] mm: simplify compat numa syscalls
Quoted 16 lines · Arnd Bergmann
Quoted 6 lines · Heiko Carstens
Quoted 6 lines
mm/mempolicy.c +6
-0+static int get_bitmap (unsigned long *mask,const unsigned long __user *nmask, +unsigned long maxnode) +{ +unsigned long nlongs =BITS_TO_LONGS (maxnode); +int ret; +Quoted 8 lines
mm/mempolicy.c static long do_mbind(unsigned long start, unsigned long len, · line 1374
Quoted 4 lines
mm/mempolicy.c +4
-0+if (in_compat_syscall ()) + ret =compat_get_bitmap (mask, + (const compat_ulong_t __user *)nmask, + maxnode);
compat_ptr()conversion for e.g. nmask is missing with the next patch which removes the compat system calls.
Is that intended or am I missing something?
Quoted 7 lines
I don't think it's needed here, since the pointer comes from the system call argument, which has the
compat_ptr()conversion applied inarch/s390/include/asm/syscall_wrapper.h, not from acompat_uptr_tthat gets passed indirectly. Thecompat_get_bitmap()conversion is only needed for byte order adjustment, not for converting pointers.It's also possible that I'm the one who's missing something.
What I was trying to say: this patch on its own is ok. However with the next patch you remove the compat system calls and map the regular system calls instead.
That is:
-COMPAT_SYSCALL_DEFINE6(mbind, compat_ulong_t, start, compat_ulong_t, len,
- compat_ulong_t, mode, compat_ulong_t __user *, nmask,
- compat_ulong_t, maxnode, compat_ulong_t, flags)
-{
- return kernel_mbind(start, len, mode, (unsigned long __user *)nmask,
- maxnode, flags);
-}
and this:
-268 common mbind sys_mbind compat_sys_mbind -269 common get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy -270 common set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy +268 common mbind sys_mbind sys_mbind +269 common get_mempolicy sys_get_mempolicy sys_get_mempolicy +270 common set_mempolicy sys_set_mempolicy sys_set_mempolicy
would remove compat_ptr() conversion from nmask above if I'm not mistaken.
Re: [PATCH v5 4/6] mm: simplify compat numa syscalls
Quoted 9 lines · Heiko Carstens
-268 common mbind sys_mbind compat_sys_mbind -269 common get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy -270 common set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy +268 common mbind sys_mbind sys_mbind +269 common get_mempolicy sys_get_mempolicy sys_get_mempolicy +270 common set_mempolicy sys_set_mempolicy sys_set_mempolicywould remove
compat_ptr()conversion from nmask above if I'm not mistaken.
Maybe I'm misremembering how compat syscalls work on s390. Doesn't SYSCALL_DEFINEx(sys_mbind) still create two entry points __s390x_sys_mbind() and __s390_sys_mbind() with different argument conversion (__SC_CAST vs __SC_COMPAT_CAST)? I thought that was the whole point of the macros.
Arnd
Heiko Carstens
maintainerRe: [PATCH v5 4/6] mm: simplify compat numa syscalls
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Heiko Carstens
-268 common mbind sys_mbind compat_sys_mbind -269 common get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy -270 common set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy +268 common mbind sys_mbind sys_mbind +269 common get_mempolicy sys_get_mempolicy sys_get_mempolicy +270 common set_mempolicy sys_set_mempolicy sys_set_mempolicy
Quoted 6 lines
Quoted 1 line
would remove
compat_ptr()conversion from nmask above if I'm not mistaken.Maybe I'm misremembering how compat syscalls work on s390. Doesn't
SYSCALL_DEFINEx(sys_mbind)still create two entry points__s390x_sys_mbind()and__s390_sys_mbind()with different argument conversion (__SC_CASTvs__SC_COMPAT_CAST)? I thought that was the whole point of the macros.
You are remembering correctly, probably because you implemented it ;) I totally forgot - sorry for the noise!
PATCH v5 5/6 compat: remove some compat entry points
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
These are all handled correctly when calling the native system call entry point, so remove the special cases.
--- arch/arm64/include/asm/unistd32.h | 10 +++--- arch/mips/kernel/syscalls/syscall_n32.tbl | 10 +++--- arch/mips/kernel/syscalls/syscall_o32.tbl | 10 +++--- arch/parisc/kernel/syscalls/syscall.tbl | 8 ++--- arch/powerpc/kernel/syscalls/syscall.tbl | 10 +++--- arch/s390/kernel/syscalls/syscall.tbl | 10 +++--- arch/sparc/kernel/syscalls/syscall.tbl | 10 +++--- arch/x86/entry/syscalls/syscall_32.tbl | 4 +-- arch/x86/entry/syscalls/syscall_64.tbl | 2 +- include/linux/compat.h | 20 ------------ include/uapi/asm-generic/unistd.h | 10 +++--- kernel/sys_ni.c | 5 --- mm/mempolicy.c | 37 ----------------------- mm/migrate.c | 13 -------- 14 files changed, 42 insertions(+), 117 deletions(-)
arch/arm64/include/asm/unistd32.h +5 -5
@@ -649,11 +649,11 @@ __SYSCALL(__NR_inotify_add_watch, sys_inotify_add_watch)#define __NR_inotify_rm_watch 318 __SYSCALL(__NR_inotify_rm_watch, sys_inotify_rm_watch)#define __NR_mbind 319 -__SYSCALL(__NR_mbind, compat_sys_mbind) +__SYSCALL(__NR_mbind, sys_mbind)#define __NR_get_mempolicy 320 -__SYSCALL(__NR_get_mempolicy, compat_sys_get_mempolicy) +__SYSCALL(__NR_get_mempolicy, sys_get_mempolicy)#define __NR_set_mempolicy 321 -__SYSCALL(__NR_set_mempolicy, compat_sys_set_mempolicy) +__SYSCALL(__NR_set_mempolicy, sys_set_mempolicy)#define __NR_openat 322 __SYSCALL(__NR_openat, compat_sys_openat)#define __NR_mkdirat 323
@@ -699,7 +699,7 @@ __SYSCALL(__NR_tee, sys_tee)#define __NR_vmsplice 343 __SYSCALL(__NR_vmsplice, sys_vmsplice)#define __NR_move_pages 344 -__SYSCALL(__NR_move_pages, compat_sys_move_pages) +__SYSCALL(__NR_move_pages, sys_move_pages)#define __NR_getcpu 345 __SYSCALL(__NR_getcpu, sys_getcpu)#define __NR_epoll_pwait 346
@@ -811,7 +811,7 @@ __SYSCALL(__NR_rseq, sys_rseq)#define __NR_io_pgetevents 399 __SYSCALL(__NR_io_pgetevents, compat_sys_io_pgetevents)#define __NR_migrate_pages 400 -__SYSCALL(__NR_migrate_pages, compat_sys_migrate_pages) +__SYSCALL(__NR_migrate_pages, sys_migrate_pages)#define __NR_kexec_file_load 401__SYSCALL (__NR_kexec_file_load, sys_kexec_file_load)/* 402 is unused */
arch/mips/kernel/syscalls/syscall_n32.tbl +5 -5
@@ -239,9 +239,9 @@ 228 n32 clock_nanosleep sys_clock_nanosleep_time32 229 n32 tgkill sys_tgkill 230 n32 utimes sys_utimes_time32 -231 n32 mbind compat_sys_mbind -232 n32 get_mempolicy compat_sys_get_mempolicy -233 n32 set_mempolicy compat_sys_set_mempolicy +231 n32 mbind sys_mbind +232 n32 get_mempolicy sys_get_mempolicy +233 n32 set_mempolicy sys_set_mempolicy 234 n32 mq_open compat_sys_mq_open 235 n32 mq_unlink sys_mq_unlink 236 n32 mq_timedsend sys_mq_timedsend_time32
@@ -258,7 +258,7 @@ 247 n32 inotify_init sys_inotify_init 248 n32 inotify_add_watch sys_inotify_add_watch 249 n32 inotify_rm_watch sys_inotify_rm_watch -250 n32 migrate_pages compat_sys_migrate_pages +250 n32 migrate_pages sys_migrate_pages 251 n32 openat sys_openat 252 n32 mkdirat sys_mkdirat 253 n32 mknodat sys_mknodat
@@ -279,7 +279,7 @@ 268 n32 sync_file_range sys_sync_file_range 269 n32 tee sys_tee 270 n32 vmsplice sys_vmsplice -271 n32 move_pages compat_sys_move_pages +271 n32 move_pages sys_move_pages 272 n32 set_robust_list compat_sys_set_robust_list 273 n32 get_robust_list compat_sys_get_robust_list 274 n32 kexec_load compat_sys_kexec_load
arch/mips/kernel/syscalls/syscall_o32.tbl +5 -5
@@ -279,9 +279,9 @@ 265 o32 clock_nanosleep sys_clock_nanosleep_time32 266 o32 tgkill sys_tgkill 267 o32 utimes sys_utimes_time32 -268 o32 mbind sys_mbind compat_sys_mbind -269 o32 get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy -270 o32 set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy +268 o32 mbind sys_mbind +269 o32 get_mempolicy sys_get_mempolicy +270 o32 set_mempolicy sys_set_mempolicy 271 o32 mq_open sys_mq_open compat_sys_mq_open 272 o32 mq_unlink sys_mq_unlink 273 o32 mq_timedsend sys_mq_timedsend_time32
@@ -298,7 +298,7 @@ 284 o32 inotify_init sys_inotify_init 285 o32 inotify_add_watch sys_inotify_add_watch 286 o32 inotify_rm_watch sys_inotify_rm_watch -287 o32 migrate_pages sys_migrate_pages compat_sys_migrate_pages +287 o32 migrate_pages sys_migrate_pages 288 o32 openat sys_openat compat_sys_openat 289 o32 mkdirat sys_mkdirat 290 o32 mknodat sys_mknodat
@@ -319,7 +319,7 @@ 305 o32 sync_file_range sys_sync_file_range sys32_sync_file_range 306 o32 tee sys_tee 307 o32 vmsplice sys_vmsplice -308 o32 move_pages sys_move_pages compat_sys_move_pages +308 o32 move_pages sys_move_pages 309 o32 set_robust_list sys_set_robust_list compat_sys_set_robust_list 310 o32 get_robust_list sys_get_robust_list compat_sys_get_robust_list 311 o32 kexec_load sys_kexec_load compat_sys_kexec_load
arch/parisc/kernel/syscalls/syscall.tbl +4 -4
@@ -292,9 +292,9 @@ 258 32 clock_nanosleep sys_clock_nanosleep_time32 258 64 clock_nanosleep sys_clock_nanosleep 259 common tgkill sys_tgkill -260 common mbind sys_mbind compat_sys_mbind -261 common get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy -262 common set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy +260 common mbind sys_mbind +261 common get_mempolicy sys_get_mempolicy +262 common set_mempolicy sys_set_mempolicy # 263 was vserver 264 common add_key sys_add_key 265 common request_key sys_request_key
@@ -331,7 +331,7 @@ 292 64 sync_file_range sys_sync_file_range 293 common tee sys_tee 294 common vmsplice sys_vmsplice -295 common move_pages sys_move_pages compat_sys_move_pages +295 common move_pages sys_move_pages 296 common getcpu sys_getcpu 297 common epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait 298 common statfs64 sys_statfs64 compat_sys_statfs64
arch/powerpc/kernel/syscalls/syscall.tbl +5 -5
@@ -330,10 +330,10 @@ 256 64 sys_debug_setcontext sys_ni_syscall 256 spu sys_debug_setcontext sys_ni_syscall # 257 reserved for vserver -258 nospu migrate_pages sys_migrate_pages compat_sys_migrate_pages -259 nospu mbind sys_mbind compat_sys_mbind -260 nospu get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy -261 nospu set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy +258 nospu migrate_pages sys_migrate_pages +259 nospu mbind sys_mbind +260 nospu get_mempolicy sys_get_mempolicy +261 nospu set_mempolicy sys_set_mempolicy 262 nospu mq_open sys_mq_open compat_sys_mq_open 263 nospu mq_unlink sys_mq_unlink 264 32 mq_timedsend sys_mq_timedsend_time32
@@ -381,7 +381,7 @@ 298 common faccessat sys_faccessat 299 common get_robust_list sys_get_robust_list compat_sys_get_robust_list 300 common set_robust_list sys_set_robust_list compat_sys_set_robust_list -301 common move_pages sys_move_pages compat_sys_move_pages +301 common move_pages sys_move_pages 302 common getcpu sys_getcpu 303 nospu epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait 304 32 utimensat sys_utimensat_time32
arch/s390/kernel/syscalls/syscall.tbl +5 -5
@@ -274,9 +274,9 @@ 265 common statfs64 sys_statfs64 compat_sys_statfs64 266 common fstatfs64 sys_fstatfs64 compat_sys_fstatfs64 267 common remap_file_pages sys_remap_file_pages sys_remap_file_pages -268 common mbind sys_mbind compat_sys_mbind -269 common get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy -270 common set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy +268 common mbind sys_mbind sys_mbind +269 common get_mempolicy sys_get_mempolicy sys_get_mempolicy +270 common set_mempolicy sys_set_mempolicy sys_set_mempolicy 271 common mq_open sys_mq_open compat_sys_mq_open 272 common mq_unlink sys_mq_unlink sys_mq_unlink 273 common mq_timedsend sys_mq_timedsend sys_mq_timedsend_time32
@@ -293,7 +293,7 @@ 284 common inotify_init sys_inotify_init sys_inotify_init 285 common inotify_add_watch sys_inotify_add_watch sys_inotify_add_watch 286 common inotify_rm_watch sys_inotify_rm_watch sys_inotify_rm_watch -287 common migrate_pages sys_migrate_pages compat_sys_migrate_pages +287 common migrate_pages sys_migrate_pages sys_migrate_pages 288 common openat sys_openat compat_sys_openat 289 common mkdirat sys_mkdirat sys_mkdirat 290 common mknodat sys_mknodat sys_mknodat
@@ -317,7 +317,7 @@ 307 common sync_file_range sys_sync_file_range compat_sys_s390_sync_file_range 308 common tee sys_tee sys_tee 309 common vmsplice sys_vmsplice sys_vmsplice -310 common move_pages sys_move_pages compat_sys_move_pages +310 common move_pages sys_move_pages sys_move_pages 311 common getcpu sys_getcpu sys_getcpu 312 common epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait 313 common utimes sys_utimes sys_utimes_time32
arch/sparc/kernel/syscalls/syscall.tbl +5 -5
@@ -365,12 +365,12 @@ 299 common unshare sys_unshare 300 common set_robust_list sys_set_robust_list compat_sys_set_robust_list 301 common get_robust_list sys_get_robust_list compat_sys_get_robust_list -302 common migrate_pages sys_migrate_pages compat_sys_migrate_pages -303 common mbind sys_mbind compat_sys_mbind -304 common get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy -305 common set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy +302 common migrate_pages sys_migrate_pages +303 common mbind sys_mbind +304 common get_mempolicy sys_get_mempolicy +305 common set_mempolicy sys_set_mempolicy 306 common kexec_load sys_kexec_load compat_sys_kexec_load -307 common move_pages sys_move_pages compat_sys_move_pages +307 common move_pages sys_move_pages 308 common getcpu sys_getcpu 309 common epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait 310 32 utimensat sys_utimensat_time32
arch/x86/entry/syscalls/syscall_32.tbl +2 -2
@@ -286,7 +286,7 @@ 272 i386 fadvise64_64 sys_ia32_fadvise64_64 273 i386 vserver 274 i386 mbind sys_mbind -275 i386 get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy +275 i386 get_mempolicy sys_get_mempolicy 276 i386 set_mempolicy sys_set_mempolicy 277 i386 mq_open sys_mq_open compat_sys_mq_open 278 i386 mq_unlink sys_mq_unlink
@@ -328,7 +328,7 @@ 314 i386 sync_file_range sys_ia32_sync_file_range 315 i386 tee sys_tee 316 i386 vmsplice sys_vmsplice -317 i386 move_pages sys_move_pages compat_sys_move_pages +317 i386 move_pages sys_move_pages 318 i386 getcpu sys_getcpu 319 i386 epoll_pwait sys_epoll_pwait 320 i386 utimensat sys_utimensat_time32
arch/x86/entry/syscalls/syscall_64.tbl +1 -1
@@ -397,7 +397,7 @@ 530 x32 set_robust_list compat_sys_set_robust_list 531 x32 get_robust_list compat_sys_get_robust_list 532 x32 vmsplice sys_vmsplice -533 x32 move_pages compat_sys_move_pages +533 x32 move_pages sys_move_pages 534 x32 preadv compat_sys_preadv64 535 x32 pwritev compat_sys_pwritev64 536 x32 rt_tgsigqueueinfo compat_sys_rt_tgsigqueueinfo
include/linux/compat.h +0 -20
@@ -799,26 +799,6 @@ asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr/* mm/fadvise.c: No generic prototype for fadvise64_64 */ /* mm/, CONFIG_MMU only */ -asmlinkage long compat_sys_mbind (compat_ulong_t start,compat_ulong_t len, -compat_ulong_t mode, -compat_ulong_t __user *nmask, -compat_ulong_t maxnode,compat_ulong_t flags); -asmlinkage long compat_sys_get_mempolicy (int __user *policy, -compat_ulong_t __user *nmask, -compat_ulong_t maxnode, -compat_ulong_t addr, -compat_ulong_t flags); -asmlinkage long compat_sys_set_mempolicy (int mode,compat_ulong_t __user *nmask, -compat_ulong_t maxnode); -asmlinkage long compat_sys_migrate_pages (compat_pid_t pid, -compat_ulong_t maxnode,const compat_ulong_t __user *old_nodes, -const compat_ulong_t __user *new_nodes); -asmlinkage long compat_sys_move_pages (pid_t pid,compat_ulong_t nr_pages, -__u32 __user *pages, -const int __user *nodes, -int __user *status, -int flags); -asmlinkage long compat_sys_rt_tgsigqueueinfo (compat_pid_t tgid,compat_pid_t pid,int sig,struct compat_siginfo __user *uinfo);
include/uapi/asm-generic/unistd.h +5 -5
@@ -673,15 +673,15 @@ __SYSCALL(__NR_madvise, sys_madvise)#define __NR_remap_file_pages 234 __SYSCALL(__NR_remap_file_pages, sys_remap_file_pages)#define __NR_mbind 235 -__SC_COMP(__NR_mbind, sys_mbind, compat_sys_mbind) +__SYSCALL(__NR_mbind, sys_mbind)#define __NR_get_mempolicy 236 -__SC_COMP(__NR_get_mempolicy, sys_get_mempolicy, compat_sys_get_mempolicy) +__SYSCALL(__NR_get_mempolicy, sys_get_mempolicy)#define __NR_set_mempolicy 237 -__SC_COMP(__NR_set_mempolicy, sys_set_mempolicy, compat_sys_set_mempolicy) +__SYSCALL(__NR_set_mempolicy, sys_set_mempolicy)#define __NR_migrate_pages 238 -__SC_COMP(__NR_migrate_pages, sys_migrate_pages, compat_sys_migrate_pages) +__SYSCALL(__NR_migrate_pages, sys_migrate_pages)#define __NR_move_pages 239 -__SC_COMP(__NR_move_pages, sys_move_pages, compat_sys_move_pages) +__SYSCALL(__NR_move_pages, sys_move_pages)#endif #define __NR_rt_tgsigqueueinfo 240
kernel/sys_ni.c +0 -5
@@ -291,15 +291,10 @@ COND_SYSCALL(madvise);COND_SYSCALL (process_madvise);COND_SYSCALL (remap_file_pages);COND_SYSCALL (mbind); -COND_SYSCALL_COMPAT (mbind);COND_SYSCALL (get_mempolicy); -COND_SYSCALL_COMPAT (get_mempolicy);COND_SYSCALL (set_mempolicy); -COND_SYSCALL_COMPAT (set_mempolicy);COND_SYSCALL (migrate_pages); -COND_SYSCALL_COMPAT (migrate_pages);COND_SYSCALL (move_pages); -COND_SYSCALL_COMPAT (move_pages);COND_SYSCALL (perf_event_open);COND_SYSCALL (accept4);
mm/mempolicy.c +0 -37
@@ -1647,43 +1647,6 @@ SYSCALL_DEFINE5(get_mempolicy, int __user *, policy,return kernel_get_mempolicy (policy, nmask, maxnode, addr, flags); } -#ifdef CONFIG_COMPAT - -COMPAT_SYSCALL_DEFINE5(get_mempolicy, int __user *, policy, - compat_ulong_t __user *, nmask, - compat_ulong_t, maxnode, - compat_ulong_t, addr, compat_ulong_t, flags) -{ -return kernel_get_mempolicy (policy, (unsigned long __user *)nmask, - maxnode, addr, flags); -} - -COMPAT_SYSCALL_DEFINE3(set_mempolicy, int, mode, compat_ulong_t __user *, nmask, - compat_ulong_t, maxnode) -{ -return kernel_set_mempolicy (mode, (unsigned long __user *)nmask, maxnode); -} - -COMPAT_SYSCALL_DEFINE6 (mbind, compat_ulong_t, start, compat_ulong_t, len, - compat_ulong_t, mode, compat_ulong_t __user *, nmask, - compat_ulong_t, maxnode, compat_ulong_t, flags) -{ -return kernel_mbind (start, len, mode, (unsigned long __user *)nmask, - maxnode, flags); -} - -COMPAT_SYSCALL_DEFINE4 (migrate_pages, compat_pid_t, pid, - compat_ulong_t, maxnode, - const compat_ulong_t __user *, old_nodes, - const compat_ulong_t __user *, new_nodes) -{ -return kernel_migrate_pages (pid, maxnode, - (const unsigned long __user *)old_nodes, - (const unsigned long __user *)new_nodes); -} - -#endif /* CONFIG_COMPAT */ -bool vma_migratable (struct vm_area_struct *vma) {if (vma->vm_flags & (VM_IO |VM_PFNMAP ))
mm/migrate.c +0 -13
@@ -1967,19 +1967,6 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,return kernel_move_pages (pid, nr_pages, pages, nodes, status, flags); } -#ifdef CONFIG_COMPAT -COMPAT_SYSCALL_DEFINE6 (move_pages, pid_t, pid, compat_ulong_t, nr_pages, - compat_uptr_t __user *, pages, - const int __user *, nodes, - int __user *, status, - int, flags) -{ -return kernel_move_pages (pid, nr_pages, - (const void __user *__user *)pages, - nodes, status, flags); -} -#endif /* CONFIG_COMPAT */ -#ifdef CONFIG_NUMA_BALANCING /* * Returns true if this is a safe migration target node for misplaced NUMA
Signature · 1 line
2.29.2
PATCH v5 6/6 arch: remove compat_alloc_user_space
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
All users of compat_alloc_user_space() and copy_in_user() have been removed from the kernel, only a few functions in sparc remain that can be changed to calling arch_copy_in_user() instead.
--- arch/arm64/include/asm/compat.h | 5 -- arch/arm64/include/asm/uaccess.h | 11 ---- arch/arm64/lib/Makefile | 2 +- arch/arm64/lib/copy_in_user.S | 77 ------------------------- arch/mips/cavium-octeon/octeon-memcpy.S | 2 - arch/mips/include/asm/compat.h | 8 --- arch/mips/include/asm/uaccess.h | 26 --------- arch/mips/lib/memcpy.S | 11 ---- arch/parisc/include/asm/compat.h | 6 -- arch/parisc/include/asm/uaccess.h | 2 - arch/parisc/lib/memcpy.c | 9 --- arch/powerpc/include/asm/compat.h | 16 ----- arch/s390/include/asm/compat.h | 10 ---- arch/s390/include/asm/uaccess.h | 3 - arch/s390/lib/uaccess.c | 63 -------------------- arch/sparc/include/asm/compat.h | 19 ------ arch/sparc/kernel/process_64.c | 2 +- arch/sparc/kernel/signal32.c | 12 ++-- arch/sparc/kernel/signal_64.c | 8 +-- arch/x86/include/asm/compat.h | 13 ----- arch/x86/include/asm/uaccess_64.h | 7 --- include/linux/compat.h | 2 - include/linux/uaccess.h | 10 ---- kernel/compat.c | 21 ------- 24 files changed, 12 insertions(+), 333 deletions(-) delete mode 100644 arch/arm64/lib/copy_in_user.S
arch/arm64/include/asm/compat.h +0 -5
@@ -107,11 +107,6 @@ struct compat_statfs {#define compat_user_stack_pointer () (user_stack_pointer(task_pt_regs(current)))#define COMPAT_MINSIGSTKSZ 2048 -static inline void __user *arch_compat_alloc_user_space (long len) -{ -return (void __user *)compat_user_stack_pointer () - len; -} -struct compat_ipc64_perm {compat_key_t key;__compat_uid32_t uid;
arch/arm64/include/asm/uaccess.h +0 -11
@@ -430,17 +430,6 @@ extern unsigned long __must_check __arch_copy_to_user(void __user *to, const voi __actu_ret; \ }) -extern unsigned long __must_check __arch_copy_in_user (void __user *to,const void __user *from,unsigned long n); -#define raw_copy_in_user (to, from, n) \ -({ \ - unsigned long __aciu_ret; \ - uaccess_ttbr0_enable(); \ - __aciu_ret = __arch_copy_in_user(__uaccess_mask_ptr(to), \ - __uaccess_mask_ptr(from), (n)); \ - uaccess_ttbr0_disable(); \ - __aciu_ret; \ -}) -#define INLINE_COPY_TO_USER #define INLINE_COPY_FROM_USER
arch/arm64/lib/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 lib-y := clear_user.o delay.o copy_from_user.o \ - copy_to_user.o copy_in_user.o copy_page.o \ + copy_to_user.o copy_page.o \ clear_page.o csum.o insn.o memchr.o memcpy.o \ memset.o memcmp.o strcmp.o strncmp.o strlen.o \ strnlen.o strchr.o strrchr.o tishift.o
arch/arm64/lib/copy_in_user.S deleted +0 -77
77 lines not on this page · raw message
arch/mips/cavium-octeon/octeon-memcpy.S +0 -2
@@ -154,8 +154,6 @@ FEXPORT(__raw_copy_from_user) EXPORT_SYMBOL(__raw_copy_from_user) FEXPORT(__raw_copy_to_user) EXPORT_SYMBOL(__raw_copy_to_user) -FEXPORT(__raw_copy_in_user) -EXPORT_SYMBOL(__raw_copy_in_user) /* * Note: dst & src may be unaligned, len may be 0 * Temps
arch/mips/include/asm/compat.h +0 -8
@@ -96,14 +96,6 @@ struct compat_statfs {#define COMPAT_OFF_T_MAX 0x7fffffff -static inline void __user *arch_compat_alloc_user_space (long len) -{ -struct pt_regs *regs = (struct pt_regs *) - ((unsigned long )current_thread_info () +THREAD_SIZE -32 ) -1 ; - -return (void __user *) (regs->regs[29 ] - len); -} -struct compat_ipc64_perm {compat_key_t key;__compat_uid32_t uid;
arch/mips/include/asm/uaccess.h +0 -26
@@ -428,7 +428,6 @@ do { \extern size_t __raw_copy_from_user (void *__to,const void *__from,size_t __n);extern size_t __raw_copy_to_user (void *__to,const void *__from,size_t __n); -extern size_t __raw_copy_in_user (void *__to,const void *__from,size_t __n);static inline unsigned long raw_copy_from_user (void *to,const void __user *from,unsigned long n)
@@ -480,31 +479,6 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)#define INLINE_COPY_FROM_USER #define INLINE_COPY_TO_USER -static inline unsigned long -raw_copy_in_user (void __user *to,const void __user *from,unsigned long n) -{ - registervoid __user *__cu_to_r __asm__("$4" ); - registerconst void __user *__cu_from_r __asm__("$5" ); - registerlong __cu_len_r __asm__("$6" ); - - __cu_to_r = to; - __cu_from_r = from; - __cu_len_r = n; - - __asm__ __volatile__( -".set\tnoreorder\n\t" - __MODULE_JAL(__raw_copy_in_user) -".set\tnoat\n\t" - __UA_ADDU"\t$1, %1, %2\n\t" -".set\tat\n\t" -".set\treorder" - : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) - : - : "$8", "$9", "$10", "$11", "$12", "$14", "$15", "$24", "$31", - DADDI_SCRATCH, "memory"); -return __cu_len_r; -} -extern __kernel_size_t __bzero (void __user *addr,__kernel_size_t size);/*
arch/mips/lib/memcpy.S +0 -11
@@ -666,8 +666,6 @@ FEXPORT(__raw_copy_from_user) EXPORT_SYMBOL(__raw_copy_from_user) FEXPORT(__raw_copy_to_user) EXPORT_SYMBOL(__raw_copy_to_user) -FEXPORT(__raw_copy_in_user) -EXPORT_SYMBOL(__raw_copy_in_user) #endif /* Legacy Mode, user <-> user */ __BUILD_COPY_USER LEGACY_MODE USEROP USEROP
@@ -703,13 +701,4 @@ EXPORT_SYMBOL(__raw_copy_to_user) __BUILD_COPY_USER EVA_MODE KERNELOP USEROP END(__raw_copy_to_user) -/* - * __copy_in_user (EVA) - */ - -LEAF(__raw_copy_in_user) -EXPORT_SYMBOL(__raw_copy_in_user) -__BUILD_COPY_USER EVA_MODE USEROP USEROP -END(__raw_copy_in_user) - #endif
arch/parisc/include/asm/compat.h +0 -6
@@ -163,12 +163,6 @@ struct compat_shmid64_ds {#define COMPAT_ELF_NGREG 80typedef compat_ulong_t compat_elf_gregset_t [COMPAT_ELF_NGREG ]; -static __inline__void __user *arch_compat_alloc_user_space (long len) -{ -struct pt_regs *regs = ¤t->thread.regs; -return (void __user *)regs->gr[30 ]; -} -static inline int __is_compat_task (struct task_struct *t) {return test_tsk_thread_flag (t,TIF_32BIT );
arch/parisc/include/asm/uaccess.h +0 -2
@@ -215,8 +215,6 @@ unsigned long __must_check raw_copy_to_user(void __user *dst, const void *src, unsigned long len);unsigned long __must_check raw_copy_from_user (void *dst,const void __user *src,unsigned long len); -unsigned long __must_check raw_copy_in_user (void __user *dst,const void __user *src, -unsigned long len);#define INLINE_COPY_TO_USER #define INLINE_COPY_FROM_USER
arch/parisc/lib/memcpy.c +0 -9
@@ -38,14 +38,6 @@ unsigned long raw_copy_from_user(void *dst, const void __user *src, }EXPORT_SYMBOL (raw_copy_from_user); -unsigned long raw_copy_in_user (void __user *dst,const void __user *src,unsigned long len) -{ -mtsp (get_user_space (),1 ); -mtsp (get_user_space (),2 ); -return pa_memcpy ((void __force *)dst, (void __force *)src, len); -} - -void *memcpy (void * dst,const void *src,size_t count) {mtsp (get_kernel_space (),1 );
@@ -54,7 +46,6 @@ void * memcpy(void * dst,const void *src, size_t count)return dst; } -EXPORT_SYMBOL (raw_copy_in_user);EXPORT_SYMBOL (memcpy);bool copy_from_kernel_nofault_allowed (const void *unsafe_src,size_t size)
arch/powerpc/include/asm/compat.h +0 -16
@@ -83,22 +83,6 @@ struct compat_statfs {#define COMPAT_OFF_T_MAX 0x7fffffff -static inline void __user *arch_compat_alloc_user_space (long len) -{ -struct pt_regs *regs = current->thread.regs; -unsigned long usp = regs->gpr[1 ]; - -/* -* We can't access below the stack pointer in the 32bit ABI and -* can access 288 bytes in the 64bit big-endian ABI, -* or 512 bytes with the new ELFv2 little-endian ABI. -*/ -if (!is_32bit_task ()) - usp -=USER_REDZONE_SIZE ; - -return (void __user *) (usp - len); -} -/* * ipc64_perm is actually 32/64bit clean but since the compat layer refers to * it we may as well define it.
arch/s390/include/asm/compat.h +0 -10
@@ -176,16 +176,6 @@ static inline int is_compat_task(void)return test_thread_flag (TIF_31BIT ); } -static inline void __user *arch_compat_alloc_user_space (long len) -{ -unsigned long stack; - - stack =KSTK_ESP (current); -if (is_compat_task ()) - stack &=0x7fffffffUL ; -return (void __user *) (stack - len); -} -#endif struct compat_ipc64_perm {
arch/s390/include/asm/uaccess.h +0 -3
@@ -227,9 +227,6 @@ static inline int __get_user_fn(void *x, const void __user *ptr, unsigned long s__get_user (x, ptr); \ }) -unsigned long __must_check -raw_copy_in_user (void __user *to,const void __user *from,unsigned long n); -/* * Copy a null terminated string from userspace. */
arch/s390/lib/uaccess.c +0 -63
69 lines not on this page · raw message
arch/sparc/include/asm/compat.h +0 -19
@@ -116,25 +116,6 @@ struct compat_statfs {#define COMPAT_OFF_T_MAX 0x7fffffff -#ifdef CONFIG_COMPAT -static inline void __user *arch_compat_alloc_user_space (long len) -{ -struct pt_regs *regs =current_thread_info ()->kregs; -unsigned long usp = regs->u_regs[UREG_I6 ]; - -if (test_thread_64bit_stack (usp)) - usp +=STACK_BIAS ; - -if (test_thread_flag (TIF_32BIT )) - usp &=0xffffffffUL ; - - usp -= len; - usp &= ~0x7UL ; - -return (void __user *) usp; -} -#endif -struct compat_ipc64_perm {compat_key_t key;__compat_uid32_t uid;
arch/sparc/kernel/process_64.c +1 -1
@@ -458,7 +458,7 @@ static unsigned long clone_stackframe(unsigned long csp, unsigned long psp) distance = fp - psp; rval = (csp - distance); -if (copy_in_user ((void __user *) rval, (void __user *) psp, distance)) +if (raw_copy_in_user ((void __user *)rval, (void __user *)psp, distance)) rval =0 ;else if (!stack_64bit) { if (put_user(((u32)csp),
arch/sparc/kernel/signal32.c +6 -6
@@ -435,9 +435,9 @@ static int setup_frame32(struct ksignal *ksig, struct pt_regs *regs, (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));if (!wsaved) { - err |=copy_in_user ((u32 __user *)sf, - (u32 __user *)(regs->u_regs[UREG_FP ]), -sizeof (struct reg_window32 )); + err |=raw_copy_in_user ((u32 __user *)sf, + (u32 __user *)(regs->u_regs[UREG_FP ]), +sizeof (struct reg_window32 )); }else {struct reg_window *rp;
@@ -567,9 +567,9 @@ static int setup_rt_frame32(struct ksignal *ksig, struct pt_regs *regs, err |=put_compat_sigset (&sf->mask, oldset,sizeof (compat_sigset_t));if (!wsaved) { - err |=copy_in_user ((u32 __user *)sf, - (u32 __user *)(regs->u_regs[UREG_FP ]), -sizeof (struct reg_window32 )); + err |=raw_copy_in_user ((u32 __user *)sf, + (u32 __user *)(regs->u_regs[UREG_FP ]), +sizeof (struct reg_window32 )); }else {struct reg_window *rp;
arch/sparc/kernel/signal_64.c +4 -4
@@ -406,10 +406,10 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs) err |=copy_to_user (&sf->mask,sigmask_to_save (),sizeof (sigset_t));if (!wsaved) { - err |=copy_in_user ((u64 __user *)sf, - (u64 __user *)(regs->u_regs[UREG_FP ] + -STACK_BIAS ), -sizeof (struct reg_window )); + err |=raw_copy_in_user ((u64 __user *)sf, + (u64 __user *)(regs->u_regs[UREG_FP ] + +STACK_BIAS ), +sizeof (struct reg_window )); }else {struct reg_window *rp;
arch/x86/include/asm/compat.h +0 -13
@@ -156,19 +156,6 @@ struct compat_shmid64_ds { (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT))#endif -static inline void __user *arch_compat_alloc_user_space (long len) -{ -compat_uptr_t sp =task_pt_regs (current)->sp; - -/* -* -128 for the x32 ABI redzone. For IA32, it is not strictly -* necessary, but not harmful. -*/ - sp -=128 ; - -return (void __user *)round_down (sp - len,16 ); -} -static inline bool in_x32_syscall (void ) {#ifdef CONFIG_X86_X32_ABI
arch/x86/include/asm/uaccess_64.h +0 -7
@@ -58,13 +58,6 @@ raw_copy_to_user(void __user *dst, const void *src, unsigned long size)return copy_user_generic ((__force void *)dst, src, size); } -static __always_inline __must_check -unsigned long raw_copy_in_user (void __user *dst,const void __user *src,unsigned long size) -{ -return copy_user_generic ((__force void *)dst, - (__force void *)src, size); -} -extern long __copy_user_nocache (void *dst,const void __user *src,unsigned size,int zerorest);
include/linux/compat.h +0 -2
@@ -511,8 +511,6 @@ extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,struct epoll_event ;/* fortunately, this one is fixed-layout */ -extern void __user *compat_alloc_user_space (unsigned long len); -int compat_restore_altstack (const compat_stack_t __user *uss);int __compat_save_altstack (compat_stack_t __user *,unsigned long );#define unsafe_compat_save_altstack (uss, sp, label) do { \
include/linux/uaccess.h +0 -10
@@ -200,16 +200,6 @@ copy_to_user(void __user *to, const void *from, unsigned long n) n =_copy_to_user (to, from, n);return n; } -#ifdef CONFIG_COMPAT -static __always_inline unsigned long __must_check -copy_in_user (void __user *to,const void __user *from,unsigned long n) -{ -might_fault (); -if (access_ok (to, n) &&access_ok (from, n)) - n =raw_copy_in_user (to, from, n); -return n; -} -#endif #ifndef copy_mc_to_kernel/*
kernel/compat.c +0 -21
@@ -269,24 +269,3 @@ get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat)return 0 ; }EXPORT_SYMBOL_GPL (get_compat_sigset); - -/* -* Allocate user-space memory for the duration of a single system call, -* in order to marshall parameters inside a compat thunk. -*/ -void __user *compat_alloc_user_space (unsigned long len) -{ -void __user *ptr; - -/* If len would occupy more than half of the entire compat space... */ -if (unlikely (len > (((compat_uptr_t )~0 ) >>1 ))) -return NULL ; - - ptr =arch_compat_alloc_user_space (len); - -if (unlikely (!access_ok (ptr, len))) -return NULL ; - -return ptr; -} -EXPORT_SYMBOL_GPL (compat_alloc_user_space);
Signature · 1 line
2.29.2
Re: [PATCH v5 6/6] arch: remove compat_alloc_user_space
finally!
Looks good,
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 3 lines · Arnd Bergmann
Since these patches are now all that remains, it would be nice to merge it all through Andrew's Linux-mm tree, which is already based on top of linux-next.
Is it?
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Andrew Morton
maintainerQuoted 6 lines · On Tue, 27 Jul 2021 15:59:55 +0100 Christoph Hellwig <[email protected]> wrote:
Quoted 3 lines · Arnd Bergmann
Since these patches are now all that remains, it would be nice to merge it all through Andrew's Linux-mm tree, which is already based on top of linux-next.
Is it?
the -mm tree is structured as
<90% of stuff>
linux-next.patch
<the other 10% of stuff>
So things like Arnd's series which have a dependency on linux-next material get added to the "other 10%" and are merged behind the linux-next material and all is good.
If possible I'll queue things ahead of linux-next.patch. Those few things which have dependencies on linux-next material get sent to Linus after the required linux-next material is merged into mainline.
Quoted 16 lines · Andrew Morton
Quoted 6 lines · On Tue, 27 Jul 2021 15:59:55 +0100 Christoph Hellwig <[email protected]> wrote:
Quoted 3 lines · Arnd Bergmann
Since these patches are now all that remains, it would be nice to merge it all through Andrew's Linux-mm tree, which is already based on top of linux-next.
Is it?
the -mm tree is structured as
<90% of stuff>
linux-next.patch
<the other 10% of stuff>
Quoted 7 lines
So things like Arnd's series which have a dependency on linux-next material get added to the "other 10%" and are merged behind the linux-next material and all is good.
If possible I'll queue things ahead of linux-next.patch. Those few things which have dependencies on linux-next material get sent to Linus after the required linux-next material is merged into mainline.
The first five patches in my series should apply cleanly on mainline kernels and make sense by themselves, the last patch is the one that depends on this series as well as another series in the netdev tree, so that has to go behind linux-next.
I suppose I could also merge the first five through my asm-generic tree and send you the last one if you prefer, but then again two of the patches are actually memory management stuff.
Arnd
Heiko Carstens
maintainerQuoted 14 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Going through
compat_alloc_user_space()to convert indirect system call arguments tends to add complexity compared to handling the native and compat logic in the same code.Out of the other remaining callers, the linux-media series went into v5.14, and the network ioctl handling is now fixed in net-next, so these are the last remaining users, and I now include the final patch to remove the definitions as well.
Since these patches are now all that remains, it would be nice to merge it all through Andrew's Linux-mm tree, which is already based on top of linux-next.
...
Quoted 8 lines
Arnd Bergmann (6):
kexec: move locking intodo_kexec_load
kexec: avoidcompat_alloc_user_space
mm: simplifycompat_sys_move_pages
mm: simplify compat numa syscalls
compat: remove some compat entry points
arch: removecompat_alloc_user_space
Our CI reports this with linux-next and running strace selftest in compat mode:
Unable to handle kernel pointer dereference in virtual kernel address space
Failing address: 0000038003e7c000 TEID: 0000038003e7c803
Fault in home space mode while using kernel ASCE.
AS:00000001fb388007 R3:000000008021c007 S:0000000082142000 P:0000000000000400
Oops: 0011 ilc:3 [#1] SMP
CPU: 0 PID: 1017495 Comm: get_mempolicy Tainted: G OE 5.14.0-20210730.rc3.git0.4ccc9e2db7ac.300.fc34.s390x+next #1
Hardware name: IBM 2827 H66 708 (LPAR)
Krnl PSW : 0704e00180000000 00000001f9f11000 (compat_put_bitmap+0x48/0xd0)
R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:2 PM:0 RI:0 EA:3
Krnl GPRS: 0000000000810000 0000000000000000 000000007d9df1c0 0000038003e7c008
0000000000000004 000000007d9df1c4 0000038003e7be40 0000000000010000
0000000000008000 0000000000000000 0000000000000390 00000000000001c8
000000020d6ea000 000002aa00401a48 00000001fa0a85fa 0000038003e7bd50
Krnl Code: 00000001f9f10ff4: a7bb0001 aghi %r11,1
00000001f9f10ff8: 41303008 la %r3,8(%r3)
#00000001f9f10ffc: 41502004 la %r5,4(%r2)
>00000001f9f11000: e3103ff8ff04 lg %r1,-8(%r3)
00000001f9f11006: 5010f0a4 st %r1,164(%r15)
00000001f9f1100a: a50e0081 llilh %r0,129
00000001f9f1100e: c8402000f0a4 mvcos 0(%r2),164(%r15),%r4
00000001f9f11014: 1799 xr %r9,%r9
Call Trace:
[<00000001f9f11000>] compat_put_bitmap+0x48/0xd0
[<00000001fa0a85fa>] kernel_get_mempolicy+0x102/0x178
[<00000001fa0a86b0>] __s390_sys_get_mempolicy+0x40/0x50
[<00000001fa92be30>] __do_syscall+0x1c0/0x1e8
[<00000001fa939148>] system_call+0x78/0xa0
Last Breaking-Event-Address:
[<0000038003e7bc00>] 0x38003e7bc00
Kernel panic - not syncing: Fatal exception: panic_on_oopsNote: I did not try to bisect this, since it looks to me like this patch series causes the problem. Also, please don't get confused with the kernel version name. The date encoded is the build date, not the linux-next version.
linux-next commit 4ccc9e2db7ac ("Add linux-next specific files for 20210729") was used to build the kernel (s390 defconfig).
Quoted 4 lines · Heiko Carstens
On Tue, Jul 27, 2021 at 04:48:53PM +0200, Arnd Bergmann wrote:
Our CI reports this with linux-next and running strace selftest in compat mode:
Thanks a lot for the report! I managed track it down based on your output, it turns out that I end up copying data from the stack according to how much the user asked for, and in this case that was much more than the 8 byte nodemask_t, copying all of the kernel stack all the way into the guard page with CONFIG_VMAP_STACK, where it crashed. Without CONFIG_VMAP_STACK, or with user space that asks for less data, it would just be an information leak, so others probably haven't noticed the problem.
The change below should fix that, I'll double-check the other callers as well before sending a proper fixup patch to Andrew.
Arnd
mm/mempolicy.c +0 -0
@@ -1438,6 +1438,7 @@ static int copy_nodes_to_user(unsigned long
__user *mask, unsigned long maxnode,
if (clear_user((char __user *)mask + nbytes, copy - nbytes))
return -EFAULT;
copy = nbytes;
+ maxnode = nr_node_ids;
}
if (compat)