• Kuniyuki Iwashima's avatar
    tcp: Fix SYN option room calculation for TCP-AO. · 0a8e987d
    Kuniyuki Iwashima authored
    When building SYN packet in tcp_syn_options(), MSS, TS, WS, and
    SACKPERM are used without checking the remaining bytes in the
    options area.
    
    To keep that logic as is, we limit the TCP-AO MAC length in
    tcp_ao_parse_crypto().  Currently, the limit is calculated as below.
    
      MAX_TCP_OPTION_SPACE - TCPOLEN_TSTAMP_ALIGNED
                           - TCPOLEN_WSCALE_ALIGNED
                           - TCPOLEN_SACKPERM_ALIGNED
    
    This looks confusing as (1) we pack SACKPERM into the leading
    2-bytes of the aligned 12-bytes of TS and (2) TCPOLEN_MSS_ALIGNED
    is not used.  Fortunately, the calculated limit is not wrong as
    TCPOLEN_SACKPERM_ALIGNED and TCPOLEN_MSS_ALIGNED are the same value.
    
    However, we should use the proper constant in the formula.
    
      MAX_TCP_OPTION_SPACE - TCPOLEN_MSS_ALIGNED
                           - TCPOLEN_TSTAMP_ALIGNED
                           - TCPOLEN_WSCALE_ALIGNED
    
    Fixes: 4954f17d ("net/tcp: Introduce TCP_AO setsockopt()s")
    Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
    Reviewed-by: default avatarDmitry Safonov <dima@arista.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    0a8e987d
tcp_ao.c 63.4 KB