From nobody Fri Apr 17 07:58:58 2026 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 78FB54964F for ; Sun, 22 Feb 2026 05:06:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771736799; cv=none; b=SCigNRljIz2SrMxxrX/+1F+E2oxC8ufz0yfZvNX9GI4r/hVLpn789To98DUNr9j/krtk7Tar9LbjReFqQb9rAqgYLk5fvnpFUOTEvLFJsrd7jZGiX5eIDkZkZSELMPthnSstaLOLu6GNIaVHR4l1xLOrz2CaxdehvU33hqyVxyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771736799; c=relaxed/simple; bh=t1HmHm/txpNwilCNIdjf84AFW98nrGgCLRcSa8+4pE4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ImKUvu2tyEmiViCRleLxssaVfbEbHhHC2BHNcVteTEv31OYDCT5WavqggxAn17VbM8kw94IOO3dbdL22Bstn3GbzSobUrsbVuIig5P8qH8ehbuxPN7/vHQRVnHS5X0nlKDH19zrZDlGFwRvhuGQwNqViT9r1HMPDLrvFiTUKACk= 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=Gntw2/dY; arc=none smtp.client-ip=209.85.219.47 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="Gntw2/dY" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-896f9397ecdso36039456d6.3 for ; Sat, 21 Feb 2026 21:06:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=u-northwestern-edu.20230601.gappssmtp.com; s=20230601; t=1771736796; x=1772341596; 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=bttcDNU2nAINHq9ZznGXMUM8VB0ktwFg7EYW3Smrsho=; b=Gntw2/dY9sUPWzTfLAec1UP7CdcXgc2J7z1oKpk3o2DIumwBBbmDdBJ2nbjxkqpLcA PhWqglu+Q545/AJ7ZloEVaWoyBRe1bMhxf7RUhUIPvtge3rnkjq6ZMSkKQ3ZrOHs0lku vbwnHyW9GORIfoeFZehPMFAmoH7vHNU1Cp2kGcuuERCVvXcISq5GJ9KXxi1NUQuhHQHO vBHIeg/eIZrmzRZhx4g610QWMjRtqgo4ryXOKbTBjefQvVmjcNXTg6BmM4eI0vCfsRDf 9iC2IcJnwxxgjWC/gCI545ZJDXDqzekctFSZp83kUNHARZFJ1oLOYLTxzcf51X3PXe1T QCpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771736796; x=1772341596; 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=bttcDNU2nAINHq9ZznGXMUM8VB0ktwFg7EYW3Smrsho=; b=NWQU8n9f6MXg1z7CclrAdioS5x1vamKlD2z+4BLyKjMYfX2K5H9ktR5p9yzjAQoGUD YZ23milWecimQ+WtCIZJrHVIPEKEIRahGd5OFy96oNJgv6wL0SandBJPhmOspn7CwLxK RJFJy2CmVori8DTAwBZI9DUqeeu3/MRqLi2vUQOlrX1zGZrPhbbpt66Ib/oL0X8eQnXW 0Ja0IzXf/ISeiueZ8FWqQ54FXKi5knPI/4w8lpCidSt1bQvqJIFkITn83Tugfck1D3Yg JSSqYlH2TLsnWSwzbg9yr+EWHPzmNQfwaAld/9PjjYiX5hLCxqlE/dSBCEI7ejzsl2el N6WQ== X-Forwarded-Encrypted: i=1; AJvYcCUCp975S5WcxBl61k+OgrJ3+TCKC3PkrJjdHdF2Gjdq/QhsVwGs6uNWDQb8q+lzH2mLPdgN4LYOpj+wlXI=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8/hfeAn+TStEedPj8ZIrjTg4pYCtVvleWYHg+UZveOp5Pxsmh vqFLrjB7Kco1MksccXq2ywbi8GaHXL5bumPtW9wSojwbUndKQWxMuLkNcTpmxDvVjWo= X-Gm-Gg: AZuq6aInJ4fDU/XldPPfkultQOAHcq08hSdjhrw/8D8doDzccEMxafSljAduxH4mI6T c1zpdOpasfRIjZSC6chzSZuCj8cPRvdcswWurqg8tz5tI6z/oabx6/ZOxrpuS3Qpg03hYNKrj/k VRqbF8PM708PZngIJnm3OI3A1j/asweFcFXKIotXX2AGrJpv/fIuupZHYSU4reQvUfXuYxrMKXD YaKMCdJ/t4Hw36VG8b7eTrwxMFBMOUXxemIZK/V5sBixx0AGYPESXTRJpprmHsxknd26BV/d9R2 3p9/tffuBpr5RJpLU9CxgnDBvHut8k95YsO8x1MZueqhDpaew2C5uZAUn1CNKwbyCpIFL8i+qiU g89xdn6jHcRYfiPhNg/CvM8mPYuIHs2r/I1bU+svsaJ3j2MUZfXrPMjjX0KORy2qDPnOIRB/QSF Rofg/pRDiZX+Q5p/lztTGJFxphhnpPvSgBUWDWBpC+DfGpHdNuwkfG8TtZzucseFEwO8ij1a9yJ btiFAIwYgYSvrIv0Y9GzIbFoM0i5RM+XbLFuO4DiWg= X-Received: by 2002:a05:6214:d65:b0:880:3ce2:65ad with SMTP id 6a1803df08f44-89979d362b3mr78240586d6.41.1771736796388; Sat, 21 Feb 2026 21:06:36 -0800 (PST) Received: from security.cs.northwestern.edu (security.cs.northwestern.edu. [165.124.184.136]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8997e7741c0sm33287246d6.50.2026.02.21.21.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Feb 2026 21:06:36 -0800 (PST) From: Ziyi Guo To: Petko Manolov , Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Ziyi Guo Subject: [PATCH net] net: usb: pegasus: enable basic endpoint checking Date: Sun, 22 Feb 2026 05:06:33 +0000 Message-Id: <20260222050633.410165-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" pegasus_probe() fills URBs with hardcoded endpoint pipes without verifying the endpoint descriptors: - usb_rcvbulkpipe(dev, 1) for RX data - usb_sndbulkpipe(dev, 2) for TX data - usb_rcvintpipe(dev, 3) for status interrupts A malformed USB device can present these endpoints with transfer types that differ from what the driver assumes. Add a pegasus_usb_ep enum for endpoint numbers, replacing magic constants throughout. Add usb_check_bulk_endpoints() and usb_check_int_endpoints() calls before any resource allocation to verify endpoint types before use, rejecting devices with mismatched descriptors at probe time, and avoid triggering assertion. Similar fix to - commit 90b7f2961798 ("net: usb: rtl8150: enable basic endpoint checking") - commit 9e7021d2aeae ("net: usb: catc: enable basic endpoint checking") Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Ziyi Guo Reviewed-by: Simon Horman --- drivers/net/usb/pegasus.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c index 7b6d6eb60709..b84968c5f074 100644 --- a/drivers/net/usb/pegasus.c +++ b/drivers/net/usb/pegasus.c @@ -28,6 +28,17 @@ static const char driver_name[] =3D "pegasus"; BMSR_100FULL | BMSR_ANEGCAPABLE) #define CARRIER_CHECK_DELAY (2 * HZ) =20 +/* + * USB endpoints. + */ + +enum pegasus_usb_ep { + PEGASUS_USB_EP_CONTROL =3D 0, + PEGASUS_USB_EP_BULK_IN =3D 1, + PEGASUS_USB_EP_BULK_OUT =3D 2, + PEGASUS_USB_EP_INT_IN =3D 3, +}; + static bool loopback; static bool mii_mode; static char *devid; @@ -542,7 +553,7 @@ static void read_bulk_callback(struct urb *urb) goto tl_sched; goon: usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, - usb_rcvbulkpipe(pegasus->usb, 1), + usb_rcvbulkpipe(pegasus->usb, PEGASUS_USB_EP_BULK_IN), pegasus->rx_skb->data, PEGASUS_MTU, read_bulk_callback, pegasus); rx_status =3D usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC); @@ -582,7 +593,7 @@ static void rx_fixup(struct tasklet_struct *t) return; } usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, - usb_rcvbulkpipe(pegasus->usb, 1), + usb_rcvbulkpipe(pegasus->usb, PEGASUS_USB_EP_BULK_IN), pegasus->rx_skb->data, PEGASUS_MTU, read_bulk_callback, pegasus); try_again: @@ -710,7 +721,7 @@ static netdev_tx_t pegasus_start_xmit(struct sk_buff *s= kb, ((__le16 *) pegasus->tx_buff)[0] =3D cpu_to_le16(l16); skb_copy_from_linear_data(skb, pegasus->tx_buff + 2, skb->len); usb_fill_bulk_urb(pegasus->tx_urb, pegasus->usb, - usb_sndbulkpipe(pegasus->usb, 2), + usb_sndbulkpipe(pegasus->usb, PEGASUS_USB_EP_BULK_OUT), pegasus->tx_buff, count, write_bulk_callback, pegasus); if ((res =3D usb_submit_urb(pegasus->tx_urb, GFP_ATOMIC))) { @@ -837,7 +848,7 @@ static int pegasus_open(struct net_device *net) set_registers(pegasus, EthID, 6, net->dev_addr); =20 usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, - usb_rcvbulkpipe(pegasus->usb, 1), + usb_rcvbulkpipe(pegasus->usb, PEGASUS_USB_EP_BULK_IN), pegasus->rx_skb->data, PEGASUS_MTU, read_bulk_callback, pegasus); if ((res =3D usb_submit_urb(pegasus->rx_urb, GFP_KERNEL))) { @@ -848,7 +859,7 @@ static int pegasus_open(struct net_device *net) } =20 usb_fill_int_urb(pegasus->intr_urb, pegasus->usb, - usb_rcvintpipe(pegasus->usb, 3), + usb_rcvintpipe(pegasus->usb, PEGASUS_USB_EP_INT_IN), pegasus->intr_buff, sizeof(pegasus->intr_buff), intr_callback, pegasus, pegasus->intr_interval); if ((res =3D usb_submit_urb(pegasus->intr_urb, GFP_KERNEL))) { @@ -1133,10 +1144,24 @@ static int pegasus_probe(struct usb_interface *intf, pegasus_t *pegasus; int dev_index =3D id - pegasus_ids; int res =3D -ENOMEM; + static const u8 bulk_ep_addr[] =3D { + PEGASUS_USB_EP_BULK_IN | USB_DIR_IN, + PEGASUS_USB_EP_BULK_OUT | USB_DIR_OUT, + 0}; + static const u8 int_ep_addr[] =3D { + PEGASUS_USB_EP_INT_IN | USB_DIR_IN, + 0}; =20 if (pegasus_blacklisted(dev)) return -ENODEV; =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(&intf->dev, "Missing or invalid endpoints\n"); + return -ENODEV; + } + net =3D alloc_etherdev(sizeof(struct pegasus)); if (!net) goto out; --=20 2.34.1