Skip to contentSkip to conversation

copy_process(): Fixed jump logic error

PATCH In review Edward Adam Davis 4 participants 4 messages Sep 24, 2025 – Sep 26, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 copy_process(): Fixed jump logic error

After futex_hash_allocate_default() fails, the logic should jump to bad_fork_cancel_cgroup, not bad_fork_core_free.

Jumping to bad_fork_core_free would cause a siglock imbalance.

---
 kernel/fork.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/fork.c +1 -1
index e9a7fb5c3e49..a0b8eeeb1d27 100644
@@ -2349,7 +2349,7 @@ __latent_entropy struct task_struct *copy_process(
 	if (need_futex_hash_allocate_default(clone_flags)) {
 		retval = futex_hash_allocate_default();
 		if (retval)
-			goto bad_fork_core_free;
+			goto bad_fork_cancel_cgroup;
 		/*
 		 * If we fail beyond this point we don't free the allocated
 		 * futex hash map. We assume that another thread will be created
Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · Edward Adam Davis

After futex_hash_allocate_default() fails, the logic should jump to bad_fork_cancel_cgroup, not bad_fork_core_free.

Jumping to bad_fork_core_free would cause a siglock imbalance.

If it's still only in -next (which I assume when looking at the Next tag), into which patch should this fixup get squashed?

Or is this already upstream and we want actually Fixes: and CC stable?

(staring at current master, this seems to be an upstream problem?)

Quoted 9 lines
---
  kernel/fork.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/fork.c +0 -0
index e9a7fb5c3e49..a0b8eeeb1d27 100644

kernel/fork.c __latent_entropy struct task_struct *copy_process( · line 2355

Quoted 8 lines
kernel/fork.c +1 -1
@@ -2349,7 +2349,7 @@ __latent_entropy struct task_struct *copy_process(
  	if (need_futex_hash_allocate_default(clone_flags)) {
  		retval = futex_hash_allocate_default();
  		if (retval)
-			goto bad_fork_core_free;
+			goto bad_fork_cancel_cgroup;
  		/*
  		 * If we fail beyond this point we don't free the allocated
  		 * futex hash map. We assume that another thread will be created

Makes me wonder whether we would have to undo anything the sched_cgroup_fork() did, or if that cleanup is implied in bad_fork_cancel_cgroup. Without digging too deep into the code, I assume the latter.

Signature · 3 lines
Cheers

David / dhildenb
#2 lore raw
In reply to Edward Adam Davis
Quoted 6 lines · Edward Adam Davis

After futex_hash_allocate_default() fails, the logic should jump to bad_fork_cancel_cgroup, not bad_fork_core_free.

Jumping to bad_fork_core_free would cause a siglock imbalance.

Sebastian already fixed this and it's in tip: locking/urgent

https://lore.kernel.org/all/[email protected]/

Quoted 17 lines
---
 kernel/fork.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/fork.c +1 -1
index e9a7fb5c3e49..a0b8eeeb1d27 100644
@@ -2349,7 +2349,7 @@ __latent_entropy struct task_struct *copy_process(
 	if (need_futex_hash_allocate_default(clone_flags)) {
 		retval = futex_hash_allocate_default();
 		if (retval)
-			goto bad_fork_core_free;
+			goto bad_fork_cancel_cgroup;
 		/*
 		 * If we fail beyond this point we don't free the allocated
 		 * futex hash map. We assume that another thread will be created
#3 lore raw
Quoted 9 lines · Vlastimil Babka
Quoted 6 lines · Edward Adam Davis

After futex_hash_allocate_default() fails, the logic should jump to bad_fork_cancel_cgroup, not bad_fork_core_free.

Jumping to bad_fork_core_free would cause a siglock imbalance.

Sebastian already fixed this and it's in tip: locking/urgent

A pull request has been sent to Linus earlier today.

Sebastian