Thread (104 messages) 104 messages, 8 authors, 2011-03-06

Re: [PATCH 0/4 RESEND] exec: unify compat/non-compat code

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2011-02-25 18:55:24
Also in: lkml

On Fri, Feb 25, 2011 at 9:52 AM, Oleg Nesterov [off-list ref] wrote:
quoted
On 12/01, Milton Miller wrote:
quoted
quoted
+#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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help