exit_mm() takes the mmap lock for reading around clearing current->mm. That goes back to 2003 (cf. [1]). A coredump took the lock for writing and counted every thread that had an mm in mm->core_waiters. An exiting thread had to look at core_waiters and clear its mm without the dumping thread getting in between. Commit 92307383082d ("coredump: Don't perform any cleanups before dumping core") moved that check into coredump_task_exit() which runs before exit_mm(). And commit 0258b5fd7c71 ("coredump: Limit coredumps to a single thread group") moved core_state into signal_struct and the check under siglock. Since then the lock in exit_mm() doesn't protect anything a coredump looks at. So don't take it. While at it, drop the comment that calls task_lock() more a memory barrier than a real lock. It's the only lock that's left around clearing current->mm. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=99365bd4725d431255ff4bdd51fb3dca60c47322 Signed-off-by: Christian Brauner (Amutable) --- kernel/exit.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index d5e7bc2af804a..38de318a07aaa 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -559,10 +559,8 @@ static void exit_mm(void) sched_cache_exit_mm(current); - mmap_read_lock(mm); mmgrab_lazy_tlb(mm); BUG_ON(mm != current->active_mm); - /* more a memory barrier than a real lock */ task_lock(current); /* * When a thread stops operating on an address space, the loop @@ -581,7 +579,6 @@ static void exit_mm(void) enter_lazy_tlb(mm, current); local_irq_enable(); task_unlock(current); - mmap_read_unlock(mm); mm_update_next_owner(mm); mmput(mm); if (test_thread_flag(TIF_MEMDIE)) -- 2.53.0