From: netdev-bot+sashiko@kernel.org
To: xmei5@asu.edu
Cc: dsahern@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, co+bfd69dd4e073f1e9@bugs.sh
Subject: Re: [PATCH net v2] vrf: pull the full IPv4 header on xmit
Date: Tue, 01 Dec 2026 20:45:22 +0000 [thread overview]
Message-ID: <179615792219.3146.18277936289940113941@kernel.org> (raw)
In-Reply-To: <20261130204412.632027-1-xmei5@asu.edu>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The fix is incomplete because the new IHL length check assumes
the IPv4 header always starts ETH_HLEN bytes into the frame.
--
vrf: pull the full IPv4 header on xmit
This patch adds a check to vrf_process_v4_outbound(). The check drops IPv4
frames sent on a VRF device if ihl < 5, or if fewer than ihl * 4 header
bytes are present. The goal is to stop an skb->len underflow in
xfrm4_transport_output() that makes ESP walk off the end of the
scatterlist.
> diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
> index 79d433f49f803..d90b7e8fb158f 100644
> --- a/drivers/net/vrf.c
> +++ b/drivers/net/vrf.c
> @@ -499,6 +499,10 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
> if (!pskb_may_pull(skb, ETH_HLEN + sizeof(struct iphdr)))
> goto err;
>
> + if (ip_hdr(skb)->ihl < 5 ||
> + !pskb_may_pull(skb, ETH_HLEN + ip_hdr(skb)->ihl * 4))
> + goto err;
> +
[Severity: High]
Is ETH_HLEN the right starting point for this length? ip_hdr() is read at
skb->network_header, but the pull length here is counted from skb->data
with a fixed ETH_HLEN. Later in the same function, the actual network
offset is stripped:
/* strip the ethernet header added for pass through VRF device */
__skb_pull(skb, skb_network_offset(skb));
Can vrf_xmit() get frames where skb_network_offset() is larger than
ETH_HLEN? This path looks like it can produce one:
1. An NBMA ipgre device (no remote, so header_ops is &ipgre_header_ops)
has hard_header_len = tunnel->hlen + sizeof(*iph), which is at least
24 bytes.
2. packet_snd() on a SOCK_RAW socket bound to that device sets
reserve = hard_header_len. The network header therefore starts 24 or
more bytes into the frame.
3. A tc clsact egress "mirred egress redirect dev vrf0" on the GRE device
goes through tcf_mirred_to_dev(). The VRF device uses ether_setup(), so
expects_nh is false. at_nh is also false, so the skb is passed on
unchanged:
expects_nh = want_ingress || !m_mac_header_xmit;
at_nh = skb->data == skb_network_header(skb);
if (at_nh != expects_nh) {
The GRE ingress side looks similar. __ipgre_rcv() calls
skb_pop_mac_header(), and mirred then pushes the outer IP + GRE mac_len
before the skb reaches the VRF device.
Take a network offset of 24, ihl = 15 and a frame length of 74 to 83:
ETH_HLEN + ihl * 4 = 14 + 60 = 74, so the new check passes
__skb_pull(skb, 24) leaves skb->len at 50..59, which is less than 60
If the route lookup returns a transport-mode ESP xfrm dst,
xfrm4_transport_output() runs this without checking the length itself:
__skb_pull(skb, ihl);
Wouldn't skb->len then wrap the same way as in the oops in the commit
message?
If the skb is non-linear, could that __skb_pull() hit the
skb->len < skb->data_len BUG() instead?
The existing 20-byte check just above makes the same ETH_HLEN assumption.
Would checks relative to the network header be more robust, for example:
if (!pskb_network_may_pull(skb, sizeof(struct iphdr)))
goto err;
if (ip_hdr(skb)->ihl < 5 ||
!pskb_network_may_pull(skb, ip_hdr(skb)->ihl * 4))
goto err;
Every step above (GRE link, tc clsact/mirred, VRF, xfrm SA and policy,
AF_PACKET) can be set up inside an unprivileged user + net namespace. That
is the same privilege the reproducer in the commit message needs.
> ip4h = ip_hdr(skb);
>
> memset(&fl4, 0, sizeof(fl4));
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130204412.632027-1-xmei5%40asu.edu
prev parent reply other threads:[~2026-12-01 20:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 20:44 [PATCH net v2] vrf: pull the full IPv4 header on xmit Xiang Mei
2026-11-30 20:46 ` Xiang Mei
2026-12-01 17:21 ` Nicolas Dichtel
2026-12-01 20:45 ` netdev-bot+sashiko [this message]
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=179615792219.3146.18277936289940113941@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=co+bfd69dd4e073f1e9@bugs.sh \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=xmei5@asu.edu \
/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