Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: ZW Tang <tangzw515@gmail.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-usb@vger.kernel.org, linux-scsi@vger.kernel.org,
	target-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [BUG] usb: gadget: f_tcm: possible circular locking dependency in usbg_make_tpg
Date: Mon, 31 Aug 2026 11:38:56 +0200	[thread overview]
Message-ID: <2026083139-enamel-result-951b@gregkh> (raw)
In-Reply-To: <CAA2SOT4Hok5xOtbviX4HkeqVK_u79NZjw3+0WKZMmUQb35jORw@mail.gmail.com>

On Mon, Aug 31, 2026 at 05:26:19PM +0800, ZW Tang wrote:
> Hi,
> 
> I am reporting a possible circular locking dependency triggered by a
> syzkaller reproducer on Linux 7.2.0-rc3. Similar issues appear to have
> been reported upstream before, but I can still reproduce this warning on
> Linux 7.2.0-rc3 with HEAD commit
> 1137d8b5df06137fb49513cc923b3b24d94cb809.
> 
> The reproducer mounts configfs, creates a USB gadget TCM function, creates
> a target usb_gadget fabric TPG, and then links the TCM function into a USB
> gadget configuration.
> 
> Lockdep reports a cycle involving the configfs inode mutex,
> tpg_instances_lock, and the f_tcm opts->dep_lock. The current path is
> creating a TPG through configfs_mkdir(). It reaches usbg_make_tpg(), holds
> tpg_instances_lock and opts->dep_lock, and then calls
> configfs_depend_item_unlocked(), which tries to acquire a configfs inode
> mutex.
> 
> The existing reverse dependency is created by the USB gadget symlink path:
> configfs_symlink() calls config_usb_cfg_link(), which calls
> usb_get_function() and then tcm_alloc(), where tpg_instances_lock is
> acquired.
> 
> This creates the following lock order cycle:
> 
> configfs inode mutex -> tpg_instances_lock -> opts->dep_lock
> opts->dep_lock -> configfs inode mutex
> 
> This looks like a lock-ordering issue in the USB gadget TCM function /
> target configfs integration. The kernel should avoid taking these locks in
> opposite orders, because this can lead to an actual deadlock.

Great, care to send a patch to fix this as you have a reproducer for the
issue?

thanks,

greg k-h

      reply	other threads:[~2026-08-31  9:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31  9:26 [BUG] usb: gadget: f_tcm: possible circular locking dependency in usbg_make_tpg ZW Tang
2026-08-31  9:38 ` Greg KH [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=2026083139-enamel-result-951b@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=tangzw515@gmail.com \
    --cc=target-devel@vger.kernel.org \
    /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