Re: __user annotations

From: Ingo Oeser (
Date: Sat Jun 07 2003 - 07:32:19 EST

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(&, &u, sizeof( 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.


Ingo Oeser
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Sat Jun 07 2003 - 22:00:33 EST