From: Josef Bacik <josef@bacik.io>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Tejun Heo <tj@kernel.org>
Cc: Christian Brauner <brauner@kernel.org>,
driver-core@lists.linux.dev, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] kernfs: fix two races in __kernfs_new_node()
Date: Wed, 02 Dec 2026 16:45:13 +0000 [thread overview]
Message-ID: <20261202-b4-kernfs-new-node-v1-0-25b4eb0468a2@bacik.io> (raw)
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
next reply other threads:[~2026-12-02 16:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 16:45 Josef Bacik [this message]
2026-12-02 16:45 ` [PATCH 2/2] kernfs: RCU free a new node that was already in the idr Josef Bacik
2026-12-02 16:45 ` [PATCH 1/2] kernfs: deactivate a new node before publishing its id Josef Bacik
2026-12-03 19:25 ` [PATCH 0/2] kernfs: fix two races in __kernfs_new_node() Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202-b4-kernfs-new-node-v1-0-25b4eb0468a2@bacik.io \
--to=josef@bacik.io \
--cc=brauner@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®