* [PATCH] configfs: give the root inode its own lockdep class
@ 2026-10-20 14:12 Nguyen Ngoc Thang
0 siblings, 0 replies; only message in thread
From: Nguyen Ngoc Thang @ 2026-10-20 14:12 UTC (permalink / raw)
To: Breno Leitao
Cc: Andreas Hindborg, linux-kernel, Nguyen Ngoc Thang,
syzbot+d123c96491067a2ee754
All configfs directory inodes with s_depth <= 0 share one i_rwsem class.
That lumps the filesystem root together with the top-level subsystem
directories, which makes lockdep chain unrelated paths into a cycle:
gadget_subsys.su_mutex -> func_lock -> tpg_instances_lock
-> root inode lock (configfs_depend_item_unlocked() from
usbg_make_tpg())
-> frag_sem (rmdir under a subsystem directory, e.g. /config/dlm)
-> gadget_subsys.su_mutex (uvcg_default_processing_bm_controls_show()
called under frag_sem from configfs_read_iter())
The root inode lock and the lock taken by rmdir are different inodes: the
root has no mkdir/rmdir operations, and nothing that holds the root inode
lock goes on to take frag_sem or a subsystem's su_mutex. The report is a
false positive, but it disables lockdep for the rest of the boot.
Give the root inode a dedicated class so it is no longer mixed with
subsystem directories.
Reported-by: syzbot+d123c96491067a2ee754@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d123c96491067a2ee754
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
---
fs/configfs/mount.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index d8cac1cbf3bd..1a7c882e9f70 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -24,6 +24,7 @@ static struct vfsmount *configfs_mount = NULL;
struct kmem_cache *configfs_dir_cachep;
static int configfs_mnt_count = 0;
+static struct lock_class_key configfs_root_key;
static void configfs_free_inode(struct inode *inode)
{
@@ -74,6 +75,8 @@ static int configfs_fill_super(struct super_block *sb, struct fs_context *fc)
if (inode) {
inode->i_op = &configfs_root_inode_operations;
inode->i_fop = &configfs_dir_operations;
+ /* root is never rmdir'd; don't share a class with subsystem dirs */
+ lockdep_set_class(&inode->i_rwsem, &configfs_root_key);
/* directory inodes start off with i_nlink == 2 (for "." entry) */
inc_nlink(inode);
} else {
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-20 14:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-20 14:12 [PATCH] configfs: give the root inode its own lockdep class Nguyen Ngoc Thang
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®