mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] xsk: reject TX checksum requests that overflow skb->csum_start
@ 2026-11-16 16:28 Tianyi Gao
  2026-11-16 16:32 ` netdev-bot+sinfo
  0 siblings, 1 reply; 3+ messages in thread
From: Tianyi Gao @ 2026-11-16 16:28 UTC (permalink / raw)
  To: netdev
  Cc: magnus.karlsson, maciej.fijalkowski, sdf, davem, edumazet, kuba,
	pabeni, horms, ast, daniel, hawk, john.fastabend,
	yoong.siang.song, kerneljasonxing, bpf, linux-kernel,
	kernel-team, tianyi.gao, Tianyi Gao, Sashiko

xsk_skb_metadata() sets the u16 skb->csum_start to hr + csum_start. With
64K pages, csum_start can be close to U16_MAX, so the sum can overflow.
The checksum offset then becomes negative. With XDP_UMEM_TX_SW_CSUM,
skb_checksum_help() triggers a warning. Without it, the device gets a
CHECKSUM_PARTIAL skb with a negative offset.

Reject this with -EINVAL. Use the limit of skb_partial_csum_set(), which
also rejects U16_MAX, the "not set" value of transport_header. That
helper cannot be used here, as the skb built for an IFF_TX_SKB_NO_LINEAR
device has no linear data.

Fixes: 48eb03dd2630 ("xsk: Add TX timestamp and TX checksum offload support")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/all/sashiko-outbox-203545@kernel.org/
Signed-off-by: Tianyi Gao <tianyi@cloudflare.com>
---
Sashiko reported this in [1], and earlier in [2][3].

Returning -EINVAL leaves the descriptor in the TX ring, as the current
check does [2]. That is a separate issue and out of scope here.

There is no selftest. The umem chunk size is at most PAGE_SIZE, so only
a 64K-page kernel can hit this.

[1] https://lore.kernel.org/all/sashiko-outbox-203545@kernel.org/
[2] https://lore.kernel.org/all/20260518063407.C3B99C2BCB7@smtp.kernel.org/
[3] https://lore.kernel.org/all/20260531042721.DBD4B1F00893@smtp.kernel.org/

 net/xdp/xsk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index f22f9a2cdbbe..ab2e4fa87a4f 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -1006,7 +1006,8 @@ static int xsk_skb_metadata(struct sk_buff *skb, void *buffer,
 		csum_offset = READ_ONCE(meta->request.csum_offset);
 
 		if (unlikely(csum_start + csum_offset +
-			     sizeof(__sum16) > desc->len))
+			     sizeof(__sum16) > desc->len ||
+			     hr + csum_start >= U16_MAX))
 			return -EINVAL;
 
 		skb->csum_start = hr + csum_start;

base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] xsk: reject TX checksum requests that overflow skb->csum_start
  2026-11-16 16:28 [PATCH net] xsk: reject TX checksum requests that overflow skb->csum_start Tianyi Gao
@ 2026-11-16 16:32 ` netdev-bot+sinfo
  2026-11-16 17:03   ` Tianyi Gao
  0 siblings, 1 reply; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-11-16 16:32 UTC (permalink / raw)
  To: Tianyi Gao
  Cc: netdev, magnus.karlsson, maciej.fijalkowski, sdf, davem,
	edumazet, kuba, pabeni, horms, ast, daniel, hawk, john.fastabend,
	yoong.siang.song, kerneljasonxing, bpf, linux-kernel,
	kernel-team, tianyi.gao, Sashiko

Hi!

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

 - 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] xsk: reject TX checksum requests that overflow skb->csum_start
  2026-11-16 16:32 ` netdev-bot+sinfo
@ 2026-11-16 17:03   ` Tianyi Gao
  0 siblings, 0 replies; 3+ messages in thread
From: Tianyi Gao @ 2026-11-16 17:03 UTC (permalink / raw)
  To: netdev-bot+sinfo
  Cc: netdev, magnus.karlsson, maciej.fijalkowski, sdf, davem,
	edumazet, kuba, pabeni, horms, ast, daniel, hawk, john.fastabend,
	yoong.siang.song, kerneljasonxing, bpf, linux-kernel,
	kernel-team, tianyi.gao, Sashiko

Hi,

On Mon, Nov 16, 2026 at 04:32:14PM +0000, netdev-bot+sinfo@kernel.org wrote:
>  - 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.

Sashiko reported this several times, and I reproduced it on a 64K-page
arm64 kernel built from net at aa40afa831eb, under QEMU.

The test sends one TX descriptor from an AF_XDP socket in copy mode on a
veth device, with XDP_UMEM_TX_SW_CSUM, a 64K chunk, a length of 65520,
csum_start 65500 and csum_offset 6. The headroom is 64, so
skb->csum_start wraps to 28:

  skb len=65520 data_len=0 headroom=64 headlen=65520 tailroom=65168
  csum(0x6001c start=28 offset=6 ip_summed=3 complete_sw=0 valid=0 level=0)
  ...
  offset (-36) >= skb_headlen() (65520)
  WARNING: net/core/dev.c:3696 at skb_checksum_help+0x1d0/0x238, CPU#0: xsk_csum_overfl/200
  ...
  Call trace:
   skb_checksum_help+0x1d0/0x238 (P)
   __xsk_generic_xmit+0xb90/0xdf0
   xsk_sendmsg+0xcc/0x188
   __sys_sendto+0x128/0x1c0
   __arm64_sys_sendto+0x2c/0x48
   invoke_syscall.constprop.0+0x60/0x108
   do_el0_svc+0x48/0xd8
   el0_svc+0x40/0x238
   el0t_64_sync_handler+0xa0/0xe8
   el0t_64_sync+0x198/0x1a0

With this patch, sendmsg() returns -EINVAL and there is no warning.

Cheers,
Tianyi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-16 17:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 16:28 [PATCH net] xsk: reject TX checksum requests that overflow skb->csum_start Tianyi Gao
2026-11-16 16:32 ` netdev-bot+sinfo
2026-11-16 17:03   ` Tianyi Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®