From: David Laight <David.Laight@ACULAB.COM>
To: 'Al Viro' <viro@zeniv.linux.org.uk>, Christoph Hellwig <hch@lst.de>
Cc: "linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
"linux-parisc@vger.kernel.org" <linux-parisc@vger.kernel.org>,
Arnd Bergmann <arnd@arndb.de>, Brian Gerst <brgerst@gmail.com>,
"x86@kernel.org" <x86@kernel.org>,
"linux-mips@vger.kernel.org" <linux-mips@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
"sparclinux@vger.kernel.org" <sparclinux@vger.kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: RE: [PATCH 3/4] exec: simplify the compat syscall handling
Date: Fri, 26 Mar 2021 16:44:48 +0000 [thread overview]
Message-ID: <da94e124fad244459fe3431077c7ffa8@AcuMS.aculab.com> (raw)
In-Reply-To: <YF4H58gozyNkoCeO@zeniv-ca.linux.org.uk>
From: Al Viro
> Sent: 26 March 2021 16:12
>
> On Fri, Mar 26, 2021 at 03:38:30PM +0100, Christoph Hellwig wrote:
>
> > +static const char __user *
> > +get_user_arg_ptr(const char __user *const __user *argv, int nr)
> > {
> > + if (in_compat_syscall()) {
> > + const compat_uptr_t __user *compat_argv =
> > + compat_ptr((unsigned long)argv);
> > compat_uptr_t compat;
> >
> > + if (get_user(compat, compat_argv + nr))
> > return ERR_PTR(-EFAULT);
> > return compat_ptr(compat);
> > + } else {
> > + const char __user *native;
> >
> > + if (get_user(native, argv + nr))
> > + return ERR_PTR(-EFAULT);
> > + return native;
> > + }
> > }
>
> Yecchhh.... So you have in_compat_syscall() called again and again, for
> each argument in the list? I agree that current version is fucking ugly,
> but I really hate that approach ;-/
Especially since in_compat_syscall() isn't entirely trivial on x86-64.
Probably all in the noise for 'exec', but all the bits do add up.
You may not want separate get_user() on some architectures either.
The user_access_begin/end aren't cheap.
OTOH if you call copy_from_user() you get hit by the stupid
additional costs of 'user copy hardening'.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2021-03-26 16:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-26 14:38 cleanup compat exec handling Christoph Hellwig
2021-03-26 14:38 ` [PATCH 1/4] exec: remove do_execve Christoph Hellwig
2021-03-26 15:04 ` Arnd Bergmann
2021-03-26 14:38 ` [PATCH 2/4] exec: remove compat_do_execve Christoph Hellwig
2021-03-26 15:42 ` Andreas Schwab
2021-03-27 19:56 ` Sergei Shtylyov
2021-03-26 14:38 ` [PATCH 3/4] exec: simplify the compat syscall handling Christoph Hellwig
2021-03-26 15:02 ` Arnd Bergmann
2021-03-26 16:12 ` Al Viro
2021-03-26 16:44 ` David Laight [this message]
2021-03-26 21:22 ` Eric W. Biederman
2021-03-26 14:38 ` [PATCH 4/4] exec: move the call to getname_flags into do_execveat Christoph Hellwig
2021-03-26 15:12 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da94e124fad244459fe3431077c7ffa8@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=arnd@arndb.de \
--cc=brgerst@gmail.com \
--cc=ebiederm@xmission.com \
--cc=hch@lst.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mcgrof@kernel.org \
--cc=sparclinux@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).