Skip to content

Commit 644c7e4

Browse files
Jozsef Kadlecsikummakynes
authored andcommitted
netfilter: nf_conntrack_tcp: Fix stack out of bounds when parsing TCP options
Baozeng Ding reported a KASAN stack out of bounds issue - it uncovered that the TCP option parsing routines in netfilter TCP connection tracking could read one byte out of the buffer of the TCP options. Therefore in the patch we check that the available data length is large enough to parse both TCP option code and size. Reported-by: Baozeng Ding <sploving1@gmail.com> Tested-by: Baozeng Ding <sploving1@gmail.com> Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent ff76def commit 644c7e4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/netfilter/nf_conntrack_proto_tcp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,8 @@ static void tcp_options(const struct sk_buff *skb,
410410
length--;
411411
continue;
412412
default:
413+
if (length < 2)
414+
return;
413415
opsize=*ptr++;
414416
if (opsize < 2) /* "silly options" */
415417
return;
@@ -470,6 +472,8 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff,
470472
length--;
471473
continue;
472474
default:
475+
if (length < 2)
476+
return;
473477
opsize = *ptr++;
474478
if (opsize < 2) /* "silly options" */
475479
return;

0 commit comments

Comments
 (0)