• Eric Dumazet's avatar
    tcp: fix tcp_inet6_sk() for 32bit kernels · f5d54767
    Eric Dumazet authored
    It turns out that struct ipv6_pinfo is not located as we think.
    
    inet6_sk_generic() and tcp_inet6_sk() disagree on 32bit kernels by 4-bytes,
    because struct tcp_sock has 8-bytes alignment,
    but ipv6_pinfo size is not a multiple of 8.
    
    sizeof(struct ipv6_pinfo): 116 (not padded to 8)
    
    I actually first coded tcp_inet6_sk() as this patch does, but thought
    that "container_of(tcp_sk(sk), struct tcp6_sock, tcp)" was cleaner.
    
    As Julian told me : Nobody should use tcp6_sock.inet6
    directly, it should be accessed via tcp_inet6_sk() or inet6_sk().
    
    This happened when we added the first u64 field in struct tcp_sock.
    
    Fixes: 93a77c11 ("tcp: add tcp_inet6_sk() helper")
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Bisected-by: default avatarJulian Anastasov <ja@ssi.bg>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    f5d54767
tcp_ipv6.c 53.2 KB