]> git.baikalelectronics.ru Git - kernel.git/commit
scm: add user copy checks to put_cmsg()
authorEric Dumazet <edumazet@google.com>
Fri, 17 Feb 2023 18:24:54 +0000 (18:24 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:33:54 +0000 (09:33 +0100)
commit61fb7ee16a5b1e70fcc3dd239d7daf604a677410
treed1998f8e769a8a7386265c9736b89cdfbf417a90
parent2fcaa93b608e7b2e340aaf197a3de803c59df594
scm: add user copy checks to put_cmsg()

[ Upstream commit 5c03c2cef1b3d2ec2f0280737caaf20eb014c37e ]

This is a followup of commit a71d0369d2a7 ("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>
net/core/scm.c