All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: stable@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Lee Jones <lee.jones@linaro.org>
Subject: [PATCH 05/12] futex: Split futex_mm_release() for exit/exec
Date: Mon,  1 Feb 2021 10:01:36 +0000	[thread overview]
Message-ID: <20210201100143.2028618-6-lee.jones@linaro.org> (raw)
In-Reply-To: <20210201100143.2028618-1-lee.jones@linaro.org>

From: Thomas Gleixner <tglx@linutronix.de>

commit 150d71584b12809144b8145b817e83b81158ae5f upstream.

To allow separate handling of the futex exit state in the futex exit code
for exit and exec, split futex_mm_release() into two functions and invoke
them from the corresponding exit/exec_mm_release() callsites.

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.332094221@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 include/linux/futex.h | 6 ++++--
 kernel/fork.c         | 5 ++---
 kernel/futex.c        | 7 ++++++-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/linux/futex.h b/include/linux/futex.h
index a0de6fe28e00b..063a5cd00d770 100644
--- a/include/linux/futex.h
+++ b/include/linux/futex.h
@@ -98,13 +98,15 @@ static inline void futex_exit_done(struct task_struct *tsk)
 	tsk->futex_state = FUTEX_STATE_DEAD;
 }
 
-void futex_mm_release(struct task_struct *tsk);
+void futex_exit_release(struct task_struct *tsk);
+void futex_exec_release(struct task_struct *tsk);
 
 long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
 	      u32 __user *uaddr2, u32 val2, u32 val3);
 #else
 static inline void futex_init_task(struct task_struct *tsk) { }
-static inline void futex_mm_release(struct task_struct *tsk) { }
 static inline void futex_exit_done(struct task_struct *tsk) { }
+static inline void futex_exit_release(struct task_struct *tsk) { }
+static inline void futex_exec_release(struct task_struct *tsk) { }
 #endif
 #endif
diff --git a/kernel/fork.c b/kernel/fork.c
index ad9dbbf03d7bc..91349fd3e162d 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1084,9 +1084,6 @@ static int wait_for_vfork_done(struct task_struct *child,
  */
 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);
-
 	uprobe_free_utask(tsk);
 
 	/* Get rid of any cached register state */
@@ -1121,11 +1118,13 @@ static void mm_release(struct task_struct *tsk, struct mm_struct *mm)
 
 void exit_mm_release(struct task_struct *tsk, struct mm_struct *mm)
 {
+	futex_exit_release(tsk);
 	mm_release(tsk, mm);
 }
 
 void exec_mm_release(struct task_struct *tsk, struct mm_struct *mm)
 {
+	futex_exec_release(tsk);
 	mm_release(tsk, mm);
 }
 
diff --git a/kernel/futex.c b/kernel/futex.c
index 51bbe57bb14ac..902ce420c4ba0 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -3269,7 +3269,7 @@ static void exit_robust_list(struct task_struct *curr)
 				   curr, pip);
 }
 
-void futex_mm_release(struct task_struct *tsk)
+void futex_exec_release(struct task_struct *tsk)
 {
 	if (unlikely(tsk->robust_list)) {
 		exit_robust_list(tsk);
@@ -3287,6 +3287,11 @@ void futex_mm_release(struct task_struct *tsk)
 		exit_pi_state_list(tsk);
 }
 
+void futex_exit_release(struct task_struct *tsk)
+{
+	futex_exec_release(tsk);
+}
+
 long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
 		u32 __user *uaddr2, u32 val2, u32 val3)
 {
-- 
2.25.1


  parent reply	other threads:[~2021-02-01 10:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 10:01 [PATCH 4.9 00/12] Futex back-port from v4.14 Lee Jones
2021-02-01 10:01 ` [PATCH 01/12] y2038: futex: Move compat implementation into futex.c Lee Jones
2021-02-01 10:01 ` [PATCH 02/12] futex: Move futex exit handling into futex code Lee Jones
2021-02-01 10:01 ` [PATCH 03/12] futex: Replace PF_EXITPIDONE with a state Lee Jones
2021-02-01 10:01 ` [PATCH 04/12] exit/exec: Seperate mm_release() Lee Jones
2021-02-01 10:01 ` Lee Jones [this message]
2021-02-01 10:01 ` [PATCH 06/12] futex: Set task::futex_state to DEAD right after handling futex exit Lee Jones
2021-02-01 10:01 ` [PATCH 07/12] futex: Mark the begin of futex exit explicitly Lee Jones
2021-02-01 10:01 ` [PATCH 08/12] futex: Sanitize exit state handling Lee Jones
2021-02-01 10:01 ` [PATCH 09/12] futex: Provide state handling for exec() as well Lee Jones
2021-02-01 10:01 ` [PATCH 10/12] futex: Add mutex around futex exit Lee Jones
2021-02-01 10:01 ` [PATCH 11/12] futex: Provide distinct return value when owner is exiting Lee Jones
2021-02-01 10:01 ` [PATCH 12/12] futex: Prevent exit livelock Lee Jones
2021-02-01 11:25 ` [PATCH 4.9 00/12] Futex back-port from v4.14 Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2021-02-01 15:12 [PATCH 4.4 00/12] Futex back-port from v4.9 Lee Jones
2021-02-01 15:12 ` [PATCH 05/12] futex: Split futex_mm_release() for exit/exec Lee Jones
2019-11-06 21:55 [patch 00/12] futex: Cure robust/PI futex exit races Thomas Gleixner
2019-11-06 21:55 ` [patch 05/12] futex: Split futex_mm_release() for exit/exec Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210201100143.2028618-6-lee.jones@linaro.org \
    --to=lee.jones@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.