๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24654

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

#24654
From: Nicolas Dichtel
Date: Mon, 30 Nov 2026 15:11
66 lines
13935 bytes
Le 29/11/2026 ร  02:34, 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 unless all ihl * 4 header bytes are present, the same
> check ip_rcv_core() does for received packets.
ip_rcv_core() also rejects a header with ihl < 5. It would be nice to add the
same check here to ensure the IP header validity.

> 
> Cc: stable@vger.kernel.org
> Fixes: 193125dbd8eb ("net: Introduce VRF device driver")
> Reported-by: co+bfd69dd4e073f1e9@bugs.sh
> Signed-off-by: Xiang Mei <xmei5@asu.edu>
> ---
>  drivers/net/vrf.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
> index 79d433f49f80..9453c26aca97 100644
> --- a/drivers/net/vrf.c
> +++ b/drivers/net/vrf.c
> @@ -496,7 +496,8 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
>  	struct net *net = dev_net(vrf_dev);
>  	struct rtable *rt;
>  
> -	if (!pskb_may_pull(skb, ETH_HLEN + sizeof(struct iphdr)))
> +	if (!pskb_may_pull(skb, ETH_HLEN + sizeof(struct iphdr)) ||
> +	    !pskb_may_pull(skb, ETH_HLEN + ip_hdr(skb)->ihl * 4))
>  		goto err;
>  
>  	ip4h = ip_hdr(skb);
Technical Details
Message-ID: <32381389-f6ae-4a1e-b3ed-bcc445430a5a@6wind.com>
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374262-linux-kernel-netdev=dewy.ru
References: <20261129013404.3192386-1-xmei5@asu.edu>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374262-linux-kernel-netdev=dewy.ru
From: nicolas.dichtel@6wind.com (Nicolas Dichtel)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] vrf: pull the full IPv4 header on xmit
Date: Mon, 30 Nov 2026 16:11:52 +0100
Organization: Usenet Network
Message-ID: <32381389-f6ae-4a1e-b3ed-bcc445430a5a@6wind.com>
References: <20261129013404.3192386-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="1453463"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:6kFexaj8ysX8RqDz7nDlz1oWwMU= sha256:TKuzOlnL3UQDJlUPqSqewKXrdrG9Tb5gL6cKX75NaU4=
	sha1:UhaG0Ubeqztkq6D28ZnmHkkS2C0= sha256:uggLEf0BI+HZRGMpFRbYE4gg4/ATKBP6oZjnhgjYGy0=
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 7F379125FF1; Mon, 30 Nov 2026 18:12:16 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.151
X-Spam-Status: No, score=-3.151 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]
	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 OUvmCHh9Da_1;
	Mon, 30 Nov 2026 18:12:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-374262-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 3E66D125FF0; Mon, 30 Nov 2026 18:12:02 +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 42A79602489; Mon, 30 Nov 2026 15:12:02 +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=1796051521;
	b=nixPRv0t1zXPTmadBIK4rb+5hJN3fZ8OJjGnEwl+4ywrNkFE+pnTAdUWhLGCphIqvyps
	 ufpJMcN+lBpMq3tZdc+9cU3gV4djh7vqRuNL3se4aWqfMj8d12B3WNqk86oleWoxbl81A
	 uJReVPW/aiM0Cw+cCRPR7LpnZYuFUtNIWxnpfas37abExBON5Y7umZxPse2GlY1O1eF80
	 wfW5pUNtGPGvDfHDg9KF10e/DZDs6H2dpecmy4Ed7xZvb6F/fKt3N//fS/htU8pHyhYg5
	 sw6+NsVLpekMgrJF6WIZz03FLRYX3vtlHwJM9Qav1z0Cr7XcZI2jQ7iNVpKdpTpmckA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796051521;
	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:Cc:References:From:Content-Language:
	 Organization:In-Reply-To:Content-Type:Content-Transfer-Encoding;
	bh=VbZfvor+lAvm/ngwI8Pzg8wAHhJs1BpNu2+XFHFARL0=;
	b=FMZv3zcG42ti9fmSxNZJgy1cRJSt+Gcb6e882ahqJ4xHn8gtOgm1GZAR2oM2jiwD0Nn2
	 txfOfEhl5Y7jvUjd3PaO/Dxyb3AlDMb3Q+0LkhfcBl9oPpwtGO4atbxTsMlFmmtVgG8j1
	 RvvvgqX0wjs+oCXMTI486UlTJtb0/AkjwYp+efwUJ2T0yGOpQfBQOxg8BAP9XmNL+stqm
	 l1erpfSadqYyhD0Pb8qL+aJe0yQ+qEu3x0GVnGQB46Mndzh+f+WXPCHdi+t3qbIG6KeUe
	 z/87X+jaa/iSCpw1LdsgVk++/GGm9u3QBvF0L2ZJ3dGkqe1mfNWZB3ma0gA/em46RYA==
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=JQhw3ILr;
	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 91FE3606A329;
	Mon, 30 Nov 2026 15:12:01 +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=JQhw3ILr
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.47
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796051515;
	b=GGAxn3FjBbYD/j93SHkJg1K60KGyL+Ksq/5HbtCxRqGBkvmjIVqpGysW93HZgiLoP2cj
	 Lw1ByISSTi0TDgIu+GL15es0V2u/EImXvU2VEco3KVzkQxw+jNraK89lx8FZxn01HqzPc
	 +I127j3w+agWJwcrKZ5wFtWr2How3TG7vQ6YJcuaVTLxWb0Yj1wY2kN9Y4VN/hj7a6PDp
	 /3XKgJnNS1UB6oxTY5oDogOT9AwEVAGCxN64AXWNHJx2jbNJMSehgUjaJesjv6ZXsao+z
	 BtI6xHCmJtc4Tfu403Kez3lI/CDY5BG2j7EY/ObwwQTfMwh3q5Db0Drt6jMD7TFLRQg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796051515;
	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:Cc:References:From:
	 Content-Language:Organization:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=VbZfvor+lAvm/ngwI8Pzg8wAHhJs1BpNu2+XFHFARL0=;
	b=3e93crbGLg91QSG7Wzq3+7anDj4uthZ8owPCdobita06ItMGABY20DRjdi4GzBZr0Fgz
	 OjnUsuuVNsb17GYKwKgPlkyrhStZEQs3aSD1cunYNaIIAnSkj0bvB3/EMGmuXhtQzFBRP
	 M2EPs7M5wlep9Ia5p9UOhsJ9KxuCjCPT6RuRCMFgHRSfZWBh5vT8zFgP0bRCfyfz94Bjt
	 j16J46vu1V5axxryMZjnYv03aGzLBWs4YH6UnpRpO/yZ2knU8AD7ra3eziffGUQgthF3N
	 lppMjiQgq2bd54X7Rev0EzBQ9R+nXmDfH30WmMDh9v7NQjhvlaIovueZ7k5NDJKOVWw==
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=JQhw3ILr;
	arc=none smtp.remote-ip=209.85.221.47
