]> Git Repo - linux.git/blobdiff - kernel/fork.c
Merge tag 'usb-5.11-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
[linux.git] / kernel / fork.c
index 7425b3224891d764d2f092e3224c140d28f58b19..d66cd1014211b92de6e9f881089175395845265c 100644 (file)
@@ -225,8 +225,8 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
                if (!s)
                        continue;
 
-               /* Clear the KASAN shadow of the stack. */
-               kasan_unpoison_shadow(s->addr, THREAD_SIZE);
+               /* Mark stack accessible for KASAN. */
+               kasan_unpoison_range(s->addr, THREAD_SIZE);
 
                /* Clear stale pointers from reused stack. */
                memset(s->addr, 0, THREAD_SIZE);
@@ -819,9 +819,8 @@ void __init fork_init(void)
        init_task.signal->rlim[RLIMIT_SIGPENDING] =
                init_task.signal->rlim[RLIMIT_NPROC];
 
-       for (i = 0; i < UCOUNT_COUNTS; i++) {
+       for (i = 0; i < UCOUNT_COUNTS; i++)
                init_user_ns.ucount_max[i] = max_threads/2;
-       }
 
 #ifdef CONFIG_VMAP_STACK
        cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "fork:vm_stack_cache",
@@ -1225,7 +1224,7 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
        struct mm_struct *mm;
        int err;
 
-       err =  mutex_lock_killable(&task->signal->exec_update_mutex);
+       err =  down_read_killable(&task->signal->exec_update_lock);
        if (err)
                return ERR_PTR(err);
 
@@ -1235,7 +1234,7 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
                mmput(mm);
                mm = ERR_PTR(-EACCES);
        }
-       mutex_unlock(&task->signal->exec_update_mutex);
+       up_read(&task->signal->exec_update_lock);
 
        return mm;
 }
@@ -1595,7 +1594,7 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
        sig->oom_score_adj_min = current->signal->oom_score_adj_min;
 
        mutex_init(&sig->cred_guard_mutex);
-       mutex_init(&sig->exec_update_mutex);
+       init_rwsem(&sig->exec_update_lock);
 
        return 0;
 }
@@ -1654,9 +1653,8 @@ static inline void init_task_pid_links(struct task_struct *task)
 {
        enum pid_type type;
 
-       for (type = PIDTYPE_PID; type < PIDTYPE_MAX; ++type) {
+       for (type = PIDTYPE_PID; type < PIDTYPE_MAX; ++type)
                INIT_HLIST_NODE(&task->pid_links[type]);
-       }
 }
 
 static inline void
@@ -3031,21 +3029,21 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
  *     the exec layer of the kernel.
  */
 
-int unshare_files(struct files_struct **displaced)
+int unshare_files(void)
 {
        struct task_struct *task = current;
-       struct files_struct *copy = NULL;
+       struct files_struct *old, *copy = NULL;
        int error;
 
        error = unshare_fd(CLONE_FILES, NR_OPEN_MAX, &copy);
-       if (error || !copy) {
-               *displaced = NULL;
+       if (error || !copy)
                return error;
-       }
-       *displaced = task->files;
+
+       old = task->files;
        task_lock(task);
        task->files = copy;
        task_unlock(task);
+       put_files_struct(old);
        return 0;
 }
 
This page took 0.034986 seconds and 4 git commands to generate.