Re: [PATCH] ipv4/ip_sockglue.c: copy msg_control optval from userto kernel space

From: David Miller
Date: Fri Jan 15 2010 - 20:30:59 EST


From: H Hartley Sweeten <hartleys@xxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxxxxx>

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?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/