X-Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47])
	(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 54803606A320
	for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 15:11:55 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 54803606A320
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-wr1-f47.google.com with SMTP id ffacd0b85a97d-4a440c9e13aso916455f8f.3
        for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 07:11:55 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=6wind.com; s=google; t=1796051514; x=1796656314; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:in-reply-to:organization
         :content-language:from:references:cc:to:subject:reply-to:user-agent
         :mime-version:date:message-id:from:to:cc:subject:date:message-id
         :reply-to:content-type;
        bh=VbZfvor+lAvm/ngwI8Pzg8wAHhJs1BpNu2+XFHFARL0=;
        b=JQhw3ILrRtlpPQSrJelecyVPlzx/D2gHlPmqRRKzhEdHODwhqJlmF/t5UDJwL1y+WQ
         feym1lynUhf7N+Zc3oTuwNdhoQAmmULLAsNQQSgeOjjfCWDbSMr0E/bT5gUa1Mk4AXBG
         Ho63ZWiaU4UeUCa6F2iGVeq9/q9nx/WDsooT0A8yXMZ4WgvHXYM5Zuy8db8P9tA7d8Ac
         XiMOdSTs+Ilz5IWLX0MBoiFtnnBednjz7laSj9TaPN5V/aGWgbr/GFNcDu+wvtkt75zq
         uqaazJjSeDIIe7qlKB9bfg0oFSukQmFhfhExq4Jr20SG+dFyEYaxJ3+iiujBVexcmEZR
         DoMg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796051514; x=1796656314;
        h=content-transfer-encoding:content-type:in-reply-to:organization
         :content-language:from:references:cc: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=VbZfvor+lAvm/ngwI8Pzg8wAHhJs1BpNu2+XFHFARL0=;
        b=hwk02PEwaXpmAtKunOPNR94lEHCQnP9+ZVAT1tjHykldcK98hH+5y1t2F5VwGKFKqE
         duQqv3KfbpnZ4ZQgqLRw3Kyrb41qx1Wz5LoGm2BLKvfMW70zsEwKlTkMhhi5jvE40dVl
         wt90EaMwx24MKv0OWmc7vmvPvhU2+lVaGSzqNk7cUDN0FCIfs3Wkk7otidMpemKKOSR0
         9WctyjvYsATFLZSrCPUoIf5rmwJqw5r3+Y9AC0pZS5QBSlgjomlp219bHxkkU2Aw6x+I
         NkgqPkm2sl2Q0lRL34ZUcpiZh2JxBRkaN5K/UDqhGwKvraJ4XZ+KQZdUaAH+UolwWzN6
         8MgA==
X-Gm-Message-State: APuU4Z+k1pk6qnstWPq7QZ/+2bqs3eizuUdx9GJYtkCqyiW52rsETdFT
	+FDYqaM8D5lpqLKY3OlJ/zEfL/nAVvpiiV0TKmq0nSdxN94g0I3uy8jaFYWZibXUZU8=
X-Gm-Gg: AZFdTZcv106O8pCe3MPSesYzJ4R7a0rg4n0lSHXMtZ7m7PijjJNJaqHKScKzS97xYN4
	zIWTkRWNWpno4fvlc6Z0AcZmSNXVwVIzUFxmSOhzlqOTcnXEX2AlYmisF8yvUodVn4DKWoddy7o
	uEwZR36mo5MYcMuavGj5ytAbZe20AA6zsyWblepnP9gJ51KggX2dxGoK8VWtb+PKhDT1a4yazJm
	K9ckSHrIgdkLeCMgAN8jPO1qjWcucWGYCokCfoyNiI87riFKYKMZBt1VpAOd4LqYhuMoaWt37jn
	QD/il7VH7kLNlImknSc/d1LltrQf5f6W9+xIE6N5ZfhiftkB9FMvM2ojqdoUcTjC9jCp29B83SF
	iaftg4GmRu3AkDaq5U7gNZ7qH3nHSZB4b6jNOwDEZCWGM/N22lGcEjHns6dzH6zxJWcw/KjDML9
	7jo6z5Yi3X2Yf5TUp7w9rSggr3AY7pLIV/UCyhpV/tkmmDe5+gkklpzDg5+D1Hp60T8Qz/YNvdB
	pDFB/f8RErGTpcGiVlBTU6KUlKeUYBgVkLwnVEwjsEwwPJzh4qM8ZSLIISGEcr9E9+2ZSCU9dmc
	yrguTNe5FRn/B734MELFvn4bz0FhRYLVo8cYmgOLCZVIQPLuaTb249cMihBPh7ER9qGnqTyHoQn
	mWrXqeg==
X-Received: by 2002:a05:600c:154c:b0:4ad:5ec2:d3b3 with SMTP id 5b1f17b1804b1-4bb887f43d8mr654577105e9.1.1796051513701;
        Mon, 30 Nov 2026 07:11:53 -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 ffacd0b85a97d-4ab69bf685asm67217317f8f.20.2026.11.30.07.11.52
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Mon, 30 Nov 2026 07:11:53 -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-Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
 stable@vger.kernel.org, co+bfd69dd4e073f1e9@bugs.sh
X-Organization: 6WIND
X-In-Reply-To: <20261129013404.3192386-1-xmei5@asu.edu>