[PATCH 0/9] avoid mixing __user and kernel pointers

Dan Carpenter dan.carpenter at oracle.com
Thu Sep 20 12:52:24 UTC 2012


On Thu, Sep 20, 2012 at 12:58:56PM +0100, Ian Abbott wrote:
> Greg originally added the __user tags, now they've been taken out.  I
> don't want to go through the same pain when one of the other "higher
> ups" objects to their removal and wants to put them back.
> Better to get it over with now!
> 

I looked back at the change you are talking about.

Greg did a mass tagging of __user pointers.  When Greg did that the
code in do_cmd_ioctl() was a mess.  Even knowing how the code is
supposed to work, when I looked at the old version of do_cmd_ioctl()
it still took me a while to figure out what was happening.  Adding a
__user tag at that time was completely understandable.

I'm not saying we should remove the __user tag from the kernel.
I've said over and over that Sparse is a great tool.

I've said that it's dangerous to reuse the same pointer in different
ways.  But that's not what is happening here.  The pointer is a
kernel pointer 99% of the time.  It is only a user pointer inside
3 functions and only before we can allocate a kernel pointer and
we preserve it so we can give it back to the user as well.

The thing is self contained.  It's clean.  It's obvious.  It's
documented.

regards,
dan carpenter



More information about the devel mailing list