[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTimv6=QuK2+ye=OFCdRN_285GsNc4CnWEQf8OY26@mail.gmail.com>
Date: Fri, 25 Feb 2011 10:54:24 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
LKML <linux-kernel@...r.kernel.org>,
linux-mm <linux-mm@...ck.org>, pageexec@...email.hu,
Solar Designer <solar@...nwall.com>,
Eugene Teo <eteo@...hat.com>,
Brad Spengler <spender@...ecurity.net>,
Roland McGrath <roland@...hat.com>,
Milton Miller <miltonm@....com>
Subject: Re: [PATCH 0/4 RESEND] exec: unify compat/non-compat code
On Fri, Feb 25, 2011 at 9:52 AM, Oleg Nesterov <oleg@...hat.com> wrote:
>> On 12/01, Milton Miller wrote:
>> >
>> > > +#ifdef CONFIG_COMPAT
>> > > +int compat_do_execve(char * filename,
>> > > + compat_uptr_t __user *argv,
>> > > + compat_uptr_t __user *envp,
>> > > + struct pt_regs * regs)
>> > > +{
>> > > + return do_execve_common(filename,
>> > > + (void __user*)argv, (void __user*)envp,
>> >
>> > Shouldn't these be compat_ptr(argv)? (makes a difference on s390)
Indeed. The "compat_uptr_t __user *argv" is wrong, and it should be just
compat_uptr_t argv;
and then every time you turn it into a pointer, it should use
"compat_ptr(argv)".
Then, since it's a pointer to an array of pointers, when you do that,
you should turn it into a pointer to "compat_uptr_t", so you actually
have this:
- user passes "compat_uptr_t"
- the kernel can turn that into "compat_uptr_t __user *" by doing
compat_uptr_t __user *pptr;
pptr = compat_ptr(argv);
- the kernel needs to fetch the individual entries with
compat_uptr_t cuptr = get_user(pptr);
- the kernel can then turn _those_ into the actual pointers to the string with
const char __user *str = compat_ptr(cuptr);
so you need two levels of compat_ptr() conversion.
> So, once again, this should not (and can not) be compat_ptr(argv) afaics.
It can be, and probably should. But the low-level s390 wrapper
function may have done one of the levels already. It probably
shouldn't, and we _should_ do the "compat_ptr()" thing a the generic C
level. That's what we do with all the other pointers, after all.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists