Patch "sctp: add a ceiling to optlen in some sockopts" has been added to the 4.14-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
sctp: add a ceiling to optlen in some sockopts
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
sctp-add-a-ceiling-to-optlen-in-some-sockopts.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Wed Feb 28 16:23:28 CET 2018
From: Marcelo Ricardo Leitner <[email protected]>
Date: Mon, 8 Jan 2018 19:02:28 -0200
Subject: sctp: add a ceiling to optlen in some sockopts
From: Marcelo Ricardo Leitner <[email protected]>
[ 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.
--- net/sctp/socket.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/sctp/socket.c +10 -0
@@ -3494,6 +3494,8 @@ static int sctp_setsockopt_hmac_ident(stif (optlen <sizeof (struct sctp_hmacalgo ))return -EINVAL ; + optlen = min_t(unsigned int, optlen, sizeof(struct sctp_hmacalgo) + +SCTP_AUTH_NUM_HMACS *sizeof (u16)); hmacs =memdup_user (optval, optlen);if (IS_ERR (hmacs))
@@ -3532,6 +3534,11 @@ static int sctp_setsockopt_auth_key(struif (optlen <=sizeof (struct sctp_authkey ))return -EINVAL ; +/* authkey->sca_keylength is u16, so optlen can't be bigger than +* this. +*/ + optlen = min_t(unsigned int, optlen, USHRT_MAX + +sizeof (struct sctp_authkey )); authkey =memdup_user (optval, optlen);if (IS_ERR (authkey))
@@ -3889,6 +3896,9 @@ static int sctp_setsockopt_reset_streamsif (optlen <sizeof (*params))return -EINVAL ; +/* srs_number_streams is u16, so optlen can't be bigger than this. */ + optlen = min_t(unsigned int, optlen, USHRT_MAX + +sizeof (__u16) *sizeof (*params)); params =memdup_user (optval, optlen);if (IS_ERR (params))
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/sctp-make-use-of-pre-calculated-len.patch queue-4.14/sctp-add-a-ceiling-to-optlen-in-some-sockopts.patch queue-4.14/sctp-fix-the-issue-that-a-__u16-variable-may-overflow-in-sctp_ulpq_renege.patch