Skip to content

Commit 0202005

Browse files
mmhalPaolo Abeni
authored andcommitted
rxrpc: Improve setsockopt() handling of malformed user input
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: 17926a7 ("[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>
1 parent 1465036 commit 0202005

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net/rxrpc/af_rxrpc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,9 +707,10 @@ static int rxrpc_setsockopt(struct socket *sock, int level, int optname,
707707
ret = -EISCONN;
708708
if (rx->sk.sk_state != RXRPC_UNBOUND)
709709
goto error;
710-
ret = copy_from_sockptr(&min_sec_level, optval,
711-
sizeof(unsigned int));
712-
if (ret < 0)
710+
ret = copy_safe_from_sockptr(&min_sec_level,
711+
sizeof(min_sec_level),
712+
optval, optlen);
713+
if (ret)
713714
goto error;
714715
ret = -EINVAL;
715716
if (min_sec_level > RXRPC_SECURITY_MAX)

0 commit comments

Comments
 (0)