๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
8 messages
8 total messages Started by Aibing Chen Mon, 16 Nov 2026 01:49
[PATCH] net: hso: cap the MTU to the mux tx buffer size
#16892
Author: Aibing Chen
Date: Mon, 16 Nov 2026 01:49
29 lines
9363 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().  The net device does not set max_mtu, so
userspace can raise the MTU up to IP_MAX_MTU and make that copy overflow
the buffer; the same length is passed to usb_fill_bulk_urb().

Cap the MTU at the buffer size, keeping the 14 byte allowance that the
default MTU already uses.

Fixes: 72dc1c096c70 ("HSO: add option hso driver")
Cc: stable@vger.kernel.org
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
 drivers/net/usb/hso.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 71caa3764..45713c994 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2393,6 +2393,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;
 
Re: [PATCH] net: hso: cap the MTU to the mux tx buffer size
#16894
Author: netdev-bot+sinfo
Date: Mon, 16 Nov 2026 01:53
23 lines
8671 bytes
Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
Re: [PATCH] net: hso: cap the MTU to the mux tx buffer size
#16916
Author: Aibing Chen
Date: Mon, 16 Nov 2026 02:58
28 lines
10127 bytes
On Mon, 16 Nov 2026 01:53:34 +0000, netdev-bot+sinfo wrote:
>  - How the issue was discovered, e.g. hit in production, hit during
>    development, syzbot report, manual code inspection, LLM or static
>    analysis tool scan.

Code inspection, prompted by the automated review of the companion
skb_tx_buf fix in the same driver:

https://lore.kernel.org/all/179477764293.3136.7267245337781305691@kernel.org/

That review noted that hso_net_start_xmit() copies skb->len bytes into
the fixed MUX_BULK_TX_BUF_SIZE (2048) buffer with no bound check, and
that hso_net_init() never sets max_mtu. Both statements check out in
the source, which is what this patch addresses. The syzbot memory leak
that started the series did not touch this path.

>  - Whether the issue was actually triggered, or is only theoretical
>    (e.g. found by LLM and not proven at runtime). If it was triggered
>    please include the symptoms, like the stack trace or kernel messages.

Theoretical: the overflow was not triggered at runtime and the patch
carries no runtime repro. The overflow is statically decidable from the
code (unbounded memcpy into a fixed 2048-byte allocation, plus the
missing max_mtu), so the fix stands on inspection alone. I chose the
max_mtu cap over a runtime length check because the default MTU already
fits the buffer with the same 14-byte allowance, so there is no reason
to allow a larger one.
Re: [PATCH] net: hso: cap the MTU to the mux tx buffer size
#19346
Author: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 19:50
101 lines
11483 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] This is an incomplete fix: the slab out-of-bounds write in
  hso_net_start_xmit() can still be triggered.

--

net: hso: cap the MTU to the mux tx buffer size

This commit sets net->max_mtu in hso_net_init() to
MUX_BULK_TX_BUF_SIZE - 14. With that cap, userspace can no longer raise
the MTU of an hso net device past the fixed 2048 byte mux_bulk_tx_buf.
The intent is to stop the memcpy() in hso_net_start_xmit() from
overflowing that buffer.

> diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
> index 71caa3764b239..45713c9940894 100644
> --- a/drivers/net/usb/hso.c
> +++ b/drivers/net/usb/hso.c
> @@ -2393,6 +2393,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;

[Severity: High]
Is this enough to keep hso_net_start_xmit() from overflowing
mux_bulk_tx_buf?

max_mtu is only enforced by dev_validate_mtu() when dev->mtu changes.
It does not limit the length of skbs passed to ndo_start_xmit.
hso_net_start_xmit() still copies skb->len bytes without checking it:

drivers/net/usb/hso.c:hso_net_start_xmit() {
    ...
	memcpy(odev->mux_bulk_tx_buf, skb->data, skb->len);
    ...
	usb_fill_bulk_urb(odev->mux_bulk_tx_urb,
			  ...
			  odev->mux_bulk_tx_buf, skb->len, write_bulk_callback,
			  odev);
    ...
}

mux_bulk_tx_buf is still a kzalloc(MUX_BULK_TX_BUF_SIZE) object
allocated in hso_create_net_device().

