mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
To: Breno Leitao <leitao@debian.org>
Cc: Andreas Hindborg <a.hindborg@kernel.org>,
	linux-kernel@vger.kernel.org,
	Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>,
	syzbot+d123c96491067a2ee754@syzkaller.appspotmail.com
Subject: [PATCH] configfs: give the root inode its own lockdep class
Date: Tue, 20 Oct 2026 21:12:43 +0700	[thread overview]
Message-ID: <20261020141243.87911-1-ngocthang2710.1999@gmail.com> (raw)

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


                 reply	other threads:[~2026-10-20 14:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261020141243.87911-1-ngocthang2710.1999@gmail.com \
    --to=ngocthang2710.1999@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+d123c96491067a2ee754@syzkaller.appspotmail.com \
    /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®