sctp: validate chunk len before actually using it
authorMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Tue, 25 Oct 2016 16:27:39 +0000 (14:27 -0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Feb 2017 10:03:53 +0000 (11:03 +0100)
commit0058a4c1b6209f86a29c4ecbca7e3ed55544d3b0
tree7ee1ffd527b48ea18e23959aa57ae6f9ecf34055
parent2b8ed05b145d934b5679f3c224e0d959ef20fa5b
sctp: validate chunk len before actually using it

commit bf911e985d6bbaa328c20c3e05f4eb03de11fdd6 upstream.

Andrey Konovalov reported that KASAN detected that SCTP was using a slab
beyond the boundaries. It was caused because when handling out of the
blue packets in function sctp_sf_ootb() it was checking the chunk len
only after already processing the first chunk, validating only for the
2nd and subsequent ones.

The fix is to just move the check upwards so it's also validated for the
1st chunk.

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
net/sctp/sm_statefuns.c