From: "Danilo Krummrich" <dakr@kernel.org>
To: "Gary Guo" <gary@garyguo.net>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Toke Høiland-Jørgensen" <toke@toke.dk>,
"Johan Hovold" <johan@kernel.org>,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, driver-core@lists.linux.dev
Subject: Re: [PATCH 4/4] usb: fix UAF when probe runs concurrent to dyn ID removal
Date: Tue, 30 Jun 2026 23:55:44 +0200 [thread overview]
Message-ID: <DJMPWDSKN8C3.1Z3RQ8WGH563R@kernel.org> (raw)
In-Reply-To: <20260630-usb_dyn_id_uaf-v1-4-160a02be5ac2@garyguo.net>
On Tue Jun 30, 2026 at 1:38 PM CEST, Gary Guo wrote:
> @@ -320,7 +321,8 @@ static int usb_probe_interface(struct device *dev)
> struct usb_driver *driver = to_usb_driver(dev->driver);
> struct usb_interface *intf = to_usb_interface(dev);
> struct usb_device *udev = interface_to_usbdev(intf);
> - const struct usb_device_id *id;
> + struct usb_device_id id;
> + const struct usb_device_id *matched_id;
> int error = -ENODEV;
> int lpm_disable_error = -ENODEV;
>
> @@ -340,11 +342,12 @@ static int usb_probe_interface(struct device *dev)
> return error;
> }
>
> - id = usb_match_dynamic_id(intf, driver);
> - if (!id)
> - id = usb_match_id(intf, driver->id_table);
> - if (!id)
> - return error;
> + if (!usb_match_dynamic_id(intf, driver, &id)) {
> + matched_id = usb_match_id(intf, driver->id_table);
> + if (!matched_id)
> + return error;
> + id = *matched_id;
> + }
I think this could just be:
struct usb_device_id id_copy;
if (usb_match_dynamic_id(intf, driver, &id_copy)) {
id = &id_copy;
} else {
id = usb_match_id(intf, driver->id_table);
if (!id)
return error;
}
Avoids the unnecessary copy and also results in a smaller diff.
next prev parent reply other threads:[~2026-06-30 21:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 11:38 [PATCH 0/4] usb: fix UAF related to dynamic ID Gary Guo
2026-06-30 11:38 ` [PATCH 1/4] wifi: ath9k_htc: don't keep usb_device_id Gary Guo
2026-06-30 21:51 ` Danilo Krummrich
2026-06-30 11:38 ` [PATCH 2/4] usb: usbtmc: " Gary Guo
2026-06-30 21:51 ` Danilo Krummrich
2026-06-30 11:38 ` [PATCH 3/4] usb: serial: spcp8x5: " Gary Guo
2026-06-30 21:52 ` Danilo Krummrich
2026-06-30 11:38 ` [PATCH 4/4] usb: fix UAF when probe runs concurrent to dyn ID removal Gary Guo
2026-06-30 21:55 ` Danilo Krummrich [this message]
2026-06-30 13:26 ` [PATCH 0/4] usb: fix UAF related to dynamic ID Manuel Ebner
2026-06-30 13:39 ` Danilo Krummrich
2026-07-01 15:02 ` Manuel Ebner
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=DJMPWDSKN8C3.1Z3RQ8WGH563R@kernel.org \
--to=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=toke@toke.dk \
/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.