netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] scm: add user copy checks to put_cmsg()
@ 2023-02-17 18:24 Eric Dumazet
  2023-02-18  1:41 ` Kees Cook
  2023-02-20 11:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2023-02-17 18:24 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: netdev, eric.dumazet, Eric Dumazet, Kees Cook

This is a followup of commit 2558b8039d05 ("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>
---
 net/core/scm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/scm.c b/net/core/scm.c
index 5c356f0dee30c3edaa57b49176cce021d5248cd7..acb7d776fa6ec29cdd9ae7d3a9970384c887ac75 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -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;
 
-- 
2.39.2.637.g21b0678d19-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] scm: add user copy checks to put_cmsg()
  2023-02-17 18:24 [PATCH net-next] scm: add user copy checks to put_cmsg() Eric Dumazet
@ 2023-02-18  1:41 ` Kees Cook
  2023-02-20 11:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2023-02-18  1:41 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, netdev,
	eric.dumazet

On Fri, Feb 17, 2023 at 06:24:54PM +0000, Eric Dumazet wrote:
> This is a followup of commit 2558b8039d05 ("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>

Thanks!

Acked-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] scm: add user copy checks to put_cmsg()
  2023-02-17 18:24 [PATCH net-next] scm: add user copy checks to put_cmsg() Eric Dumazet
  2023-02-18  1:41 ` Kees Cook
@ 2023-02-20 11:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-02-20 11:50 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: davem, kuba, pabeni, netdev, eric.dumazet, keescook

Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 17 Feb 2023 18:24:54 +0000 you wrote:
> This is a followup of commit 2558b8039d05 ("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]
> 
> [...]

Here is the summary with links:
  - [net-next] scm: add user copy checks to put_cmsg()
    https://git.kernel.org/netdev/net-next/c/5f1eb1ff58ea

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-20 11:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-17 18:24 [PATCH net-next] scm: add user copy checks to put_cmsg() Eric Dumazet
2023-02-18  1:41 ` Kees Cook
2023-02-20 11:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).