From: Simon Horman <horms@kernel.org>
To: Ziyi Guo <n7l8m4@u.northwestern.edu>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-usb@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: usb: catc: enable basic endpoint checking
Date: Thu, 12 Feb 2026 17:09:43 +0000 [thread overview]
Message-ID: <aY4JV-aEInRDHYqW@horms.kernel.org> (raw)
In-Reply-To: <20260210024341.3216007-1-n7l8m4@u.northwestern.edu>
On Tue, Feb 10, 2026 at 02:43:41AM +0000, Ziyi Guo wrote:
> catc_probe() fills three URBs with hardcoded endpoint pipes without
> verifying the endpoint descriptors:
>
> - usb_sndbulkpipe(usbdev, 1) and usb_rcvbulkpipe(usbdev, 1) for TX/RX
> - usb_rcvintpipe(usbdev, 2) for interrupt status
>
> A malformed USB device can present these endpoints with transfer types
> that differ from what the driver assumes.
>
> Add usb_check_bulk_endpoints() and usb_check_int_endpoints() calls
> after usb_set_interface() to verify endpoint types before use, rejecting
> devices with mismatched descriptors at probe time.
>
> Similar to
> - commit 90b7f2961798 ("net: usb: rtl8150: enable basic endpoint checking")
> which fixed the issue in rtl8150.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
> ---
> drivers/net/usb/catc.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c
> index 6759388692f8..e92773cbf5f9 100644
> --- a/drivers/net/usb/catc.c
> +++ b/drivers/net/usb/catc.c
> @@ -770,6 +770,13 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
> struct net_device *netdev;
> struct catc *catc;
> u8 broadcast[ETH_ALEN];
> + static const u8 bulk_ep_addr[] = {
> + USB_DIR_OUT | 1, /* EP 1 OUT (TX) */
> + USB_DIR_IN | 1, /* EP 1 IN (RX) */
> + 0};
> + static const u8 int_ep_addr[] = {
> + USB_DIR_IN | 2, /* EP 2 IN (interrupt) */
Hi,
I think that it would be good to use an enum instead of the magic
numbers 1 and 2, even if documented inline.
I'm suggesting something similar to what was done in the cited commit.
> + 0};
> u8 *macbuf;
> int pktsz, ret = -ENOMEM;
>
> @@ -784,6 +791,14 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
> goto fail_mem;
> }
>
> + /* Verify that all required endpoints are present */
> + if (!usb_check_bulk_endpoints(intf, bulk_ep_addr) ||
> + !usb_check_int_endpoints(intf, int_ep_addr)) {
> + dev_err(dev, "Missing or invalid endpoints\n");
> + ret = -ENODEV;
> + goto fail_mem;
> + }
> +
> netdev = alloc_etherdev(sizeof(struct catc));
> if (!netdev)
> goto fail_mem;
> --
> 2.34.1
>
>
next prev parent reply other threads:[~2026-02-12 17:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 2:43 [PATCH net] net: usb: catc: enable basic endpoint checking Ziyi Guo
2026-02-12 17:09 ` Simon Horman [this message]
2026-02-12 19:21 ` Ziyi Guo
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=aY4JV-aEInRDHYqW@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=n7l8m4@u.northwestern.edu \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox