Skip to content

Commit fe81417

Browse files
Christoph Hellwigtorvalds
authored andcommitted
exec: use force_uaccess_begin during exec and exit
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>
1 parent 3d13f31 commit fe81417

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎fs/exec.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,12 @@ int begin_new_exec(struct linux_binprm * bprm)
14021402
if (retval)
14031403
goto out_unlock;
14041404

1405-
set_fs(USER_DS);
1405+
/*
1406+
* Ensure that the uaccess routines can actually operate on userspace
1407+
* pointers:
1408+
*/
1409+
force_uaccess_begin();
1410+
14061411
me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD |
14071412
PF_NOFREEZE | PF_NO_SETAFFINITY);
14081413
flush_thread();

‎kernel/exit.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ void __noreturn do_exit(long code)
732732
* mm_release()->clear_child_tid() from writing to a user-controlled
733733
* kernel address.
734734
*/
735-
set_fs(USER_DS);
735+
force_uaccess_begin();
736736

737737
if (unlikely(in_atomic())) {
738738
pr_info("note: %s[%d] exited with preempt_count %d\n",

0 commit comments

Comments
 (0)