Re: [PATCH] configfs: give the root directory inode its own lockdep class

From: William Chuang

Date: Tue Nov 17 2026 - 10:04:24 EST


On Tue, Nov 17, 2026, Sashiko AI review wrote:
> Does assigning a separate lockdep class to the configfs root inode's
> i_rwsem hide a real ABBA deadlock between renameat2() and mkdir()?

Yes, and the deadlock is real. Please drop this patch.

My analysis missed rename(): lock_rename() locks both parent
directories before vfs_rename() finds that configfs has no ->rename(),
and when one parent is the configfs root, the root is locked first.
mkdir() of target/usb_gadget/naa.<wwn>/tpgt_1 runs with the naa.<wwn>
directory locked by the VFS, and usbg_make_tpg() then locks the root in
configfs_depend_item_unlocked(). The two orders are opposite.

Reproduced on mainline 666539eec without this patch, in QEMU (x86_64,
2 CPUs): one process loops mkdir/rmdir of tpgt_1, another loops

rename("/sys/kernel/config/nonexistent",
"/sys/kernel/config/target/usb_gadget/naa.<wwn>/nonexistent")

Both hang within about a second. sysrq-w shows:

mkdir: down_write
configfs_depend_item_unlocked
usbg_make_tpg
target_fabric_make_tpg
configfs_mkdir
vfs_mkdir

rename: down_write_nested
lock_two_directories
__start_renaming
filename_renameat2

A third process doing readdir() of the configfs root then blocks in
configfs_dir_open(). I ran the test as root; I have not checked how
much privilege the rename() side needs.

So the root lock that configfs_depend_item_unlocked() takes for a
target in another subsystem, when called from a ->make_group()
callback, can deadlock against rename() whatever the su_mutex chain in
the syzbot report. I don't have a fix to propose yet. Is the root
lock there only to keep the target subsystem from being unregistered
during the dependency, or does it protect more than that?

Thanks,
William