From nobody Thu Apr 2 20:22:13 2026 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE01029BDBD for ; Thu, 12 Feb 2026 21:41:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770932520; cv=none; b=j9e7GOPmYGVRGk5rMC0Sm9U6HRBXbT/uReyCP9YVFwG86Dad+q+cG4mEPhXy1oQIkXiR8i9O4rpBFfMZud/lmpJVboxhbTUvtgtD0j91hEwCyKz09vaAET2dM9dAxgjr7Do2mNGcwdAhI3zmsRvxfCASKAWcBVHvkLlSLDW57Lg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770932520; c=relaxed/simple; bh=0IYVgRHd6TZ2pI2ZFTsmGN2BGGlg3CLyrtR2RDlfs9o=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jLsvGCZSFcxC0U1vbo62FvycBvqsQhpv9cVhUzVEuIf6ZrLWwXkIH7rWcsABj/JdYTQmNk/mMpzXDmb2fEns6lEr0+kQ+jDnErXRQbWXl/f9nt/pjRZMe/ypveaToK8Eg493FVKqM9wKUCdnmKImG7z66Ti1OaanecRVfqCPuII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=u.northwestern.edu; spf=pass smtp.mailfrom=u.northwestern.edu; dkim=pass (2048-bit key) header.d=u-northwestern-edu.20230601.gappssmtp.com header.i=@u-northwestern-edu.20230601.gappssmtp.com header.b=NJp9S3ZA; arc=none smtp.client-ip=209.85.222.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=u.northwestern.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=u.northwestern.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=u-northwestern-edu.20230601.gappssmtp.com header.i=@u-northwestern-edu.20230601.gappssmtp.com header.b="NJp9S3ZA" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-8cb3fd71badso29010285a.0 for ; Thu, 12 Feb 2026 13:41:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=u-northwestern-edu.20230601.gappssmtp.com; s=20230601; t=1770932517; x=1771537317; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fBNWNtgJkDT4c7Jvgggf4qsijVRD2mBYjYmT91hYIoQ=; b=NJp9S3ZA0X2ffNGovgYwZMO5u+0VjJUF5iNZrDcTcuhzI8QXINswxPynJMKEIOSD3r 1Cy/PfSUCs2AbN6al3CYOTZ7P9pb0ShAWGaVR1jC9EtpwWh+fpidumbMSvX3IMWgm5gO VjLqeOV4Wuue+ZW9d/Nf8X1oydxUEACtfbAcnOhxZwSa+KliiM7o6eMcGn1ncFX38I96 iwITs28bZ+kb1abfOK/FgqVcT5kYYNTgyr/c8iknKe25HDfkhOvgog9v8On1aSR9uBpz +1/wp2/Tw+K9c5V+12+yOfaIK7KOU2ocAnl77hM3aJdb5X/+loj8oFArHfDmZsfgX/1+ 61Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770932517; x=1771537317; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fBNWNtgJkDT4c7Jvgggf4qsijVRD2mBYjYmT91hYIoQ=; b=Hlqz35mcjvDR0+gAHrntvxt3UafFRvWBhxP+cVaZ4tF724cTRfqVnjsPmlwvW3+7QD BfiB52cHnX9UpNR+ysTvuMBawaaRbTca1x8Zl7xe+KFEhieQ3Y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002:a05:620a:44c3:b0:8b2:7558:406d with SMTP id af79cd13be357-8cb408f24f8mr52997085a.61.1770932516736; Thu, 12 Feb 2026 13:41:56 -0800 (PST) Received: from security.cs.northwestern.edu (security.cs.northwestern.edu. [165.124.184.136]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8971cc823a4sm45245976d6.8.2026.02.12.13.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 13:41:56 -0800 (PST) From: Ziyi Guo To: Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Ziyi Guo Subject: [PATCH net v2] net: usb: catc: enable basic endpoint checking Date: Thu, 12 Feb 2026 21:41:54 +0000 Message-Id: <20260212214154.3609844-1-n7l8m4@u.northwestern.edu> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 a catc_usb_ep enum for endpoint numbers, replacing magic constants throughout. 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") Suggested-by: Simon Horman Signed-off-by: Ziyi Guo --- v2: - Use an enum instead of the magic numbers drivers/net/usb/catc.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c index 6759388692f8..632e27ee9101 100644 --- a/drivers/net/usb/catc.c +++ b/drivers/net/usb/catc.c @@ -64,6 +64,16 @@ static const char driver_name[] =3D "catc"; #define CTRL_QUEUE 16 /* Max control requests in flight (power of two) */ #define RX_PKT_SZ 1600 /* Max size of receive packet for F5U011 */ =20 +/* + * USB endpoints. + */ + +enum catc_usb_ep { + CATC_USB_EP_CONTROL =3D 0, + CATC_USB_EP_BULK =3D 1, + CATC_USB_EP_INT_IN =3D 2, +}; + /* * Control requests. */ @@ -772,6 +782,13 @@ static int catc_probe(struct usb_interface *intf, cons= t struct usb_device_id *id u8 broadcast[ETH_ALEN]; u8 *macbuf; int pktsz, ret =3D -ENOMEM; + static const u8 bulk_ep_addr[] =3D { + CATC_USB_EP_BULK | USB_DIR_OUT, + CATC_USB_EP_BULK | USB_DIR_IN, + 0}; + static const u8 int_ep_addr[] =3D { + CATC_USB_EP_INT_IN | USB_DIR_IN, + 0}; =20 macbuf =3D kmalloc(ETH_ALEN, GFP_KERNEL); if (!macbuf) @@ -784,6 +801,14 @@ static int catc_probe(struct usb_interface *intf, cons= t struct usb_device_id *id goto fail_mem; } =20 + /* 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 =3D -ENODEV; + goto fail_mem; + } + netdev =3D alloc_etherdev(sizeof(struct catc)); if (!netdev) goto fail_mem; @@ -828,14 +853,14 @@ static int catc_probe(struct usb_interface *intf, con= st struct usb_device_id *id usb_fill_control_urb(catc->ctrl_urb, usbdev, usb_sndctrlpipe(usbdev, 0), NULL, NULL, 0, catc_ctrl_done, catc); =20 - usb_fill_bulk_urb(catc->tx_urb, usbdev, usb_sndbulkpipe(usbdev, 1), - NULL, 0, catc_tx_done, catc); + usb_fill_bulk_urb(catc->tx_urb, usbdev, usb_sndbulkpipe(usbdev, CATC_USB_= EP_BULK), + NULL, 0, catc_tx_done, catc); =20 - usb_fill_bulk_urb(catc->rx_urb, usbdev, usb_rcvbulkpipe(usbdev, 1), - catc->rx_buf, pktsz, catc_rx_done, catc); + usb_fill_bulk_urb(catc->rx_urb, usbdev, usb_rcvbulkpipe(usbdev, CATC_USB_= EP_BULK), + catc->rx_buf, pktsz, catc_rx_done, catc); =20 - usb_fill_int_urb(catc->irq_urb, usbdev, usb_rcvintpipe(usbdev, 2), - catc->irq_buf, 2, catc_irq_done, catc, 1); + usb_fill_int_urb(catc->irq_urb, usbdev, usb_rcvintpipe(usbdev, CATC_USB_E= P_INT_IN), + catc->irq_buf, 2, catc_irq_done, catc, 1); =20 if (!catc->is_f5u011) { u32 *buf; --=20 2.34.1