Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Xiang Mei
Sun, 29 Nov 2026 01:34
[PATCH net] vrf: pull the full IPv4 header on xmit
Author: Xiang Mei
Date: Sun, 29 Nov 2026 01:34
Date: Sun, 29 Nov 2026 01:34
64 lines
12931 bytes
12931 bytes
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.
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);
--
2.43.0
Re: [PATCH net] vrf: pull the full IPv4 header on xmit
Author: Nicolas Dichtel
Date: Mon, 30 Nov 2026 15:11
Date: Mon, 30 Nov 2026 15:11
66 lines
13935 bytes
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);
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads