From: Vasileios Almpanis <vasilisalmpanis@gmail.com>
To: Breno Leitao <leitao@debian.org>
Cc: Andreas Hindborg <a.hindborg@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
syzbot+6b16e3d085833cbf3e25@syzkaller.appspotmail.com
Subject: Re: [PATCH 2/2] configfs: unhash the dentry before dropping the item in rmdir
Date: Fri, 31 Jul 2026 11:55:11 +0200 [thread overview]
Message-ID: <a91f850e-0bc2-484a-ba77-2138949eba58@gmail.com> (raw)
In-Reply-To: <amxrCqfgaWnoWcte@gmail.com>
On 7/31/26 11:29 AM, Breno Leitao wrote:
> On Thu, Jul 30, 2026 at 11:30:25AM +0200, Vasileios Almpanis wrote:
>> configfs_get_config_item() treats a hashed dentry as proof that
>> sd->s_element is a live config_item. configfs_rmdir() breaks that:
>> simple_rmdir() leaves the dentry hashed, the last reference to the item is
>> dropped right after, and the dentry is only unhashed by d_delete() once
>> ->rmdir() has returned. configfs_symlink() resolves its target holding no
>> lock on it, so get_target() can land in that window:
>>
>> BUG: KASAN: slab-use-after-free in config_item_get+0x26/0x90
>> get_target fs/configfs/symlink.c:128 [inline]
>> configfs_symlink+0x4ab/0x1030 fs/configfs/symlink.c:185
>>
>> Unhash in configfs_remove_dir(), while the item is still guaranteed to be
>> there. A reference obtained just before that stays harmless, as
>> create_link() rechecks CONFIGFS_USET_DROPPING, already set by
>> configfs_detach_prep(). Both configfs_unregister_subsystem() paths
>> d_drop() after detaching, so this only makes rmdir match them.
> Is the claim that "a reference obtained just before that stays harmless,
> as create_link() rechecks CONFIGFS_USET_DROPPING" accurate?
I believe so. Everything configfs_remove_dir() will now d_drop(), had
DROPPING set on its dirent beforehand by configfs_detach_prep(), and
once detach_prep() has succeeded the flag is never cleared again on
that subtree.
The race is closed by configfs_dirent_lock. create_link() checks DROPPING
and incs ->s_links in one locked section, and detach_prep() set DROPPING
and checks ->s_links in another. Either symlink gets ->s_links++ in
first and
rmdir fails with -EBUSY before unhashing, or DROPPING is set first and
create_link() fails with -ENOENT.
prev parent reply other threads:[~2026-07-31 9:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 9:30 [PATCH 0/2] configfs: fix use-after-free of symlink target racing with rmdir Vasileios Almpanis
2026-07-30 9:30 ` [PATCH 1/2] configfs: pin the symlink target's dirent instead of chasing ->ci_dentry Vasileios Almpanis
2026-07-30 9:30 ` [PATCH 2/2] configfs: unhash the dentry before dropping the item in rmdir Vasileios Almpanis
2026-07-31 9:29 ` Breno Leitao
2026-07-31 9:55 ` Vasileios Almpanis [this message]
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=a91f850e-0bc2-484a-ba77-2138949eba58@gmail.com \
--to=vasilisalmpanis@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=leitao@debian.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+6b16e3d085833cbf3e25@syzkaller.appspotmail.com \
--cc=viro@zeniv.linux.org.uk \
/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