All of lore.kernel.org
 help / color / mirror / Atom feed
From: syzbot <syzbot+2ec7fc1793a63864d9d6@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] usb: gadget: net2280: fix NULL pointer deref in usb_reinit_338x()
Date: Fri, 21 Aug 2026 04:23:19 -0700	[thread overview]
Message-ID: <6a883527.ae6ddae5.3da009.0036.GAE@google.com> (raw)
In-Reply-To: <6a88066b.ae6ddae5.3da009.002c.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] usb: gadget: net2280: fix NULL pointer deref in usb_reinit_338x()
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci

net2280_probe() only maps dev->llregs when the PLX_PCIE quirk bit is
set. usb_reinit() dispatches to usb_reinit_338x() for any device that
doesn't have PLX_LEGACY set, assuming such a device must have
PLX_PCIE set (and thus llregs mapped). That assumption holds for
every entry in the driver's pci_device_id table, but a forced driver
bind (e.g. via sysfs bind/driver_override) can invoke probe() with
quirks that have neither bit set, leaving llregs NULL and crashing
in usb_reinit_338x() on the first readl().

Reject probe() early when quirks has neither PLX_LEGACY nor
PLX_PCIE set, instead of proceeding into a reinit path that assumes
one of them is always present.

Reported-by: syzbot+2ec7fc1793a63864d9d6@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=2ec7fc1793a63864d9d6
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 7c5f30cfd24d..02d12c2ad58b 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -3708,6 +3708,17 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		writel(0, &dev->usb->usbctl);
 	}
 
+	/* usb_reinit() dispatches on PLX_LEGACY vs PLX_PCIE and assumes
+	 * every non-legacy chip has llregs mapped (PLX_PCIE branch above).
+	 * A forced/mismatched driver bind can hand us quirks that satisfy
+         * neither, so refuse to proceed rather than dereference NULL.
+         */
+	if (!(dev->quirks & (PLX_LEGACY | PLX_PCIE))) {
+		ep_err(dev, "unsupported device (quirks=%#lx)\n", dev->quirks);
+		retval = -ENODEV;
+		goto done;
+	}
+
 	usb_reset(dev);
 	usb_reinit(dev);
 
-- 
2.43.0


  reply	other threads:[~2026-08-21 11:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21  8:03 [syzbot] [usb?] BUG: unable to handle kernel NULL pointer dereference in usb_reinit syzbot
2026-08-21 11:23 ` syzbot [this message]
2026-09-08  9:26 ` Aleksandr Nogikh

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=6a883527.ae6ddae5.3da009.0036.GAE@google.com \
    --to=syzbot+2ec7fc1793a63864d9d6@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 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.