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 11/12] futex: Provide distinct return value when owner is exiting
Date: Mon,  1 Feb 2021 15:12:13 +0000	[thread overview]
Message-ID: <20210201151214.2193508-12-lee.jones@linaro.org> (raw)
In-Reply-To: <20210201151214.2193508-1-lee.jones@linaro.org>

From: Thomas Gleixner <tglx@linutronix.de>

commit ac31c7ff8624409ba3c4901df9237a616c187a5d upstream.

attach_to_pi_owner() returns -EAGAIN for various cases:

 - Owner task is exiting
 - Futex value has changed

The caller drops the held locks (hash bucket, mmap_sem) and retries the
operation. In case of the owner task exiting this can result in a live
lock.

As a preparatory step for seperating those cases, provide a distinct return
value (EBUSY) for the owner exiting case.

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.935606117@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 kernel/futex.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index d21b151216aa3..32d799b9bd205 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1909,12 +1909,13 @@ retry_private:
 			if (!ret)
 				goto retry;
 			goto out;
+		case -EBUSY:
 		case -EAGAIN:
 			/*
 			 * Two reasons for this:
-			 * - Owner is exiting and we just wait for the
+			 * - EBUSY: Owner is exiting and we just wait for the
 			 *   exit to complete.
-			 * - The user space value changed.
+			 * - EAGAIN: The user space value changed.
 			 */
 			free_pi_state(pi_state);
 			pi_state = NULL;
@@ -2580,12 +2581,13 @@ retry_private:
 			goto out_unlock_put_key;
 		case -EFAULT:
 			goto uaddr_faulted;
+		case -EBUSY:
 		case -EAGAIN:
 			/*
 			 * Two reasons for this:
-			 * - Task is exiting and we just wait for the
+			 * - EBUSY: Task is exiting and we just wait for the
 			 *   exit to complete.
-			 * - The user space value changed.
+			 * - EAGAIN: The user space value changed.
 			 */
 			queue_unlock(hb);
 			put_futex_key(&q.key);
-- 
2.25.1


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

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