Linux USB
 help / color / mirror / Atom feed
From: Felipe Infante de Castro <felipe.infante.de.castro@gmail.com>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: [NOTE] usb: dwc3: qcom: .shutdown = dwc3_qcom_remove double-remove hazard on guest unbind during shutdown
Date: Sun, 29 Nov 2026 05:53:07 -0500	[thread overview]
Message-ID: <179594958702.39790.7164177942155143370@gmail.com> (raw)

Hi Thinh, Greg, Bjorn, and Konrad,

While bringing up an out-of-tree USB4 host router driver on a Snapdragon
X Elite laptop (Linux v7.3.6 arm64), we hit a reproducible (3/3) PID 1
kernel panic on reboot with a USB4 dock attached.

Scope note upfront: nothing in mainline Linux triggers this today. It
requires a second driver that unbinds a bound dwc3-qcom device during
system shutdown (which our USB4 host router driver initially did when
tearing down its guest USB3 session). We have already fixed our USB4
driver to skip device_release_driver() during shutdown, so this is
purely a hardening note for dwc3-qcom in case it is useful upstream.

What happened:

1. dwc3-qcom wires .shutdown = dwc3_qcom_remove.
2. When dwc3-qcom is re-bound as a guest after the USB4 router starts,
   it sits later on devices_kset, so device_shutdown() invokes
   dwc3_qcom_remove() on it *before* the USB4 router's .shutdown().
3. dwc3_qcom_remove() tears down dwc3_qcom and clears
   dev_set_drvdata(dev, NULL), while leaving dev->driver bound (normal
   for Linux ->shutdown()).
4. When the USB4 router's .shutdown() then called
   device_release_driver() on the guest dwc3-qcom device, driver core
   saw dev->driver still set and called dwc3_qcom_remove() a second time
   with NULL drvdata, faulting at fffffffffffffff0 (-0x10) in PID 1:

     Unable to handle kernel paging request at virtual address fffffffffffffff0
     pc : dwc3_qcom_remove+0x28/0x168 [dwc3_qcom]
       ...
       device_shutdown / kernel_restart
     Kernel panic - not syncing: Attempted to kill init!

Hardening thought:

Guarding dwc3_qcom_remove() with `if (!qcom) return;` (or using a
dedicated idempotent .shutdown callback) would make dwc3-qcom safe
against any future driver-core or parent-triggered teardown running
after ->shutdown().

Details:
https://github.com/fidecastro/surface-laptop-7-15in-facts/blob/main/upstream-reports/dwc3-qcom-shutdown.md

Best regards,
Felipe Infante de Castro

Signed-off-by: Felipe Infante de Castro <felipe.infante.de.castro@gmail.com>

             reply	other threads:[~2026-11-29 10:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 10:53 Felipe Infante de Castro [this message]
2026-11-29 12:14 ` [NOTE] usb: dwc3: qcom: .shutdown = dwc3_qcom_remove double-remove hazard on guest unbind during shutdown Greg Kroah-Hartman

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=179594958702.39790.7164177942155143370@gmail.com \
    --to=felipe.infante.de.castro@gmail.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=andersson@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-usb@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