Re: KASAN: use-after-free Read in ipv6_gso_pull_exthdrs
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: 2018-07-06 22:17:36
Also in:
lkml
On Fri, Jul 6, 2018 at 1:55 PM syzbot [off-list ref] wrote:
syzbot has found a reproducer for the following crash on: HEAD commit: 70ba5b6db96f ipv4: Return EINVAL when ping_group_range sys.. git tree: net console output: https://syzkaller.appspot.com/x/log.txt?x=13cd2970400000 kernel config: https://syzkaller.appspot.com/x/.config?x=2ca6c7a31d407f86 dashboard link: https://syzkaller.appspot.com/bug?extid=7b9ed9872dab8c32305d compiler: gcc (GCC) 8.0.1 20180413 (experimental) syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=15dfb748400000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12a1050c400000 IMPORTANT: if you fix the bug, please add the following tag to the commit: Reported-by: syzbot+7b9ed9872dab8c32305d@syzkaller.appspotmail.com IPv6: ADDRCONF(NETDEV_UP): veth0: link is not ready IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready IPv6: ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready 8021q: adding VLAN 0 to HW filter on device team0 ================================================================== BUG: KASAN: use-after-free in ipv6_gso_pull_exthdrs+0x57a/0x5f0 net/ipv6/ip6_offload.c:45 Read of size 1 at addr ffff8801ce17f3a9 by task syz-executor655/4567
This is an 8 byte packet with a virtio_net_hdr describing it as VIRTIO_NET_HDR_GSO_TCPV4, but with protocol ETH_P_NSH. That matches the occurrence of nsh_gso_segment in the stack trace. This pulls the struct nshhdr of 8B, passing a packet with skb->len 0 to skb_mac_gso_segment. That is the only GRO function that unconditionally calls _skb_pull without first checking pskb_may_pull. Adding that check does catch this: + if (unlikely(!pskb_may_pull(skb, vlan_depth))) + return ERR_PTR(-EINVAL);