The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 0/2] kernfs: fix two races in __kernfs_new_node()
@ 2026-12-02 16:45 Josef Bacik
  2026-12-02 16:45 ` [PATCH 1/2] kernfs: deactivate a new node before publishing its id Josef Bacik
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Josef Bacik @ 2026-12-02 16:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Tejun Heo
  Cc: Christian Brauner, driver-core, linux-fsdevel, linux-kernel

Hello,

kernfs_find_and_get_node_by_id() can find a node in the idr while
__kernfs_new_node() is still setting it up, and after its error path has
freed it.  Patch 1 sets the deactivated bias before the node goes into
the idr, and patch 2 frees the node with kernfs_free_rcu() on that error
path.

Each bug reproduced in QEMU with KASAN, lockdep and kmemleak only with
added delays, plus a forced failure for patch 2, and the same runs are
clean with both patches.  kernfs_test and the cgroup test_core,
test_kill, test_pids and test_freezer selftests pass.

This is against vfs.fixes, since the recent kernfs fixes went through
Christian's tree, and it applies to mainline as well.  Thanks,

Josef

---
Josef Bacik (2):
      kernfs: deactivate a new node before publishing its id
      kernfs: RCU free a new node that was already in the idr

 fs/kernfs/dir.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
---
base-commit: b8e026b973764a52b92c0cdc1d3cf96f2abc1058
change-id: 20261202-b4-kernfs-new-node-cfcf607114b4

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

end of thread, other threads:[~2026-12-03 19:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 16:45 [PATCH 0/2] kernfs: fix two races in __kernfs_new_node() Josef Bacik
2026-12-02 16:45 ` [PATCH 1/2] kernfs: deactivate a new node before publishing its id Josef Bacik
2026-12-02 16:45 ` [PATCH 2/2] kernfs: RCU free a new node that was already in the idr Josef Bacik
2026-12-03 19:25 ` [PATCH 0/2] kernfs: fix two races in __kernfs_new_node() Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox