๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25385

Re: [PATCH net v2] vrf: pull the full IPv4 header on xmit

#25385
From: Nicolas Dichtel
Date: Tue, 01 Dec 2026 17:21
84 lines
14514 bytes
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));
Technical Details
Message-ID: <b93b11f1-a22c-4977-8122-4596217e2394@6wind.com>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375240-linux-kernel-netdev=dewy.ru
References: <20261130204412.632027-1-xmei5@asu.edu>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375240-linux-kernel-netdev=dewy.ru
From: nicolas.dichtel@6wind.com (Nicolas Dichtel)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] vrf: pull the full IPv4 header on xmit
Date: Tue, 1 Dec 2026 18:21:16 +0100
Organization: Usenet Network
Message-ID: <b93b11f1-a22c-4977-8122-4596217e2394@6wind.com>
References: <20261130204412.632027-1-xmei5@asu.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1776569"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:pOxcrMUR7uIG7xvD9DoqPKktrWA= sha256:8sic1bylXBJsV4Rv3oiM/G71IR/3PBQzciTXJ19ethI=
	sha1:3Ch41rQXLsT4lc5rOIC7btgJKlQ= sha256:56rHQnAEku2wjYPs89js6kCG4ChTExxSx7wNuHinaWk=
Content-Language: en-US
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 64D2A117436; Tue,  1 Dec 2026 20:21:35 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.15
X-Spam-Status: No, score=-3.15 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=6wind.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id IfIxBoROxdVZ;
	Tue,  1 Dec 2026 20:21:31 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-375240-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=6wind.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 6849311737D; Tue,  1 Dec 2026 20:21:22 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 2AA42602A69; Tue,  1 Dec 2026 17:21:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796145680;
	b=zXq196L5TB6YGKzU6DDb1qXDoOw4o1Zp0moa7+C0CxZIc6daAU3DekFqtP2hIXvRKnoh
	 UKult+pWeFP1Vid8VxuRUZgnyrN8PPrKDJuneotT+vzxPB2tVfw8PPbHwMoISH4oyXwmH
	 lKJ9+/INhDkIMYZw9x+eUN13kCfu1GfM6ujNdNI4Xgy7VgjiQiR8xct4D4fG+g5be0SRF
	 c/pp86GKXOcYTU5PRNDdVEJa7FuU6teYM3ZDF0GkSbOks5HQv6r+YPsW3qmW5qhwzeAsK
	 ocRuDKg+M2TxAc/05tZO8hpbrqLN3hEEXcI1NxlvagmtIlHpsENDwluQLl/onC1UNbw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796145680;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:Message-ID:Date:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 User-Agent:Reply-To:Subject:To:References:From:Content-Language:
	 Organization:In-Reply-To:Content-Type:Content-Transfer-Encoding;
	bh=vWAxngyEbJrWe1VcSRUUPcYiU8Ha5oP3szagwEUnKT0=;
	b=kSDG07xAm4pa+K9PNpj9rgan+Si6NWlw1ohZhC96sUzNtus8NK5gRl92okG67xfAvRDt
	 3fO6bs6z2XBNK+MAXtQ1RgTvxZNtmJahCuvLu6enIMajkG7Z6HBg0A8TIizwxpjHhcR8p
	 Ahg98ehj13VCJ/jC/+E0Iujk9/p8j0k4uAVav/x1wcAGcwVpvBsI6EwknG/h2E5EjN8Cl
	 kfzYZNKIJ1iOh5vrjFmDcj/0awgHv9CRV6dqDxuVd0LaWVGnXHA0XaGmgeJnzE0BIxGCG
	 UOsEaPwDjxCUSWfF2qXF7k9OZBpm1apAMQKuloWBbqGwx9Elj8Bqh+ZExgZFSmpawDQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=6wind.com header.i=@6wind.com header.a=rsa-sha256 header.s=google header.b=bsG50iVS;
	dmarc=pass header.from=6wind.com;
	spf=pass smtp.mailfrom=6wind.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D75BA606A336;
	Tue,  1 Dec 2026 17:21:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=6wind.com header.i=@6wind.com header.a=rsa-sha256 header.s=google header.b=bsG50iVS
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.44
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796145680;
	b=P0V2BIIllLEloVihuIX96TydeqG0u4UQTZmfIiWeQOCXI5Kj1qQI5YV2YzrhhZL9LXxU
	 wEq0ye9n0XCuGuguh35/6/kthPeLYvG3TgU4T1Mz4mIQcXW1OjzCo/OH09yMV+FZjTqmL
	 srZWrYYo+EOEZHjw3eqiqFknp7oylro8AeHAEmWnitvg7iorJ17ua21YbZlFHN8sN0VoQ
	 FS6ksI9F85Af6ZKqRe1zmU5XaQRhSFV41V63XEp5j+2Od+J60ATGGEY2zsNNhsBuWMFIw
	 O5y0lPRGdUfmEeFuhI/v+jSut69SmOsg5m45qsIGp2NY31iKctiw4/EJj1GwTLrFCHQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796145680;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-ID:Date:
	 MIME-Version:User-Agent:Reply-To:Subject:To:References:From:
	 Content-Language:Organization:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=vWAxngyEbJrWe1VcSRUUPcYiU8Ha5oP3szagwEUnKT0=;
	b=kgJrmpIouVpTSGavFuLYKnUUU+5KbEkwhol8AGABwmMkC6hKoGTvnyzrjTWzEQZbvS6w
	 zSmIVdyp/n2eQmK7D/PEY2b3l+iECb0oNeyGofmT70aRoAzS3pencj0Gf9h5tOje7f9f9
	 7jvG8qVTR36VKdqSeQrY6zyYvOU8CFNBtJknr3o55WqDBPca+NGrlvrjqVoY5Rt718fdL
	 h+N4dBtcCJpt0eqnOb4eVDaNUAmTO7RpJOq799uQfD9oRzIhY42nkNfck7lSnHbFQ4OIJ
	 MwUJBjoPHWVh77Hx1nhtYI94lBT0C6nnSYrqMxDTk3XpJqajwgwxdMY/W6LRQwEgpnQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=6wind.com;
	spf=pass smtp.mailfrom=6wind.com;
	dkim=pass header.d=6wind.com header.i=@6wind.com header.a=rsa-sha256 header.s=google header.b=bsG50iVS;
	arc=none smtp.remote-ip=209.85.128.44
X-Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7D52606A334
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 17:21:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A7D52606A334
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=6wind.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=6wind.com
X-Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4bb5e3cbf45so11274595e9.1
        for <netdev@vger.kernel.org>; Tue, 01 Dec 2026 09:21:19 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=6wind.com; s=google; t=1796145678; x=1796750478; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:in-reply-to:organization
         :content-language:from:references:to:subject:reply-to:user-agent
         :mime-version:date:message-id:from:to:cc:subject:date:message-id
         :reply-to:content-type;
        bh=vWAxngyEbJrWe1VcSRUUPcYiU8Ha5oP3szagwEUnKT0=;
        b=bsG50iVSEg2cfDn98/oxo9I2zVhbgt1B3LUHJlrRtE8Kp/HnsItJHKacRGyJ16JhDt
         teVINUZxhorC9gvKqVnErrmhpC2VjdxF2xlDGpye1xD+WXMcTPOZwrkPgSHo5SOw10eG
         Qa5hYmcO1uAseKQbBiZF/hx2iCBpmPDzi7GlCihbk0eYE6yhgZAvI4qeKNVHsX7KwI5r
         TMtvHpF1ERB9nSp7u6q0lZyamQtAsOaxiYNJfu6wSeQLznZpUBbgCkfHhoFvSyaYiuPP
         2A4J2c4caaA0YxSyg/GPLIDCYMAEcJKH4yZk8/jtxCl91/z3Brsqi4yN3NPz/GUJgzya
         QYtQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796145678; x=1796750478;
        h=content-transfer-encoding:content-type:in-reply-to:organization
         :content-language:from:references:to:subject:reply-to:user-agent
         :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to:content-type;
        bh=vWAxngyEbJrWe1VcSRUUPcYiU8Ha5oP3szagwEUnKT0=;
        b=ydKrLTh1H+R83KLuaDac5OK804lUdUcAN/HsdZdZ0t4yPsEhdoYIQVSDT0eCWN0sDf
         TI1JYczmmbh+q5SBtHIwrZ7RXXxjBHaht1D9fTDleDi610mN/kO3UEjDtHT4ncQ5i9UO
         snThuSMWFRPbpChth2fznJdWt98zhTYXLmTV0fE8ef1jCYhQbYjUTfsE6aE5cMku0qXn
         mhjhZTPCQ3ZsZV1MAUT5eNI3ocQVLfUhr7uK0JcpX8U2etc8gAJwFxtDZIflaYVoxOtu
         VSJI+BHrON0xf/3TaHWdEeIjtz+C0EYrm5O651nJz6vMzAPq5hLQU0XpTXYzR5LH862g
         O23Q==
