]> git.baikalelectronics.ru Git - kernel.git/commitdiff
exec: use force_uaccess_begin during exec and exit
authorChristoph Hellwig <hch@lst.de>
Wed, 12 Aug 2020 01:33:50 +0000 (18:33 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 12 Aug 2020 17:57:59 +0000 (10:57 -0700)
Both exec and exit want to ensure that the uaccess routines actually do
access user pointers.  Use the newly added force_uaccess_begin helper
instead of an open coded set_fs for that to prepare for kernel builds
where set_fs() does not exist.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nick Hu <nickhu@andestech.com>
Cc: Greentime Hu <green.hu@gmail.com>
Cc: Vincent Chen <deanbo422@gmail.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Link: http://lkml.kernel.org/r/20200710135706.537715-7-hch@lst.de
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/exec.c
kernel/exit.c

index 3698252719a33d21049d0f4f58b0ca898bc4d29d..29ef78ae9f50206f18e7d08b8bfa373cf00a6426 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1402,7 +1402,12 @@ int begin_new_exec(struct linux_binprm * bprm)
        if (retval)
                goto out_unlock;
 
-       set_fs(USER_DS);
+       /*
+        * Ensure that the uaccess routines can actually operate on userspace
+        * pointers:
+        */
+       force_uaccess_begin();
+
        me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD |
                                        PF_NOFREEZE | PF_NO_SETAFFINITY);
        flush_thread();
index e731c414e024a001d2f19c243fde024cf583a27d..c2d2961576f2ab1a46a3fb26b5f253f019f25745 100644 (file)
@@ -732,7 +732,7 @@ void __noreturn do_exit(long code)
         * mm_release()->clear_child_tid() from writing to a user-controlled
         * kernel address.
         */
-       set_fs(USER_DS);
+       force_uaccess_begin();
 
        if (unlikely(in_atomic())) {
                pr_info("note: %s[%d] exited with preempt_count %d\n",