Re: [PATCH v2 0/5] exec: unify native/compat code

From: Linus Torvalds
Date: Tue Mar 01 2011 - 16:40:34 EST


On Tue, Mar 1, 2011 at 12:47 PM, Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
>        where that 'do_execve_common()' takes it's arguments as
>
>                union conditional_user_ptr_t __user *argv,
>                union conditional_user_ptr_t __user *envp
>
> I hope you didn't really mean this...

I really did mean that (although not the double "union" + "_t" thing
for the typedef).

But I'm not going to claim that it has to be done exactly that way,
the union can certainly be encapsulated differently too.

So I'm ok with your alternative

>        typedef union {
>                const char __user *const __user *native;
>                compat_uptr_t __user *compat;
>        } conditional_user_ptr_t;

model instead, which moves the pointer into the union.

However, if you do this, then I have one more suggestion: just move
the "compat" flag in there too!

Every time you pass the union, you're going to pass the compat flag to
distinguish the cases. So do it like this:

struct conditional_ptr {
int is_compat;
union {
const char __user *const __user *native;
compat_uptr_t __user *compat;
};
};

and it will all look much cleaner, I bet.

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/