From nobody Mon Jun 8 08:30:47 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0CF948A2BF; Wed, 3 Jun 2026 14:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780496705; cv=none; b=th0+MSZFgnlcewkMboodoQ6E2hASeqfSm/sdGus0SL6zOx8g6eNByM96zG4JY5/T3atL3zo+n8i/V54z4/Cg+soFHS6Nuavjrk5X9ULvyrK15ZNxqhQMsfjmVJZfR1MyZcPI5rI6RLy2uOLLvKr3XcRpHjlzf9B7H1mBkK4Q67A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780496705; c=relaxed/simple; bh=clCgFYPgHn0rS8yj9kKZV7THpQERbpoTVm9qogb6Om8=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=gq4MlX0nk1xc4DmFitTGf/zLSrkQTBdF+CVjWgFitog7ISkz03Z9ZUyCYIktU9nJnvi89b8/l0C6ddUgufRkVVzxPWr0pDEhAoiThqDwNhzcOnF6iaeHejjSPWxsNnbeqrsQKhWrGmtmh0TmWXMlek84boHeUraIeMhSgmebnoU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=VUsy/lJF; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=1IgwriUu; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VUsy/lJF"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="1IgwriUu" Date: Wed, 03 Jun 2026 14:25:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780496702; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MarDePqEBAmB0hkjKGCdqK7G/4WywDgCqxCCczkktwY=; b=VUsy/lJFRwWF3GTKB8b1psjz3mGO7IAzpt32EkBG/agajftJFi96b64FJXIUf0Gc8pGot9 e8OJ0HcJAShQWqceqxdyWUc/vQBgaw/5h/dulZ4m4L87MST/MQ5K3C4NHA35eILKGh+k4L /i5EmM5+1egpSjUEtFGEKFsWc/1tPjbhQVowTdlu22cuHVyn/hgcQBHK8K5+HCG7gPVQZb nhMkMAZ9Dy1EP0uGIP/bkZMIC+7pE8PXSDRdjil66p8CaUjEZS0xGFllt1lZlL06Owos4i UPJt3zJhrsKVa9lQW0mkoG/y97QQAg4CPglL3LXYajVx9rEcIVGgGCkpsVioEg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780496702; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MarDePqEBAmB0hkjKGCdqK7G/4WywDgCqxCCczkktwY=; b=1IgwriUulK7QZctqu3DMlSdBK5LqIJCdWzkwYvIKUNh8CLwDtk3LPmk82c9VDzIShQz9I2 Kmv2L3YEVg0nFYAw== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] futex: Provide UABI defines for robust list entry modifiers Cc: Thomas Gleixner , "Peter Zijlstra (Intel)" , Mathieu Desnoyers , andrealmeid@igalia.com, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260602090535.458758556@kernel.org> References: <20260602090535.458758556@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178049670121.710.16562962968189724993.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the locking/core branch of tip: Commit-ID: 2cb5251d3d64d57c172185b9b608f704b3015f26 Gitweb: https://git.kernel.org/tip/2cb5251d3d64d57c172185b9b608f704b= 3015f26 Author: Thomas Gleixner AuthorDate: Tue, 02 Jun 2026 11:09:38 +02:00 Committer: Peter Zijlstra CommitterDate: Wed, 03 Jun 2026 11:38:50 +02:00 futex: Provide UABI defines for robust list entry modifiers The marker for PI futexes in the robust list is a hardcoded 0x1 which lacks any sensible form of documentation. Provide proper defines for the bit and the mask and fix up the usage sites. Thereby convert the boolean pi argument into a modifier argument, which allows new modifier bits to be trivially added and conveyed. Signed-off-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Mathieu Desnoyers Reviewed-by: Andr=C3=A9 Almeida Link: https://patch.msgid.link/20260602090535.458758556@kernel.org --- include/uapi/linux/futex.h | 4 +++- kernel/futex/core.c | 53 +++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/include/uapi/linux/futex.h b/include/uapi/linux/futex.h index 7e2744e..29bf2f6 100644 --- a/include/uapi/linux/futex.h +++ b/include/uapi/linux/futex.h @@ -177,6 +177,10 @@ struct robust_list_head { */ #define ROBUST_LIST_LIMIT 2048 =20 +/* Modifiers for robust_list_head::list_op_pending */ +#define FUTEX_ROBUST_MOD_PI (0x1UL) +#define FUTEX_ROBUST_MOD_MASK (FUTEX_ROBUST_MOD_PI) + /* * bitset with all bits set for the FUTEX_xxx_BITSET OPs to request a * match of any bit. diff --git a/kernel/futex/core.c b/kernel/futex/core.c index 79456b0..61f4f55 100644 --- a/kernel/futex/core.c +++ b/kernel/futex/core.c @@ -1008,8 +1008,9 @@ void futex_unqueue_pi(struct futex_q *q) * dying task, and do notification if so: */ static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, - bool pi, bool pending_op) + unsigned int mod, bool pending_op) { + bool pi =3D !!(mod & FUTEX_ROBUST_MOD_PI); u32 uval, nval, mval; pid_t owner; int err; @@ -1127,21 +1128,21 @@ retry: */ static inline int fetch_robust_entry(struct robust_list __user **entry, struct robust_list __user * __user *head, - unsigned int *pi) + unsigned int *mod) { unsigned long uentry; =20 if (get_user(uentry, (unsigned long __user *)head)) return -EFAULT; =20 - *entry =3D (void __user *)(uentry & ~1UL); - *pi =3D uentry & 1; + *entry =3D (void __user *)(uentry & ~FUTEX_ROBUST_MOD_MASK); + *mod =3D uentry & FUTEX_ROBUST_MOD_MASK; =20 return 0; } =20 /* - * Walk curr->robust_list (very carefully, it's a userspace list!) + * Walk curr->futex.robust_list (very carefully, it's a userspace list!) * and mark any locks found there dead, and notify any waiters. * * We silently return on any sign of list-walking problem. @@ -1149,9 +1150,8 @@ static inline int fetch_robust_entry(struct robust_li= st __user **entry, static void exit_robust_list(struct task_struct *curr) { struct robust_list_head __user *head =3D curr->futex.robust_list; + unsigned int limit =3D ROBUST_LIST_LIMIT, cur_mod, next_mod, pend_mod; struct robust_list __user *entry, *next_entry, *pending; - unsigned int limit =3D ROBUST_LIST_LIMIT, pi, pip; - unsigned int next_pi; unsigned long futex_offset; int rc; =20 @@ -1159,7 +1159,7 @@ static void exit_robust_list(struct task_struct *curr) * Fetch the list head (which was registered earlier, via * sys_set_robust_list()): */ - if (fetch_robust_entry(&entry, &head->list.next, &pi)) + if (fetch_robust_entry(&entry, &head->list.next, &cur_mod)) return; /* * Fetch the relative futex offset: @@ -1170,7 +1170,7 @@ static void exit_robust_list(struct task_struct *curr) * Fetch any possibly pending lock-add first, and handle it * if it exists: */ - if (fetch_robust_entry(&pending, &head->list_op_pending, &pip)) + if (fetch_robust_entry(&pending, &head->list_op_pending, &pend_mod)) return; =20 next_entry =3D NULL; /* avoid warning with gcc */ @@ -1179,20 +1179,20 @@ static void exit_robust_list(struct task_struct *cu= rr) * Fetch the next entry in the list before calling * handle_futex_death: */ - rc =3D fetch_robust_entry(&next_entry, &entry->next, &next_pi); + rc =3D fetch_robust_entry(&next_entry, &entry->next, &next_mod); /* * A pending lock might already be on the list, so * don't process it twice: */ if (entry !=3D pending) { if (handle_futex_death((void __user *)entry + futex_offset, - curr, pi, HANDLE_DEATH_LIST)) + curr, cur_mod, HANDLE_DEATH_LIST)) return; } if (rc) return; entry =3D next_entry; - pi =3D next_pi; + cur_mod =3D next_mod; /* * Avoid excessively long or circular lists: */ @@ -1204,7 +1204,7 @@ static void exit_robust_list(struct task_struct *curr) =20 if (pending) { handle_futex_death((void __user *)pending + futex_offset, - curr, pip, HANDLE_DEATH_PENDING); + curr, pend_mod, HANDLE_DEATH_PENDING); } } =20 @@ -1223,29 +1223,28 @@ static void __user *futex_uaddr(struct robust_list = __user *entry, */ static inline int compat_fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user= **entry, - compat_uptr_t __user *head, unsigned int *pi) + compat_uptr_t __user *head, unsigned int *pflags) { if (get_user(*uentry, head)) return -EFAULT; =20 - *entry =3D compat_ptr((*uentry) & ~1); - *pi =3D (unsigned int)(*uentry) & 1; + *entry =3D compat_ptr((*uentry) & ~FUTEX_ROBUST_MOD_MASK); + *pflags =3D (unsigned int)(*uentry) & FUTEX_ROBUST_MOD_MASK; =20 return 0; } =20 /* - * Walk curr->robust_list (very carefully, it's a userspace list!) + * Walk curr->futex.robust_list (very carefully, it's a userspace list!) * and mark any locks found there dead, and notify any waiters. * * We silently return on any sign of list-walking problem. */ static void compat_exit_robust_list(struct task_struct *curr) { - struct compat_robust_list_head __user *head =3D curr->futex.compat_robust= _list; + struct compat_robust_list_head __user *head =3D current->futex.compat_rob= ust_list; + unsigned int limit =3D ROBUST_LIST_LIMIT, cur_mod, next_mod, pend_mod; struct robust_list __user *entry, *next_entry, *pending; - unsigned int limit =3D ROBUST_LIST_LIMIT, pi, pip; - unsigned int next_pi; compat_uptr_t uentry, next_uentry, upending; compat_long_t futex_offset; int rc; @@ -1254,7 +1253,7 @@ static void compat_exit_robust_list(struct task_struc= t *curr) * Fetch the list head (which was registered earlier, via * sys_set_robust_list()): */ - if (compat_fetch_robust_entry(&uentry, &entry, &head->list.next, &pi)) + if (compat_fetch_robust_entry(&uentry, &entry, &head->list.next, &cur_mod= )) return; /* * Fetch the relative futex offset: @@ -1265,8 +1264,7 @@ static void compat_exit_robust_list(struct task_struc= t *curr) * Fetch any possibly pending lock-add first, and handle it * if it exists: */ - if (compat_fetch_robust_entry(&upending, &pending, - &head->list_op_pending, &pip)) + if (compat_fetch_robust_entry(&upending, &pending, &head->list_op_pending= , &pend_mod)) return; =20 next_entry =3D NULL; /* avoid warning with gcc */ @@ -1276,7 +1274,7 @@ static void compat_exit_robust_list(struct task_struc= t *curr) * handle_futex_death: */ rc =3D compat_fetch_robust_entry(&next_uentry, &next_entry, - (compat_uptr_t __user *)&entry->next, &next_pi); + (compat_uptr_t __user *)&entry->next, &next_mod); /* * A pending lock might already be on the list, so * dont process it twice: @@ -1284,15 +1282,14 @@ static void compat_exit_robust_list(struct task_str= uct *curr) if (entry !=3D pending) { void __user *uaddr =3D futex_uaddr(entry, futex_offset); =20 - if (handle_futex_death(uaddr, curr, pi, - HANDLE_DEATH_LIST)) + if (handle_futex_death(uaddr, curr, cur_mod, HANDLE_DEATH_LIST)) return; } if (rc) return; uentry =3D next_uentry; entry =3D next_entry; - pi =3D next_pi; + cur_mod =3D next_mod; /* * Avoid excessively long or circular lists: */ @@ -1304,7 +1301,7 @@ static void compat_exit_robust_list(struct task_struc= t *curr) if (pending) { void __user *uaddr =3D futex_uaddr(pending, futex_offset); =20 - handle_futex_death(uaddr, curr, pip, HANDLE_DEATH_PENDING); + handle_futex_death(uaddr, curr, pend_mod, HANDLE_DEATH_PENDING); } } #endif