]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
exit: perform add_device_randomness() without tasklist_lock
authorMateusz Guzik <mjguzik@gmail.com>
Thu, 6 Feb 2025 16:44:10 +0000 (17:44 +0100)
committerChristian Brauner <brauner@kernel.org>
Fri, 7 Feb 2025 10:22:43 +0000 (11:22 +0100)
Parallel calls to add_device_randomness() contend on their own.

The clone side aleady runs outside of tasklist_lock, which in turn means
any caller on the exit side extends the tasklist_lock hold time while
contending on the random-private lock.

Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Link: https://lore.kernel.org/r/20250206164415.450051-2-mjguzik@gmail.com
Acked-by: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
kernel/exit.c

index 0acb94b17caae52ae3db76659e56ecaecff2f9ac..a00273db024b3a5de0b23570fab690e80d495e2f 100644 (file)
@@ -174,9 +174,6 @@ static void __exit_signal(struct task_struct *tsk)
                        sig->curr_target = next_thread(tsk);
        }
 
-       add_device_randomness((const void*) &tsk->se.sum_exec_runtime,
-                             sizeof(unsigned long long));
-
        /*
         * Accumulate here the counters for all threads as they die. We could
         * skip the group leader because it is the last user of signal_struct,
@@ -270,6 +267,8 @@ repeat:
        write_unlock_irq(&tasklist_lock);
        proc_flush_pid(thread_pid);
        put_pid(thread_pid);
+       add_device_randomness(&p->se.sum_exec_runtime,
+                             sizeof(p->se.sum_exec_runtime));
        release_thread(p);
        /*
         * This task was already removed from the process/thread/pid lists