mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
llc: Improve setsockopt() handling of malformed user input
[ Upstream commit1465036b10
] 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:1da177e4c3
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
f688979e42
commit
981d647c6f
@ -1099,7 +1099,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;
|
||||
|
Loading…
Reference in New Issue
Block a user