* [PATCH] ipv4/ip_sockglue.c: copy msg_control optval from user to kernel space
@ 2010-01-15 17:24 H Hartley Sweeten
2010-01-16 1:30 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: H Hartley Sweeten @ 2010-01-15 17:24 UTC (permalink / raw)
To: Linux Kernel, netdev; +Cc: davem, kuznet, pekkas, jmorris, yoshfuji, kaber
ipv4/ip_sockglue.c: copy msg_control optval from user to kernel space
In do_ip_getsockopt the char __user *optval is used directly in
IP_PKTOPTIONS for the msg.msg_control and not copied from
user to kernel address space. This produces a sparse warning:
warning: incorrect type in assignment (different address spaces)
expected void *msg_control
got char [noderef] <asn:1>*optval
Fix this by using copy _from_user to set msg.msg_control.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: "Pekka Savola (ipv6)" <pekkas@netcore.fi>
Cc: James Morris <jmorris@namei.org>
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Cc: Patrick McHardy <kaber@trash.net>
---
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index cafad9b..8065456 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -1173,7 +1173,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
if (sk->sk_type != SOCK_STREAM)
return -ENOPROTOOPT;
- msg.msg_control = optval;
+ if (copy_from_user(msg.msg_control, optval, len))
+ return -EFAULT;
msg.msg_controllen = len;
msg.msg_flags = 0;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ipv4/ip_sockglue.c: copy msg_control optval from user to kernel space
2010-01-15 17:24 [PATCH] ipv4/ip_sockglue.c: copy msg_control optval from user to kernel space H Hartley Sweeten
@ 2010-01-16 1:30 ` David Miller
[not found] ` <BD79186B4FD85F4B8E60E381CAEE19091E790C@mi8nycmail19.Mi8.com>
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2010-01-16 1:30 UTC (permalink / raw)
To: hartleys; +Cc: linux-kernel, netdev, kuznet, pekkas, jmorris, yoshfuji, kaber
From: H Hartley Sweeten <hartleys@visionengravers.com>
Date: Fri, 15 Jan 2010 10:24:59 -0700
> ipv4/ip_sockglue.c: copy msg_control optval from user to kernel space
>
> In do_ip_getsockopt the char __user *optval is used directly in
> IP_PKTOPTIONS for the msg.msg_control and not copied from
> user to kernel address space. This produces a sparse warning:
>
> warning: incorrect type in assignment (different address spaces)
> expected void *msg_control
> got char [noderef] <asn:1>*optval
>
> Fix this by using copy _from_user to set msg.msg_control.
>
> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
This isn't right.
We want the 'optval' pointer itself, not the data it points to, stored
in msg.msg_control
And 'msg_control' is, in this case a user pointer.
It just isn't annotated (along with the rest of struct msghdr) with
"__user" because we mix the usage of this object with kernel and user
pointers.
How did you test your change?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-16 8:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-15 17:24 [PATCH] ipv4/ip_sockglue.c: copy msg_control optval from user to kernel space H Hartley Sweeten
2010-01-16 1:30 ` David Miller
[not found] ` <BD79186B4FD85F4B8E60E381CAEE19091E790C@mi8nycmail19.Mi8.com>
2010-01-16 8:50 ` David Miller
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).