Re: __user annotations

Ingo Oeser (ingo.oeser@informatik.tu-chemnitz.de)
Sat, 7 Jun 2003 14:32:19 +0200


Hi Linus,

On Fri, Jun 06, 2003 at 10:28:22AM -0700, Linus Torvalds wrote:
> HOWEVER, usually it's very obvious to fix the whole chain, unless some
> type is sometimes used for kernel addresses and sometimes for user
> addresses (which networking does with iovec's, for example).

Then it's not very useful for me. I usally define the ABI between
user space and kernel space trough IOCTL like that:

/* These structures are usally bigger and nested deeper */
struct in_foo_ioctl_name {
int bla;
}

struct out_foo_ioctl_name {
char blubb;
}

union foo_ioctl_name {
struct in_foo_ioctl_name in;
struct out_foo_ioctl_name out;
}

#define SUBSYS_IOCTL 0xee

#define SUBSYS_FOO _IOWR(SUBSYS_IOCTL, 0x1, union foo_ioctl_name)

Now I do in principle

union foo_ioctl_name k, *u = (union foo_ioctl_name *)arg;

if (copy_from_user(&k.in, &u, sizeof(k.in)) return -EFAULT;
if (handle_foo(&k)) return -EINVAL;
if (copy_to_user(&u, &k.out, sizeof(k.out)) return -EFAULT;

which I consider very clean (our project provides both: The
only ABI provider and the only ABI user) and works from 2.0
trough 2.5 so far.

This will NOT work anymore with __user annotations, right?

That's a big pity. How do I workaround this? I would like to
help resolving this issues, if you are interested.

Regards

Ingo Oeser
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/