The stack does not guarantee skb->len <= dev->mtu at this point. These
paths look like they can send larger skbs whatever max_mtu is set to.

AF_PACKET packet_snd() with PACKET_VNET_HDR skips both MTU checks when
vnet_hdr.gso_type is set:

	if (!vnet_hdr.gso_type &&
	    (len > dev->mtu + reserve + VLAN_HLEN + extra_len))

If gso_size is at least the payload size, __virtio_net_hdr_to_skb()
leaves the skb as non-GSO:

	if (skb->len - nh_off > gso_size) {

So the skb is not segmented. validate_xmit_skb() only linearizes it, and
it reaches hso_net_start_xmit() at up to about 64KB.

AF_PACKET tpacket_snd() only clamps size_max to the MTU when no vnet
header is configured:

	if ((size_max > dev->mtu + reserve + VLAN_HLEN) && !vnet_hdr_sz)

The per-frame MTU check is skipped in the same case.

For IPv4, ip_dst_mtu_maybe_forward() returns the route's RTAX_MTU
metric. That value is capped at IP_MAX_MTU but not at dev->mtu or
max_mtu. A route through the hso device with something like
"mtu lock 4000" would send 4000 byte packets to the driver without
fragmenting them.

In each case, an skb longer than 2048 bytes writes data chosen by the
sender past the end of mux_bulk_tx_buf. The same length is also used as
the URB transfer length.

Would a length check in hso_net_start_xmit() before the memcpy() be the
right fix? For example, if skb->len > MUX_BULK_TX_BUF_SIZE, drop the
skb, increment tx_dropped and restart the queue. The max_mtu cap could
stay as an extra guard.

Since this is tagged Cc: stable, wouldn't the backport as written leave
the mux_bulk_tx_buf overflow reachable?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116014904.556-1-chenaibing%40cmss.chinamobile.com
[PATCH v2] net: hso: cap the MTU and drop oversized frames
#19526
Author: Aibing Chen
Date: Fri, 20 Nov 2026 01:23
56 lines
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;
 
Re: [PATCH v2] net: hso: cap the MTU and drop oversized frames
#19527
Author: netdev-bot+sinfo
Date: Fri, 20 Nov 2026 01:26
23 lines
8749 bytes
Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
Re: [PATCH v2] net: hso: cap the MTU and drop oversized frames
#19733
Author: Aibing Chen
Date: Fri, 20 Nov 2026 09:53
18 lines
9359 bytes
Hi,

Same provenance as for v1: the missing bound was found by code inspection,
after the automated review of the companion skb_tx_buf fix in this driver
reported that hso_net_start_xmit() copies skb->len bytes into the fixed
2048 byte mux_bulk_tx_buf without a bound check, and that hso_net_init()
never sets max_mtu.

The overflow itself was not triggered at runtime; it is statically
decidable from the code.  The additional paths listed in the review of v1
(AF_PACKET with PACKET_VNET_HDR, tpacket_snd() with a vnet header, and a
route MTU metric above the device MTU) are covered by the length check
added in v2, which drops such frames with SKB_DROP_REASON_PKT_TOO_BIG and
tx_dropped accounting.

Thanks,
Aibing Chen
Re: [PATCH v2] net: hso: cap the MTU and drop oversized frames
#23922
Author: Simon Horman
Date: Sat, 28 Nov 2026 15:24
18 lines
8615 bytes
On Fri, Nov 20, 2026 at 05:53:37PM +0800, Aibing Chen wrote:
> Hi,
> 
> Same provenance as for v1: the missing bound was found by code inspection,
> after the automated review of the companion skb_tx_buf fix in this driver
> reported that hso_net_start_xmit() copies skb->len bytes into the fixed
> 2048 byte mux_bulk_tx_buf without a bound check, and that hso_net_init()
> never sets max_mtu.
> 
> The overflow itself was not triggered at runtime; it is statically
> decidable from the code.  The additional paths listed in the review of v1
> (AF_PACKET with PACKET_VNET_HDR, tpacket_snd() with a vnet header, and a
> route MTU metric above the device MTU) are covered by the length check
> added in v2, which drops such frames with SKB_DROP_REASON_PKT_TOO_BIG and
> tx_dropped accounting.

Reviewed-by: Simon Horman <horms@kernel.org>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads