[PATCH v2 for-11.2 0/2] net/checksum.c: Fix errors in dealing with IP header length

Peter Maydell posted 2 patches 1 week, 1 day ago
include/net/checksum.h |  2 +-
net/checksum.c         | 46 ++++++++++++++++++++++++++++++------------
2 files changed, 34 insertions(+), 14 deletions(-)
[PATCH v2 for-11.2 0/2] net/checksum.c: Fix errors in dealing with IP header length
Posted by Peter Maydell 1 week, 1 day ago
The main point of this patchset is patch 1, which fixes a bug where a
crafted packet whose header fields claimed a header length smaller
than its total length could cause us to set ip_len to a negative
value, which then (because of a signed vs unsigned comparison where
ip_len gets promoted to unsigned) makes it through range checks so
that we checksum 64K of data off the end of the packet buffer and then
write the two byte checksum also potentially off the end of the packet
buffer.

This is CVE-2026-127233. The code is used by at least xen-nic,
virtio-net and the COLO filter rewriter, as well as various
out-of-security-scope devices, though it's not clear whether the bug
is exploitable in all those scenarios.

Patch 2 fixes something noted by one of the reporters in passing,
which is that we don't account for IP options in figuring out the
offset of the TCP or UDP header in the packet, which means that we
will write the checksum to the wrong place. This is just incorrect
behaviour, not a security issue.

v1->v2 changes:
 * use 'size_t' for length argument, and drop assert(length >= 0)
 * use 'unsigned int' for mac_hdr_len, ip_len, ip_hdr_len
 * use 'void *' for ip_payload, and drop casts

thanks
-- PMM

Peter Maydell (2):
  net/checksum.c: Correct handling of IP header length
  net/checksum: Correct handling of checksums when IP options present

 include/net/checksum.h |  2 +-
 net/checksum.c         | 46 ++++++++++++++++++++++++++++++------------
 2 files changed, 34 insertions(+), 14 deletions(-)

-- 
2.43.0
Re: [PATCH v2 for-11.2 0/2] net/checksum.c: Fix errors in dealing with IP header length
Posted by Akihiko Odaki 21 hours ago
On 2026/11/14 22:23, Peter Maydell wrote:
> The main point of this patchset is patch 1, which fixes a bug where a
> crafted packet whose header fields claimed a header length smaller
> than its total length could cause us to set ip_len to a negative
> value, which then (because of a signed vs unsigned comparison where
> ip_len gets promoted to unsigned) makes it through range checks so
> that we checksum 64K of data off the end of the packet buffer and then
> write the two byte checksum also potentially off the end of the packet
> buffer.
> 
> This is CVE-2026-127233. The code is used by at least xen-nic,
> virtio-net and the COLO filter rewriter, as well as various
> out-of-security-scope devices, though it's not clear whether the bug
> is exploitable in all those scenarios.
> 
> Patch 2 fixes something noted by one of the reporters in passing,
> which is that we don't account for IP options in figuring out the
> offset of the TCP or UDP header in the packet, which means that we
> will write the checksum to the wrong place. This is just incorrect
> behaviour, not a security issue.
> 
> v1->v2 changes:
>   * use 'size_t' for length argument, and drop assert(length >= 0)
>   * use 'unsigned int' for mac_hdr_len, ip_len, ip_hdr_len
>   * use 'void *' for ip_payload, and drop casts
> 
> thanks
> -- PMM
> 
> Peter Maydell (2):
>    net/checksum.c: Correct handling of IP header length
>    net/checksum: Correct handling of checksums when IP options present
> 
>   include/net/checksum.h |  2 +-
>   net/checksum.c         | 46 ++++++++++++++++++++++++++++++------------
>   2 files changed, 34 insertions(+), 14 deletions(-)
> 

Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>

Regards,
Akihiko Odaki
Re: [PATCH v2 for-11.2 0/2] net/checksum.c: Fix errors in dealing with IP header length
Posted by Richard Henderson 5 days, 10 hours ago
On 11/14/26 05:23, Peter Maydell wrote:
> v1->v2 changes:
>   * use 'size_t' for length argument, and drop assert(length >= 0)
>   * use 'unsigned int' for mac_hdr_len, ip_len, ip_hdr_len
>   * use 'void *' for ip_payload, and drop casts
> 
> thanks
> -- PMM
> 
> Peter Maydell (2):
>    net/checksum.c: Correct handling of IP header length
>    net/checksum: Correct handling of checksums when IP options present

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~