Re: Using __user with compat_uptr_t

From: Linus Torvalds
Date: Tue Apr 26 2005 - 09:41:47 EST




On Tue, 26 Apr 2005, David Howells wrote:
>
> For example, is this right?:
>
> struct compat_nfs_string {
> compat_uint_t len;
> compat_uptr_t __user data;
> };

Nope. That makes "data" itself (the compat-pointer, not the thing it
points to) be marked as being in user space, which is not right.

> Or is this right?:
>
> struct compat_nfs_string {
> compat_uint_t len;
> compat_uptr_t data;
> };

Yes. Now, when you use "compat_ptr()" on that thing, compat_ptr() will do
the proper thing, and results in a "void __user *", so assuming you
convert the pointer correctly, it will always end up having the right user
annotation.

(Except on MIPS, where compat_ptr() doesn't, but MIPS hasn't been updated
to do any sparse checking anyway).

Linus
-
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/