All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls
@ 2026-12-04 16:15 André Almeida
  2026-12-04 16:15 ` [PATCH v9 01/14] futex: Use explicit sizes for compat_robust_list structs André Almeida
                   ` (13 more replies)
  0 siblings, 14 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

This patchset creates two new syscalls {set,get}_robust_list2(), that allows for
setting multiple lists per task and using 32-bit lists on 64-bit kernels.

 * Use case

The use-case for the new syscalls is detailed in the last patch version:

  https://lore.kernel.org/lkml/20250626-tonyk-robust_futex-v5-0-179194dbde8f@igalia.com

 * The syscall interface

Userspace have access to two sysctl to get the list limits:
 - futex.robust_list2_list_limit: the number of robust_list heads per task
 - futex.robust_list2_elements_per_list: for every list, how many elements can
 it handle

After that, userspace can set a robust list like:

  idx = set_robust_list2(head, 0, FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY);

On success, idx gives the index on the robust lists array that where head was
set.

Getting the list head for this index:

  get_robust_list2(0, &head, idx, 0);

To clean such index later, userspace can use:

  set_robust_list2(NULL, idx, 0);

The kernel guarantees that an index returned by NEW_ENTRY is an empty element.
Userspace is the responsible for not messing up with the list.

The commit message that introduces each syscall has the detailed information
about the interface.

 * Testing

I expanded the current robust list selftest to use the new interface,
and also ported the original syscall to use the new syscall internals,
and everything survived the tests. Tested on both x86 and arm64.

Also tested with glibc's tests nptl/tst-robust* and nptl/tst-mutex*.

 * Changelog

Changes from v8:
- Simplified the syscall interface. No more CREATE/MODIFY flags.
- The code itself got much simpler as well, without the switch case multiplexing
- User can modify any index at any giving time. To create, a flag
  FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY returns an unused index
- Reordered the preparatory patches
- Link to v8: https://patch.msgid.link/20261115-tonyk-robust_futex-v8-0-a4fe47333a28@igalia.com

Changes from v7:
- Expanded the selftest for more corner cases and error handling
- Fix a lot of Sashiko findings, including:
- Refactor handling of 32-bit lists in get_robust_list2 
- Fix legacy 32-bit list creation overwritting 64-bit list
- Fix 32-bit list never getting cleared
- Fix corrupting error code
- Fix logic for modifying list elements
- Link to v7: https://patch.msgid.link/20260925-tonyk-robust_futex-v7-0-d1095991152c@igalia.com

Changes from v6:
 - Interface now uses CREATE/MODIFY semantics instead of SET. This allows to
 both libc and app to use the lists without conflicts.
 - Rebased on top of mainline, including the new VDSO changes
 - v6: https://lore.kernel.org/r/20251122-tonyk-robust_futex-v6-0-05fea005a0fd@igalia.com

Changes from v5:
 - Complete interface rewrite, there are so many changes but the main
   ones are the following points
 - Array of robust lists now has a static size, allocated once during the
   first usage of the list
 - Now that the list of robust lists have a fixed size, I removed the
   logic of having a command for creating a new index on the list. To
   simplify things for everyone, userspace just need to call
   set_robust_list2(head, 32-bit/64-bit type, index).
 - Created get_robust_list2()
 - The new code can be better integrated with the original interface
 - v5: https://lore.kernel.org/r/20250626-tonyk-robust_futex-v5-0-179194dbde8f@igalia.com

Feedback is very welcomed!

---
---
André Almeida (14):
      futex: Use explicit sizes for compat_robust_list structs
      futex: Make exit_robust_list32() unconditionally available for 64-bit kernels
      futex: Give a specific head pointer to exit_robust_list()
      futex: Introduce futex_get_robust_lists() and futex_sched_data::robust_lists
      futex: Create exit_robust_lists() for multi-robust list
      futex: Use the multi-robust list infrastructure for current syscalls
      futex: Expose robust_list2 limits via sysctl
      futex: Create syscall set_robust_list2()
      futex: Make futex_task_robust_list() get list by index
      futex: Create get_robust_list2() syscall
      futex: Wire up set_robust_list2 syscall
      futex: Wire up get_robust_list2 syscall
      selftests/futex: Expand for set_robust_list2()
      selftests/futex: Expand for get_robust_list2()

 arch/alpha/kernel/syscalls/syscall.tbl             |   2 +
 arch/arm/tools/syscall.tbl                         |   2 +
 arch/m68k/kernel/syscalls/syscall.tbl              |   2 +
 arch/microblaze/kernel/syscalls/syscall.tbl        |   2 +
 arch/mips/kernel/syscalls/syscall_n32.tbl          |   2 +
 arch/mips/kernel/syscalls/syscall_n64.tbl          |   2 +
 arch/mips/kernel/syscalls/syscall_o32.tbl          |   2 +
 arch/parisc/kernel/syscalls/syscall.tbl            |   2 +
 arch/powerpc/kernel/syscalls/syscall.tbl           |   2 +
 arch/s390/kernel/syscalls/syscall.tbl              |   2 +
 arch/sh/kernel/syscalls/syscall.tbl                |   2 +
 arch/sparc/kernel/syscalls/syscall.tbl             |   2 +
 arch/x86/entry/syscalls/syscall_32.tbl             |   2 +
 arch/x86/entry/syscalls/syscall_64.tbl             |   2 +
 arch/xtensa/kernel/syscalls/syscall.tbl            |   2 +
 include/linux/compat.h                             |  13 +-
 include/linux/futex.h                              |   1 +
 include/linux/futex_types.h                        |   9 +-
 include/uapi/asm-generic/unistd.h                  |   7 +-
 include/uapi/linux/futex.h                         |  17 +
 kernel/futex/core.c                                | 193 +++++--
 kernel/futex/futex.h                               |  16 +
 kernel/futex/syscalls.c                            |  91 +++-
 scripts/syscall.tbl                                |   2 +
 .../selftests/futex/functional/robust_list.c       | 594 +++++++++++++++++++--
 25 files changed, 856 insertions(+), 117 deletions(-)
---
base-commit: 39cc4e512ebcd2a6d106d710285040a4e43c2dd9
change-id: 20250225-tonyk-robust_futex-60adeedac695

Best regards,
--  
André Almeida <andrealmeid@igalia.com>


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v9 01/14] futex: Use explicit sizes for compat_robust_list structs
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-04 16:15 ` [PATCH v9 02/14] futex: Make exit_robust_list32() unconditionally available for 64-bit kernels André Almeida
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

There are two functions for handling robust lists during a task exit:
exit_robust_list() and compat_exit_robust_list(). The first one handles
either 64-bit or 32-bit lists, depending on the kernel bitness.
compat_exit_robust_list() exists only in 64-bit kernels that supports
32-bit syscalls entry points (also known as compat entry points).

The new syscall set_robust_list2() needs to handle both 64-bit and
32-bit robust lists, regardless of compat entry being enabled, so it
needs to have both functions always available.

In preparation for this, use explicit size for struct members of
compat_robust_list and compat_robust_list_head. Rename the structs and
compat_exit_robust_list() to make clear which bitness it handles.

Keep exit_robust_list() as it is: used to handle the native bit size of
the kernel.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 include/linux/compat.h      | 13 +++----------
 include/linux/futex.h       |  4 ++++
 include/linux/futex_types.h |  5 ++---
 include/uapi/linux/futex.h  | 10 ++++++++++
 kernel/futex/core.c         | 33 +++++++++++++++++----------------
 kernel/futex/syscalls.c     |  9 +++++----
 6 files changed, 41 insertions(+), 33 deletions(-)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index ad37ca617e65..77bfef1b3bd2 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -390,15 +390,8 @@ struct compat_ifconf {
 	compat_caddr_t  ifcbuf;
 };
 
-struct compat_robust_list {
-	compat_uptr_t			next;
-};
-
-struct compat_robust_list_head {
-	struct compat_robust_list	list;
-	compat_long_t			futex_offset;
-	compat_uptr_t			list_op_pending;
-};
+struct robust_list32;
+struct robust_list_head32;
 
 #ifdef CONFIG_COMPAT_OLD_SIGACTION
 struct compat_old_sigaction {
@@ -677,7 +670,7 @@ asmlinkage long compat_sys_waitid(int, compat_pid_t,
 		struct compat_siginfo __user *, int,
 		struct compat_rusage __user *);
 asmlinkage long
-compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
+compat_sys_set_robust_list(struct robust_list_head32 __user *head,
 			   compat_size_t len);
 asmlinkage long
 compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
diff --git a/include/linux/futex.h b/include/linux/futex.h
index a895d8c69d66..93316876a4ee 100644
--- a/include/linux/futex.h
+++ b/include/linux/futex.h
@@ -72,6 +72,10 @@ static inline void futex_init_task(struct task_struct *tsk)
 	INIT_LIST_HEAD(&tsk->futex.pi_state_list);
 	tsk->futex.state = FUTEX_STATE_OK;
 	mutex_init(&tsk->futex.exit_mutex);
+	tsk->futex.robust_list = NULL;
+#ifdef CONFIG_COMPAT
+	tsk->futex.robust_list32 = NULL;
+#endif
 }
 
 void futex_exit_recursive(struct task_struct *tsk);
diff --git a/include/linux/futex_types.h b/include/linux/futex_types.h
index 34b16f2828e7..f58616d7e20b 100644
--- a/include/linux/futex_types.h
+++ b/include/linux/futex_types.h
@@ -7,14 +7,13 @@
 #include <linux/mutex_types.h>
 #include <linux/types.h>
 
-struct compat_robust_list_head;
 struct futex_pi_state;
 struct robust_list_head;
 
 /**
  * struct futex_sched_data - Futex related per task data
  * @robust_list:	User space registered robust list pointer
- * @compat_robust_list:	User space registered robust list pointer for compat tasks
+ * @robust_list32:	User space registered robust list pointer for compat tasks
  * @pi_state_list:	List head for Priority Inheritance (PI) state management
  * @pi_state_cache:	Pointer to cache one PI state object per task
  * @exit_mutex:		Mutex for serializing exit
@@ -23,7 +22,7 @@ struct robust_list_head;
 struct futex_sched_data {
 	struct robust_list_head __user		*robust_list;
 #ifdef CONFIG_COMPAT
-	struct compat_robust_list_head __user	*compat_robust_list;
+	struct robust_list_head32 __user *robust_list32;
 #endif
 	struct list_head			pi_state_list;
 	struct futex_pi_state			*pi_state_cache;
diff --git a/include/uapi/linux/futex.h b/include/uapi/linux/futex.h
index 10a36c551675..b39f8a23a84b 100644
--- a/include/uapi/linux/futex.h
+++ b/include/uapi/linux/futex.h
@@ -179,6 +179,16 @@ struct robust_list_head {
 	struct robust_list __user *list_op_pending;
 };
 
+struct robust_list32 {
+	__u32 next;
+};
+
+struct robust_list_head32 {
+	struct robust_list32	list;
+	__s32			futex_offset;
+	__u32			list_op_pending;
+};
+
 /*
  * Are there any waiters for this robust futex:
  */
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index a240638f69e5..28a6ad4a8da4 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1243,9 +1243,10 @@ static void __user *futex_uaddr(struct robust_list __user *entry,
 /*
  * Fetch a robust-list pointer. Bit 0 signals PI futexes:
  */
-static inline int
-compat_fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
-		   compat_uptr_t __user *head, unsigned int *pflags)
+static inline int fetch_robust_entry32(compat_uptr_t *uentry,
+				       struct robust_list __user **entry,
+				       compat_uptr_t __user *head,
+				       unsigned int *pflags)
 {
 	if (get_user(*uentry, head))
 		return -EFAULT;
@@ -1262,9 +1263,9 @@ compat_fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **ent
  *
  * We silently return on any sign of list-walking problem.
  */
-static void compat_exit_robust_list(struct task_struct *curr)
+static void exit_robust_list32(struct task_struct *curr)
 {
-	struct compat_robust_list_head __user *head = current->futex.compat_robust_list;
+	struct robust_list_head32 __user *head = curr->futex.robust_list32;
 	unsigned int limit = ROBUST_LIST_LIMIT, cur_mod, next_mod, pend_mod;
 	struct robust_list __user *entry, *next_entry, *pending;
 	compat_uptr_t uentry, next_uentry, upending;
@@ -1275,7 +1276,7 @@ static void compat_exit_robust_list(struct task_struct *curr)
 	 * Fetch the list head (which was registered earlier, via
 	 * sys_set_robust_list()):
 	 */
-	if (compat_fetch_robust_entry(&uentry, &entry, &head->list.next, &cur_mod))
+	if (fetch_robust_entry32(&uentry, &entry, &head->list.next, &cur_mod))
 		return;
 	/*
 	 * Fetch the relative futex offset:
@@ -1286,7 +1287,7 @@ static void compat_exit_robust_list(struct task_struct *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, &pend_mod))
+	if (fetch_robust_entry32(&upending, &pending, &head->list_op_pending, &pend_mod))
 		return;
 
 	next_entry = NULL;	/* avoid warning with gcc */
@@ -1295,7 +1296,7 @@ static void compat_exit_robust_list(struct task_struct *curr)
 		 * Fetch the next entry in the list before calling
 		 * handle_futex_death:
 		 */
-		rc = compat_fetch_robust_entry(&next_uentry, &next_entry,
+		rc = fetch_robust_entry32(&next_uentry, &next_entry,
 			(compat_uptr_t __user *)&entry->next, &next_mod);
 		/*
 		 * A pending lock might already be on the list, so
@@ -1327,20 +1328,20 @@ static void compat_exit_robust_list(struct task_struct *curr)
 	}
 }
 
-static bool compat_robust_list_clear_pending(u32 __user *pop)
+static bool robust_list_clear_pending32(u32 __user *pop)
 {
-	struct compat_robust_list_head __user *head = current->futex.compat_robust_list;
+	struct robust_list_head32 __user *head = current->futex.robust_list32;
 
 	if (!put_user(0U, pop))
 		return true;
 
 	/* See comment in robust_list_clear_pending(). */
 	if (pop == &head->list_op_pending)
-		current->futex.compat_robust_list = NULL;
+		current->futex.robust_list32 = NULL;
 	return false;
 }
 #else
-static bool compat_robust_list_clear_pending(u32 __user *pop_addr) { return false; }
+static bool robust_list_clear_pending32(u32 __user *pop_addr) { return false; }
 #endif
 
 #ifdef CONFIG_FUTEX_PI
@@ -1443,7 +1444,7 @@ bool futex_robust_list_clear_pending(void __user *pop, unsigned int flags)
 		return false;
 
 	if (IS_ENABLED(CONFIG_64BIT) && size32bit)
-		return compat_robust_list_clear_pending(pop);
+		return robust_list_clear_pending32(pop);
 
 	return robust_list_clear_pending(pop);
 }
@@ -1472,9 +1473,9 @@ static void futex_cleanup(struct task_struct *tsk)
 	}
 
 #ifdef CONFIG_COMPAT
-	if (unlikely(tsk->futex.compat_robust_list)) {
-		compat_exit_robust_list(tsk);
-		tsk->futex.compat_robust_list = NULL;
+	if (unlikely(tsk->futex.robust_list32)) {
+		exit_robust_list32(tsk);
+		tsk->futex.robust_list32 = NULL;
 	}
 #endif
 
diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index 2fa19d9d008d..4a45bace75fc 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -39,7 +39,7 @@ static inline void __user *futex_task_robust_list(struct task_struct *p, bool co
 {
 #ifdef CONFIG_COMPAT
 	if (compat)
-		return p->futex.compat_robust_list;
+		return p->futex.robust_list32;
 #endif
 	return p->futex.robust_list;
 }
@@ -478,13 +478,14 @@ SYSCALL_DEFINE4(futex_requeue,
 }
 
 #ifdef CONFIG_COMPAT
-COMPAT_SYSCALL_DEFINE2(set_robust_list, struct compat_robust_list_head __user *, head,
+COMPAT_SYSCALL_DEFINE2(set_robust_list, struct robust_list_head32 __user *, head,
 		       compat_size_t, len)
 {
 	if (unlikely(len != sizeof(*head)))
 		return -EINVAL;
 
-	current->futex.compat_robust_list = head;
+	current->futex.robust_list32 = head;
+
 	return 0;
 }
 
@@ -492,7 +493,7 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
 			compat_uptr_t __user *, head_ptr,
 			compat_size_t __user *, len_ptr)
 {
-	struct compat_robust_list_head __user *head = futex_get_robust_list_common(pid, true);
+	struct robust_list_head32 __user *head = futex_get_robust_list_common(pid, true);
 
 	if (IS_ERR(head))
 		return PTR_ERR(head);

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 02/14] futex: Make exit_robust_list32() unconditionally available for 64-bit kernels
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
  2026-12-04 16:15 ` [PATCH v9 01/14] futex: Use explicit sizes for compat_robust_list structs André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-04 16:15 ` [PATCH v9 03/14] futex: Give a specific head pointer to exit_robust_list() André Almeida
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

The new syscall set_robust_list2() needs to handle both 64-bit and
32-bit robust lists, but not every 64-bit platform have compat entry
points. Make exit_robust_list32() unconditionally available for 64-bit
kernels regardless of having a compat configuration.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 kernel/futex/core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index 28a6ad4a8da4..6fce97012015 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1230,12 +1230,12 @@ static bool robust_list_clear_pending(unsigned long __user *pop)
 	return false;
 }
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_64BIT
 static void __user *futex_uaddr(struct robust_list __user *entry,
 				compat_long_t futex_offset)
 {
-	compat_uptr_t base = ptr_to_compat(entry);
-	void __user *uaddr = compat_ptr(base + futex_offset);
+	u32 base = (u32)(unsigned long)(entry);
+	void __user *uaddr = (void __user *)(unsigned long)(base + futex_offset);
 
 	return uaddr;
 }
@@ -1268,8 +1268,8 @@ static void exit_robust_list32(struct task_struct *curr)
 	struct robust_list_head32 __user *head = curr->futex.robust_list32;
 	unsigned int limit = ROBUST_LIST_LIMIT, cur_mod, next_mod, pend_mod;
 	struct robust_list __user *entry, *next_entry, *pending;
-	compat_uptr_t uentry, next_uentry, upending;
-	compat_long_t futex_offset;
+	u32 uentry, next_uentry, upending;
+	s32 futex_offset;
 	int rc;
 
 	/*
@@ -1472,7 +1472,7 @@ static void futex_cleanup(struct task_struct *tsk)
 		tsk->futex.robust_list = NULL;
 	}
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_64BIT
 	if (unlikely(tsk->futex.robust_list32)) {
 		exit_robust_list32(tsk);
 		tsk->futex.robust_list32 = NULL;

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 03/14] futex: Give a specific head pointer to exit_robust_list()
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
  2026-12-04 16:15 ` [PATCH v9 01/14] futex: Use explicit sizes for compat_robust_list structs André Almeida
  2026-12-04 16:15 ` [PATCH v9 02/14] futex: Make exit_robust_list32() unconditionally available for 64-bit kernels André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-04 16:15 ` [PATCH v9 04/14] futex: Introduce futex_get_robust_lists() and futex_sched_data::robust_lists André Almeida
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

