summaryrefslogtreecommitdiff
path: root/net/rxrpc
diff options
context:
space:
mode:
authorMichal Luczaj <mhal@rbox.co>2024-11-19 14:31:42 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-14 19:53:52 +0100
commita7845361d51e910a820054543dc854dea4e6d9e9 (patch)
tree5d9b30421053dc94b3517def12070ec6a7565e29 /net/rxrpc
parent981d647c6f664871cc75ad424eead207df7dc571 (diff)
downloadlinux-a7845361d51e910a820054543dc854dea4e6d9e9.tar.gz
linux-a7845361d51e910a820054543dc854dea4e6d9e9.tar.bz2
linux-a7845361d51e910a820054543dc854dea4e6d9e9.zip
rxrpc: Improve setsockopt() handling of malformed user input
[ Upstream commit 02020056647017e70509bb58c3096448117099e1 ] copy_from_sockptr() does not return negative value on error; instead, it reports the number of bytes that failed to copy. Since it's deprecated, switch to copy_safe_from_sockptr(). Note: Keeping the `optlen != sizeof(unsigned int)` check as copy_safe_from_sockptr() by itself would also accept optlen > sizeof(unsigned int). Which would allow a more lenient handling of inputs. Fixes: 17926a79320a ("[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both") Signed-off-by: Michal Luczaj <mhal@rbox.co> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/rxrpc')
-rw-r--r--net/rxrpc/af_rxrpc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index ceba28e9dce6..9b3efe6d580f 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -641,9 +641,10 @@ static int rxrpc_setsockopt(struct socket *sock, int level, int optname,
ret = -EISCONN;
if (rx->sk.sk_state != RXRPC_UNBOUND)
goto error;
- ret = copy_from_sockptr(&min_sec_level, optval,
- sizeof(unsigned int));
- if (ret < 0)
+ ret = copy_safe_from_sockptr(&min_sec_level,
+ sizeof(min_sec_level),
+ optval, optlen);
+ if (ret)
goto error;
ret = -EINVAL;
if (min_sec_level > RXRPC_SECURITY_MAX)