• Eric Dumazet's avatar
    packet: fix match_fanout_group() · 161642e2
    Eric Dumazet authored
    Recent TCP listener patches exposed a prior af_packet bug :
    match_fanout_group() blindly assumes it is always safe
    to cast sk to a packet socket to compare fanout with af_packet_priv
    
    But SYNACK packets can be sent while attached to request_sock, which
    are smaller than a "struct sock".
    
    We can read non existent memory and crash.
    
    Fixes: c0de08d0 ("af_packet: don't emit packet on orig fanout group")
    Fixes: ca6fb065 ("tcp: attach SYNACK messages to request sockets instead of listener")
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Cc: Willem de Bruijn <willemb@google.com>
    Cc: Eric Leblond <eric@regit.org>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    161642e2
af_packet.c 103 KB