Change exit_robust_list() and exit_robust_list32() signatures to process a
specific robust list head, instead of processing the list from the
task_struct argument. This makes it easier to implement multi-robust lists
per task. No functional change.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 kernel/futex/core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index 6fce97012015..bcfa59168911 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1148,9 +1148,9 @@ static inline int fetch_robust_entry(struct robust_list __user **entry,
  *
  * We silently return on any sign of list-walking problem.
  */
-static void exit_robust_list(struct task_struct *curr)
+static void exit_robust_list(struct task_struct *curr,
+			     struct robust_list_head __user *head)
 {
-	struct robust_list_head __user *head = curr->futex.robust_list;
 	unsigned int limit = ROBUST_LIST_LIMIT, cur_mod, next_mod, pend_mod;
 	struct robust_list __user *entry, *next_entry, *pending;
 	unsigned long futex_offset;
@@ -1263,9 +1263,9 @@ static inline int fetch_robust_entry32(compat_uptr_t *uentry,
  *
  * We silently return on any sign of list-walking problem.
  */
-static void exit_robust_list32(struct task_struct *curr)
+static void exit_robust_list32(struct task_struct *curr,
+			       struct robust_list_head32 __user *head)
 {
-	struct robust_list_head32 __user *head = curr->futex.robust_list32;
 	unsigned int limit = ROBUST_LIST_LIMIT, cur_mod, next_mod, pend_mod;
 	struct robust_list __user *entry, *next_entry, *pending;
 	u32 uentry, next_uentry, upending;
@@ -1468,13 +1468,13 @@ void __futex_fixup_robust_unlock(struct pt_regs *regs, struct futex_unlock_cs_ra
 static void futex_cleanup(struct task_struct *tsk)
 {
 	if (unlikely(tsk->futex.robust_list)) {
-		exit_robust_list(tsk);
+		exit_robust_list(tsk, tsk->futex.robust_list);
 		tsk->futex.robust_list = NULL;
 	}
 
 #ifdef CONFIG_64BIT
 	if (unlikely(tsk->futex.robust_list32)) {
-		exit_robust_list32(tsk);
+		exit_robust_list32(tsk, tsk->futex.robust_list32);
 		tsk->futex.robust_list32 = NULL;
 	}
 #endif

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 04/14] futex: Introduce futex_get_robust_lists() and futex_sched_data::robust_lists
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
                   ` (2 preceding siblings ...)
  2026-12-04 16:15 ` [PATCH v9 03/14] futex: Give a specific head pointer to exit_robust_list() André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-04 16:15 ` [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list André Almeida
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

Add a new field robust_lists to struct futex_sched_data. This field stores
a pointer to an array of robust list head pointers, to support multi-lists
per task.

Create futex_get_robust_lists() to get the robust_lists pointer. If the
list is not yet allocated, try to allocate it. The caller is responsible
for checking if the allocation failed and if it's a NULL pointer.
Allocation is race free giving that this is a per-task data, allocated from
syscall context.

futex_sched_data::robust_lists has two reserved indexes:
`FUTEX_ROBUST_LIST2_NATIVE_IDX` to store the robust list head pointer for
the current syscall set_robust_list() and `FUTEX_ROBUST_LIST2_COMPAT_IDX`
for the compat entry point head pointer. Those elements will be used to
replace futex_sched_data::{robust_list, robust_list32}.

futex_sched_data::robust_lists will be freed in a following commit.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 include/linux/futex.h       |  1 +
 include/linux/futex_types.h |  2 ++
 kernel/futex/core.c         | 12 ++++++++++++
 kernel/futex/futex.h        |  8 ++++++++
 4 files changed, 23 insertions(+)

diff --git a/include/linux/futex.h b/include/linux/futex.h
index 93316876a4ee..0da95f94cfe9 100644
--- a/include/linux/futex.h
+++ b/include/linux/futex.h
@@ -76,6 +76,7 @@ static inline void futex_init_task(struct task_struct *tsk)
 #ifdef CONFIG_COMPAT
 	tsk->futex.robust_list32 = NULL;
 #endif
+	tsk->futex.robust_lists = NULL;
 }
 
 void futex_exit_recursive(struct task_struct *tsk);
diff --git a/include/linux/futex_types.h b/include/linux/futex_types.h
index f58616d7e20b..20123110c80d 100644
--- a/include/linux/futex_types.h
+++ b/include/linux/futex_types.h
@@ -14,6 +14,7 @@ struct robust_list_head;
  * struct futex_sched_data - Futex related per task data
  * @robust_list:	User space registered robust list pointer
  * @robust_list32:	User space registered robust list pointer for compat tasks
+ * @robust_lists:	List of robust lists heads
  * @pi_state_list:	List head for Priority Inheritance (PI) state management
  * @pi_state_cache:	Pointer to cache one PI state object per task
  * @exit_mutex:		Mutex for serializing exit
@@ -24,6 +25,7 @@ struct futex_sched_data {
 #ifdef CONFIG_COMPAT
 	struct robust_list_head32 __user *robust_list32;
 #endif
+	uintptr_t				*robust_lists;
 	struct list_head			pi_state_list;
 	struct futex_pi_state			*pi_state_cache;
 	struct mutex				exit_mutex;
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index bcfa59168911..dc5b6379060e 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1124,6 +1124,18 @@ static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr,
 	return 0;
 }
 
+uintptr_t *futex_get_robust_lists(void)
+{
+	uintptr_t *rl = current->futex.robust_lists;
+
+	if (!rl) {
+		rl = kcalloc(FUTEX_ROBUST_LIST2_MAX_IDX, sizeof(*rl), GFP_KERNEL);
+		current->futex.robust_lists = rl;
+	}
+
+	return rl;
+}
+
 /*
  * Fetch a robust-list pointer. Bit 0 signals PI futexes:
  */
diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
index f00f0863ed44..bd552a1ce5f6 100644
--- a/kernel/futex/futex.h
+++ b/kernel/futex/futex.h
@@ -43,6 +43,12 @@
 #define FLAGS_ROBUST_UNLOCK	0x0400
 #define FLAGS_ROBUST_LIST32	0x0800
 
+#define FUTEX_ROBUST_LIST2_NATIVE_IDX	0
+#define FUTEX_ROBUST_LIST2_COMPAT_IDX	1
+#define FUTEX_ROBUST_LIST2_IDX		2
+#define FUTEX_ROBUST_LIST2_PER_USER	8
+#define FUTEX_ROBUST_LIST2_MAX_IDX	(FUTEX_ROBUST_LIST2_IDX + FUTEX_ROBUST_LIST2_PER_USER)
+
 /* FUTEX_ to FLAGS_ */
 static inline unsigned int futex_to_flags(unsigned int op)
 {
@@ -478,4 +484,6 @@ extern int futex_lock_pi(u32 __user *uaddr, unsigned int flags, ktime_t *time, i
 
 bool futex_robust_list_clear_pending(void __user *pop, unsigned int flags);
 
+uintptr_t *futex_get_robust_lists(void);
+
 #endif /* _FUTEX_H */

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
                   ` (3 preceding siblings ...)
  2026-12-04 16:15 ` [PATCH v9 04/14] futex: Introduce futex_get_robust_lists() and futex_sched_data::robust_lists André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-05  9:55   ` kernel test robot
  2026-12-04 16:15 ` [PATCH v9 06/14] futex: Use the multi-robust list infrastructure for current syscalls André Almeida
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

Create function exit_robust_lists() to process task's list of robust lists.
This function processes an array of robust list heads and call the
appropriate function to deal with it, according to the pointer size. The
low bit of each entry indicates whether the list is 32-bit.

Giving that the current syscalls don't use the multi-list array, this
introduction is a no-op and futex::robust_lists is always empty.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 kernel/futex/core.c  | 35 +++++++++++++++++++++++++++++++++++
 kernel/futex/futex.h |  6 ++++++
 2 files changed, 41 insertions(+)

diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index dc5b6379060e..d15906f3c80c 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1477,8 +1477,43 @@ void __futex_fixup_robust_unlock(struct pt_regs *regs, struct futex_unlock_cs_ra
 }
 #endif /* CONFIG_FUTEX_ROBUST_UNLOCK */
 
+static void exit_robust_lists(struct task_struct *tsk)
+{
+	uintptr_t *rl = tsk->futex.robust_lists;
+	unsigned int idx;
+
+	if (!rl)
+		return;
+
+	tsk->futex.robust_lists = NULL;
+
+	for (idx = 0; idx < FUTEX_ROBUST_LIST2_MAX_IDX; idx++) {
+		uintptr_t entry = rl[idx] & FUTEX_ROBUST_LIST2_ENTRY_MASK;
+
+		if (!entry)
+			continue;
+
+		if (IS_ENABLED(CONFIG_64BIT) && (rl[idx] & FUTEX_ROBUST_LIST2_ENTRY_32BIT)) {
+			struct robust_list_head32 __user *head;
+
+			head = (__force struct robust_list_head32 __user *)entry;
+			exit_robust_list32(tsk, head);
+		} else {
+			struct robust_list_head __user *head;
+
+			head = (__force struct robust_list_head __user *)entry;
+			exit_robust_list(tsk, head);
+		}
+	}
+
+	kfree(rl);
+}
+
 static void futex_cleanup(struct task_struct *tsk)
 {
+	if (unlikely(tsk->futex.robust_lists))
+		exit_robust_lists(tsk);
+
 	if (unlikely(tsk->futex.robust_list)) {
 		exit_robust_list(tsk, tsk->futex.robust_list);
 		tsk->futex.robust_list = NULL;
diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
index bd552a1ce5f6..c1da53fd7187 100644
--- a/kernel/futex/futex.h
+++ b/kernel/futex/futex.h
@@ -49,6 +49,12 @@
 #define FUTEX_ROBUST_LIST2_PER_USER	8
 #define FUTEX_ROBUST_LIST2_MAX_IDX	(FUTEX_ROBUST_LIST2_IDX + FUTEX_ROBUST_LIST2_PER_USER)
 
+/*
+ * List entries without _32BIT flag are using the native machine size
+ */
+#define FUTEX_ROBUST_LIST2_ENTRY_32BIT	0x1UL
+#define FUTEX_ROBUST_LIST2_ENTRY_MASK	(~(uintptr_t)FUTEX_ROBUST_LIST2_ENTRY_32BIT)
+
 /* FUTEX_ to FLAGS_ */
 static inline unsigned int futex_to_flags(unsigned int op)
 {

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 06/14] futex: Use the multi-robust list infrastructure for current syscalls
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
                   ` (4 preceding siblings ...)
  2026-12-04 16:15 ` [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-04 16:15 ` [PATCH v9 07/14] futex: Expose robust_list2 limits via sysctl André Almeida
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

Use the multi-robust list infrastructure for the current system calls and
drop robust_list and robust_list32 from struct futex_sched_data, relying
solely on the robust_lists member. Make use of the reserved array positions
for the current system call and the compat entry point.

For the robust_list_clear_pending() functions, walk the array of robust
list heads checking which one, if any, matches the pop address.

Syscall set_robust_list() now can return -ENOMEM in case the allocation
fails.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 include/linux/futex.h       |  4 ----
 include/linux/futex_types.h |  4 ----
 kernel/futex/core.c         | 58 +++++++++++++++++++++++++++++++--------------
 kernel/futex/syscalls.c     | 24 +++++++++++++++----
 4 files changed, 59 insertions(+), 31 deletions(-)

diff --git a/include/linux/futex.h b/include/linux/futex.h
index 0da95f94cfe9..75a83f262d1c 100644
--- a/include/linux/futex.h
+++ b/include/linux/futex.h
@@ -72,10 +72,6 @@ static inline void futex_init_task(struct task_struct *tsk)
 	INIT_LIST_HEAD(&tsk->futex.pi_state_list);
 	tsk->futex.state = FUTEX_STATE_OK;
 	mutex_init(&tsk->futex.exit_mutex);
-	tsk->futex.robust_list = NULL;
-#ifdef CONFIG_COMPAT
-	tsk->futex.robust_list32 = NULL;
-#endif
 	tsk->futex.robust_lists = NULL;
 }
 
diff --git a/include/linux/futex_types.h b/include/linux/futex_types.h
index 20123110c80d..a2b4ec0cb125 100644
--- a/include/linux/futex_types.h
+++ b/include/linux/futex_types.h
@@ -21,10 +21,6 @@ struct robust_list_head;
  * @state:		Futex handling state to handle exit races correctly
  */
 struct futex_sched_data {
-	struct robust_list_head __user		*robust_list;
-#ifdef CONFIG_COMPAT
-	struct robust_list_head32 __user *robust_list32;
-#endif
 	uintptr_t				*robust_lists;
 	struct list_head			pi_state_list;
 	struct futex_pi_state			*pi_state_cache;
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index d15906f3c80c..a0a391330408 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1223,7 +1223,8 @@ static void exit_robust_list(struct task_struct *curr,
 
 static bool robust_list_clear_pending(unsigned long __user *pop)
 {
-	struct robust_list_head __user *head = current->futex.robust_list;
+	uintptr_t *rl = current->futex.robust_lists;
+	unsigned int i;
 
 	if (!put_user(0UL, pop))
 		return true;
@@ -1237,8 +1238,24 @@ static bool robust_list_clear_pending(unsigned long __user *pop)
 	 * task exits.  Better a few stale futexes than corrupted memory. But
 	 * that's mostly an academic exercise.
 	 */
-	if (pop == (unsigned long __user *)&head->list_op_pending)
-		current->futex.robust_list = NULL;
+	if (!rl)
+		return false;
+
+	for (i = 0; i < FUTEX_ROBUST_LIST2_MAX_IDX; i++) {
+		struct robust_list_head __user *head;
+
+		if (!rl[i] || rl[i] & FUTEX_ROBUST_LIST2_ENTRY_32BIT)
+			continue;
+
+		head = (struct robust_list_head __user *)
+		       (rl[i] & FUTEX_ROBUST_LIST2_ENTRY_MASK);
+
+		if (pop == (unsigned long __user *)&head->list_op_pending) {
+			rl[i] = (uintptr_t) NULL;
+			break;
+		}
+	}
+
 	return false;
 }
 
@@ -1342,14 +1359,31 @@ static void exit_robust_list32(struct task_struct *curr,
 
 static bool robust_list_clear_pending32(u32 __user *pop)
 {
-	struct robust_list_head32 __user *head = current->futex.robust_list32;
+	uintptr_t *rl = current->futex.robust_lists;
+	unsigned int i;
 
 	if (!put_user(0U, pop))
 		return true;
 
 	/* See comment in robust_list_clear_pending(). */
-	if (pop == &head->list_op_pending)
-		current->futex.robust_list32 = NULL;
+	if (!rl)
+		return false;
+
+	for (i = 0; i < FUTEX_ROBUST_LIST2_MAX_IDX; i++) {
+		struct robust_list_head32 __user *head;
+
+		if (!rl[i] || !(rl[i] & FUTEX_ROBUST_LIST2_ENTRY_32BIT))
+			continue;
+
+		head = (struct robust_list_head32 __user *)
+		       (rl[i] & FUTEX_ROBUST_LIST2_ENTRY_MASK);
+
+		if (pop == (unsigned __user *)&head->list_op_pending) {
+			rl[i] = (uintptr_t) NULL;
+			break;
+		}
+	}
+
 	return false;
 }
 #else
@@ -1514,18 +1548,6 @@ static void futex_cleanup(struct task_struct *tsk)
 	if (unlikely(tsk->futex.robust_lists))
 		exit_robust_lists(tsk);
 
-	if (unlikely(tsk->futex.robust_list)) {
-		exit_robust_list(tsk, tsk->futex.robust_list);
-		tsk->futex.robust_list = NULL;
-	}
-
-#ifdef CONFIG_64BIT
-	if (unlikely(tsk->futex.robust_list32)) {
-		exit_robust_list32(tsk, tsk->futex.robust_list32);
-		tsk->futex.robust_list32 = NULL;
-	}
-#endif
-
 	if (unlikely(!list_empty(&tsk->futex.pi_state_list)))
 		exit_pi_state_list(tsk);
 }
diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index 4a45bace75fc..8e7aec8fe03b 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -27,21 +27,31 @@
  */
 SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head, size_t, len)
 {
+	uintptr_t *rl = futex_get_robust_lists();
+
 	/* The kernel knows only one size for now. */
 	if (unlikely(len != sizeof(*head)))
 		return -EINVAL;
 
-	current->futex.robust_list = head;
+	if (!rl)
+		return -ENOMEM;
+
+	rl[FUTEX_ROBUST_LIST2_NATIVE_IDX] = (uintptr_t)head;
 	return 0;
 }
 
 static inline void __user *futex_task_robust_list(struct task_struct *p, bool compat)
 {
+	uintptr_t *rl = p->futex.robust_lists;
+
+	if (!rl)
+		return NULL;
+
 #ifdef CONFIG_COMPAT
 	if (compat)
-		return p->futex.robust_list32;
+		return (void __user *)rl[FUTEX_ROBUST_LIST2_COMPAT_IDX];
 #endif
-	return p->futex.robust_list;
+	return (void __user *)rl[FUTEX_ROBUST_LIST2_NATIVE_IDX];
 }
 
 static void __user *futex_get_robust_list_common(int pid, bool compat)
@@ -76,7 +86,7 @@ static void __user *futex_get_robust_list_common(int pid, bool compat)
 	up_read(&p->signal->exec_update_lock);
 	put_task_struct(p);
 
-	return head;
+	return (void __user *)((uintptr_t) head & FUTEX_ROBUST_LIST2_ENTRY_MASK);
 
 err_unlock:
 	up_read(&p->signal->exec_update_lock);
@@ -481,11 +491,15 @@ SYSCALL_DEFINE4(futex_requeue,
 COMPAT_SYSCALL_DEFINE2(set_robust_list, struct robust_list_head32 __user *, head,
 		       compat_size_t, len)
 {
+	uintptr_t *rl = futex_get_robust_lists();
+
 	if (unlikely(len != sizeof(*head)))
 		return -EINVAL;
 
-	current->futex.robust_list32 = head;
+	if (!rl)
+		return -ENOMEM;
 
+	rl[FUTEX_ROBUST_LIST2_COMPAT_IDX] = (uintptr_t)head | FUTEX_ROBUST_LIST2_ENTRY_32BIT;
 	return 0;
 }
 

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 07/14] futex: Expose robust_list2 limits via sysctl
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
                   ` (5 preceding siblings ...)
  2026-12-04 16:15 ` [PATCH v9 06/14] futex: Use the multi-robust list infrastructure for current syscalls André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-04 16:15 ` [PATCH v9 08/14] futex: Create syscall set_robust_list2() André Almeida
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

Expose to userspace the limit of robust lists per task and the
number of elements per robust list via sysctl.

Userspace should check this values to safely use set/get_robust_list2()
syscalls.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 kernel/futex/core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index a0a391330408..0dd2f5594061 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -44,6 +44,7 @@
 #include <linux/prctl.h>
 #include <linux/rseq.h>
 #include <linux/slab.h>
+#include <linux/sysctl.h>
 #include <linux/vmalloc.h>
 #include <linux/kmemleak.h>
 #include <linux/wait_bit.h>
@@ -2161,6 +2162,26 @@ int futex_hash_prctl(unsigned long arg2, unsigned long arg3, unsigned long arg4)
 	return ret;
 }
 
+static int robust_list2_list_limit = FUTEX_ROBUST_LIST2_PER_USER;
+static int robust_list2_elements_per_list = ROBUST_LIST_LIMIT;
+
+static const struct ctl_table futex_sysctls[] = {
+	{
+		.procname	= "robust_list2_list_limit",
+		.data		= &robust_list2_list_limit,
+		.maxlen		= sizeof(int),
+		.mode		= 0444,
+		.proc_handler	= proc_dointvec,
+	},
+	{
+		.procname	= "robust_list2_elements_per_list",
+		.data		= &robust_list2_elements_per_list,
+		.maxlen		= sizeof(int),
+		.mode		= 0444,
+		.proc_handler	= proc_dointvec,
+	},
+};
+
 static int __init futex_init(void)
 {
 	unsigned long hashsize, i;
@@ -2187,6 +2208,8 @@ static int __init futex_init(void)
 	runtime_const_init(mask,  __futex_mask);
 	runtime_const_init(ptr,   __futex_queues);
 
+	register_sysctl_init("kernel/futex", futex_sysctls);
+
 	barrier();
 
 	BUG_ON(!futex_queues());

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 08/14] futex: Create syscall set_robust_list2()
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
                   ` (6 preceding siblings ...)
  2026-12-04 16:15 ` [PATCH v9 07/14] futex: Expose robust_list2 limits via sysctl André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-04 16:15 ` [PATCH v9 09/14] futex: Make futex_task_robust_list() get list by index André Almeida
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

Emulators (like FEX-Emu, to run x86 apps on top of Aarch64) have two
special needs about robust lists: to be able to register more than one
robust list, one of the app being emulated and one list for the emulator
itself; and to be able to walk 32-bit robust lists on a 64-bit
platform without compat entry points.

The current syscall allows one robust list per task (on x86-64, it
can have two if compat is enabled) and on Aarch64 there's no way to
parse a 32-bit robust list. The current syscall cannot be expanded to
solve both needs due to the lack of `flags` argument, so create a new
syscall, set_robust_list2() with the following signature:

  sys_set_robust_list2(struct robust_list_head __user *head,
		       unsigned int index, unsigned int flags)

The new syscall allows setting multiple lists per task, of 64-bit or
32-bit types. These are the arguments:

 - `*head` is the same structure used in the current syscall.
 - `index` is used to set which index of task array of heads to be changed.
 It should be between zero and the number of elements in the robust list
 array, [0, robust_list2_list_limit).
 - `flags` can be used for special operations:
   - `FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY`: to avoid conflicts between the
   app logic and libc, the kernel provides this special flag to get an
   unused index. `index` must be zero and `head` must point to a valid
   address. The kernel looks for an empty index, sets `head` there and
   returns such index.
   - `FUTEX_ROBUST_LIST2_FLAG_32BIT_ENTRY`: to specify that a given `head`
   is a 32-bit pointer. The kernel will later call the appropriate
   function to walk the list in 64-bit kernels. `head` should point to
   a `struct robust_list_head32`, defined in the uAPI header. Using this
   flag from a compat app is a no-op, given that the kernel will flag
   every entry as a 32-bit struct anyway.
   - Both flags can be combined and used together.

Kernel is responsible for always providing valid indexes, but userspace is
responsible for managing such indexes afterwards. Userspace can rewrite any
index at any given time. Using `head` as `NULL` to a given index makes it
free to be later returned by the kernel. However, it's invalid to ask for a
new entry while setting `head` as `NULL`.

And those are the error return values:

 - `EINVAL`: for invalid flags, unaligned `head` address, `index` out of
 range, when `head` is NULL or `index` is not zero when using
 `FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY`.
 - `ENOMEM`: the allocation of the array of robust list heads failed.
 - `EFAULT`: `head` address can't be accessed.
 - `ENOSPC`: when `FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY` is used but there's
 no empty index available at the moment.

The array of lists is dynamically allocated on first use, but has a fixed
size determined by the kernel. Userspace should use sysctl interfaces
to gather how many `head` indexes are allocated
(`futex.robust_list2_list_limit`) and how many elements each list can
handle (`futex.robust_list2_elements_per_list`).

8 slots cover the target use case with headroom. However, userspace should
always check this number and not make assumptions.

The first two slots are internally reserved for the kernel, to store the
original syscall robust_list_head's (the native and compat one). Map the
indexes in such a way that userspace can't touch those indexes with the new
syscall and needs to use the original syscalls to manipulate such
addresses.

The array of lists is destroyed only during task exit. There are no
guarantees about the order of the lists.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 include/uapi/linux/futex.h |  7 +++++++
 kernel/futex/core.c        | 32 ++++++++++++++++++++++++++++++++
 kernel/futex/futex.h       |  2 ++
 kernel/futex/syscalls.c    | 30 ++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+)

diff --git a/include/uapi/linux/futex.h b/include/uapi/linux/futex.h
index b39f8a23a84b..a114a19c53f1 100644
--- a/include/uapi/linux/futex.h
+++ b/include/uapi/linux/futex.h
@@ -131,6 +131,13 @@ struct futex_waitv {
  * thread exit time.
  */
 
+/*
+ * User flags for set/get_robust_list2() syscalls
+ */
+#define FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY	0x1
+#define FUTEX_ROBUST_LIST2_FLAG_32BIT_ENTRY	0x2
+#define FUTEX_ROBUST_LIST2_FLAGS		0x3
+
 /*
  * Per-lock list entry - embedded in user-space locks, somewhere close
  * to the futex field. (Note: user-space uses a double-linked list to
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index 0dd2f5594061..b01b3501df55 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1137,6 +1137,38 @@ uintptr_t *futex_get_robust_lists(void)
 	return rl;
 }
 
+static unsigned int __futex_robust_list_install(uintptr_t *rl, unsigned int idx, uintptr_t entry)
+{
+	rl[idx] = entry;
+	return idx - FUTEX_ROBUST_LIST2_IDX;
+}
+
+int futex_robust_list_install(uintptr_t entry, unsigned int idx, bool new, bool compat)
+{
+	uintptr_t *rl = futex_get_robust_lists();
+
+	if (!rl)
+		return -ENOMEM;
+
+	if (compat && entry)
+		entry |= FUTEX_ROBUST_LIST2_ENTRY_32BIT;
+
+	if (!new) {
+		if (idx >= FUTEX_ROBUST_LIST2_PER_USER)
+			return -EINVAL;
+
+		return __futex_robust_list_install(rl, idx + FUTEX_ROBUST_LIST2_IDX, entry);
+	}
+
+	/* Search for an empty slot */
+	for (idx = FUTEX_ROBUST_LIST2_IDX; idx < FUTEX_ROBUST_LIST2_MAX_IDX; idx++) {
+		if (!rl[idx])
+			return __futex_robust_list_install(rl, idx, entry);
+	}
+
+	return -ENOSPC;
+}
+
 /*
  * Fetch a robust-list pointer. Bit 0 signals PI futexes:
  */
diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
index c1da53fd7187..8258d6fda227 100644
--- a/kernel/futex/futex.h
+++ b/kernel/futex/futex.h
@@ -492,4 +492,6 @@ bool futex_robust_list_clear_pending(void __user *pop, unsigned int flags);
 
 uintptr_t *futex_get_robust_lists(void);
 
+int futex_robust_list_install(uintptr_t entry, unsigned int idx, bool new, bool compat);
+
 #endif /* _FUTEX_H */
diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index 8e7aec8fe03b..af75ffb70956 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -115,6 +115,36 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,
 	return put_user(head, head_ptr);
 }
 
+SYSCALL_DEFINE3(set_robust_list2, struct robust_list_head * __user, head,
+		unsigned int, index, unsigned int, flags)
+{
+	size_t align = sizeof(u64), head_size = sizeof(*head);
+	bool new = false, compat = false;
+
+	if (flags & ~FUTEX_ROBUST_LIST2_FLAGS)
+		return -EINVAL;
+
+	if (flags & FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY) {
+		if (index || !head)
+			return -EINVAL;
+		new = true;
+	}
+
+	if (flags & FUTEX_ROBUST_LIST2_FLAG_32BIT_ENTRY || in_compat_syscall()) {
+		compat = true;
+		align = sizeof(u32);
+		head_size = sizeof(struct robust_list_head32);
+	}
+
+	if (!IS_ALIGNED((uintptr_t)head, align))
+		return -EINVAL;
+
+	if (head && unlikely(!access_ok(head, head_size)))
+		return -EFAULT;
+
+	return futex_robust_list_install((uintptr_t) head, index, new, compat);
+}
+
 long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
 		u32 __user *uaddr2, u32 val2, u32 val3)
 {

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 09/14] futex: Make futex_task_robust_list() get list by index
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
                   ` (7 preceding siblings ...)
  2026-12-04 16:15 ` [PATCH v9 08/14] futex: Create syscall set_robust_list2() André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-04 16:15 ` [PATCH v9 10/14] futex: Create get_robust_list2() syscall André Almeida
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

Instead of a boolean compat flag, pass the robust list index directly.
This is in preparation for supporting multiple robust lists per task,
beyond the native/compat pair.

No functional changes.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 kernel/futex/syscalls.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index af75ffb70956..29be7d88c8f7 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -40,21 +40,17 @@ SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head, size_t,
 	return 0;
 }
 
-static inline void __user *futex_task_robust_list(struct task_struct *p, bool compat)
+static inline void __user *futex_task_robust_list(struct task_struct *p, unsigned int idx)
 {
 	uintptr_t *rl = p->futex.robust_lists;
 
-	if (!rl)
+	if (!rl || idx >= FUTEX_ROBUST_LIST2_MAX_IDX)
 		return NULL;
 
-#ifdef CONFIG_COMPAT
-	if (compat)
-		return (void __user *)rl[FUTEX_ROBUST_LIST2_COMPAT_IDX];
-#endif
-	return (void __user *)rl[FUTEX_ROBUST_LIST2_NATIVE_IDX];
+	return (void __user *)(rl[idx] & FUTEX_ROBUST_LIST2_ENTRY_MASK);
 }
 
-static void __user *futex_get_robust_list_common(int pid, bool compat)
+static void __user *futex_get_robust_list_common(int pid, unsigned int idx)
 {
 	struct task_struct *p = current;
 	void __user *head;
@@ -81,12 +77,12 @@ static void __user *futex_get_robust_list_common(int pid, bool compat)
 	if (!ptrace_may_access(p, PTRACE_MODE_READ_REALCREDS))
 		goto err_unlock;
 
-	head = futex_task_robust_list(p, compat);
+	head = futex_task_robust_list(p, idx);
 
 	up_read(&p->signal->exec_update_lock);
 	put_task_struct(p);
 
-	return (void __user *)((uintptr_t) head & FUTEX_ROBUST_LIST2_ENTRY_MASK);
+	return (void __user *)head;
 
 err_unlock:
 	up_read(&p->signal->exec_update_lock);
@@ -105,7 +101,9 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,
 		struct robust_list_head __user * __user *, head_ptr,
 		size_t __user *, len_ptr)
 {
-	struct robust_list_head __user *head = futex_get_robust_list_common(pid, false);
+	struct robust_list_head __user *head;
+
+	head = futex_get_robust_list_common(pid, FUTEX_ROBUST_LIST2_NATIVE_IDX);
 
 	if (IS_ERR(head))
 		return PTR_ERR(head);
@@ -537,7 +535,9 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
 			compat_uptr_t __user *, head_ptr,
 			compat_size_t __user *, len_ptr)
 {
-	struct robust_list_head32 __user *head = futex_get_robust_list_common(pid, true);
+	struct robust_list_head32 __user *head;
+
+	head = futex_get_robust_list_common(pid, FUTEX_ROBUST_LIST2_COMPAT_IDX);
 
 	if (IS_ERR(head))
 		return PTR_ERR(head);

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 10/14] futex: Create get_robust_list2() syscall
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
                   ` (8 preceding siblings ...)
  2026-12-04 16:15 ` [PATCH v9 09/14] futex: Make futex_task_robust_list() get list by index André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-04 16:15 ` [PATCH v9 11/14] futex: Wire up set_robust_list2 syscall André Almeida
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

As in the original robust list interface, to pair with set_robust_list2(),
create a get_robust_list2() syscall with the following signature:

  get_robust_list2(int pid, void __user **head_ptr, unsigned int index,
		   unsigned int flags)

  - `pid` selects which task's list should be returned. If is 0, it gets
     the list of the calling task.
  - `index` is the index of the list to get.
  - `flags` must be 0, reserved for future extensions.

Return value is 0 when the operations succeeds, returns and error
otherwise.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 kernel/futex/syscalls.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index 29be7d88c8f7..904b5820294b 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -143,6 +143,24 @@ SYSCALL_DEFINE3(set_robust_list2, struct robust_list_head * __user, head,
 	return futex_robust_list_install((uintptr_t) head, index, new, compat);
 }
 
+SYSCALL_DEFINE4(get_robust_list2, int, pid, void __user * __user *, head_ptr,
+		unsigned int, index, unsigned int, flags)
+{
+	struct robust_list_head __user *head;
+
+	if (flags || index >= FUTEX_ROBUST_LIST2_PER_USER)
+		return -EINVAL;
+
+	head = futex_get_robust_list_common(pid, index + FUTEX_ROBUST_LIST2_IDX);
+
+	if (IS_ERR(head))
+		return PTR_ERR(head);
+
+	if (in_compat_syscall())
+		return put_user(ptr_to_compat(head), (u32 __user *)head_ptr);
+	return put_user(head, head_ptr);
+}
+
 long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
 		u32 __user *uaddr2, u32 val2, u32 val3)
 {

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 11/14] futex: Wire up set_robust_list2 syscall
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
                   ` (9 preceding siblings ...)
  2026-12-04 16:15 ` [PATCH v9 10/14] futex: Create get_robust_list2() syscall André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-05  9:55   ` kernel test robot
  2026-12-05  9:55   ` kernel test robot
  2026-12-04 16:15 ` [PATCH v9 12/14] futex: Wire up get_robust_list2 syscall André Almeida
                   ` (2 subsequent siblings)
  13 siblings, 2 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

Wire up the new set_robust_list2 syscall in all available architectures.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 arch/alpha/kernel/syscalls/syscall.tbl      | 1 +
 arch/arm/tools/syscall.tbl                  | 1 +
 arch/m68k/kernel/syscalls/syscall.tbl       | 1 +
 arch/microblaze/kernel/syscalls/syscall.tbl | 1 +
 arch/mips/kernel/syscalls/syscall_n32.tbl   | 1 +
 arch/mips/kernel/syscalls/syscall_n64.tbl   | 1 +
 arch/mips/kernel/syscalls/syscall_o32.tbl   | 1 +
 arch/parisc/kernel/syscalls/syscall.tbl     | 1 +
 arch/powerpc/kernel/syscalls/syscall.tbl    | 1 +
 arch/s390/kernel/syscalls/syscall.tbl       | 1 +
 arch/sh/kernel/syscalls/syscall.tbl         | 1 +
 arch/sparc/kernel/syscalls/syscall.tbl      | 1 +
 arch/x86/entry/syscalls/syscall_32.tbl      | 1 +
 arch/x86/entry/syscalls/syscall_64.tbl      | 1 +
 arch/xtensa/kernel/syscalls/syscall.tbl     | 1 +
 include/uapi/asm-generic/unistd.h           | 5 ++++-
 scripts/syscall.tbl                         | 1 +
 17 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/arch/alpha/kernel/syscalls/syscall.tbl b/arch/alpha/kernel/syscalls/syscall.tbl
index 52e3538cc7df..cdf641845014 100644
--- a/arch/alpha/kernel/syscalls/syscall.tbl
+++ b/arch/alpha/kernel/syscalls/syscall.tbl
@@ -512,3 +512,4 @@
 580	common	listns				sys_listns
 581	common	rseq_slice_yield		sys_rseq_slice_yield
 582	common	fchroot				sys_fchroot
+583	common	set_robust_list2		sys_set_robust_list2
diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl
index 55717ed32c27..c287461803ff 100644
--- a/arch/arm/tools/syscall.tbl
+++ b/arch/arm/tools/syscall.tbl
@@ -487,3 +487,4 @@
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
+473	common	set_robust_list2		sys_set_robust_list2
diff --git a/arch/m68k/kernel/syscalls/syscall.tbl b/arch/m68k/kernel/syscalls/syscall.tbl
index ba7a4d8903d0..beb0ba7f350c 100644
--- a/arch/m68k/kernel/syscalls/syscall.tbl
+++ b/arch/m68k/kernel/syscalls/syscall.tbl
@@ -472,3 +472,4 @@
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
+473	common  set_robust_list2		sys_set_robust_list2
diff --git a/arch/microblaze/kernel/syscalls/syscall.tbl b/arch/microblaze/kernel/syscalls/syscall.tbl
index 76d7cbe2a133..bf04133f7239 100644
--- a/arch/microblaze/kernel/syscalls/syscall.tbl
+++ b/arch/microblaze/kernel/syscalls/syscall.tbl
@@ -478,3 +478,4 @@
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
+473	common	set_robust_list2		sys_set_robust_list2
diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl b/arch/mips/kernel/syscalls/syscall_n32.tbl
index 9ae88e4eac61..5b5b217ee7f3 100644
--- a/arch/mips/kernel/syscalls/syscall_n32.tbl
+++ b/arch/mips/kernel/syscalls/syscall_n32.tbl
@@ -411,3 +411,4 @@
 470	n32	listns				sys_listns
 471	n32	rseq_slice_yield		sys_rseq_slice_yield
 472	n32	fchroot				sys_fchroot
+473	n32	set_robust_list2		sys_set_robust_list2
diff --git a/arch/mips/kernel/syscalls/syscall_n64.tbl b/arch/mips/kernel/syscalls/syscall_n64.tbl
index 83dc93a0712f..6f203cb3a558 100644
--- a/arch/mips/kernel/syscalls/syscall_n64.tbl
+++ b/arch/mips/kernel/syscalls/syscall_n64.tbl
@@ -387,3 +387,4 @@
 470	n64	listns				sys_listns
 471	n64	rseq_slice_yield		sys_rseq_slice_yield
 472	n64	fchroot				sys_fchroot
+473	n64	set_robust_list2		sys_set_robust_list2
diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl b/arch/mips/kernel/syscalls/syscall_o32.tbl
index 9c62429c9b7b..d170650521a7 100644
--- a/arch/mips/kernel/syscalls/syscall_o32.tbl
+++ b/arch/mips/kernel/syscalls/syscall_o32.tbl
@@ -460,3 +460,4 @@
 470	o32	listns				sys_listns
 471	o32	rseq_slice_yield		sys_rseq_slice_yield
 472	o32	fchroot				sys_fchroot
+473	o32	set_robust_list2		sys_set_robust_list2
diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl
index 88adc4016cce..f9317ff28e37 100644
--- a/arch/parisc/kernel/syscalls/syscall.tbl
+++ b/arch/parisc/kernel/syscalls/syscall.tbl
@@ -471,3 +471,4 @@
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
+473	common	set_robust_list2		sys_set_robust_list2
diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl
index cfbb70039ff0..acb9d446d1f6 100644
--- a/arch/powerpc/kernel/syscalls/syscall.tbl
+++ b/arch/powerpc/kernel/syscalls/syscall.tbl
@@ -563,3 +563,4 @@
 470	common	listns				sys_listns
 471	nospu	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
+473	common	set_robust_list2		sys_set_robust_list2
diff --git a/arch/s390/kernel/syscalls/syscall.tbl b/arch/s390/kernel/syscalls/syscall.tbl
index 1b45e68a217b..987e026ffbcf 100644
--- a/arch/s390/kernel/syscalls/syscall.tbl
+++ b/arch/s390/kernel/syscalls/syscall.tbl
@@ -399,3 +399,4 @@
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
+473	common	set_robust_list2		sys_set_robust_list2
diff --git a/arch/sh/kernel/syscalls/syscall.tbl b/arch/sh/kernel/syscalls/syscall.tbl
index ace068dff0de..c944333c1990 100644
--- a/arch/sh/kernel/syscalls/syscall.tbl
+++ b/arch/sh/kernel/syscalls/syscall.tbl
@@ -476,3 +476,4 @@
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
+473	common	set_robust_list2		sys_set_robust_list2
diff --git a/arch/sparc/kernel/syscalls/syscall.tbl b/arch/sparc/kernel/syscalls/syscall.tbl
index 5b9fe0e8140f..3c01fa1cd885 100644
--- a/arch/sparc/kernel/syscalls/syscall.tbl
+++ b/arch/sparc/kernel/syscalls/syscall.tbl
@@ -518,3 +518,4 @@
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
+473	common	set_robust_list2		sys_set_robust_list2
diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
index 2c172ef48dfd..11ebbf074920 100644
--- a/arch/x86/entry/syscalls/syscall_32.tbl
+++ b/arch/x86/entry/syscalls/syscall_32.tbl
@@ -478,3 +478,4 @@
 470	i386	listns			sys_listns
 471	i386	rseq_slice_yield	sys_rseq_slice_yield
 472	i386	fchroot			sys_fchroot
+473	i386	set_robust_list2	sys_set_robust_list2
diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl
index d5b6045b0090..53398e8d4981 100644
--- a/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/arch/x86/entry/syscalls/syscall_64.tbl
@@ -397,6 +397,7 @@
 470	common	listns			sys_listns
 471	common	rseq_slice_yield	sys_rseq_slice_yield
 472	common	fchroot			sys_fchroot
+473	common	set_robust_list2	sys_set_robust_list2
 
 #
 # Due to a historical design error, certain syscalls are numbered differently
diff --git a/arch/xtensa/kernel/syscalls/syscall.tbl b/arch/xtensa/kernel/syscalls/syscall.tbl
index d354bb231796..7ba9d6993800 100644
--- a/arch/xtensa/kernel/syscalls/syscall.tbl
+++ b/arch/xtensa/kernel/syscalls/syscall.tbl
@@ -443,3 +443,4 @@
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
+473	common	set_robust_list2		sys_set_robust_list2
diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
index 5b7e77a7c736..7525e0add809 100644
--- a/include/uapi/asm-generic/unistd.h
+++ b/include/uapi/asm-generic/unistd.h
@@ -867,8 +867,11 @@ __SYSCALL(__NR_rseq_slice_yield, sys_rseq_slice_yield)
 #define __NR_fchroot 472
 __SYSCALL(__NR_fchroot, sys_fchroot)
 
+#define __NR_set_robust_list2 473
+__SYSCALL(__NR_set_robust_list2, sys_set_robust_list2)
+
 #undef __NR_syscalls
-#define __NR_syscalls 473
+#define __NR_syscalls 474
 
 /*
  * 32 bit systems traditionally used different
diff --git a/scripts/syscall.tbl b/scripts/syscall.tbl
index 0ab531605120..c8d261cb8762 100644
--- a/scripts/syscall.tbl
+++ b/scripts/syscall.tbl
@@ -413,3 +413,4 @@
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
+473	common	set_robust_list2		sys_set_robust_list2

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 12/14] futex: Wire up get_robust_list2 syscall
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
                   ` (10 preceding siblings ...)
  2026-12-04 16:15 ` [PATCH v9 11/14] futex: Wire up set_robust_list2 syscall André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-04 16:15 ` [PATCH v9 13/14] selftests/futex: Expand for set_robust_list2() André Almeida
  2026-12-04 16:15 ` [PATCH v9 14/14] selftests/futex: Expand for get_robust_list2() André Almeida
  13 siblings, 0 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

Wire up the new get_robust_list2 syscall in all available architectures.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 arch/alpha/kernel/syscalls/syscall.tbl      | 1 +
 arch/arm/tools/syscall.tbl                  | 1 +
 arch/m68k/kernel/syscalls/syscall.tbl       | 1 +
 arch/microblaze/kernel/syscalls/syscall.tbl | 1 +
 arch/mips/kernel/syscalls/syscall_n32.tbl   | 1 +
 arch/mips/kernel/syscalls/syscall_n64.tbl   | 1 +
 arch/mips/kernel/syscalls/syscall_o32.tbl   | 1 +
 arch/parisc/kernel/syscalls/syscall.tbl     | 1 +
 arch/powerpc/kernel/syscalls/syscall.tbl    | 1 +
 arch/s390/kernel/syscalls/syscall.tbl       | 1 +
 arch/sh/kernel/syscalls/syscall.tbl         | 1 +
 arch/sparc/kernel/syscalls/syscall.tbl      | 1 +
 arch/x86/entry/syscalls/syscall_32.tbl      | 1 +
 arch/x86/entry/syscalls/syscall_64.tbl      | 1 +
 arch/xtensa/kernel/syscalls/syscall.tbl     | 1 +
 include/uapi/asm-generic/unistd.h           | 4 +++-
 scripts/syscall.tbl                         | 1 +
 17 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/alpha/kernel/syscalls/syscall.tbl b/arch/alpha/kernel/syscalls/syscall.tbl
index cdf641845014..e26df2cf9de7 100644
--- a/arch/alpha/kernel/syscalls/syscall.tbl
+++ b/arch/alpha/kernel/syscalls/syscall.tbl
@@ -513,3 +513,4 @@
 581	common	rseq_slice_yield		sys_rseq_slice_yield
 582	common	fchroot				sys_fchroot
 583	common	set_robust_list2		sys_set_robust_list2
+584	common	get_robust_list2		sys_get_robust_list2
diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl
index c287461803ff..0268a887f90d 100644
--- a/arch/arm/tools/syscall.tbl
+++ b/arch/arm/tools/syscall.tbl
@@ -488,3 +488,4 @@
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
 473	common	set_robust_list2		sys_set_robust_list2
+474	common	get_robust_list2		sys_get_robust_list2
diff --git a/arch/m68k/kernel/syscalls/syscall.tbl b/arch/m68k/kernel/syscalls/syscall.tbl
index beb0ba7f350c..91cc1ea407ec 100644
--- a/arch/m68k/kernel/syscalls/syscall.tbl
+++ b/arch/m68k/kernel/syscalls/syscall.tbl
@@ -473,3 +473,4 @@
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
 473	common  set_robust_list2		sys_set_robust_list2
+474	common  get_robust_list2		sys_get_robust_list2
diff --git a/arch/microblaze/kernel/syscalls/syscall.tbl b/arch/microblaze/kernel/syscalls/syscall.tbl
index bf04133f7239..18a59b24724c 100644
--- a/arch/microblaze/kernel/syscalls/syscall.tbl
+++ b/arch/microblaze/kernel/syscalls/syscall.tbl
@@ -479,3 +479,4 @@
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
 473	common	set_robust_list2		sys_set_robust_list2
+474	common	get_robust_list2		sys_get_robust_list2
diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl b/arch/mips/kernel/syscalls/syscall_n32.tbl
index 5b5b217ee7f3..f498b01178e4 100644
--- a/arch/mips/kernel/syscalls/syscall_n32.tbl
+++ b/arch/mips/kernel/syscalls/syscall_n32.tbl
@@ -412,3 +412,4 @@
 471	n32	rseq_slice_yield		sys_rseq_slice_yield
 472	n32	fchroot				sys_fchroot
 473	n32	set_robust_list2		sys_set_robust_list2
+474	n32	get_robust_list2		sys_get_robust_list2
diff --git a/arch/mips/kernel/syscalls/syscall_n64.tbl b/arch/mips/kernel/syscalls/syscall_n64.tbl
index 6f203cb3a558..b12328d537e3 100644
--- a/arch/mips/kernel/syscalls/syscall_n64.tbl
+++ b/arch/mips/kernel/syscalls/syscall_n64.tbl
@@ -388,3 +388,4 @@
 471	n64	rseq_slice_yield		sys_rseq_slice_yield
 472	n64	fchroot				sys_fchroot
 473	n64	set_robust_list2		sys_set_robust_list2
+474	n64	get_robust_list2		sys_get_robust_list2
diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl b/arch/mips/kernel/syscalls/syscall_o32.tbl
index d170650521a7..3c8e3890644f 100644
--- a/arch/mips/kernel/syscalls/syscall_o32.tbl
+++ b/arch/mips/kernel/syscalls/syscall_o32.tbl
@@ -461,3 +461,4 @@
 471	o32	rseq_slice_yield		sys_rseq_slice_yield
 472	o32	fchroot				sys_fchroot
 473	o32	set_robust_list2		sys_set_robust_list2
+474	o32	get_robust_list2		sys_get_robust_list2
diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl
index f9317ff28e37..f746f152cd51 100644
--- a/arch/parisc/kernel/syscalls/syscall.tbl
+++ b/arch/parisc/kernel/syscalls/syscall.tbl
@@ -472,3 +472,4 @@
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
 473	common	set_robust_list2		sys_set_robust_list2
+474	common	get_robust_list2		sys_get_robust_list2
diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl
index acb9d446d1f6..b785d6861963 100644
--- a/arch/powerpc/kernel/syscalls/syscall.tbl
+++ b/arch/powerpc/kernel/syscalls/syscall.tbl
@@ -564,3 +564,4 @@
 471	nospu	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
 473	common	set_robust_list2		sys_set_robust_list2
+474	common	get_robust_list2		sys_get_robust_list2
diff --git a/arch/s390/kernel/syscalls/syscall.tbl b/arch/s390/kernel/syscalls/syscall.tbl
index 987e026ffbcf..eb0c5bf1d71f 100644
--- a/arch/s390/kernel/syscalls/syscall.tbl
+++ b/arch/s390/kernel/syscalls/syscall.tbl
@@ -400,3 +400,4 @@
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
 473	common	set_robust_list2		sys_set_robust_list2
+474	common	get_robust_list2		sys_get_robust_list2
diff --git a/arch/sh/kernel/syscalls/syscall.tbl b/arch/sh/kernel/syscalls/syscall.tbl
index c944333c1990..520ec9072ce3 100644
--- a/arch/sh/kernel/syscalls/syscall.tbl
+++ b/arch/sh/kernel/syscalls/syscall.tbl
@@ -477,3 +477,4 @@
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
 473	common	set_robust_list2		sys_set_robust_list2
+474	common	get_robust_list2		sys_get_robust_list2
diff --git a/arch/sparc/kernel/syscalls/syscall.tbl b/arch/sparc/kernel/syscalls/syscall.tbl
index 3c01fa1cd885..8d332ffde99f 100644
--- a/arch/sparc/kernel/syscalls/syscall.tbl
+++ b/arch/sparc/kernel/syscalls/syscall.tbl
@@ -519,3 +519,4 @@
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
 473	common	set_robust_list2		sys_set_robust_list2
+474	common	get_robust_list2		sys_get_robust_list2
diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
index 11ebbf074920..be72e54ce2fd 100644
--- a/arch/x86/entry/syscalls/syscall_32.tbl
+++ b/arch/x86/entry/syscalls/syscall_32.tbl
@@ -479,3 +479,4 @@
 471	i386	rseq_slice_yield	sys_rseq_slice_yield
 472	i386	fchroot			sys_fchroot
 473	i386	set_robust_list2	sys_set_robust_list2
+474	i386	get_robust_list2	sys_get_robust_list2
diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl
index 53398e8d4981..d5f91d276e75 100644
--- a/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/arch/x86/entry/syscalls/syscall_64.tbl
@@ -398,6 +398,7 @@
 471	common	rseq_slice_yield	sys_rseq_slice_yield
 472	common	fchroot			sys_fchroot
 473	common	set_robust_list2	sys_set_robust_list2
+474	common	get_robust_list2	sys_get_robust_list2
 
 #
 # Due to a historical design error, certain syscalls are numbered differently
diff --git a/arch/xtensa/kernel/syscalls/syscall.tbl b/arch/xtensa/kernel/syscalls/syscall.tbl
index 7ba9d6993800..4908baf60363 100644
--- a/arch/xtensa/kernel/syscalls/syscall.tbl
+++ b/arch/xtensa/kernel/syscalls/syscall.tbl
@@ -444,3 +444,4 @@
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
 473	common	set_robust_list2		sys_set_robust_list2
+474	common	get_robust_list2		sys_get_robust_list2
diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
index 7525e0add809..3d84f306e677 100644
--- a/include/uapi/asm-generic/unistd.h
+++ b/include/uapi/asm-generic/unistd.h
@@ -869,9 +869,11 @@ __SYSCALL(__NR_fchroot, sys_fchroot)
 
 #define __NR_set_robust_list2 473
 __SYSCALL(__NR_set_robust_list2, sys_set_robust_list2)
+#define __NR_get_robust_list2 474
+__SYSCALL(__NR_get_robust_list2, sys_get_robust_list2)
 
 #undef __NR_syscalls
-#define __NR_syscalls 474
+#define __NR_syscalls 475
 
 /*
  * 32 bit systems traditionally used different
diff --git a/scripts/syscall.tbl b/scripts/syscall.tbl
index c8d261cb8762..b4fb5e1a2141 100644
--- a/scripts/syscall.tbl
+++ b/scripts/syscall.tbl
@@ -414,3 +414,4 @@
 471	common	rseq_slice_yield		sys_rseq_slice_yield
 472	common	fchroot				sys_fchroot
 473	common	set_robust_list2		sys_set_robust_list2
+474	common	get_robust_list2		sys_get_robust_list2

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 13/14] selftests/futex: Expand for set_robust_list2()
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
                   ` (11 preceding siblings ...)
  2026-12-04 16:15 ` [PATCH v9 12/14] futex: Wire up get_robust_list2 syscall André Almeida
@ 2026-12-04 16:15 ` André Almeida
  2026-12-04 16:15 ` [PATCH v9 14/14] selftests/futex: Expand for get_robust_list2() André Almeida
  13 siblings, 0 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

Reuse the same selftest for the original set_robust_list() syscall for
the new set_robust_list2() syscall. Use kselftest variants feature to
run the relevant tests for both interfaces. Create new test cases for
checking invalid parameters, the ability to correctly set multiple lists
for the same task, and to use 32-bit lists in a 64-bit task.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 .../selftests/futex/functional/robust_list.c       | 443 +++++++++++++++++++--
 1 file changed, 409 insertions(+), 34 deletions(-)

diff --git a/tools/testing/selftests/futex/functional/robust_list.c b/tools/testing/selftests/futex/functional/robust_list.c
index 5076a685ba97..8723f8a3606c 100644
--- a/tools/testing/selftests/futex/functional/robust_list.c
+++ b/tools/testing/selftests/futex/functional/robust_list.c
@@ -49,6 +49,23 @@
 # define BUILD_64
 #endif
 
+#ifndef SYS_set_robust_list2
+# define SYS_set_robust_list2 473
+
+#define FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY	0x1
+#define FUTEX_ROBUST_LIST2_FLAG_32BIT_ENTRY	0x2
+
+struct robust_list32 {
+	uint32_t next;
+};
+
+struct robust_list_head32 {
+	struct robust_list32	list;
+	int32_t			futex_offset;
+	uint32_t		list_op_pending;
+};
+#endif
+
 static pthread_barrier_t barrier, barrier2;
 
 static int set_robust_list(struct robust_list_head *head, size_t len)
@@ -67,6 +84,67 @@ static int sys_futex_robust_unlock(_Atomic(uint32_t) *uaddr, unsigned int op, in
 	return syscall(SYS_futex, uaddr, op, val, NULL, list_op_pending, val3, 0);
 }
 
+static int set_robust_list2(struct robust_list_head *head, unsigned int index,
+			    unsigned int flags)
+{
+	return syscall(SYS_set_robust_list2, head, index, flags, 0, 0);
+}
+
+static int robust_list2_get_list_limit(void)
+{
+	const char *sysctl = "/proc/sys/kernel/futex/robust_list2_list_limit";
+	FILE *f = fopen(sysctl, "r");
+	unsigned int limit;
+
+	if (!f)
+		return -1;
+
+	if (fscanf(f, "%d", &limit) != 1) {
+		fclose(f);
+		return -1;
+	}
+
+	fclose(f);
+
+	return limit;
+}
+
+static bool robust_list2_support(void)
+{
+	if (robust_list2_get_list_limit() == -1)
+		return false;
+
+	return true;
+}
+
+FIXTURE(robust_api) {};
+
+FIXTURE_VARIANT(robust_api)
+{
+	bool robust2;
+};
+
+FIXTURE_SETUP(robust_api)
+{
+	if (!variant->robust2)
+		return;
+
+	if (!robust_list2_support())
+		SKIP(return, "robust_list2 not supported");
+}
+
+FIXTURE_TEARDOWN(robust_api) {}
+
+FIXTURE_VARIANT_ADD(robust_api, robust1)
+{
+	.robust2 = false,
+};
+
+FIXTURE_VARIANT_ADD(robust_api, robust2)
+{
+	.robust2 = true,
+};
+
 /*
  * Basic lock struct, contains just the futex word and the robust list element
  * Real implementations have also a *prev to easily walk in the list
@@ -76,6 +154,12 @@ typedef _Atomic(unsigned int) atomic_futex_t;
 struct lock_struct {
 	atomic_futex_t		futex;
 	struct robust_list	list;
+	bool			robust2;
+};
+
+struct lock_struct32 {
+	_Atomic(uint32_t)	futex;
+	struct robust_list32	list;
 };
 
 struct child_args {
@@ -118,20 +202,32 @@ static int create_child(struct __test_metadata *_metadata, int (*fn)(void *arg),
 /*
  * Helper function to prepare and register a robust list
  */
-static int set_list(struct robust_list_head *head)
+static int set_list(struct robust_list_head *head, bool robust2, int *index)
 {
 	int ret;
 
-	ret = set_robust_list(head, sizeof(*head));
-	if (ret)
-		return ret;
-
 	head->futex_offset = (size_t) offsetof(struct lock_struct, futex) -
 			     (size_t) offsetof(struct lock_struct, list);
 	head->list.next = &head->list;
 	head->list_op_pending = NULL;
 
-	return 0;
+	if (!robust2)
+		return set_robust_list(head, sizeof(*head));
+
+	ret = set_robust_list2(head, 0, FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY);
+
+	if (ret >= 0 && index)
+		*index = ret;
+
+	return ret;
+}
+
+/*
+ * Change a given list index to a different head
+ */
+static int modify_list(struct robust_list_head *head, int index)
+{
+	return set_robust_list2(head, index, 0);
 }
 
 /*
@@ -203,12 +299,12 @@ static int child_fn_lock(void *arg)
 	struct __test_metadata *_metadata = cargs->_metadata;
 	struct lock_struct *lock = cargs->arg;
 	struct robust_list_head head;
-	int ret;
+	int ret, index;
 
 	free(cargs);
 
-	ret = set_list(&head);
-	ASSERT_EQ(ret, 0)
+	ret = set_list(&head, lock->robust2, &index);
+	ASSERT_NE(ret, -1)
 		TH_LOG("set_robust_list error");
 
 	ret = mutex_lock(lock, &head, false);
@@ -233,15 +329,17 @@ static int child_fn_lock(void *arg)
  * in the robust list and die. The parent thread will wait on this futex, and
  * should be waken up when the child exits.
  */
-TEST(test_robustness)
+TEST_F(robust_api, test_robustness)
 {
 	struct lock_struct lock = { .futex = 0 };
 	atomic_futex_t *futex = &lock.futex;
 	struct robust_list_head head;
-	int ret, pid, wstatus;
+	int ret, pid, wstatus, index;
 
-	ret = set_list(&head);
-	ASSERT_EQ(ret, 0);
+	lock.robust2 = variant->robust2;
+
+	ret = set_list(&head, lock.robust2, &index);
+	ASSERT_NE(ret, -1);
 
 	/*
 	 * Lets use a barrier to ensure that the child thread takes the lock
@@ -281,7 +379,7 @@ TEST(test_set_robust_list_invalid_size)
 	int ret;
 
 	ret = set_robust_list(&head, head_size);
-	ASSERT_EQ(ret, 0);
+	ASSERT_GE(ret, 0);
 
 	ret = set_robust_list(&head, head_size * 2);
 	ASSERT_EQ(ret, -1);
@@ -296,6 +394,40 @@ TEST(test_set_robust_list_invalid_size)
 	ASSERT_EQ(errno, EINVAL);
 }
 
+/*
+ * Test invalid parameters
+ */
+TEST(test_set_robust_list2_inval)
+{
+	struct robust_list_head head;
+	int i, ret, index, list_limit;
+
+	if (!robust_list2_support())
+		SKIP(return, "robust_list2 not supported\n");
+
+	/* Bad flag */
+	ret = set_robust_list2(&head, 0, 999);
+	ASSERT_EQ(ret, -1);
+	ASSERT_EQ(errno, EINVAL);
+
+	/* List out of range */
+	list_limit = robust_list2_get_list_limit();
+	ASSERT_GT(list_limit, 1);
+
+	for (i = 0; i < list_limit; i++) {
+		ret = set_list(&head, true, &index);
+		ASSERT_EQ(ret, i);
+	}
+
+	ret = set_list(&head, true, &index);
+	ASSERT_EQ(ret, -1);
+	ASSERT_EQ(errno, ENOSPC);
+
+	/* clear the list */
+	for (i = 0; i < list_limit; i++)
+		modify_list(NULL, i);
+}
+
 /*
  * Test get_robust_list with pid = 0, getting the list of the running thread
  */
@@ -388,12 +520,12 @@ static int child_fn_lock_with_error(void *arg)
 	struct __test_metadata *_metadata = cargs->_metadata;
 	struct lock_struct *lock = cargs->arg;
 	struct robust_list_head head;
-	int ret;
+	int ret, index;
 
 	free(cargs);
 
-	ret = set_list(&head);
-	ASSERT_EQ(ret, 0)
+	ret = set_list(&head, lock->robust2, &index);
+	ASSERT_NE(ret, -1)
 		TH_LOG("set_robust_list error");
 
 	ret = mutex_lock(lock, &head, true);
@@ -413,15 +545,17 @@ static int child_fn_lock_with_error(void *arg)
  * earlier, just after setting list_op_pending and taking the lock, to test the
  * list_op_pending mechanism
  */
-TEST(test_set_list_op_pending)
+TEST_F(robust_api, test_set_list_op_pending)
 {
 	struct lock_struct lock = { .futex = 0 };
 	atomic_futex_t *futex = &lock.futex;
 	struct robust_list_head head;
-	int ret, wstatus;
+	int ret, wstatus, index;
 
-	ret = set_list(&head);
-	ASSERT_EQ(ret, 0);
+	lock.robust2 = variant->robust2;
+
+	ret = set_list(&head, lock.robust2, &index);
+	ASSERT_NE(ret, -1);
 
 	ret = pthread_barrier_init(&barrier, NULL, 2);
 	ASSERT_EQ(ret, 0);
@@ -450,11 +584,11 @@ static int child_lock_holder(void *arg)
 	struct child_args *cargs = arg;
 	struct lock_struct *locks = cargs->arg;
 	struct robust_list_head head;
-	int i;
+	int i, index;
 
 	free(cargs);
 
-	set_list(&head);
+	set_list(&head, locks[0].robust2, &index);
 
 	for (i = 0; i < CHILD_NR; i++) {
 		locks[i].futex = 0;
@@ -495,17 +629,23 @@ static int child_wait_lock(void *arg)
  * Test a robust list of more than one element. All the waiters should wake when
  * the holder dies
  */
-TEST(test_robust_list_multiple_elements)
+TEST_F(robust_api, test_robust_list_multiple_elements)
 {
 	struct lock_struct locks[CHILD_NR];
 	pid_t pids[CHILD_NR + 1];
 	int i, ret, wstatus;
 
+	if (variant->robust2 && !robust_list2_support())
+		SKIP(return, "robust_list2 not supported\n");
+
+	locks[0].robust2 = variant->robust2;
+
 	ret = pthread_barrier_init(&barrier, NULL, 2);
 	ASSERT_EQ(ret, 0);
 	ret = pthread_barrier_init(&barrier2, NULL, CHILD_NR + 1);
 	ASSERT_EQ(ret, 0);
 
+
 	pids[0] = create_child(_metadata, &child_lock_holder, &locks);
 	ASSERT_NE(pids[0], -1);
 
@@ -532,18 +672,112 @@ TEST(test_robust_list_multiple_elements)
 		TH_LOG("One or more children failed");
 }
 
+static int child_lock_holder_multiple_lists(void *arg)
+{
+	struct child_args *cargs = arg;
+	struct __test_metadata *_metadata = cargs->_metadata;
+	struct lock_struct *locks = cargs->arg;
+	struct robust_list_head *heads;
+	int i, list_limit, index, ret;
+
+	free(cargs);
+
+	list_limit = robust_list2_get_list_limit();
+	ASSERT_GT(list_limit, 1);
+
+	heads = malloc(list_limit * sizeof(*heads));
+	ASSERT_TRUE((uintptr_t) heads);
+
+	/*
+	 * Try to clear any exiting list, ignore errors if they didn't exit
+	 */
+	for (i = 0; i < list_limit; i++)
+		modify_list(NULL, i);
+
+	/*
+	 * Given that this thread has no robust list attached yet, it should
+	 * get as return all available lists in order [0, list_limit)
+	 */
+	for (i = 0; i < list_limit; i++) {
+		ret = set_list(&heads[i], true, &index);
+		ASSERT_EQ(ret, i);
+		locks[i].futex = 0;
+		mutex_lock(&locks[i], &heads[i], false);
+	}
+
+	pthread_barrier_wait(&barrier);
+	pthread_barrier_wait(&barrier2);
+
+	/* See comment at child_fn_lock() */
+	usleep(SLEEP_US * 10);
+
+	return 0;
+}
+
+/*
+ * Similar to test_robust_list_multiple_elements, but instead of one list with
+ * several elements, create several lists with one element.
+ */
+TEST(test_robust_list_multiple_lists)
+{
+	int i, ret, wstatus, list_limit;
+	struct lock_struct *locks;
+	pid_t *pids;
+
+	if (!robust_list2_support())
+		SKIP(return, "robust_list2 not supported\n");
+
+	list_limit = robust_list2_get_list_limit();
+	ASSERT_GT(list_limit, 1);
+
+	locks = malloc(list_limit * sizeof(*locks));
+	ASSERT_NE(locks, NULL);
+
+	pids = malloc(list_limit * sizeof(*pids));
+	ASSERT_NE(pids, NULL);
+
+	ret = pthread_barrier_init(&barrier, NULL, 2);
+	ASSERT_EQ(ret, 0);
+	ret = pthread_barrier_init(&barrier2, NULL, list_limit + 1);
+	ASSERT_EQ(ret, 0);
+
+	pids[0] = create_child(_metadata, &child_lock_holder_multiple_lists, locks);
+
+	/* Wait until the locker thread takes the look */
+	pthread_barrier_wait(&barrier);
+
+	for (i = 0; i < list_limit; i++)
+		pids[i+1] = create_child(_metadata, &child_wait_lock, &locks[i]);
+
+	/* Wait for all children to return */
+	ret = 0;
+
+	for (i = 0; i < list_limit; i++) {
+		waitpid(pids[i], &wstatus, 0);
+		if (WEXITSTATUS(wstatus))
+			ret = -1;
+	}
+
+	pthread_barrier_destroy(&barrier);
+	pthread_barrier_destroy(&barrier2);
+
+	free(locks);
+	free(pids);
+}
+
 static int child_circular_list(void *arg)
 {
 	struct child_args *cargs = arg;
+	bool robust2 = cargs->arg;
 	struct __test_metadata *_metadata = cargs->_metadata;
 	static struct lock_struct a, b, c;
 	struct robust_list_head head;
-	int ret;
+	int ret, index;
 
 	free(cargs);
 
-	ret = set_list(&head);
-	ASSERT_EQ(ret, 0)
+	ret = set_list(&head, robust2, &index);
+	ASSERT_NE(ret, -1)
 		TH_LOG("set_list error");
 
 	head.list.next = &a.list;
@@ -563,11 +797,13 @@ static int child_circular_list(void *arg)
  * while processing it so it won't be trapped in an infinite loop while handling
  * a process exit
  */
-TEST(test_circular_list)
+TEST_F(robust_api, test_circular_list)
 {
+	bool robust2 = variant->robust2;
 	int wstatus;
 	pid_t pid;
 
+	create_child(_metadata, child_circular_list, (void *) robust2);
 	pid = create_child(_metadata, child_circular_list, NULL);
 	ASSERT_NE(pid, -1);
 
@@ -660,8 +896,8 @@ TEST_F(vdso_unlock, test_robust_try_unlock_uncontended)
 
 	*futex = tid;
 
-	ret = set_list(&head);
-	if (ret)
+	ret = set_list(&head, false, NULL);
+	if (ret == -1)
 		ksft_test_result_fail("set_robust_list error\n");
 
 	head.list_op_pending = &lock.list;
@@ -700,8 +936,8 @@ TEST_F(vdso_unlock, test_robust_try_unlock_contended)
 
 	*futex = tid | FUTEX_WAITERS;
 
-	ret = set_list(&head);
-	if (ret)
+	ret = set_list(&head, false, NULL);
+	if (ret == -1)
 		ksft_test_result_fail("set_robust_list error\n");
 
 	head.list_op_pending = &lock.list;
@@ -783,8 +1019,8 @@ TEST_F(futex_op, test_futex_robust_unlock)
 
 	*futex = tid | FUTEX_WAITERS;
 
-	ret = set_list(&head);
-	if (ret)
+	ret = set_list(&head, false, 0);
+	if (ret == -1)
 		ksft_test_result_fail("set_robust_list error\n");
 
 	head.list_op_pending = &lock.list;
@@ -806,4 +1042,143 @@ TEST_F(futex_op, test_futex_robust_unlock)
 	ASSERT_EQ((uintptr_t)(unsigned long)head.list_op_pending, exp);
 }
 
+/*
+ * 32-bit version of child_lock_holder.
+ */
+static int child_lock_holder32(void *arg)
+{
+	struct child_args *cargs = arg;
+	struct lock_struct32 *locks = cargs->arg;
+	struct __test_metadata *_metadata = cargs->_metadata;
+	struct robust_list_head32 *head;
+	pid_t tid = gettid();
+	int i, ret;
+
+	head = mmap((void *)0x10000, sizeof(*head), PROT_READ | PROT_WRITE,
+		    MAP_FIXED_NOREPLACE | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+	ASSERT_TRUE((uintptr_t) head);
+	ASSERT_LT(((uint32_t)(uintptr_t) head), 0x7FFFFFFF);
+
+	head->futex_offset = (uint32_t) ((size_t) offsetof(struct lock_struct32, futex) -
+			     (size_t) offsetof(struct lock_struct32, list));
+	head->list.next = (uint32_t)(uintptr_t) &head->list;
+	head->list_op_pending = (uint32_t)(uintptr_t) NULL;
+
+	ret = set_robust_list2((struct robust_list_head *) head, 0,
+				FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY |
+				FUTEX_ROBUST_LIST2_FLAG_32BIT_ENTRY);
+	ASSERT_GE(ret, 0);
+
+	/*
+	 * Take all the locks and insert them in the list
+	 */
+	for (i = 0; i < CHILD_NR; i++) {
+		struct robust_list32 *list = &head->list;
+
+		locks[i].futex = tid;
+
+		while (list->next != (uint32_t)(uintptr_t) &head->list)
+			list = (struct robust_list32 *)(uintptr_t) list->next;
+
+		list->next = (uint32_t)(uintptr_t) &locks[i].list;
+		locks[i].list.next = (uint32_t)(uintptr_t) &head->list;
+	}
+
+	pthread_barrier_wait(&barrier);
+	pthread_barrier_wait(&barrier2);
+
+	/* See comment at child_fn_lock() */
+	usleep(SLEEP_US);
+
+	/* Exit holding all the locks */
+	return 0;
+}
+
+static int child_wait_lock32(void *arg)
+{
+	struct child_args *cargs = arg;
+	struct __test_metadata *_metadata = cargs->_metadata;
+	struct lock_struct32 *lock = cargs->arg;
+	atomic_futex_t *futex;
+	struct timespec to;
+	pid_t tid;
+	int ret;
+
+	futex = &lock->futex;
+
+	pthread_barrier_wait(&barrier2);
+
+	to.tv_sec = FUTEX_TIMEOUT;
+	to.tv_nsec = 0;
+
+	tid = atomic_load(futex);
+
+	/* Kernel ignores futexes without the waiters flag */
+	tid |= FUTEX_WAITERS;
+	atomic_store(futex, tid);
+
+	ret = futex_wait((futex_t *) futex, tid, &to, 0);
+
+	ASSERT_EQ(ret, 0);
+	ASSERT_TRUE(lock->futex & FUTEX_OWNER_DIED);
+
+	return 0;
+}
+
+/*
+ * Test to create a 32-bit robust list in a 64-bit kernel. Replicate
+ * test_robust_list_multiple_elements, but it's simplified: don't do all the
+ * mutex lock dance, just insert futexes in the list and check if the kernel
+ * correctly walks the list and wake the threads
+ */
+TEST(test_32bit_lists)
+{
+	struct lock_struct32 *locks;
+	pid_t pids[CHILD_NR + 1];
+	int i, ret, wstatus;
+
+#ifndef BUILD_64
+	SKIP(return, "Test only for 64-bit\n");
+#endif
+
+	if (!robust_list2_support())
+		SKIP(return, "robust_list2 not supported\n");
+
+	locks = mmap((void *)0x20000, sizeof(*locks) * CHILD_NR,
+		     PROT_READ | PROT_WRITE,
+		     MAP_FIXED_NOREPLACE | MAP_PRIVATE | MAP_ANONYMOUS,
+		     -1, 0);
+
+	ASSERT_NE(locks, NULL);
+	ASSERT_LT((uintptr_t) locks, 0x7FFFFFFF);
+
+	ret = pthread_barrier_init(&barrier, NULL, 2);
+	ASSERT_EQ(ret, 0);
+	ret = pthread_barrier_init(&barrier2, NULL, CHILD_NR + 1);
+	ASSERT_EQ(ret, 0);
+
+	pids[0] = create_child(_metadata, &child_lock_holder32, locks);
+
+	/* Wait until the locker thread takes the look */
+	pthread_barrier_wait(&barrier);
+
+	for (i = 0; i < CHILD_NR; i++)
+		pids[i+1] = create_child(_metadata, &child_wait_lock32, &locks[i]);
+
+	/* Wait for all children to return */
+	ret = 0;
+
+	for (i = 0; i < CHILD_NR; i++) {
+		waitpid(pids[i], &wstatus, 0);
+		if (WEXITSTATUS(wstatus))
+			ret = -1;
+	}
+
+	pthread_barrier_destroy(&barrier);
+	pthread_barrier_destroy(&barrier2);
+
+	munmap(locks, sizeof(*locks) * CHILD_NR);
+}
+
 TEST_HARNESS_MAIN

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v9 14/14] selftests/futex: Expand for get_robust_list2()
  2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
                   ` (12 preceding siblings ...)
  2026-12-04 16:15 ` [PATCH v9 13/14] selftests/futex: Expand for set_robust_list2() André Almeida
@ 2026-12-04 16:15 ` André Almeida
  13 siblings, 0 replies; 20+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

Reuse the same selftest for the original set_robust_list() syscall for
the new set_robust_list2() syscall. Use kselftest variants feature to
run the relevant tests for both interfaces. Create a new test case to
get different lists from the same task.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 .../selftests/futex/functional/robust_list.c       | 157 ++++++++++++++++++---
 1 file changed, 136 insertions(+), 21 deletions(-)

diff --git a/tools/testing/selftests/futex/functional/robust_list.c b/tools/testing/selftests/futex/functional/robust_list.c
index 8723f8a3606c..143e36473539 100644
--- a/tools/testing/selftests/futex/functional/robust_list.c
+++ b/tools/testing/selftests/futex/functional/robust_list.c
@@ -51,6 +51,7 @@
 
 #ifndef SYS_set_robust_list2
 # define SYS_set_robust_list2 473
+# define SYS_get_robust_list2 474
 
 #define FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY	0x1
 #define FUTEX_ROBUST_LIST2_FLAG_32BIT_ENTRY	0x2
@@ -109,6 +110,12 @@ static int robust_list2_get_list_limit(void)
 	return limit;
 }
 
+static int get_robust_list2(int pid, struct robust_list_head **head,
+			    unsigned int index, unsigned int flags)
+{
+	return syscall(SYS_get_robust_list2, pid, head, index, flags);
+}
+
 static bool robust_list2_support(void)
 {
 	if (robust_list2_get_list_limit() == -1)
@@ -230,6 +237,23 @@ static int modify_list(struct robust_list_head *head, int index)
 	return set_robust_list2(head, index, 0);
 }
 
+static int get_list(pid_t pid, struct robust_list_head **head, bool robust2, int index)
+{
+	int ret;
+
+	if (!robust2) {
+		size_t len_ptr;
+
+		ret = get_robust_list(pid, head, &len_ptr);
+		if (sizeof(**head) != len_ptr)
+			return -EINVAL;
+
+		return ret;
+	}
+
+	return get_robust_list2(pid, head, index, 0);
+}
+
 /*
  * A basic (and incomplete) mutex lock function with robustness
  */
@@ -431,40 +455,45 @@ TEST(test_set_robust_list2_inval)
 /*
  * Test get_robust_list with pid = 0, getting the list of the running thread
  */
-TEST(test_get_robust_list_self)
+TEST_F(robust_api, test_get_robust_list_self)
 {
 	struct robust_list_head head, head2, *get_head;
-	size_t head_size = sizeof(head), len_ptr;
-	int ret;
+	bool robust2 = variant->robust2;
+	int ret, index = 0;
 
-	ret = set_robust_list(&head, head_size);
-	ASSERT_EQ(ret, 0);
+	ret = set_list(&head, robust2, 0);
+	ASSERT_GE(ret, 0);
 
-	ret = get_robust_list(0, &get_head, &len_ptr);
+	ret = get_list(0, &get_head, robust2, 0);
 	ASSERT_EQ(ret, 0);
 	ASSERT_EQ(get_head, &head);
-	ASSERT_EQ(head_size, len_ptr);
 
-	ret = set_robust_list(&head2, head_size);
-	ASSERT_EQ(ret, 0);
+	ret = set_list(&head2, robust2, &index);
+	ASSERT_GE(ret, 0);
 
-	ret = get_robust_list(0, &get_head, &len_ptr);
+	ret = get_list(0, &get_head, robust2, index);
 	ASSERT_EQ(ret, 0);
 	ASSERT_EQ(get_head, &head2);
-	ASSERT_EQ(head_size, len_ptr);
 }
 
+struct child_arg_struct {
+	struct robust_list_head *head;
+	bool robust2;
+};
+
 static int child_list(void *arg)
 {
 	struct child_args *cargs = arg;
 	struct __test_metadata *_metadata = cargs->_metadata;
-	struct robust_list_head *head = cargs->arg;
+	struct child_arg_struct *child_arg = (struct child_arg_struct *) cargs->arg;
+	struct robust_list_head *head = child_arg->head;
+	bool robust2 = child_arg->robust2;
 	int ret;
 
 	free(cargs);
 
-	ret = set_robust_list(head, sizeof(*head));
-	ASSERT_EQ(ret, 0)
+	ret = set_list(head, robust2, 0);
+	ASSERT_GE(ret, 0)
 		TH_LOG("set_robust_list error");
 
 	/*
@@ -484,23 +513,25 @@ static int child_list(void *arg)
  * parent
  *   2) the child thread still alive when we try to get the list from it
  */
-TEST(test_get_robust_list_child)
+TEST_F(robust_api, test_get_robust_list_child)
 {
 	struct robust_list_head head, *get_head;
+	bool robust2 = variant->robust2;
+	struct child_arg_struct child = {.robust2 = robust2, .head = &head};
 	int ret, wstatus;
-	size_t len_ptr;
 	pid_t tid;
 
+
 	ret = pthread_barrier_init(&barrier, NULL, 2);
 	ret = pthread_barrier_init(&barrier2, NULL, 2);
 	ASSERT_EQ(ret, 0);
 
-	tid = create_child(_metadata, &child_list, &head);
+	tid = create_child(_metadata, &child_list, &child);
 	ASSERT_NE(tid, -1);
 
 	pthread_barrier_wait(&barrier);
 
-	ret = get_robust_list(tid, &get_head, &len_ptr);
+	ret = get_list(tid, &get_head, robust2, 0);
 	ASSERT_EQ(ret, 0);
 	ASSERT_EQ(&head, get_head);
 
@@ -1050,9 +1081,9 @@ static int child_lock_holder32(void *arg)
 	struct child_args *cargs = arg;
 	struct lock_struct32 *locks = cargs->arg;
 	struct __test_metadata *_metadata = cargs->_metadata;
-	struct robust_list_head32 *head;
+	struct robust_list_head32 *head, *head_ptr;
 	pid_t tid = gettid();
-	int i, ret;
+	int i, ret, index;
 
 	head = mmap((void *)0x10000, sizeof(*head), PROT_READ | PROT_WRITE,
 		    MAP_FIXED_NOREPLACE | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
@@ -1065,10 +1096,15 @@ static int child_lock_holder32(void *arg)
 	head->list.next = (uint32_t)(uintptr_t) &head->list;
 	head->list_op_pending = (uint32_t)(uintptr_t) NULL;
 
-	ret = set_robust_list2((struct robust_list_head *) head, 0,
+	index = set_robust_list2((struct robust_list_head *) head, 0,
 				FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY |
 				FUTEX_ROBUST_LIST2_FLAG_32BIT_ENTRY);
+	ASSERT_GE(index, 0);
+
+	/* Test get list */
+	ret = get_robust_list2(0, (struct robust_list_head **)&head_ptr, index, 0);
 	ASSERT_GE(ret, 0);
+	ASSERT_EQ(head, head_ptr);
 
 	/*
 	 * Take all the locks and insert them in the list
@@ -1181,4 +1217,83 @@ TEST(test_32bit_lists)
 	munmap(locks, sizeof(*locks) * CHILD_NR);
 }
 
+/*
+ * Test setting and getting multiple head lists
+ */
+TEST(set_and_get_robust2)
+{
+	struct robust_list_head *head = NULL, *heads;
+	int list_limit, ret, *index, i, j;
+
+	if (!robust_list2_support()) {
+		SKIP(return, "robust_list2 not supported\n");
+		return;
+	}
+
+	list_limit = robust_list2_get_list_limit();
+	ASSERT_GT(list_limit, 1);
+
+	heads = malloc(list_limit * sizeof(*heads));
+	ASSERT_NE(heads, NULL);
+
+	index = malloc(list_limit * sizeof(*index));
+	ASSERT_NE(index, NULL);
+
+	/*
+	 * Insert various elements into the lists
+	 */
+	for (i = 0; i < list_limit; i++) {
+		ret = set_list(&heads[i], true, &index[i]);
+		ASSERT_GE(ret, 0);
+		ASSERT_EQ(i, index[i]);
+	}
+
+	for (i = 0; i < list_limit; i++) {
+		ret = get_list(0, &head, true, index[i]);
+		ASSERT_EQ(ret, 0);
+		ASSERT_EQ(head, &heads[i]);
+	}
+
+	/*
+	 * Modify the list, adding the elements in the other ordering
+	 */
+	for (i = 0, j = list_limit; i < list_limit; i++, j--) {
+		ret = modify_list(&heads[j], index[i]);
+		ASSERT_EQ(ret, index[i]);
+	}
+
+	for (i = 0, j = list_limit; i < list_limit; i++, j--) {
+		ret = get_list(0, &head, true, index[i]);
+		ASSERT_EQ(ret, 0);
+		ASSERT_EQ(head, &heads[j]);
+	}
+
+	/*
+	 * Delete all elements
+	 */
+	for (i = 0; i < list_limit; i++) {
+		ret = modify_list(NULL, index[i]);
+		ASSERT_EQ(ret, index[i]);
+	}
+
+	for (i = 0; i < list_limit; i++) {
+		ret = get_list(0, &head, true, index[i]);
+		ASSERT_EQ(ret, 0);
+		ASSERT_EQ(head, NULL);
+	}
+
+	/*
+	 * Recreate the list. It should support the same number of elements as
+	 * before, given that we just cleared the list.
+	 */
+	for (i = 0; i < list_limit; i++) {
+		ret = set_list(&heads[i], true, &index[i]);
+		ASSERT_EQ(ret, index[i]);
+		ASSERT_EQ(i, index[i]);
+	}
+
+	free(heads);
+	free(index);
+}
+
 TEST_HARNESS_MAIN

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list
  2026-12-04 16:15 ` [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list André Almeida
@ 2026-12-05  9:55   ` kernel test robot
  0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2026-12-05  9:55 UTC (permalink / raw)
  To: André Almeida, Ingo Molnar, Peter Zijlstra, Darren Hart,
	Davidlohr Bueso, Arnd Bergmann, Sebastian Andrzej Siewior,
	Waiman Long, Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: oe-kbuild-all, linux-kernel, linux-kselftest, linux-api,
	kernel-dev, libc-coord, André Almeida

Hi André,

kernel test robot noticed the following build errors:

[auto build test ERROR on 39cc4e512ebcd2a6d106d710285040a4e43c2dd9]

url:    https://github.com/intel-lab-lkp/linux/commits/Andr-Almeida/futex-Use-explicit-sizes-for-compat_robust_list-structs/20261204-131517
base:   39cc4e512ebcd2a6d106d710285040a4e43c2dd9
patch link:    https://lore.kernel.org/r/20261204-tonyk-robust_futex-v9-5-743d68d488b5%40igalia.com
patch subject: [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list
config: openrisc-defconfig (https://download.01.org/0day-ci/archive/20261205/20261205041736.L8DSYdGV-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 16.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261205/20261205041736.L8DSYdGV-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261205041736.L8DSYdGV-lkp@intel.com/

All errors (new ones prefixed by >>):

   kernel/futex/core.c: In function 'exit_robust_lists':
>> kernel/futex/core.c:1500:25: error: implicit declaration of function 'exit_robust_list32'; did you mean 'exit_robust_lists'? [-Wimplicit-function-declaration]
    1500 |                         exit_robust_list32(tsk, head);
         |                         ^~~~~~~~~~~~~~~~~~
         |                         exit_robust_lists


vim +1500 kernel/futex/core.c

  1479	
  1480	static void exit_robust_lists(struct task_struct *tsk)
  1481	{
  1482		uintptr_t *rl = tsk->futex.robust_lists;
  1483		unsigned int idx;
  1484	
  1485		if (!rl)
  1486			return;
  1487	
  1488		tsk->futex.robust_lists = NULL;
  1489	
  1490		for (idx = 0; idx < FUTEX_ROBUST_LIST2_MAX_IDX; idx++) {
  1491			uintptr_t entry = rl[idx] & FUTEX_ROBUST_LIST2_ENTRY_MASK;
  1492	
  1493			if (!entry)
  1494				continue;
  1495	
  1496			if (IS_ENABLED(CONFIG_64BIT) && (rl[idx] & FUTEX_ROBUST_LIST2_ENTRY_32BIT)) {
  1497				struct robust_list_head32 __user *head;
  1498	
  1499				head = (__force struct robust_list_head32 __user *)entry;
> 1500				exit_robust_list32(tsk, head);
  1501			} else {
  1502				struct robust_list_head __user *head;
  1503	
  1504				head = (__force struct robust_list_head __user *)entry;
  1505				exit_robust_list(tsk, head);
  1506			}
  1507		}
  1508	
  1509		kfree(rl);
  1510	}
  1511	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v9 11/14] futex: Wire up set_robust_list2 syscall
  2026-12-04 16:15 ` [PATCH v9 11/14] futex: Wire up set_robust_list2 syscall André Almeida
@ 2026-12-05  9:55   ` kernel test robot
  2026-12-05  9:55   ` kernel test robot
  1 sibling, 0 replies; 20+ messages in thread
From: kernel test robot @ 2026-12-05  9:55 UTC (permalink / raw)
  To: André Almeida, Ingo Molnar, Peter Zijlstra, Darren Hart,
	Davidlohr Bueso, Arnd Bergmann, Sebastian Andrzej Siewior,
	Waiman Long, Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: oe-kbuild-all, linux-kernel, linux-kselftest, linux-api,
	kernel-dev, libc-coord, André Almeida

Hi André,

kernel test robot noticed the following build errors:

[auto build test ERROR on 39cc4e512ebcd2a6d106d710285040a4e43c2dd9]

url:    https://github.com/intel-lab-lkp/linux/commits/Andr-Almeida/futex-Use-explicit-sizes-for-compat_robust_list-structs/20261204-131517
base:   39cc4e512ebcd2a6d106d710285040a4e43c2dd9
patch link:    https://lore.kernel.org/r/20261204-tonyk-robust_futex-v9-11-743d68d488b5%40igalia.com
patch subject: [PATCH v9 11/14] futex: Wire up set_robust_list2 syscall
config: nios2-allnoconfig (https://download.01.org/0day-ci/archive/20261205/20261205043229.GW1ixpGT-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 11.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261205/20261205043229.GW1ixpGT-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261205043229.GW1ixpGT-lkp@intel.com/

All errors (new ones prefixed by >>):

         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:465:1: note: in expansion of macro '__SYSCALL'
     465 | __SYSCALL(464, sys_getxattrat)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: warning: initialized field overwritten [-Woverride-init]
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:466:1: note: in expansion of macro '__SYSCALL'
     466 | __SYSCALL(465, sys_listxattrat)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: note: (near initialization for 'sys_call_table[465]')
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:466:1: note: in expansion of macro '__SYSCALL'
     466 | __SYSCALL(465, sys_listxattrat)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: warning: initialized field overwritten [-Woverride-init]
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:467:1: note: in expansion of macro '__SYSCALL'
     467 | __SYSCALL(466, sys_removexattrat)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: note: (near initialization for 'sys_call_table[466]')
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:467:1: note: in expansion of macro '__SYSCALL'
     467 | __SYSCALL(466, sys_removexattrat)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: warning: initialized field overwritten [-Woverride-init]
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:468:1: note: in expansion of macro '__SYSCALL'
     468 | __SYSCALL(467, sys_open_tree_attr)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: note: (near initialization for 'sys_call_table[467]')
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:468:1: note: in expansion of macro '__SYSCALL'
     468 | __SYSCALL(467, sys_open_tree_attr)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: warning: initialized field overwritten [-Woverride-init]
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:469:1: note: in expansion of macro '__SYSCALL'
     469 | __SYSCALL(468, sys_file_getattr)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: note: (near initialization for 'sys_call_table[468]')
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:469:1: note: in expansion of macro '__SYSCALL'
     469 | __SYSCALL(468, sys_file_getattr)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: warning: initialized field overwritten [-Woverride-init]
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:470:1: note: in expansion of macro '__SYSCALL'
     470 | __SYSCALL(469, sys_file_setattr)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: note: (near initialization for 'sys_call_table[469]')
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:470:1: note: in expansion of macro '__SYSCALL'
     470 | __SYSCALL(469, sys_file_setattr)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: warning: initialized field overwritten [-Woverride-init]
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:471:1: note: in expansion of macro '__SYSCALL'
     471 | __SYSCALL(470, sys_listns)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: note: (near initialization for 'sys_call_table[470]')
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:471:1: note: in expansion of macro '__SYSCALL'
     471 | __SYSCALL(470, sys_listns)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: warning: initialized field overwritten [-Woverride-init]
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:472:1: note: in expansion of macro '__SYSCALL'
     472 | __SYSCALL(471, sys_rseq_slice_yield)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: note: (near initialization for 'sys_call_table[471]')
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:472:1: note: in expansion of macro '__SYSCALL'
     472 | __SYSCALL(471, sys_rseq_slice_yield)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: warning: initialized field overwritten [-Woverride-init]
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:473:1: note: in expansion of macro '__SYSCALL'
     473 | __SYSCALL(472, sys_fchroot)
         | ^~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:36: note: (near initialization for 'sys_call_table[472]')
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                    ^
   ./arch/nios2/include/generated/asm/syscall_table_32.h:473:1: note: in expansion of macro '__SYSCALL'
     473 | __SYSCALL(472, sys_fchroot)
         | ^~~~~~~~~
>> ./arch/nios2/include/generated/asm/syscall_table_32.h:474:16: error: 'sys_set_robust_list2' undeclared here (not in a function); did you mean 'sys_set_robust_list'?
     474 | __SYSCALL(473, sys_set_robust_list2)
         |                ^~~~~~~~~~~~~~~~~~~~
   arch/nios2/kernel/syscall_table.c:12:37: note: in definition of macro '__SYSCALL'
      12 | #define __SYSCALL(nr, call) [nr] = (call),
         |                                     ^~~~

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v9 11/14] futex: Wire up set_robust_list2 syscall
  2026-12-04 16:15 ` [PATCH v9 11/14] futex: Wire up set_robust_list2 syscall André Almeida
  2026-12-05  9:55   ` kernel test robot
@ 2026-12-05  9:55   ` kernel test robot
  1 sibling, 0 replies; 20+ messages in thread
From: kernel test robot @ 2026-12-05  9:55 UTC (permalink / raw)
  To: André Almeida, Ingo Molnar, Peter Zijlstra, Darren Hart,
	Davidlohr Bueso, Arnd Bergmann, Sebastian Andrzej Siewior,
	Waiman Long, Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: oe-kbuild-all, linux-kernel, linux-kselftest, linux-api,
	kernel-dev, libc-coord, André Almeida

Hi André,

kernel test robot noticed the following build errors:

[auto build test ERROR on 39cc4e512ebcd2a6d106d710285040a4e43c2dd9]

url:    https://github.com/intel-lab-lkp/linux/commits/Andr-Almeida/futex-Use-explicit-sizes-for-compat_robust_list-structs/20261204-131517
base:   39cc4e512ebcd2a6d106d710285040a4e43c2dd9
patch link:    https://lore.kernel.org/r/20261204-tonyk-robust_futex-v9-11-743d68d488b5%40igalia.com
patch subject: [PATCH v9 11/14] futex: Wire up set_robust_list2 syscall
config: csky-defconfig (https://download.01.org/0day-ci/archive/20261205/20261205043715.eAGw5noN-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 16.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261205/20261205043715.eAGw5noN-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261205043715.eAGw5noN-lkp@intel.com/

All errors (new ones prefixed by >>):

   arch/csky/kernel/syscall_table.c:8:35: warning: initialized field overwritten [-Woverride-init]
       8 | #define __SYSCALL(nr, call)[nr] = (call),
         |                                   ^
   ./arch/csky/include/generated/asm/syscall_table_32.h:464:1: note: in expansion of macro '__SYSCALL'
     464 | __SYSCALL(463, sys_setxattrat)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: note: (near initialization for 'sys_call_table[463]')
   ./arch/csky/include/generated/asm/syscall_table_32.h:464:1: note: in expansion of macro '__SYSCALL'
     464 | __SYSCALL(463, sys_setxattrat)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: warning: initialized field overwritten [-Woverride-init]
       8 | #define __SYSCALL(nr, call)[nr] = (call),
         |                                   ^
   ./arch/csky/include/generated/asm/syscall_table_32.h:465:1: note: in expansion of macro '__SYSCALL'
     465 | __SYSCALL(464, sys_getxattrat)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: note: (near initialization for 'sys_call_table[464]')
   ./arch/csky/include/generated/asm/syscall_table_32.h:465:1: note: in expansion of macro '__SYSCALL'
     465 | __SYSCALL(464, sys_getxattrat)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: warning: initialized field overwritten [-Woverride-init]
       8 | #define __SYSCALL(nr, call)[nr] = (call),
         |                                   ^
   ./arch/csky/include/generated/asm/syscall_table_32.h:466:1: note: in expansion of macro '__SYSCALL'
     466 | __SYSCALL(465, sys_listxattrat)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: note: (near initialization for 'sys_call_table[465]')
   ./arch/csky/include/generated/asm/syscall_table_32.h:466:1: note: in expansion of macro '__SYSCALL'
     466 | __SYSCALL(465, sys_listxattrat)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: warning: initialized field overwritten [-Woverride-init]
       8 | #define __SYSCALL(nr, call)[nr] = (call),
         |                                   ^
   ./arch/csky/include/generated/asm/syscall_table_32.h:467:1: note: in expansion of macro '__SYSCALL'
     467 | __SYSCALL(466, sys_removexattrat)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: note: (near initialization for 'sys_call_table[466]')
   ./arch/csky/include/generated/asm/syscall_table_32.h:467:1: note: in expansion of macro '__SYSCALL'
     467 | __SYSCALL(466, sys_removexattrat)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: warning: initialized field overwritten [-Woverride-init]
       8 | #define __SYSCALL(nr, call)[nr] = (call),
         |                                   ^
   ./arch/csky/include/generated/asm/syscall_table_32.h:468:1: note: in expansion of macro '__SYSCALL'
     468 | __SYSCALL(467, sys_open_tree_attr)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: note: (near initialization for 'sys_call_table[467]')
   ./arch/csky/include/generated/asm/syscall_table_32.h:468:1: note: in expansion of macro '__SYSCALL'
     468 | __SYSCALL(467, sys_open_tree_attr)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: warning: initialized field overwritten [-Woverride-init]
       8 | #define __SYSCALL(nr, call)[nr] = (call),
         |                                   ^
   ./arch/csky/include/generated/asm/syscall_table_32.h:469:1: note: in expansion of macro '__SYSCALL'
     469 | __SYSCALL(468, sys_file_getattr)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: note: (near initialization for 'sys_call_table[468]')
   ./arch/csky/include/generated/asm/syscall_table_32.h:469:1: note: in expansion of macro '__SYSCALL'
     469 | __SYSCALL(468, sys_file_getattr)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: warning: initialized field overwritten [-Woverride-init]
       8 | #define __SYSCALL(nr, call)[nr] = (call),
         |                                   ^
   ./arch/csky/include/generated/asm/syscall_table_32.h:470:1: note: in expansion of macro '__SYSCALL'
     470 | __SYSCALL(469, sys_file_setattr)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: note: (near initialization for 'sys_call_table[469]')
   ./arch/csky/include/generated/asm/syscall_table_32.h:470:1: note: in expansion of macro '__SYSCALL'
     470 | __SYSCALL(469, sys_file_setattr)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: warning: initialized field overwritten [-Woverride-init]
       8 | #define __SYSCALL(nr, call)[nr] = (call),
         |                                   ^
   ./arch/csky/include/generated/asm/syscall_table_32.h:471:1: note: in expansion of macro '__SYSCALL'
     471 | __SYSCALL(470, sys_listns)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: note: (near initialization for 'sys_call_table[470]')
   ./arch/csky/include/generated/asm/syscall_table_32.h:471:1: note: in expansion of macro '__SYSCALL'
     471 | __SYSCALL(470, sys_listns)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: warning: initialized field overwritten [-Woverride-init]
       8 | #define __SYSCALL(nr, call)[nr] = (call),
         |                                   ^
   ./arch/csky/include/generated/asm/syscall_table_32.h:472:1: note: in expansion of macro '__SYSCALL'
     472 | __SYSCALL(471, sys_rseq_slice_yield)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: note: (near initialization for 'sys_call_table[471]')
   ./arch/csky/include/generated/asm/syscall_table_32.h:472:1: note: in expansion of macro '__SYSCALL'
     472 | __SYSCALL(471, sys_rseq_slice_yield)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: warning: initialized field overwritten [-Woverride-init]
       8 | #define __SYSCALL(nr, call)[nr] = (call),
         |                                   ^
   ./arch/csky/include/generated/asm/syscall_table_32.h:473:1: note: in expansion of macro '__SYSCALL'
     473 | __SYSCALL(472, sys_fchroot)
         | ^~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:35: note: (near initialization for 'sys_call_table[472]')
   ./arch/csky/include/generated/asm/syscall_table_32.h:473:1: note: in expansion of macro '__SYSCALL'
     473 | __SYSCALL(472, sys_fchroot)
         | ^~~~~~~~~
>> ./arch/csky/include/generated/asm/syscall_table_32.h:474:16: error: 'sys_set_robust_list2' undeclared here (not in a function); did you mean 'sys_set_robust_list'?
     474 | __SYSCALL(473, sys_set_robust_list2)
         |                ^~~~~~~~~~~~~~~~~~~~
   arch/csky/kernel/syscall_table.c:8:36: note: in definition of macro '__SYSCALL'
       8 | #define __SYSCALL(nr, call)[nr] = (call),
         |                                    ^~~~

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list
@ 2026-12-05  9:55 kernel test robot
  0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2026-12-05  9:55 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "same reports for this branch"
:::::: 

BCC: lkp@intel.com
CC: llvm@lists.linux.dev
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20261204-tonyk-robust_futex-v9-5-743d68d488b5@igalia.com>
References: <20261204-tonyk-robust_futex-v9-5-743d68d488b5@igalia.com>
TO: "André Almeida" <andrealmeid@igalia.com>
TO: Ingo Molnar <mingo@redhat.com>
TO: Peter Zijlstra <peterz@infradead.org>
TO: Darren Hart <dvhart@infradead.org>
TO: Davidlohr Bueso <dave@stgolabs.net>
TO: Arnd Bergmann <arnd@arndb.de>
TO: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
TO: Waiman Long <longman@redhat.com>
TO: Ryan Houdek <Sonicadvance1@gmail.com>
TO: Florian Weimer <fweimer@redhat.com>
TO: Thomas Gleixner <tglx@kernel.org>
CC: linux-kernel@vger.kernel.org
CC: linux-kselftest@vger.kernel.org
CC: linux-api@vger.kernel.org
CC: kernel-dev@igalia.com
CC: libc-coord@lists.openwall.com
CC: "André Almeida" <andrealmeid@igalia.com>

Hi André,

kernel test robot noticed the following build errors:

[auto build test ERROR on 39cc4e512ebcd2a6d106d710285040a4e43c2dd9]

url:    https://github.com/intel-lab-lkp/linux/commits/Andr-Almeida/futex-Use-explicit-sizes-for-compat_robust_list-structs/20261204-131517
base:   39cc4e512ebcd2a6d106d710285040a4e43c2dd9
patch link:    https://lore.kernel.org/r/20261204-tonyk-robust_futex-v9-5-743d68d488b5%40igalia.com
patch subject: [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list
:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago
config: hexagon-defconfig (https://download.01.org/0day-ci/archive/20261205/20261205060307.npUP8f8x-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 63b30c97f6082ebf34b31bdd81bb50df7672b67b)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261205/20261205060307.npUP8f8x-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/20261205060307.npUP8f8x-lkp@intel.com/

All errors (new ones prefixed by >>):

>> kernel/futex/core.c:1500:4: error: call to undeclared function 'exit_robust_list32'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    1500 |                         exit_robust_list32(tsk, head);
         |                         ^
   1 error generated.


vim +/exit_robust_list32 +1500 kernel/futex/core.c

7010c39d8fc5063 Thomas Gleixner 2026-06-02  1479  
53323289ae96226 André Almeida   2026-12-04  1480  static void exit_robust_lists(struct task_struct *tsk)
53323289ae96226 André Almeida   2026-12-04  1481  {
53323289ae96226 André Almeida   2026-12-04  1482  	uintptr_t *rl = tsk->futex.robust_lists;
53323289ae96226 André Almeida   2026-12-04  1483  	unsigned int idx;
53323289ae96226 André Almeida   2026-12-04  1484  
53323289ae96226 André Almeida   2026-12-04  1485  	if (!rl)
53323289ae96226 André Almeida   2026-12-04  1486  		return;
53323289ae96226 André Almeida   2026-12-04  1487  
53323289ae96226 André Almeida   2026-12-04  1488  	tsk->futex.robust_lists = NULL;
53323289ae96226 André Almeida   2026-12-04  1489  
53323289ae96226 André Almeida   2026-12-04  1490  	for (idx = 0; idx < FUTEX_ROBUST_LIST2_MAX_IDX; idx++) {
53323289ae96226 André Almeida   2026-12-04  1491  		uintptr_t entry = rl[idx] & FUTEX_ROBUST_LIST2_ENTRY_MASK;
53323289ae96226 André Almeida   2026-12-04  1492  
53323289ae96226 André Almeida   2026-12-04  1493  		if (!entry)
53323289ae96226 André Almeida   2026-12-04  1494  			continue;
53323289ae96226 André Almeida   2026-12-04  1495  
53323289ae96226 André Almeida   2026-12-04  1496  		if (IS_ENABLED(CONFIG_64BIT) && (rl[idx] & FUTEX_ROBUST_LIST2_ENTRY_32BIT)) {
53323289ae96226 André Almeida   2026-12-04  1497  			struct robust_list_head32 __user *head;
53323289ae96226 André Almeida   2026-12-04  1498  
53323289ae96226 André Almeida   2026-12-04  1499  			head = (__force struct robust_list_head32 __user *)entry;
53323289ae96226 André Almeida   2026-12-04 @1500  			exit_robust_list32(tsk, head);
53323289ae96226 André Almeida   2026-12-04  1501  		} else {
53323289ae96226 André Almeida   2026-12-04  1502  			struct robust_list_head __user *head;
53323289ae96226 André Almeida   2026-12-04  1503  
53323289ae96226 André Almeida   2026-12-04  1504  			head = (__force struct robust_list_head __user *)entry;
53323289ae96226 André Almeida   2026-12-04  1505  			exit_robust_list(tsk, head);
53323289ae96226 André Almeida   2026-12-04  1506  		}
53323289ae96226 André Almeida   2026-12-04  1507  	}
53323289ae96226 André Almeida   2026-12-04  1508  
53323289ae96226 André Almeida   2026-12-04  1509  	kfree(rl);
53323289ae96226 André Almeida   2026-12-04  1510  }
53323289ae96226 André Almeida   2026-12-04  1511  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list
@ 2026-12-05  9:55 kernel test robot
  0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2026-12-05  9:55 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "too many reports for this commit"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20261204-tonyk-robust_futex-v9-5-743d68d488b5@igalia.com>
References: <20261204-tonyk-robust_futex-v9-5-743d68d488b5@igalia.com>
TO: "André Almeida" <andrealmeid@igalia.com>
TO: Ingo Molnar <mingo@redhat.com>
TO: Peter Zijlstra <peterz@infradead.org>
TO: Darren Hart <dvhart@infradead.org>
TO: Davidlohr Bueso <dave@stgolabs.net>
TO: Arnd Bergmann <arnd@arndb.de>
TO: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
TO: Waiman Long <longman@redhat.com>
TO: Ryan Houdek <Sonicadvance1@gmail.com>
TO: Florian Weimer <fweimer@redhat.com>
TO: Thomas Gleixner <tglx@kernel.org>
CC: linux-kernel@vger.kernel.org
CC: linux-kselftest@vger.kernel.org
CC: linux-api@vger.kernel.org
CC: kernel-dev@igalia.com
CC: libc-coord@lists.openwall.com
CC: "André Almeida" <andrealmeid@igalia.com>

Hi André,

kernel test robot noticed the following build errors:

[auto build test ERROR on 39cc4e512ebcd2a6d106d710285040a4e43c2dd9]

url:    https://github.com/intel-lab-lkp/linux/commits/Andr-Almeida/futex-Use-explicit-sizes-for-compat_robust_list-structs/20261204-131517
base:   39cc4e512ebcd2a6d106d710285040a4e43c2dd9
patch link:    https://lore.kernel.org/r/20261204-tonyk-robust_futex-v9-5-743d68d488b5%40igalia.com
patch subject: [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list
:::::: branch date: 13 hours ago
:::::: commit date: 13 hours ago
config: m68k-allnoconfig (https://download.01.org/0day-ci/archive/20261205/20261205133947.C1FYsKQx-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 16.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261205/20261205133947.C1FYsKQx-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/20261205133947.C1FYsKQx-lkp@intel.com/

All errors (new ones prefixed by >>):

   kernel/futex/core.c: In function 'exit_robust_lists':
>> kernel/futex/core.c:1500:25: error: implicit declaration of function 'exit_robust_list32'; did you mean 'exit_robust_lists'? [-Wimplicit-function-declaration]
    1500 |                         exit_robust_list32(tsk, head);
         |                         ^~~~~~~~~~~~~~~~~~
         |                         exit_robust_lists


vim +1500 kernel/futex/core.c

7010c39d8fc506 Thomas Gleixner 2026-06-02  1479  
53323289ae9622 André Almeida   2026-12-04  1480  static void exit_robust_lists(struct task_struct *tsk)
53323289ae9622 André Almeida   2026-12-04  1481  {
53323289ae9622 André Almeida   2026-12-04  1482  	uintptr_t *rl = tsk->futex.robust_lists;
53323289ae9622 André Almeida   2026-12-04  1483  	unsigned int idx;
53323289ae9622 André Almeida   2026-12-04  1484  
53323289ae9622 André Almeida   2026-12-04  1485  	if (!rl)
53323289ae9622 André Almeida   2026-12-04  1486  		return;
53323289ae9622 André Almeida   2026-12-04  1487  
53323289ae9622 André Almeida   2026-12-04  1488  	tsk->futex.robust_lists = NULL;
53323289ae9622 André Almeida   2026-12-04  1489  
53323289ae9622 André Almeida   2026-12-04  1490  	for (idx = 0; idx < FUTEX_ROBUST_LIST2_MAX_IDX; idx++) {
53323289ae9622 André Almeida   2026-12-04  1491  		uintptr_t entry = rl[idx] & FUTEX_ROBUST_LIST2_ENTRY_MASK;
53323289ae9622 André Almeida   2026-12-04  1492  
53323289ae9622 André Almeida   2026-12-04  1493  		if (!entry)
53323289ae9622 André Almeida   2026-12-04  1494  			continue;
53323289ae9622 André Almeida   2026-12-04  1495  
53323289ae9622 André Almeida   2026-12-04  1496  		if (IS_ENABLED(CONFIG_64BIT) && (rl[idx] & FUTEX_ROBUST_LIST2_ENTRY_32BIT)) {
53323289ae9622 André Almeida   2026-12-04  1497  			struct robust_list_head32 __user *head;
53323289ae9622 André Almeida   2026-12-04  1498  
53323289ae9622 André Almeida   2026-12-04  1499  			head = (__force struct robust_list_head32 __user *)entry;
53323289ae9622 André Almeida   2026-12-04 @1500  			exit_robust_list32(tsk, head);
53323289ae9622 André Almeida   2026-12-04  1501  		} else {
53323289ae9622 André Almeida   2026-12-04  1502  			struct robust_list_head __user *head;
53323289ae9622 André Almeida   2026-12-04  1503  
53323289ae9622 André Almeida   2026-12-04  1504  			head = (__force struct robust_list_head __user *)entry;
53323289ae9622 André Almeida   2026-12-04  1505  			exit_robust_list(tsk, head);
53323289ae9622 André Almeida   2026-12-04  1506  		}
53323289ae9622 André Almeida   2026-12-04  1507  	}
53323289ae9622 André Almeida   2026-12-04  1508  
53323289ae9622 André Almeida   2026-12-04  1509  	kfree(rl);
53323289ae9622 André Almeida   2026-12-04  1510  }
53323289ae9622 André Almeida   2026-12-04  1511  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-12-05  9:56 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
2026-12-04 16:15 ` [PATCH v9 01/14] futex: Use explicit sizes for compat_robust_list structs André Almeida
2026-12-04 16:15 ` [PATCH v9 02/14] futex: Make exit_robust_list32() unconditionally available for 64-bit kernels André Almeida
2026-12-04 16:15 ` [PATCH v9 03/14] futex: Give a specific head pointer to exit_robust_list() André Almeida
2026-12-04 16:15 ` [PATCH v9 04/14] futex: Introduce futex_get_robust_lists() and futex_sched_data::robust_lists André Almeida
2026-12-04 16:15 ` [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list André Almeida
2026-12-05  9:55   ` kernel test robot
2026-12-04 16:15 ` [PATCH v9 06/14] futex: Use the multi-robust list infrastructure for current syscalls André Almeida
2026-12-04 16:15 ` [PATCH v9 07/14] futex: Expose robust_list2 limits via sysctl André Almeida
2026-12-04 16:15 ` [PATCH v9 08/14] futex: Create syscall set_robust_list2() André Almeida
2026-12-04 16:15 ` [PATCH v9 09/14] futex: Make futex_task_robust_list() get list by index André Almeida
2026-12-04 16:15 ` [PATCH v9 10/14] futex: Create get_robust_list2() syscall André Almeida
2026-12-04 16:15 ` [PATCH v9 11/14] futex: Wire up set_robust_list2 syscall André Almeida
2026-12-05  9:55   ` kernel test robot
2026-12-05  9:55   ` kernel test robot
2026-12-04 16:15 ` [PATCH v9 12/14] futex: Wire up get_robust_list2 syscall André Almeida
2026-12-04 16:15 ` [PATCH v9 13/14] selftests/futex: Expand for set_robust_list2() André Almeida
2026-12-04 16:15 ` [PATCH v9 14/14] selftests/futex: Expand for get_robust_list2() André Almeida
  -- strict thread matches above, loose matches on Subject: below --
2026-12-05  9:55 [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list kernel test robot
2026-12-05  9:55 kernel test robot

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.