Linux USB
 help / color / mirror / Atom feed
From: William Chuang <founder@logarcheon.com>
To: Breno Leitao <leitao@debian.org>
Cc: Andreas Hindborg <a.hindborg@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	syzbot+c75a7db5ca6ae96ed2d4@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] configfs: give the root directory inode its own lockdep class
Date: Tue, 17 Nov 2026 15:04:06 +0000	[thread overview]
Message-ID: <20261117150358.8149-1-founder@logarcheon.com> (raw)
In-Reply-To: <20261117065314.4309-1-founder@logarcheon.com>

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


      parent reply	other threads:[~2026-11-17 15:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  6:53 [PATCH] configfs: give the root directory inode its own lockdep class William Chuang
2026-11-17  7:13 ` sashiko-bot
2026-11-17 15:04 ` William Chuang [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=20261117150358.8149-1-founder@logarcheon.com \
    --to=founder@logarcheon.com \
    --cc=a.hindborg@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=leitao@debian.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=syzbot+c75a7db5ca6ae96ed2d4@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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