exec_mmap() takes the mmap lock of the old mm for reading while it switches the task over to the new mm. And it does that with exec_update_lock held for writing. That lock was only ever needed for coredumps. The coredump code used to take the mmap lock for writing and then killed every task using the mm. So exec had to check for a coredump in progress under the mmap lock before it left the mm. Commit 7e3c4fb7fc19 ("exec: Check for a pending fatal signal instead of core_state") replaced that check with mmap_read_lock_killable(). And since commit 0258b5fd7c71 ("coredump: Limit coredumps to a single thread group") a coredump doesn't kill anything outside of its own thread-group and doesn't take the mmap lock to find tasks anymore. An exec in the same thread-group is serialized against the coredump in de_thread(). Nothing else relies on the mmap lock to keep a task from leaving its mm. exit_mm() takes the mmap lock for the same historical reason. The next patch removes that one. Signed-off-by: Christian Brauner (Amutable) --- fs/exec.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 6120310f3fbab..78046ed839646 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -864,19 +864,6 @@ static int exec_mmap(struct linux_binprm *bprm) if (ret) return ret; - if (old_mm) { - /* - * If there is a pending fatal signal perhaps a signal - * whose default action is to create a coredump get - * out and die instead of going through with the exec. - */ - ret = mmap_read_lock_killable(old_mm); - if (ret) { - up_write(&tsk->signal->exec_update_lock); - return ret; - } - } - task_lock(tsk); membarrier_exec_mmap(mm); @@ -903,7 +890,6 @@ static int exec_mmap(struct linux_binprm *bprm) task_unlock(tsk); lru_gen_use_mm(mm); if (old_mm) { - mmap_read_unlock(old_mm); BUG_ON(active_mm != old_mm); /* Defer teardown to setup_new_exec(), outside the exec locks. */ bprm->old_mm = old_mm; -- 2.53.0