[PATCH v2 0/5] exec: unify native/compat code
From: Oleg Nesterov
Date: Tue Mar 01 2011 - 15:56:44 EST
On 02/26, Oleg Nesterov wrote:
>
> On 02/26, Linus Torvalds wrote:
> >
> > See? The advantage of the union is that the types are correct, which
> > means that the casts are unnecessary.
>
> My point was, apart from the trivial get_arg_ptr() helper, nobody else
> uses this argv/envp, so I thought it is OK to drop the type info and
> use "void *".
>
> But as I said, I won't insist. I'll redo/resend.
Well, yes... But it turns out I didn't actually read what you proposed.
typedef union {
compat_uptr_t compat;
const char __user *native;
} conditional_user_ptr_t;
...
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...
OK, we have two kinds of pointers, the union makes sense. But I think
we do not want the 3rd kind, pointer to the union. This can't help to
avoid the casts. Yes, get_arg_ptr() can do
&argv->native
but this still means the cast even if looks differently (and tricky).
And. How can we pass "argv" from do_execve() to do_execve_common() ?
We need another cast.
So. If you insist you prefer the pointer to the union - no need to
convince me. Just say this and I'll redo again.
This patch does:
typedef union {
const char __user *const __user *native;
compat_uptr_t __user *compat;
} conditional_user_ptr_t;
static int do_execve_common(const char *filename,
conditional_user_ptr_t argv,
conditional_user_ptr_t envp,
struct pt_regs *regs, bool compat)
get_arg_ptr() does argv.native/compat, this looks more understandable.
Do you agree?
copy_strings_kernel() still needs the cast, but this is only because
we want to add "__user" for annotation.
Oleg.
--
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/