All of lore.kernel.org
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Slawomir Stepien <sst@poczta.fm>
Cc: a.hindborg@kernel.org, k.opasiak@samsung.com,
	nab@linux-iscsi.org,  linux-kernel@vger.kernel.org,
	syzbot+b3410eb576b568216ae5@syzkaller.appspotmail.com
Subject: Re: [PATCH 2/2] configfs: give the root inode its own lockdep class
Date: Tue, 27 Oct 2026 05:51:17 -0700	[thread overview]
Message-ID: <auCeMlxBJ0DyaF6S@gmail.com> (raw)
In-Reply-To: <20261022134443.1122318-2-sst@poczta.fm>

On Thu, Oct 22, 2026 at 03:44:43PM +0200, Slawomir Stepien wrote:
> configfs_depend_item_unlocked() is meant to be called from configfs
> callbacks, where VFS already holds directory inode locks and configfs
> holds the subsystem's su_mutex. When the target item lives in another
> subsystem, it additionally locks the configfs root inode so that the
> target subsystem cannot be unregistered underneath it.
> 
> The root inode shares the &sb->s_type->i_mutex_key lockdep class with
> every user-created configfs directory, so lockdep cannot tell it apart
> from the directory inode locks taken by mkdir, rmdir and symlink. Any
> lock held by the depend caller therefore looks like it nests both
> inside and outside "the" configfs inode lock. f_tcm's usbg_make_tpg(),
> which depends on a gadget function item from the target subsystem's
> mkdir callback, triggers this in two ways:
> 
>   target su_mutex -> root inode (depend), while
>   rmdir under target/: directory inode -> target su_mutex
> 
>   tpg_instances_lock -> root inode (depend), while
>   mkdir functions/tcm.N: directory inode -> gadget su_mutex ->
>     func_lock -> tpg_instances_lock (tcm_alloc_inst())
> 
> Neither is a real deadlock, because no holder of the root inode lock
> waits for su_mutex, tpg_instances_lock or a directory inode lock held
> by a depend caller:
> 
>  - configfs_depend_item() and configfs_depend_item_unlocked() only look
>    up the subsystem and scan the tree under configfs_dirent_lock, a
>    spinlock.
>  - Lookup and readdir in the configfs root only take
>    configfs_dirent_lock. mkdir and symlink in the root fail with
>    -EPERM before any other lock is taken, and configfs_rmdir() of a
>    subsystem directory never gets as far as taking su_mutex.
>  - configfs_register_subsystem() only locks the inodes of the new
>    subsystem directory it is creating, which nobody else can hold yet.
>  - configfs_unregister_subsystem() does wait for the subsystem
>    directory's inode lock, but it only runs from the subsystem module's
>    exit path. Every mkdir and rmdir in that subsystem holds a reference
>    on the module, so none of them can be in progress at that point.
> 
> Put the root inode's i_rwsem into its own lock class so that lockdep
> stops aliasing it with ordinary directory inodes. Splitting a class
> cannot create new lockdep cycles, and real dependencies on the root
> inode are still tracked under the new class. This is an annotation
> only: without CONFIG_LOCKDEP the key is empty and lockdep_set_class()
> compiles away.
> 
> Fixes: d79d75b5c518 ("fs: configfs: Add unlocked version of configfs_depend_item()")
> Reported-by: syzbot+b3410eb576b568216ae5@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=b3410eb576b568216ae5
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Slawomir Stepien <sst@poczta.fm>

Reviewed-by: Breno Leitao <leitao@debian.org>

  reply	other threads:[~2026-10-27 12:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 13:44 [PATCH 1/2] configfs: handle unlinked target in configfs_depend_item_unlocked() Slawomir Stepien
2026-10-22 13:44 ` [PATCH 2/2] configfs: give the root inode its own lockdep class Slawomir Stepien
2026-10-27 12:51   ` Breno Leitao [this message]
2026-10-27 12:50 ` [PATCH 1/2] configfs: handle unlinked target in configfs_depend_item_unlocked() Breno Leitao
2026-10-27 13:27 ` Breno Leitao

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=auCeMlxBJ0DyaF6S@gmail.com \
    --to=leitao@debian.org \
    --cc=a.hindborg@kernel.org \
    --cc=k.opasiak@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    --cc=sst@poczta.fm \
    --cc=syzbot+b3410eb576b568216ae5@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.