linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/ipv6: propagate user pointer annotation
@ 2020-11-27  9:34 Lukas Bulwahn
  2020-12-01 14:43 ` Christoph Hellwig
  2020-12-01 21:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Lukas Bulwahn @ 2020-11-27  9:34 UTC (permalink / raw)
  To: Christoph Hellwig, David S . Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Jakub Kicinski, netdev
  Cc: kernel-janitors, linux-kernel, Lukas Bulwahn

For IPV6_2292PKTOPTIONS, do_ipv6_getsockopt() stores the user pointer
optval in the msg_control field of the msghdr.

Hence, sparse rightfully warns at ./net/ipv6/ipv6_sockglue.c:1151:33:

  warning: incorrect type in assignment (different address spaces)
      expected void *msg_control
      got char [noderef] __user *optval

Since commit 1f466e1f15cf ("net: cleanly handle kernel vs user buffers for
->msg_control"), user pointers shall be stored in the msg_control_user
field, and kernel pointers in the msg_control field. This allows to
propagate __user annotations nicely through this struct.

Store optval in msg_control_user to properly record and propagate the
memory space annotation of this pointer.

Note that msg_control_is_user is set to true, so the key invariant, i.e.,
use msg_control_user if and only if msg_control_is_user is true, holds.

The msghdr is further used in the six alternative put_cmsg() calls, with
msg_control_is_user being true, put_cmsg() picks msg_control_user
preserving the __user annotation and passes that properly to
copy_to_user().

No functional change. No change in object code.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
---
Christoph, please review and ack.

David, Alexey, Hideaki-san, Jakub,
  please pick this minor non-urgent clean-up patch.

 net/ipv6/ipv6_sockglue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 43a894bf9a1b..a6804a7e34c1 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -1148,7 +1148,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
 		if (sk->sk_type != SOCK_STREAM)
 			return -ENOPROTOOPT;
 
-		msg.msg_control = optval;
+		msg.msg_control_user = optval;
 		msg.msg_controllen = len;
 		msg.msg_flags = flags;
 		msg.msg_control_is_user = true;
-- 
2.17.1


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

* Re: [PATCH] net/ipv6: propagate user pointer annotation
  2020-11-27  9:34 [PATCH] net/ipv6: propagate user pointer annotation Lukas Bulwahn
@ 2020-12-01 14:43 ` Christoph Hellwig
  2020-12-01 21:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2020-12-01 14:43 UTC (permalink / raw)
  To: Lukas Bulwahn
  Cc: Christoph Hellwig, David S . Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Jakub Kicinski, netdev, kernel-janitors,
	linux-kernel

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH] net/ipv6: propagate user pointer annotation
  2020-11-27  9:34 [PATCH] net/ipv6: propagate user pointer annotation Lukas Bulwahn
  2020-12-01 14:43 ` Christoph Hellwig
@ 2020-12-01 21:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2020-12-01 21:00 UTC (permalink / raw)
  To: Lukas Bulwahn
  Cc: hch, davem, kuznet, yoshfuji, kuba, netdev, kernel-janitors,
	linux-kernel

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Fri, 27 Nov 2020 10:34:21 +0100 you wrote:
> For IPV6_2292PKTOPTIONS, do_ipv6_getsockopt() stores the user pointer
> optval in the msg_control field of the msghdr.
> 
> Hence, sparse rightfully warns at ./net/ipv6/ipv6_sockglue.c:1151:33:
> 
>   warning: incorrect type in assignment (different address spaces)
>       expected void *msg_control
>       got char [noderef] __user *optval
> 
> [...]

Here is the summary with links:
  - net/ipv6: propagate user pointer annotation
    https://git.kernel.org/netdev/net-next/c/9e39394faef6

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:[~2020-12-01 21:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-27  9:34 [PATCH] net/ipv6: propagate user pointer annotation Lukas Bulwahn
2020-12-01 14:43 ` Christoph Hellwig
2020-12-01 21:00 ` 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).