Netdev List
 help / color / mirror / Atom feed
From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: netdev@vger.kernel.org
Subject: Re: [PATCH net v2] vrf: pull the full IPv4 header on xmit
Date: Tue, 1 Dec 2026 18:21:16 +0100	[thread overview]
Message-ID: <b93b11f1-a22c-4977-8122-4596217e2394@6wind.com> (raw)
In-Reply-To: <20261130204412.632027-1-xmei5@asu.edu>

Le 30/11/2026 à 21:44, Xiang Mei a écrit :> A frame sent on a VRF device with
AF_PACKET carries an IPv4 header
> written by the user.  vrf_process_v4_outbound() makes sure the first 20
> bytes are there, but never checks that the packet is as long as the
> header says it is (ihl * 4).
> 
> With a transport-mode ESP SA, xfrm4_transport_output() strips ihl * 4
> bytes from the front of the packet.  If the packet is shorter than that,
> skb->len wraps around to ~4G and ESP walks off the end of the
> scatterlist.  An unprivileged user can do this inside a user + net
> namespace:
> 
>   Oops: general protection fault, probably for non-canonical address ...
>   KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
>   RIP: 0010:scatterwalk_ffwd (crypto/scatterwalk.c:191)
>   Call Trace:
>    crypto_authenc_encrypt (crypto/authenc.c:201)
>    crypto_aead_encrypt (crypto/aead.c:91)
>    esp_output_tail (net/ipv4/esp4.c:600)
>    esp_output (net/ipv4/esp4.c:675)
>    xfrm_output_resume (net/xfrm/xfrm_output.c:562 net/xfrm/xfrm_output.c:597)
>    xfrm_output (net/xfrm/xfrm_output.c:656 net/xfrm/xfrm_output.c:837)
>    __xfrm4_output (net/ipv4/xfrm4_output.c:28)
>    xfrm4_output (./include/linux/netfilter.h:314 net/ipv4/xfrm4_output.c:33)
>    vrf_ip_local_out (./include/net/dst.h:471 drivers/net/vrf.c:485)
>    vrf_xmit (drivers/net/vrf.c:537 ... drivers/net/vrf.c:568)
>    dev_hard_start_xmit (net/core/dev.c:4084)
>    __dev_queue_xmit (net/core/dev.c:5101)
>    packet_xmit (net/packet/af_packet.c:274)
>    packet_sendmsg (net/packet/af_packet.c:3209)
>    __sock_sendmsg (net/socket.c:818)
>    __sys_sendto (net/socket.c:2283)
>    __x64_sys_sendto (net/socket.c:2286)
>    do_syscall_64 (arch/x86/entry/syscall_64.c:89)
>    entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
>   Kernel panic - not syncing: Fatal exception in interrupt
> 
> Drop the frame if ihl < 5 or not all ihl * 4 header bytes are present,
> the same checks ip_rcv_core() does for received packets.
Nit: ip_rcv_core() also checks version != 4

> 
> Cc: stable@vger.kernel.org
> Fixes: 193125dbd8eb ("net: Introduce VRF device driver")
> Reported-by: co+bfd69dd4e073f1e9@bugs.sh
I did not found the report on netdev. checkpatch complains that Reported-by:
should be immediately followed by a Closes: or Link: tag pointing to the report.

The commit log should state how the issue was discovered, please see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/maintainer-netdev.rst#n286

> Signed-off-by: Xiang Mei <xmei5@asu.edu>
Please also add a changelog below the "---" line, with a link to the
previous postings:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/maintainer-netdev.rst#n235

> ---
>  drivers/net/vrf.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
> index 79d433f49f80..d90b7e8fb158 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;
> +

nit: one if would do the job:
if (!pskb_may_pull(skb, ETH_HLEN + sizeof(struct iphdr)) ||
    ip_hdr(skb)->ihl < 5 ||
    !pskb_may_pull(skb, ETH_HLEN + ip_hdr(skb)->ihl * 4))
        goto err;


>  	ip4h = ip_hdr(skb);
>  
>  	memset(&fl4, 0, sizeof(fl4));


  parent reply	other threads:[~2026-12-01 17:21 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 [this message]
2026-12-01 20:45 ` netdev-bot+sashiko

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=b93b11f1-a22c-4977-8122-4596217e2394@6wind.com \
    --to=nicolas.dichtel@6wind.com \
    --cc=netdev@vger.kernel.org \
    /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