From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796071460; b=Z5qdwBTI+JKK7T65IlQL4XCopxqaha5c6fk52qruHAkqafyiEW2xLu2PRPzipLN1/h0e Ey7z/ZjaEuhQuhyJe4guRZrsLDQnWTdPw5pgYJYVQi09YTSVkLUEwOQ+nctKFkv0jVRSB MWJOB7GBP2j/8gHwZqVI7aWsB3+w6BnMeX4Gl9A/V4bTt7vZ3CBPVcCWqL9d8mGJ2te2d eIrcdKq1SglhgI5hG5qXb6vm3l/RBGdtyaEXrvbtmHdEbg07/ru1IAIlYl12C8sd1C8Ak Anx60VmdjVSSB3XACoc8nev2xcMeIgA5x77MPMjZ04LUPqcKD5DWzNDc0MaNvn9ugUg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796071460; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=UGs/QIj4gB6+uihVtcbZRTEG7ljrA5X+4csPHQoC8Sw=; b=Wbt/KnSJtLUy99osfbkF37Bv83BGCfmZAlXAdY0RLd5sz2SVlW3cNlPzk801db3QojrS zG/CYOtwfeYsSIofYfF37jh/hTLn0Bfl8dnkZbCRki8YTVSyA+WVe3WvkJjm8c3uH7NfH 52M9v/TNJWsrhCx3VucCiSikqOULk/GUPytZxlEEV4Na9tRfDclyFhlxzlGnScwxloXRj 0s4K9KGEFB4+C7bGoWWXIJcRYVLe4ptmTt0wQjQoQEvcYmT/G125uo30rWxO355KCEGAD 24noow3K0wQ/1oAw5PDOmUllZkRYZo59uNV+5mWFzMVjMJGNTOeVb+5p3v/65dOTU/A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=asu.edu; spf=pass smtp.mailfrom=asu.edu; dkim=pass header.d=asu.edu header.i=@asu.edu header.a=rsa-sha256 header.s=google header.b=nM5IslV4; arc=none smtp.remote-ip=74.125.82.45 Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45]) (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 EAB1B606A325 for ; Mon, 30 Nov 2026 20:44:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EAB1B606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asu.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.a=rsa-sha256 header.s=google header.b=nM5IslV4 Received: by mail-dl1-f45.google.com with SMTP id a92af1059eb24-170135e43c7so3406559c88.0 for ; Mon, 30 Nov 2026 12:44:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu.edu; s=google; t=1796071459; x=1796676259; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=UGs/QIj4gB6+uihVtcbZRTEG7ljrA5X+4csPHQoC8Sw=; b=nM5IslV45aTdr3g6ahajoVkzBvpxg4LYnp6o31wV4Ofc/B6Oo16xvL8MqeDYiwSsov j4UitGu/UBY1ISuwUGfhxFwJRrL+bqPMuosTEkmR8CLQw7tH9nRUN0mK5eG1EJHi3Y3j kpLeLObCzobyG+va7H48QE3ryLRKpuA4LhksCg4Z+zVixN5QNMSyNCTJUCSHC2/JmL6m sFd+bE0weoUzM1TaRSC/D42W+w5fOAgyFXbOOwCvsWA7gBPwPwb0RbEpG/T5DULWm+0/ 5PCVwhTFwYh3e4d4dL7Ql9/dH4V7JS2l8Mb5W2GvmGTBp2wF+c6zDtVTWwD3dsV3Twx6 G6UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796071459; x=1796676259; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=UGs/QIj4gB6+uihVtcbZRTEG7ljrA5X+4csPHQoC8Sw=; b=x0COhppUWdhp/Vaqm9N/msrtVo48V1x9pXXzawM4cUrwanmJj89U/6V7zCv6yKjd6E XyWh79aZN7b7VpdaEV6iQ62kfQYJr+rZevSlx2eO606CEZXDfSwA+ftYqj4oyqdL74Ef 4sAu4KVq+EJGOM3wMc+KIR9KZZXrYIpGq1RoFxbeFrDIoKkaqgio9p2Hxzyoa73ibbHI +VLxHEjJQ7/HyD4ooRrSi6myx7ugyB18sqtUY4bBajh5gGsPB1oLE01GOXEG944rlGVb 0i5vr8xsUNUHWswVimlzCG6/0xx0tsyNGeusfYC7CVJ9Q9HFRgxNar3fRL7TJ2KhoZcW nxog== X-Forwarded-Encrypted: i=1; AL+hErG9upK3yreRv7KnbdDIpJzm0KdJrv59kOR5+SheGrcDTVe+izOmh779uEuz1XEW8jVfA9Mjo5rzpehGVpU=@vger.kernel.org X-Gm-Message-State: APuU4Z+fZRV8Fgd3xHFjSkr/QJ2KvA6K/kT38sO6y0bsFCr5J0Tk4rWg 23w1Oq+efl54TcjuHy6oZOizFOqc2lYfmoVauhPyzRt440MiEXNqpvT+lB5ehqTQDg== X-Gm-Gg: AZFdTZeZKGfhS+FXyJPzewzG3gp1xUsI/n9BDKsXboZ3Hpm/iidNJqpuAW7XldJLlyd hh1lsvtBuqVpXM6LSYxWZ3hfVXvAuIv+tBbrzb2HAf2hWezatTczhiinG9SbYXab5Ak0QQUPmb7 u50a6scfF4TwuEqfEHvuXd5cfeJBSQgUpbb2saFGngtuoIFN+4piwcmdWS5rPiF+yOSmgLbR38G 4n4ujq8hypNsVvI1yY6IrZNj1c5qPJck67OlzCxucTWogEmRRQhoq2X91MOPfDqnAxjvH5OAVY6 SAtgVvrGBeOs3cg0Pfu8DRZzPODhgmHXDKH9CiwdIg0G6irMtvoVvTCz5tKk8rWkxZAPb6gFTtd fGAhJATsPKiQQ5BAEZ3b6iZe7FSfli3Vz8fWbXd4BfQyik/2uVj9G5MH6zPTPqKBdloJ82ICO9V kjNqHtWzghEvX337kYUSbBz7eHtpSbaBPxzMnkY57vT79lq6itjQvLHsZJaM1kN1VCQaG/owQA3 03chbfXAGu9llsK1TliHkjSuxC+2roK8yaISWPbmQ9OUon2LUdRDeT5bFVlnbqbinUS8s5O9n2P 18dKExuVZE0Ggq/rCLSojcy3jdJ4NatIe25Mcws+k5dj9Tt5wzFpu5aQkW5u1FuQpHjvvQeQEkB cTJFWF+6QHTSvuQ== X-Received: by 2002:a05:701b:2918:b0:192:e5a8:6bae with SMTP id a92af1059eb24-1b570d52afcmr23968205c88.40.1796071458893; Mon, 30 Nov 2026 12:44:18 -0800 (PST) Received: from p1.. (209-147-138-4.nat.asu.edu. [209.147.138.4]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5569bffd2sm74814111c88.0.2026.11.30.12.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 12:44:18 -0800 (PST) From: Xiang Mei To: David Ahern , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, co+bfd69dd4e073f1e9@bugs.sh, Xiang Mei Subject: [PATCH net v2] vrf: pull the full IPv4 header on xmit Date: Mon, 30 Nov 2026 13:44:12 -0700 Message-ID: <20261130204412.632027-1-xmei5@asu.edu> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Cc: stable@vger.kernel.org Fixes: 193125dbd8eb ("net: Introduce VRF device driver") Reported-by: co+bfd69dd4e073f1e9@bugs.sh Signed-off-by: Xiang Mei --- 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; + ip4h = ip_hdr(skb); memset(&fl4, 0, sizeof(fl4)); -- 2.43.0