OSDN Git Service

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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 3 Mar 2018 09:24:37 +0000 (10:24 +0100)
commit413e58ac3d845144f9b70b85b2f4add7d3249948
tree6f737078488878c6a541d7fc12261bc88c6f6388
parentcd659881219d8a39a523d2a42ae04e3fc416d030
sctp: add a ceiling to optlen in some sockopts

[ Upstream commit 5960cefab9df76600a1a7d4ff592c59e14616e88 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sctp/socket.c