Merge tag 'execve-v5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 2 Aug 2022 21:36:19 +0000 (14:36 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 2 Aug 2022 21:36:19 +0000 (14:36 -0700)
Pull execve updates from Kees Cook:

 - Allow unsharing time namespace on vfork+exec (Andrei Vagin)

 - Replace usage of deprecated kmap APIs (Fabio M. De Francesco)

 - Fix spelling mistake (Zhang Jiaming)

* tag 'execve-v5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  exec: Call kmap_local_page() in copy_string_kernel()
  exec: Fix a spelling mistake
  selftests/timens: add a test for vfork+exit
  fs/exec: allow to unshare a time namespace on vfork+exec

1  2 
fs/exec.c

diff --combined fs/exec.c
+++ b/fs/exec.c
@@@ -65,6 -65,7 +65,7 @@@
  #include <linux/io_uring.h>
  #include <linux/syscall_user_dispatch.h>
  #include <linux/coredump.h>
+ #include <linux/time_namespace.h>
  
  #include <linux/uaccess.h>
  #include <asm/mmu_context.h>
@@@ -630,7 -631,6 +631,6 @@@ int copy_string_kernel(const char *arg
                unsigned int bytes_to_copy = min_t(unsigned int, len,
                                min_not_zero(offset_in_page(pos), PAGE_SIZE));
                struct page *page;
-               char *kaddr;
  
                pos -= bytes_to_copy;
                arg -= bytes_to_copy;
                page = get_arg_page(bprm, pos, 1);
                if (!page)
                        return -E2BIG;
-               kaddr = kmap_atomic(page);
                flush_arg_page(bprm, pos & PAGE_MASK, page);
-               memcpy(kaddr + offset_in_page(pos), arg, bytes_to_copy);
-               flush_dcache_page(page);
-               kunmap_atomic(kaddr);
+               memcpy_to_page(page, offset_in_page(pos), arg, bytes_to_copy);
                put_arg_page(page);
        }
  
@@@ -982,10 -979,12 +979,12 @@@ static int exec_mmap(struct mm_struct *
  {
        struct task_struct *tsk;
        struct mm_struct *old_mm, *active_mm;
+       bool vfork;
        int ret;
  
        /* Notify parent that we're no longer interested in the old VM */
        tsk = current;
+       vfork = !!tsk->vfork_done;
        old_mm = current->mm;
        exec_mm_release(tsk, old_mm);
        if (old_mm)
        tsk->mm->vmacache_seqnum = 0;
        vmacache_flush(tsk);
        task_unlock(tsk);
+       if (vfork)
+               timens_on_fork(tsk->nsproxy, tsk);
        if (old_mm) {
                mmap_read_unlock(old_mm);
                BUG_ON(active_mm != old_mm);
@@@ -1149,7 -1152,7 +1152,7 @@@ static int de_thread(struct task_struc
                /*
                 * We are going to release_task()->ptrace_unlink() silently,
                 * the tracer can sleep in do_wait(). EXIT_DEAD guarantees
-                * the tracer wont't block again waiting for this thread.
+                * the tracer won't block again waiting for this thread.
                 */
                if (unlikely(leader->ptrace))
                        __wake_up_parent(leader, leader->parent);
@@@ -1301,7 -1304,7 +1304,7 @@@ int begin_new_exec(struct linux_binprm 
        bprm->mm = NULL;
  
  #ifdef CONFIG_POSIX_TIMERS
 -      exit_itimers(me->signal);
 +      exit_itimers(me);
        flush_itimer_signals();
  #endif