]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
sch_cake: Fix out of bounds when parsing TCP options and header
authorMaxim Mikityanskiy <maximmi@nvidia.com>
Thu, 10 Jun 2021 16:40:31 +0000 (19:40 +0300)
committerSasha Levin <sashal@kernel.org>
Wed, 30 Jun 2021 12:48:17 +0000 (08:48 -0400)
commit595897ef118d6fe66690c4fc5b572028c9da95b7
tree048a24441147bf0eb09676f3e2b7c6865e1353a4
parent7d9a9a1a88a3da574e019b4de756bc73337b3b0b
sch_cake: Fix out of bounds when parsing TCP options and header

[ Upstream commit ba91c49dedbde758ba0b72f57ac90b06ddf8e548 ]

The TCP option parser in cake qdisc (cake_get_tcpopt and
cake_tcph_may_drop) could read one byte out of bounds. When the length
is 1, the execution flow gets into the loop, reads one byte of the
opcode, and if the opcode is neither TCPOPT_EOL nor TCPOPT_NOP, it reads
one more byte, which exceeds the length of 1.

This fix is inspired by commit 9609dad263f8 ("ipv4: tcp_input: fix stack
out of bounds when parsing TCP options.").

v2 changes:

Added doff validation in cake_get_tcphdr to avoid parsing garbage as TCP
header. Although it wasn't strictly an out-of-bounds access (memory was
allocated), garbage values could be read where CAKE expected the TCP
header if doff was smaller than 5.

Cc: Young Xiao <92siuyang@gmail.com>
Fixes: 8b7138814f29 ("sch_cake: Add optional ACK filter")
Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sched/sch_cake.c