Skip to content

Commit 1357232

Browse files
edumazetgregkh
authored andcommitted
tcp: md5: fix potential overestimation of TCP option space
[ Upstream commit 9424e2e ] Back in 2008, Adam Langley fixed the corner case of packets for flows having all of the following options : MD5 TS SACK Since MD5 needs 20 bytes, and TS needs 12 bytes, no sack block can be cooked from the remaining 8 bytes. tcp_established_options() correctly sets opts->num_sack_blocks to zero, but returns 36 instead of 32. This means TCP cooks packets with 4 extra bytes at the end of options, containing unitialized bytes. Fixes: 33ad798 ("tcp: options clean up") Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: syzbot <syzkaller@googlegroups.com> Acked-by: Neal Cardwell <ncardwell@google.com> Acked-by: Soheil Hassas Yeganeh <soheil@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9d47e13 commit 1357232

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎net/ipv4/tcp_output.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,9 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb
755755
min_t(unsigned int, eff_sacks,
756756
(remaining - TCPOLEN_SACK_BASE_ALIGNED) /
757757
TCPOLEN_SACK_PERBLOCK);
758-
size += TCPOLEN_SACK_BASE_ALIGNED +
759-
opts->num_sack_blocks * TCPOLEN_SACK_PERBLOCK;
758+
if (likely(opts->num_sack_blocks))
759+
size += TCPOLEN_SACK_BASE_ALIGNED +
760+
opts->num_sack_blocks * TCPOLEN_SACK_PERBLOCK;
760761
}
761762

762763
return size;

0 commit comments

Comments
 (0)