• Willem de Bruijn's avatar
    net: gro: initialize network_offset in network layer · be008726
    Willem de Bruijn authored
    Syzkaller was able to trigger
    
        kernel BUG at net/core/gro.c:424 !
        RIP: 0010:gro_pull_from_frag0 net/core/gro.c:424 [inline]
        RIP: 0010:gro_try_pull_from_frag0 net/core/gro.c:446 [inline]
        RIP: 0010:dev_gro_receive+0x242f/0x24b0 net/core/gro.c:571
    
    Due to using an incorrect NAPI_GRO_CB(skb)->network_offset.
    
    The referenced commit sets this offset to 0 in skb_gro_reset_offset.
    That matches the expected case in dev_gro_receive:
    
            pp = INDIRECT_CALL_INET(ptype->callbacks.gro_receive,
                                    ipv6_gro_receive, inet_gro_receive,
                                    &gro_list->list, skb);
    
    But syzkaller injected an skb with protocol ETH_P_TEB into an ip6gre
    device (by writing the IP6GRE encapsulated version to a TAP device).
    The result was a first call to eth_gro_receive, and thus an extra
    ETH_HLEN in network_offset that should not be there. First issue hit
    is when computing offset from network header in ipv6_gro_pull_exthdrs.
    
    Initialize both offsets in the network layer gro_receive.
    
    This pairs with all reads in gro_receive, which use
    skb_gro_receive_network_offset().
    
    Fixes: 186b1ea7 ("net: gro: use cb instead of skb->network_header")
    Reported-by: default avatarsyzkaller <syzkaller@googlegroups.com>
    Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
    CC: Richard Gobert <richardbgobert@gmail.com>
    Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
    Link: https://lore.kernel.org/r/20240523141434.1752483-1-willemdebruijn.kernel@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    be008726
af_inet.c 50.7 KB