Re: [syzbot] [net?] KASAN: use-after-free Read in __skb_flow_dissect (3)

From: Hillf Danton
Date: Fri Jan 19 2024 - 05:31:31 EST


On Mon, 01 Jan 2024 09:18:16 -0800
> syzbot found the following issue on:
>
> HEAD commit: f5837722ffec Merge tag 'mm-hotfixes-stable-2023-12-27-15-0..
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=122dfc65e80000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

--- x/net/core/filter.c
+++ y/net/core/filter.c
@@ -2161,6 +2161,10 @@ static int __bpf_redirect_no_mac(struct
}
skb_pop_mac_header(skb);
skb_reset_mac_len(skb);
+
+ if (skb->data[0] < 2)
+ flags = 0;
+
return flags & BPF_F_INGRESS ?
__bpf_rx_skb_no_mac(dev, skb) : __bpf_tx_skb(dev, skb);
}
--- x/net/ipv4/ipip.c
+++ y/net/ipv4/ipip.c
@@ -281,6 +281,9 @@ static netdev_tx_t ipip_tunnel_xmit(stru
if (!pskb_inet_may_pull(skb))
goto tx_error;

+ if (skb->data[0] < 2)
+ DEV_STATS_INC(dev, tx_errors);
+
switch (skb->protocol) {
case htons(ETH_P_IP):
ipproto = IPPROTO_IPIP;
@@ -302,6 +305,9 @@ static netdev_tx_t ipip_tunnel_xmit(stru

skb_set_inner_ipproto(skb, ipproto);

+ if (skb->data[0] < 2)
+ DEV_STATS_INC(dev, tx_errors);
+
if (tunnel->collect_md)
ip_md_tunnel_xmit(skb, dev, ipproto, 0);
else
--- x/net/ipv4/ip_tunnel.c
+++ y/net/ipv4/ip_tunnel.c
@@ -745,6 +745,9 @@ void ip_tunnel_xmit(struct sk_buff *skb,
}
}

+ if (skb->data[0] < 2)
+ DEV_STATS_INC(dev, tx_errors);
+
ip_tunnel_init_flow(&fl4, protocol, dst, tnl_params->saddr,
tunnel->parms.o_key, RT_TOS(tos),
dev_net(dev), tunnel->parms.link,
@@ -828,6 +831,9 @@ void ip_tunnel_xmit(struct sk_buff *skb,
return;
}

+ if (skb->data[0] < 2)
+ DEV_STATS_INC(dev, tx_errors);
+
iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, protocol, tos, ttl,
df, !net_eq(tunnel->net, dev_net(dev)));
return;
--