sctp: add a ceiling to optlen in some sockopts
authorMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Mon, 8 Jan 2018 21:02:28 +0000 (19:02 -0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 10 Jan 2018 19:53:22 +0000 (14:53 -0500)
commit5960cefab9df76600a1a7d4ff592c59e14616e88
treef7fe350ca04f5ebb6ffa9d7fa09fcc822641c4a1
parent2e83acb970684008baee471427270c029a76ddbd
sctp: add a ceiling to optlen in some sockopts

Hangbin Liu reported that some sockopt calls could cause the kernel to log
a warning on memory allocation failure if the user supplied a large optlen
value. That is because some of them called memdup_user() without a ceiling
on optlen, allowing it to try to allocate really large buffers.

This patch adds a ceiling by limiting optlen to the maximum allowed that
would still make sense for these sockopt.

Reported-by: Hangbin Liu <haliu@redhat.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/socket.c