Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752209Ab1BZMoY (ORCPT ); Sat, 26 Feb 2011 07:44:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52100 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751971Ab1BZMoX (ORCPT ); Sat, 26 Feb 2011 07:44:23 -0500 Date: Sat, 26 Feb 2011 13:35:22 +0100 From: Oleg Nesterov To: Linus Torvalds Cc: Andrew Morton , KOSAKI Motohiro , LKML , linux-mm , pageexec@freemail.hu, Solar Designer , Eugene Teo , Brad Spengler , Roland McGrath , Milton Miller Subject: Re: [PATCH 0/4 RESEND] exec: unify compat/non-compat code Message-ID: <20110226123522.GA4416@redhat.com> References: <20101130200129.GG11905@redhat.com> <20101201182747.GB6143@redhat.com> <20110225175202.GA19059@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3128 Lines: 93 On 02/25, Linus Torvalds wrote: > > On Fri, Feb 25, 2011 at 9:52 AM, Oleg Nesterov 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)". Oh, perhaps, and I was thinking about this too. But this is another issue, no? Or I misunderstood. First of all, I agree that perhaps it makes sense to change the signature of compat_do_execve() - compat_do_execve(compat_uptr_t __user *argv) + compat_do_execve(compat_uptr_t argv) but this has nothing to do with this series. We can do this before or after ("after" seems simpler"). > - user passes "compat_uptr_t" Yes, > - the kernel can turn that into "compat_uptr_t __user *" by doing > > compat_uptr_t __user *pptr; > pptr = compat_ptr(argv); Yes! and the kernel already does this before it calls compat_do_execve(), iow compat_do_execve() gets the result of compat_ptr(compat_ptr_from_user). > - 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); Yes, and this is exactly what get_arg_ptr(compat => true) does. > > So, once again, this should not (and can not) be compat_ptr(argv) afaics. > > It can be, and probably should. Only if we change the signature of compat_do_execve(). With the current code yet another compat_ptr() is not needed and it is simply wrong, this is what I meant when I replied to Milton. > 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. Agreed, but currently this compat_ptr() thing belongs to the caller. IOW. Lets look at the current code. arch/ calls compat_do_execve(compat_uptr_t __user *argv)->compat_count(argv) which does get_user(argv) without any conversion, because argv was already converted or arch/ is buggy. Both do_execve() and compat_do_execve() accept the valid pointer which does not need any conversion. But this pointer points to different things, either to "char*" of "compat_uptr_t". However, please see my reply to 2-3/5, I agree that this is confusing and can be cleanuped. Or do you think I missed something else? Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/