diff options
author | Michal Luczaj <mhal@rbox.co> | 2024-11-19 14:31:41 +0100 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2024-11-28 08:57:42 +0100 |
commit | 1465036b10be4b8b00eb31c879e86de633ad74c1 (patch) | |
tree | 1094d8a2f4978549b5d2999fbd7abe780305dcf8 /net | |
parent | 5dfd7d940094e1a1ec974d90f6d28162d372b56b (diff) |
llc: Improve setsockopt() handling of malformed user input
copy_from_sockptr() is used incorrectly: return value is the number of
bytes that could not be copied. Since it's deprecated, switch to
copy_safe_from_sockptr().
Note: Keeping the `optlen != sizeof(int)` check as copy_safe_from_sockptr()
by itself would also accept optlen > sizeof(int). Which would allow a more
lenient handling of inputs.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Suggested-by: David Wei <dw@davidwei.uk>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/llc/af_llc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index 4eb52add7103..0259cde394ba 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c @@ -1098,7 +1098,7 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname, lock_sock(sk); if (unlikely(level != SOL_LLC || optlen != sizeof(int))) goto out; - rc = copy_from_sockptr(&opt, optval, sizeof(opt)); + rc = copy_safe_from_sockptr(&opt, sizeof(opt), optval, optlen); if (rc) goto out; rc = -EINVAL; |