]> git.baikalelectronics.ru Git - kernel.git/commit
sctp: fix slab-out-of-bounds in SCTP_DELAYED_SACK processing
authorChristoph Hellwig <hch@lst.de>
Fri, 24 Jul 2020 06:48:55 +0000 (08:48 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 24 Jul 2020 23:40:36 +0000 (16:40 -0700)
commiteff67f0b2e5ca373ebde655f48866ddb9a0a67e9
tree4f25eeb9ee33acce00d6f04f7dcdd95c64134d23
parente671531f95c7f7eea7735dca68d9751ab57d3bca
sctp: fix slab-out-of-bounds in SCTP_DELAYED_SACK processing

This sockopt accepts two kinds of parameters, using struct
sctp_sack_info and struct sctp_assoc_value. The mentioned commit didn't
notice an implicit cast from the smaller (latter) struct to the bigger
one (former) when copying the data from the user space, which now leads
to an attempt to write beyond the buffer (because it assumes the storing
buffer is bigger than the parameter itself).

Fix it by allocating a sctp_sack_info on stack and filling it out based
on the small struct for the compat case.

Changelog stole from an earlier patch from Marcelo Ricardo Leitner.

Fixes: f818b1bda430 ("sctp: pass a kernel pointer to sctp_setsockopt_delayed_ack")
Reported-by: syzbot+0e4699d000d8b874d8dc@syzkaller.appspotmail.com
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/socket.c