Kuniyuki Iwashima 0a8e987dcc tcp: Fix SYN option room calculation for TCP-AO.
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: 4954f17ddefc ("net/tcp: Introduce TCP_AO setsockopt()s")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2023-11-06 08:59:54 +00:00
..
2023-05-31 13:06:57 +02:00
2023-10-25 10:38:07 +01:00
2023-10-01 19:39:18 +01:00
2023-04-13 16:43:38 -07:00
2023-10-16 21:05:33 -07:00
2023-11-03 09:16:42 +00:00
2022-09-20 10:21:49 -07:00
2023-11-03 09:16:42 +00:00
2023-10-27 10:35:46 +01:00
2023-11-03 09:16:42 +00:00
2022-12-20 03:13:45 +01:00
2023-10-27 10:35:46 +01:00
2022-11-16 09:43:35 +00:00
2023-10-30 14:36:57 -07:00
2023-09-14 16:16:36 +02:00
2023-08-29 17:39:15 -07:00