]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
exit/exec: Seperate mm_release()
authorThomas Gleixner <tglx@linutronix.de>
Wed, 6 Nov 2019 21:55:38 +0000 (22:55 +0100)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 5 Dec 2019 22:29:58 +0000 (16:29 -0600)
commit 4610ba7ad877fafc0a25a30c6c82015304120426 upstream.

mm_release() contains the futex exit handling. mm_release() is called from
do_exit()->exit_mm() and from exec()->exec_mm().

In the exit_mm() case PF_EXITING and the futex state is updated. In the
exec_mm() case these states are not touched.

As the futex exit code needs further protections against exit races, this
needs to be split into two functions.

Preparatory only, no functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20191106224556.240518241@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
fs/exec.c
include/linux/sched/mm.h
kernel/exit.c
kernel/fork.c

index 81f52b42fd858ca8f5bb3caa4f0dbcfb19962c1e..1d328d37af4c52029c4d5e2844035bf3d6568cbe 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1027,7 +1027,7 @@ static int exec_mmap(struct mm_struct *mm)
        /* Notify parent that we're no longer interested in the old VM */
        tsk = current;
        old_mm = current->mm;
-       mm_release(tsk, old_mm);
+       exec_mm_release(tsk, old_mm);
 
        if (old_mm) {
                sync_mm_rss(old_mm);
index e6770012db1819e3c8d2975ffbd1a9e84fdac372..c49257a3b5108495e7dc36494b3a67e3a2196c65 100644 (file)
@@ -117,8 +117,10 @@ extern struct mm_struct *get_task_mm(struct task_struct *task);
  * succeeds.
  */
 extern struct mm_struct *mm_access(struct task_struct *task, unsigned int mode);
-/* Remove the current tasks stale references to the old mm_struct */
-extern void mm_release(struct task_struct *, struct mm_struct *);
+/* Remove the current tasks stale references to the old mm_struct on exit() */
+extern void exit_mm_release(struct task_struct *, struct mm_struct *);
+/* Remove the current tasks stale references to the old mm_struct on exec() */
+extern void exec_mm_release(struct task_struct *, struct mm_struct *);
 
 #ifdef CONFIG_MEMCG
 extern void mm_update_next_owner(struct mm_struct *mm);
index d11bdcaac2e1d22a3fd898759752fe59dd622c2d..cd893b5309023df4e1e33a06e5832825df4ec5a0 100644 (file)
@@ -437,7 +437,7 @@ static void exit_mm(void)
        struct mm_struct *mm = current->mm;
        struct core_state *core_state;
 
-       mm_release(current, mm);
+       exit_mm_release(current, mm);
        if (!mm)
                return;
        sync_mm_rss(mm);
index ada64ac61e7195421b70ae0727cf551a14e95e65..3ab3d52118541aeb705ff8e7adcdb391322daf84 100644 (file)
@@ -1289,7 +1289,7 @@ static int wait_for_vfork_done(struct task_struct *child,
  * restoring the old one. . .
  * Eric Biederman 10 January 1998
  */
-void mm_release(struct task_struct *tsk, struct mm_struct *mm)
+static void mm_release(struct task_struct *tsk, struct mm_struct *mm)
 {
        /* Get rid of any futexes when releasing the mm */
        futex_mm_release(tsk);
@@ -1326,6 +1326,16 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
                complete_vfork_done(tsk);
 }
 
+void exit_mm_release(struct task_struct *tsk, struct mm_struct *mm)
+{
+       mm_release(tsk, mm);
+}
+
+void exec_mm_release(struct task_struct *tsk, struct mm_struct *mm)
+{
+       mm_release(tsk, mm);
+}
+
 /**
  * dup_mm() - duplicates an existing mm structure
  * @tsk: the task_struct with which the new mm will be associated.