From: Paolo Abeni <pabeni@redhat.com>
To: kuniyu@google.com
Cc: willemb@google.com, serge@hallyn.com,
linux-security-module@vger.kernel.org, netdev@vger.kernel.org,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, dsahern@kernel.org, jmorris@namei.org,
casey@schaufler-ca.com, paul@paul-moore.com, kuni1840@gmail.com,
fw@strlen.de, horms@kernel.org, willemdebruijn.kernel@gmail.com
Subject: Re: [v2,net-next,07/15] udp: Remove partial csum code in RX.
Date: Tue, 10 Mar 2026 11:25:55 +0100 [thread overview]
Message-ID: <20260310102555.147680-1-pabeni@redhat.com> (raw)
In-Reply-To: <20260305215013.2984628-8-kuniyu@google.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
udp: Remove partial csum code in RX.
This commit removes UDP-Lite specific partial checksum handling from UDP
receive paths, including removal of UDP_SKB_CB fields, simplification of
checksum initialization functions, and elimination of UDP-Lite guards.
Link: https://lore.kernel.org/netdev/20260305215013.2984628-8-kuniyu@google.com/
> diff --git a/include/net/udp.h b/include/net/udp.h
> --- a/include/net/udp.h
> +++ b/include/net/udp.h
[ ... ]
> diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> --- a/net/ipv4/udp.c
> +++ b/net/ipv4/udp.c
[ ... ]
> @@ -2703,14 +2647,15 @@ static int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
> if (ulen > skb->len)
> goto short_packet;
>
> - if (proto == IPPROTO_UDP) {
> - /* UDP validates ulen. */
> - if (ulen < sizeof(*uh) || pskb_trim_rcsum(skb, ulen))
> + /* UDP validates ulen. */
> + if (ulen < sizeof(*uh)) {
> + if (pskb_trim_rcsum(skb, ulen))
> goto short_packet;
> +
> uh = udp_hdr(skb);
> }
>
> - if (udp4_csum_init(skb, uh, proto))
> + if (udp4_csum_init(skb, uh))
> goto csum_error;
>
Does this refactoring introduce two bugs?
The old code checked both conditions with short-circuit OR:
if (ulen < sizeof(*uh) || pskb_trim_rcsum(skb, ulen))
goto short_packet;
This correctly (1) rejected packets where ulen < 8, and (2) trimmed the
SKB to the declared UDP length when ulen < skb->len.
The new code changes the logic structure:
if (ulen < sizeof(*uh)) {
if (pskb_trim_rcsum(skb, ulen))
goto short_packet;
uh = udp_hdr(skb);
}
First potential bug: When sizeof(*uh) <= ulen < skb->len, the entire block
is skipped. This means pskb_trim_rcsum() is never called, so the SKB
retains trailing data beyond the declared UDP length. Won't this cause
checksum calculations to include extraneous bytes, leading to valid packets
being incorrectly rejected?
This scenario occurs when UDP length < IP payload length, which can happen
with malformed or crafted packets.
Second potential bug: When ulen < sizeof(*uh), the old code would
immediately goto short_packet via the || short-circuit. The new code enters
the block and tries to trim the SKB to a sub-header-size length. If
pskb_trim_rcsum() succeeds, processing continues with skb->len <
sizeof(struct udphdr). Is this safe?
Looking at the IPv6 counterpart __udp6_lib_rcv(), it handles this
differently:
if (ulen < sizeof(*uh))
goto short_packet;
if (ulen < skb->len) {
if (pskb_trim_rcsum(skb, ulen))
goto short_packet;
saddr = &ipv6_hdr(skb)->saddr;
daddr = &ipv6_hdr(skb)->daddr;
uh = udp_hdr(skb);
}
Should the IPv4 code follow the same pattern, or should it preserve the
original short-circuit logic:
if (ulen < sizeof(*uh) || pskb_trim_rcsum(skb, ulen))
goto short_packet;
uh = udp_hdr(skb);
next prev parent reply other threads:[~2026-03-10 10:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 21:49 [PATCH v2 net-next 00/15] udp: Retire UDP-Lite Kuniyuki Iwashima
2026-03-05 21:49 ` [PATCH v2 net-next 01/15] udp: Make udp[46]_seq_show() static Kuniyuki Iwashima
2026-03-05 21:49 ` [PATCH v2 net-next 02/15] ipv6: Retire UDP-Lite Kuniyuki Iwashima
2026-03-05 21:49 ` [PATCH v2 net-next 03/15] ipv6: Remove UDP-Lite support for IPV6_ADDRFORM Kuniyuki Iwashima
2026-03-05 21:49 ` [PATCH v2 net-next 04/15] ipv4: Retire UDP-Lite Kuniyuki Iwashima
2026-03-05 21:49 ` [PATCH v2 net-next 05/15] udp: Remove UDP-Lite SNMP stats Kuniyuki Iwashima
2026-03-05 21:49 ` [PATCH v2 net-next 06/15] smack: Remove IPPROTO_UDPLITE support in security_sock_rcv_skb() Kuniyuki Iwashima
2026-03-05 21:49 ` [PATCH v2 net-next 07/15] udp: Remove partial csum code in RX Kuniyuki Iwashima
2026-03-10 10:25 ` Paolo Abeni [this message]
2026-03-10 16:17 ` [v2,net-next,07/15] " Kuniyuki Iwashima
2026-03-10 20:00 ` [PATCH v2 net-next 07/15] " David Laight
2026-03-05 21:49 ` [PATCH v2 net-next 08/15] udp: Remove partial csum code in TX Kuniyuki Iwashima
2026-03-05 21:49 ` [PATCH v2 net-next 09/15] udp: Remove UDPLITE_SEND_CSCOV and UDPLITE_RECV_CSCOV Kuniyuki Iwashima
2026-03-05 21:49 ` [PATCH v2 net-next 10/15] udp: Remove struct proto.h.udp_table Kuniyuki Iwashima
2026-03-05 21:49 ` [PATCH v2 net-next 11/15] udp: Remove udp_table in struct udp_seq_afinfo Kuniyuki Iwashima
2026-03-05 21:49 ` [PATCH v2 net-next 12/15] udp: Remove dead check in __udp[46]_lib_lookup() for BPF Kuniyuki Iwashima
2026-03-05 21:49 ` [PATCH v2 net-next 13/15] udp: Don't pass udptable to IPv6 socket lookup functions Kuniyuki Iwashima
2026-03-05 21:50 ` [PATCH v2 net-next 14/15] udp: Don't pass udptable to IPv4 " Kuniyuki Iwashima
2026-03-05 21:50 ` [PATCH v2 net-next 15/15] udp: Don't pass proto to __udp4_lib_rcv() and __udp6_lib_rcv() Kuniyuki Iwashima
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260310102555.147680-1-pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=casey@schaufler-ca.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=horms@kernel.org \
--cc=jmorris@namei.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=kuniyu@google.com \
--cc=linux-security-module@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
--cc=willemb@google.com \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox