From: Paolo Abeni <pabeni@redhat.com>
To: Guoyu Su <yss2813483011xxl@gmail.com>,
edumazet@google.com, davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, horms@kernel.org,
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com,
syzbot+1543a7d954d9c6d00407@syzkaller.appspotmail.com
Subject: Re: [PATCH net v3] net: use skb_header_pointer() only for DODGY TCPv4 GSO skbs
Date: Tue, 17 Mar 2026 11:22:14 +0100 [thread overview]
Message-ID: <0a25f57e-fe08-4fe9-9722-e1c6adb81e91@redhat.com> (raw)
In-Reply-To: <20260312104351.185370-1-yss2813483011xxl@gmail.com>
On 3/12/26 11:43 AM, Guoyu Su wrote:
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 14a83f2035b9..f3340d7dd87c 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -3805,10 +3805,21 @@ static netdev_features_t gso_features_check(const struct sk_buff *skb,
> * segmentation-offloads.rst).
> */
> if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) {
> - struct iphdr *iph = skb->encapsulation ?
> - inner_ip_hdr(skb) : ip_hdr(skb);
> + int nhoff = skb->encapsulation ?
> + skb_inner_network_offset(skb) :
> + skb_network_offset(skb);
> + const struct iphdr *iph;
>
> - if (!(iph->frag_off & htons(IP_DF)))
> + if (unlikely(skb_shinfo(skb)->gso_type & SKB_GSO_DODGY)) {
> + struct iphdr _iph;
> +
> + iph = nhoff < 0 ? NULL :
> + skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph);
> + } else {
> + iph = skb->encapsulation ? inner_ip_hdr(skb) : ip_hdr(skb);
> + }
> +
> + if (!iph || !(iph->frag_off & htons(IP_DF)))
> features &= ~dev->mangleid_features;
AI review noted the following:
Does this code use `_iph` after it goes out of scope?
The stack-local variable `_iph` is declared inside the
`if (unlikely(...SKB_GSO_DODGY))` block, but `iph` (which may point to
`&_iph` when skb_header_pointer() copies the header) is dereferenced via
`iph->frag_off` after that block's closing brace, where `_iph` is out of
scope.
When skb_header_pointer() needs to copy the IP header from paged
fragments (the exact scenario this patch targets for DODGY packets from
AF_PACKET or HSR), it returns `&_iph`. The subsequent access to
`iph->frag_off` then reads from a dead stack variable.
All other skb_header_pointer() usage patterns in the kernel declare the
buffer at the same scope as the pointer usage. For example, in
qdisc_pkt_len_segs_init():
static int qdisc_pkt_len_segs_init(struct sk_buff *skb)
{
const struct skb_shared_info *shinfo = skb_shinfo(skb);
unsigned int hdr_len, mss = shinfo->gso_size;
u16 gso_segs = shinfo->gso_segs;
const struct iphdr *iph;
struct iphdr _iph; // <-- buffer declared in same scope as usage
int pkt_len;
...
iph = skb_header_pointer(skb, skb_network_offset(skb),
sizeof(_iph), &_iph);
...
if (iph->protocol != IPPROTO_TCP && iph->protocol != IPPROTO_UDP)
return -EINVAL;
Should `struct iphdr _iph;` be moved to the outer block, next to the
`const struct iphdr *iph;` declaration?
next prev parent reply other threads:[~2026-03-17 10:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 16:29 [PATCH net] net: clear mangleid_features for SKB_GSO_DODGY TCPv4 Guoyu Su
2026-03-07 16:43 ` Eric Dumazet
2026-03-08 8:33 ` [PATCH net v2] net: use skb_header_pointer() in gso_features_check() for TCPv4 GSO Guoyu Su
2026-03-11 0:48 ` Jakub Kicinski
2026-03-12 10:43 ` [PATCH net v3] net: use skb_header_pointer() only for DODGY TCPv4 GSO skbs Guoyu Su
2026-03-17 10:22 ` Paolo Abeni [this message]
2026-03-19 0:54 ` [PATCH net v4] " Guoyu Su
2026-03-19 13:17 ` Willem de Bruijn
2026-03-20 14:14 ` [PATCH net v5] " Guoyu Su
2026-03-20 19:24 ` Willem de Bruijn
2026-03-21 1:36 ` Willem de Bruijn
2026-03-21 15:31 ` Scars
2026-03-21 20:58 ` Willem de Bruijn
2026-03-22 4:26 ` Guoyu Su
2026-03-23 3:36 ` Willem de Bruijn
2026-03-24 10:40 ` Guoyu Su
2026-03-26 3:12 ` Willem de Bruijn
2026-03-26 12:18 ` [PATCH net v6] net: use skb_header_pointer() for TCPv4 GSO frag_off Guoyu Su
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=0a25f57e-fe08-4fe9-9722-e1c6adb81e91@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=syzbot+1543a7d954d9c6d00407@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=yss2813483011xxl@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