Article View: linux.kernel.netdev
Article #19526[PATCH v2] net: hso: cap the MTU and drop oversized frames
From: Aibing Chen
Date: Fri, 20 Nov 2026 01:23
Date: Fri, 20 Nov 2026 01:23
56 lines
10800 bytes
10800 bytes
hso_net_start_xmit() copies skb->len bytes into odev->mux_bulk_tx_buf,
which is a fixed MUX_BULK_TX_BUF_SIZE (2048) allocation made by
hso_create_net_device(), and passes the same length to
usb_fill_bulk_urb(). Nothing bounds skb->len today: the net device does
not set max_mtu, and even with max_mtu set the core does not clamp the
length of the frames handed to ndo_start_xmit(), so AF_PACKET with
PACKET_VNET_HDR, tpacket_snd() with a vnet header and an IPv4 route MTU
metric above the device MTU can all deliver larger skbs.
Cap the MTU at the buffer size and drop oversized frames in
hso_net_start_xmit() instead of copying them past the end of the buffer.
Fixes: 72dc1c096c70 ("HSO: add option hso driver")
Cc: stable@vger.kernel.org
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
v2:
- also drop frames larger than MUX_BULK_TX_BUF_SIZE in hso_net_start_xmit()
with tx_dropped accounting: the max_mtu cap alone does not bound
skb->len, as pointed out in the netdev review.
drivers/net/usb/hso.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 71caa3764..0df1d19cc 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -769,6 +769,18 @@ static netdev_tx_t hso_net_start_xmit(struct sk_buff *skb,
struct hso_net *odev = netdev_priv(net);
int result;
+ /*
+ * max_mtu only limits the MTU userspace can configure; the core does
+ * not clamp skb->len to it (AF_PACKET with PACKET_VNET_HDR, tpacket_snd()
+ * with a vnet header and a route MTU metric above the device MTU can all
+ * deliver larger frames), so drop anything that does not fit here.
+ */
+ if (unlikely(skb->len > MUX_BULK_TX_BUF_SIZE)) {
+ net->stats.tx_dropped++;
+ kfree_skb_reason(skb, SKB_DROP_REASON_PKT_TOO_BIG);
+ return NETDEV_TX_OK;
+ }
+
/* Tell the kernel, "No more frames 'til we are done with this one." */
netif_stop_queue(net);
if (hso_get_activity(odev->parent) == -EAGAIN) {
@@ -2393,6 +2405,7 @@ static void hso_net_init(struct net_device *net)
net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
net->type = ARPHRD_NONE;
net->mtu = DEFAULT_MTU - 14;
+ net->max_mtu = MUX_BULK_TX_BUF_SIZE - 14;
net->tx_queue_len = 10;
net->ethtool_ops = &ops;
Technical Details
Message-ID:
<20261120012309.19-1-chenaibing@cmss.chinamobile.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367528-linux-kernel-netdev=dewy.ruReferences:
<20261116014904.556-1-chenaibing@cmss.chinamobile.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367528-linux-kernel-netdev=dewy.ru From: chenaibing@cmss.chinamobile.com (Aibing Chen) Newsgroups: linux.kernel.netdev Subject: [PATCH v2] net: hso: cap the MTU and drop oversized frames Date: Fri, 20 Nov 2026 09:23:09 +0800 Organization: Usenet Network Message-ID: <20261120012309.19-1-chenaibing@cmss.chinamobile.com> References: <20261116014904.556-1-chenaibing@cmss.chinamobile.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3029448"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:701rrmLdb0/RjNMXq4q815nkCr0= sha256:u1Ct37eJAhd37Gqstpwy5wYDDBii7n+bIDAmUX5uAOY= sha1:HwW+7kAUKQktoHckPYIRGw+U7Fo= sha256:MGFoSYhy2tUPY+3+Wr1BdBKR4wz1HYD7P1+DCaOunxw= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id BB2CA115829; Fri, 20 Nov 2026 04:23:45 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.85 X-Spam-Status: No, score=-2.85 tagged_above=-9999 required=6.31 tests=[DKIM_INVALID=0.1, DKIM_SIGNED=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key) reason="fail (body has been altered)" header.d=cmss.chinamobile.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ph64ML9jsslN; Fri, 20 Nov 2026 04:23:41 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-367528-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id BB79E11548D; Fri, 20 Nov 2026 04:23:31 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id D7ED8610C61; Fri, 20 Nov 2026 01:23:30 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795137806; b=XwWA7NsSiotOIniYYqYiENNvU/PdLOlevi6dVNtA454hTriQckCoMTaQve/8+ERe/9DF innnlz4QCDcK72pmuJI0SfOdxmgwoa8Oi7wNIOM3NYCmgm/Y4R124CL/QQNdSHzzN9yF0 Elabhg2BwbCaWj6t1Eqw8ZPk5/MpHEG8odI3piKGrIknJ2NSNTrfxDR7Rk5/D2NIYbE9S vpC7SLOeWLuEqrH1yYfV5nizuG2jv/vSo0edXWvTl/l8G94sylquy1qZeHs2HWw/eTacH HdVjUgHLBEjPczf8YlUksDrXXoTNrExVETK6BB76thgqruLpmVr5HhZYto2J8UgFXPw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795137806; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo: X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG: Received:X-RM-TRANSID:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=aPwQ4j4gpAhDa+nABR08gUCjnD81/Bc7CRwqvIRsJR4=; b=m2S+iGoeX+MSpbLX14K4+uIEqlQVoRZN32FGtFtO8wJZo1cuMkDIEzmfzTGmLnxPTF66 UA/DwYpZF9Zn8zaGmAw3yRCl37NgewRd7+Vj+5ThTBGQhjXtNVyyvC/dtALZVZYRs7V2e 6omj1FqfXzH/hat8px1yin3CjLgts/kLWwIWUq2iGEuCbZh+lMa/YqmULNNf5OLGOUYV0 p/dsddAZnUWzGzR5Yo/tkK3bhx7Xzr9zKXiVf2mzRvNY4JyGkErFpWbbpvhoiMxwnYPha 17dQSQ4mg4TAuY/iLSvKraq9qCl5yP324sDlfZWmePUiNyZ32FLJ3gCaBdMyLvXZhqA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=vWIfijUG; dmarc=pass header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64502606A326; Fri, 20 Nov 2026 01:23:26 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=vWIfijUG X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.139 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795137800; b=U6qvFUSGD1Eib8VqLT2WpO/AK/AHWovNahhtdQMNgh2GfWbkKRiR97U5NYAoeKntx9BD EIGBP3v38p9zIcLsvZmLzdjzL8Tvfe16bqt2LI2b7e/mvKLwHIPuTn+eA+p6Bud+oJjPZ s1K9raClAEJJ9gU0zo7wNm22n25P5GFqd9mPLVcBu1MRe5Dl071scFZNwUtTeU882SNEg YcRU86xMzDVQkJUu2FVu2Zi+uNFc2PDOc4FG5flQQuLrfrFqoFWFWdGkzeazRkAHwVe0P Rgea6cvTlnTtb6kF498ohBzi8S2dYDWW2Fma62gR8lXNFJR2MX5X3sdvBpFRdtta0cA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795137800; h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received: X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From: To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=aPwQ4j4gpAhDa+nABR08gUCjnD81/Bc7CRwqvIRsJR4=; b=AfME2KXaf6p7XGOrR4lmJBT2gE2IVs8nufPoylj0F3RFdyqNfFx63QiMLz+BDJRkMeT7 Y24fn1rkE7jVSRyprnN6jYN3/49yKpcP5/zyFBsfArBPZ20jXftzOEO4Q0ygikezi9+7x wEdEBMRCPvdUAUkhj0KSqjaoE/8EaZisgTiCQDo1TrJk/pny/rOKZtuS6F4UeAdiuqfSg y3ClGE6lq/BVQw/NP5GZgIh/Buis5dQr/IRA53TKn9ipwAaThTGHzKrD0lh0B5zQoQQPH DL5M3BLi4RaLKKHCYSsjaUkkw5qlzuOC0ZjLNJfTKeGVT5skn/YfO5HMOjE0QozLOaQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.com; dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=vWIfijUG; arc=none smtp.remote-ip=111.22.67.139 X-Received: from cmccmta6.chinamobile.com (cmccmta6.chinamobile.com [111.22.67.139]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C87B7606A320; Fri, 20 Nov 2026 01:23:17 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C87B7606A320 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmss.chinamobile.com; s=default; l=0; h=from:subject:message-id:to:cc:mime-version; bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=; b=vWIfijUGnJ6H96Cr5pSJlX6Nv7q9Pbr2VuFZB0a6YxQGC+8qsuQ2L8V3uQbSm1I/8MDJgXDPUIA97 mI9BQ4guIG5sZcUcX/WUb1zOCFov20bF6/smwAPO3BXRtTSLrh0fs89yNaUQKjVam+96olq/WLtU0r w4vB6Oe//BpRBl+Q= X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87]) by rmmx-syy-dmz-app09-12009 (RichMail) with SMTP id 2ee96affa0ffb08-274cb; Fri, 20 Nov 2026 09:23:12 +0800 (CST) X-RM-TRANSID: 2ee96affa0ffb08-274cb X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-Received: from FHD-W7400297 (unknown[10.55.1.70]) by rmsmtp-syy-appsvr06-12006 (RichMail) with SMTP id 2ee66affa0fe9ee-0f733; Fri, 20 Nov 2026 09:23:12 +0800 (CST) X-RM-TRANSID: 2ee66affa0fe9ee-0f733 X-Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: git-send-email 2.50.1.windows.1 X-In-Reply-To: <20261116014904.556-1-chenaibing@cmss.chinamobile.com> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list