Re: [PATCH net] net/sched: act_csum: bound the IPv6 jumbo payload length

From: Piyus Kedia

Date: Mon Nov 16 2026 - 13:22:17 EST


> Could the changelog say that TCP and ICMP csum configurations (for
> example "action csum tcp") were also exposed to a bounded over-read? As
> written, it reads as if only TCA_CSUM_UPDATE_FLAG_UDPLITE setups were
> affected.

You are right. v2 follows this mail with the changelog corrected. v1
claimed those handlers were "protected by accident" because csum_partial()
takes an int; that is true only of the kernel it was tested on, and I
should have checked why.

The reason is worth putting in the changelog, because it is also why a
KASAN fuzzer cannot find those three paths. On x86 there are two
implementations of csum_partial() and the configuration chooses between
them:

arch/x86/Kconfig
config GENERIC_CSUM
bool
default y if KMSAN || KASAN

arch/x86/lib/Makefile
ifneq ($(CONFIG_GENERIC_CSUM),y)
lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o
endif

lib/Makefile
obj-$(CONFIG_GENERIC_CSUM) += checksum.o

So a kernel with KASAN gets lib/checksum.c, whose do_csum() opens with

if (len <= 0)
goto out;

and a negative length reads nothing. A kernel without KASAN - which is
to say a production kernel - gets arch/x86/lib/csum-partial_64.c, which
has no such test and dispatches like this:

if (likely(len >= 80)) { ... } /* signed, false when negative */
if (len >= 40) { ... } /* signed, false */
if (len & 32) { ... } /* bitwise, runs */
if (len & 16) { ... }
if (len & 8) { ... }
if (len & 7) { ... }

The first two tests are signed comparisons and the last four are bitwise,
so a negative length reads whatever its low six bits say, up to
32+16+8+7 = 63 bytes. Your example confirms it exactly: len = -70 is
0xFFFFFFBA, low byte 1011 1010, so the 32, 16, 8 and 2 blocks run and 58
bytes are summed from the transport header.

That is why the KASAN report in the changelog names lib/checksum.c:119
rather than the x86_64 file, and why only the UDP-Lite arm showed up: on
the kernel that found this, the other three paths genuinely did read
nothing, because enabling the sanitiser had replaced the implementation
that would have over-read. The over-read on tcf_csum_ipv6_tcp(),
tcf_csum_ipv6_icmp() and the ul == 0 arm of tcf_csum_ipv6_udp() is real,
it is bounded at 63 bytes rather than 65535, and it is invisible to the
tool that would normally catch it.

This is a new posting rather than a reply in the old thread, so here is
the context. v1 and the review being answered:

https://lore.kernel.org/r/20261112075445.3555341-1-piyus@xxxxxxxxxxx

and the [BUG] report, with the original KASAN trace and the reproduction
conditions, which went out as its own thread - not threaded with v1, which
is my fault:

https://lore.kernel.org/r/20261112075159.3552470-1-piyus@xxxxxxxxxxx

I checked your arithmetic and the three call sites before writing this,
on net-next: act_csum.c:245, :196 and :343 respectively, each reached
with the negative value behind only the wrapping pskb_may_pull() in
tcf_csum_skb_nextlayer().

The code change is unchanged in v2 - as you say, bounding *pl in
tcf_csum_ipv6_hopopts() closes all four paths, so the diff is byte-for-byte
the same. Only the changelog grows: it now says that TCP, ICMP and the
ul == 0 UDP-Lite arm were exposed to a bounded over-read of up to 63 bytes
on kernels without KASAN, and that the 65535-byte read is the UDP-Lite case
specifically.

Thank you for the review - the KASAN-swaps-the-implementation part is
something I would not have gone looking for.