X-Gm-Message-State: APuU4Z9iSWTpaSHBb4t0vAw5TnbYlXE3UqfIr0tZYhljdlntUINgT9fS
	RuDQeEPDpMZuxrbs95xSnsNwY/VsOxAPKqHeyg7UW3SFQPHXUPuolZc53CoT7lMZPpk7345nbpw
	xMcKGnBo=
X-Gm-Gg: AZFdTZdDnBThMzoRhy5Dls/uPTaEzdhN4gNp1MxnWv2xABAPjZUTN81Jk7vCM4W4FfD
	DgwWidrkn5fgbAVs71QkMniceIVmIjPeLdmf47a5gT98bDFu0N+K93kZECUaWgmBql3P8bpcFS/
	niC/MfWZN66iSV0BxTS7u84kQVNiAU5IvJ0qiJ1dWv6F48s8c3Bj995s0Pxf/yhsIAD7USmTCaR
	eeZrwba5z6smdqynxXVP+HigoSKb7mcJsAu5bSbj6ljrRdJiV4yJQjf9fW6Z/g6a19AnvnwpkJ0
	2YBVx6CDrk368sKO0vDFAntZ0p+ma8MH2L/5XYXAFq3sOt5ekLDW/RIXsxSXxa09K9qnECiDWjV
	MFojFO8ZeIvRbi94RSEtos+wgpsmhOF/kpxm4yTJKS5zcMQ3YtZ7avAIOkD+CUzeDykvTT+Buu7
	jo3gfyAl6+gIRJKQ974quiUIorYyZVknPokA9KAEBqlXypT6GntoeOgOptqmxMU7CatITaepX4y
	9G1O53qk9YMYPlnRdvJTNo+hsSZLRaBDpFC2Ahuk/DFzTtIt/GnabXwza3ygfND6sz6od8Uhhrt
	ZfgVaY3aw9ObGrCuzSpxaaQAWHeq4/I53IqjmWElcktQICZXyTNCuIh6xzqmhWhF/gGVKnAZGVh
	vvn4n
X-Received: by 2002:a05:600c:8210:b0:4bb:7ad8:99f2 with SMTP id 5b1f17b1804b1-4bb88785da4mr694844145e9.0.1796145678056;
        Tue, 01 Dec 2026 09:21:18 -0800 (PST)
X-Received: from ?IPV6:2a01:e0a:ab7:2110:6a1d:efff:fe52:1959? ([2a01:e0a:ab7:2110:6a1d:efff:fe52:1959])
        by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884b8429sm1618474625e9.14.2026.12.01.09.21.16
        for <netdev@vger.kernel.org>
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Tue, 01 Dec 2026 09:21:16 -0800 (PST)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-User-Agent: Mozilla Thunderbird
X-Reply-To: nicolas.dichtel@6wind.com
X-Organization: 6WIND
X-In-Reply-To: <20261130204412.632027-1-xmei5@asu.edu>