mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 04:06:26 +00:00
scm: add user copy checks to put_cmsg()
[ Upstream commit5f1eb1ff58
] This is a followup of commit2558b8039d
("net: use a bounce buffer for copying skb->mark") x86 and powerpc define user_access_begin, meaning that they are not able to perform user copy checks when using user_write_access_begin() / unsafe_copy_to_user() and friends [1] Instead of waiting bugs to trigger on other arches, add a check_object_size() in put_cmsg() to make sure that new code tested on x86 with CONFIG_HARDENED_USERCOPY=y will perform more security checks. [1] We can not generically call check_object_size() from unsafe_copy_to_user() because UACCESS is enabled at this point. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Kees Cook <keescook@chromium.org> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
eb726a7910
commit
fa66c02e4c
@ -229,6 +229,8 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
|
||||
if (msg->msg_control_is_user) {
|
||||
struct cmsghdr __user *cm = msg->msg_control_user;
|
||||
|
||||
check_object_size(data, cmlen - sizeof(*cm), true);
|
||||
|
||||
if (!user_write_access_begin(cm, cmlen))
|
||||
goto efault;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user