Skip to content

Commit 1465036

Browse files
mmhalPaolo Abeni
authored andcommitted
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>
1 parent 5dfd7d9 commit 1465036

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/llc/af_llc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname,
10981098
lock_sock(sk);
10991099
if (unlikely(level != SOL_LLC || optlen != sizeof(int)))
11001100
goto out;
1101-
rc = copy_from_sockptr(&opt, optval, sizeof(opt));
1101+
rc = copy_safe_from_sockptr(&opt, sizeof(opt), optval, optlen);
11021102
if (rc)
11031103
goto out;
11041104
rc = -EINVAL;

0 commit comments

Comments
 (0)