All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Christoph Hellwig <hch@lst.de>, Al Viro <viro@zeniv.linux.org.uk>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	"open list:BROADCOM NVRAM DRIVER" <linux-mips@vger.kernel.org>,
	Parisc List <linux-parisc@vger.kernel.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	linux-s390 <linux-s390@vger.kernel.org>,
	sparclinux <sparclinux@vger.kernel.org>,
	Linux FS-devel Mailing List <linux-fsdevel@vger.kernel.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/6] exec: simplify the compat syscall handling
Date: Mon, 15 Jun 2020 16:12:39 +0200	[thread overview]
Message-ID: <20200615141239.GA12951@lst.de> (raw)
In-Reply-To: <CAK8P3a0bRD3RzE_X6Tjzu9Tj+OhHhP+S=k6+VYODBGko8oQhew@mail.gmail.com>

On Mon, Jun 15, 2020 at 03:31:35PM +0200, Arnd Bergmann wrote:
> >  #ifdef CONFIG_COMPAT
> > -       if (unlikely(argv.is_compat)) {
> > +       if (in_compat_syscall()) {
> > +               const compat_uptr_t __user *compat_argv =
> > +                       compat_ptr((unsigned long)argv);
> >                 compat_uptr_t compat;
> >
> > -               if (get_user(compat, argv.ptr.compat + nr))
> > +               if (get_user(compat, compat_argv + nr))
> >                         return ERR_PTR(-EFAULT);
> >
> >                 return compat_ptr(compat);
> >         }
> >  #endif
> 
> I would expect that the "#ifdef CONFIG_COMPAT" can be removed
> now, since compat_ptr() and in_compat_syscall() are now defined
> unconditionally. I have not tried that though.

True, I'll give it a spin.

> > +/*
> > + * x32 syscalls are listed in the same table as x86_64 ones, so we need to
> > + * define compat syscalls that are exactly the same as the native version for
> > + * the syscall table machinery to work.  Sigh..
> > + */
> > +#ifdef CONFIG_X86_X32
> >  COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename,
> > -       const compat_uptr_t __user *, argv,
> > -       const compat_uptr_t __user *, envp)
> > +                      const char __user *const __user *, argv,
> > +                      const char __user *const __user *, envp)
> >  {
> > -       return do_compat_execve(AT_FDCWD, getname(filename), argv, envp, 0);
> > +       return do_execveat(AT_FDCWD, getname(filename), argv, envp, 0, NULL);
> >  }
> 
> Maybe move it to arch/x86/kernel/process_64.c or arch/x86/entry/syscall_x32.c
> to keep it out of the common code if this is needed.

I'd rather keep it in common code as that allows all the low-level
exec stuff to be marked static, and avoid us growing new pointless
compat variants through copy and paste.
smart compiler to d

> I don't really understand
> the comment, why can't this just use this?

That errors out with:

ld: arch/x86/entry/syscall_x32.o:(.rodata+0x1040): undefined reference to
`__x32_sys_execve'
ld: arch/x86/entry/syscall_x32.o:(.rodata+0x1108): undefined reference to
`__x32_sys_execveat'
make: *** [Makefile:1139: vmlinux] Error 1

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Christoph Hellwig <hch@lst.de>, Al Viro <viro@zeniv.linux.org.uk>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	"open list:BROADCOM NVRAM DRIVER" <linux-mips@vger.kernel.org>,
	Parisc List <linux-parisc@vger.kernel.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	linux-s390 <linux-s390@vger.kernel.org>,
	sparclinux <sparclinux@vger.kernel.org>,
	Linux FS-devel Mailing List <linux-fsdevel@vger.kernel.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/6] exec: simplify the compat syscall handling
Date: Mon, 15 Jun 2020 14:12:39 +0000	[thread overview]
Message-ID: <20200615141239.GA12951@lst.de> (raw)
In-Reply-To: <CAK8P3a0bRD3RzE_X6Tjzu9Tj+OhHhP+S=k6+VYODBGko8oQhew@mail.gmail.com>

On Mon, Jun 15, 2020 at 03:31:35PM +0200, Arnd Bergmann wrote:
> >  #ifdef CONFIG_COMPAT
> > -       if (unlikely(argv.is_compat)) {
> > +       if (in_compat_syscall()) {
> > +               const compat_uptr_t __user *compat_argv > > +                       compat_ptr((unsigned long)argv);
> >                 compat_uptr_t compat;
> >
> > -               if (get_user(compat, argv.ptr.compat + nr))
> > +               if (get_user(compat, compat_argv + nr))
> >                         return ERR_PTR(-EFAULT);
> >
> >                 return compat_ptr(compat);
> >         }
> >  #endif
> 
> I would expect that the "#ifdef CONFIG_COMPAT" can be removed
> now, since compat_ptr() and in_compat_syscall() are now defined
> unconditionally. I have not tried that though.

True, I'll give it a spin.

> > +/*
> > + * x32 syscalls are listed in the same table as x86_64 ones, so we need to
> > + * define compat syscalls that are exactly the same as the native version for
> > + * the syscall table machinery to work.  Sigh..
> > + */
> > +#ifdef CONFIG_X86_X32
> >  COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename,
> > -       const compat_uptr_t __user *, argv,
> > -       const compat_uptr_t __user *, envp)
> > +                      const char __user *const __user *, argv,
> > +                      const char __user *const __user *, envp)
> >  {
> > -       return do_compat_execve(AT_FDCWD, getname(filename), argv, envp, 0);
> > +       return do_execveat(AT_FDCWD, getname(filename), argv, envp, 0, NULL);
> >  }
> 
> Maybe move it to arch/x86/kernel/process_64.c or arch/x86/entry/syscall_x32.c
> to keep it out of the common code if this is needed.

I'd rather keep it in common code as that allows all the low-level
exec stuff to be marked static, and avoid us growing new pointless
compat variants through copy and paste.
smart compiler to d

> I don't really understand
> the comment, why can't this just use this?

That errors out with:

ld: arch/x86/entry/syscall_x32.o:(.rodata+0x1040): undefined reference to
`__x32_sys_execve'
ld: arch/x86/entry/syscall_x32.o:(.rodata+0x1108): undefined reference to
`__x32_sys_execveat'
make: *** [Makefile:1139: vmlinux] Error 1

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arch <linux-arch@vger.kernel.org>,
	linux-s390 <linux-s390@vger.kernel.org>,
	Parisc List <linux-parisc@vger.kernel.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	"open list:BROADCOM NVRAM DRIVER" <linux-mips@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux FS-devel Mailing List <linux-fsdevel@vger.kernel.org>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	sparclinux <sparclinux@vger.kernel.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	Christoph Hellwig <hch@lst.de>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/6] exec: simplify the compat syscall handling
Date: Mon, 15 Jun 2020 16:12:39 +0200	[thread overview]
Message-ID: <20200615141239.GA12951@lst.de> (raw)
In-Reply-To: <CAK8P3a0bRD3RzE_X6Tjzu9Tj+OhHhP+S=k6+VYODBGko8oQhew@mail.gmail.com>

On Mon, Jun 15, 2020 at 03:31:35PM +0200, Arnd Bergmann wrote:
> >  #ifdef CONFIG_COMPAT
> > -       if (unlikely(argv.is_compat)) {
> > +       if (in_compat_syscall()) {
> > +               const compat_uptr_t __user *compat_argv =
> > +                       compat_ptr((unsigned long)argv);
> >                 compat_uptr_t compat;
> >
> > -               if (get_user(compat, argv.ptr.compat + nr))
> > +               if (get_user(compat, compat_argv + nr))
> >                         return ERR_PTR(-EFAULT);
> >
> >                 return compat_ptr(compat);
> >         }
> >  #endif
> 
> I would expect that the "#ifdef CONFIG_COMPAT" can be removed
> now, since compat_ptr() and in_compat_syscall() are now defined
> unconditionally. I have not tried that though.

True, I'll give it a spin.

> > +/*
> > + * x32 syscalls are listed in the same table as x86_64 ones, so we need to
> > + * define compat syscalls that are exactly the same as the native version for
> > + * the syscall table machinery to work.  Sigh..
> > + */
> > +#ifdef CONFIG_X86_X32
> >  COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename,
> > -       const compat_uptr_t __user *, argv,
> > -       const compat_uptr_t __user *, envp)
> > +                      const char __user *const __user *, argv,
> > +                      const char __user *const __user *, envp)
> >  {
> > -       return do_compat_execve(AT_FDCWD, getname(filename), argv, envp, 0);
> > +       return do_execveat(AT_FDCWD, getname(filename), argv, envp, 0, NULL);
> >  }
> 
> Maybe move it to arch/x86/kernel/process_64.c or arch/x86/entry/syscall_x32.c
> to keep it out of the common code if this is needed.

I'd rather keep it in common code as that allows all the low-level
exec stuff to be marked static, and avoid us growing new pointless
compat variants through copy and paste.
smart compiler to d

> I don't really understand
> the comment, why can't this just use this?

That errors out with:

ld: arch/x86/entry/syscall_x32.o:(.rodata+0x1040): undefined reference to
`__x32_sys_execve'
ld: arch/x86/entry/syscall_x32.o:(.rodata+0x1108): undefined reference to
`__x32_sys_execveat'
make: *** [Makefile:1139: vmlinux] Error 1

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arch <linux-arch@vger.kernel.org>,
	linux-s390 <linux-s390@vger.kernel.org>,
	Parisc List <linux-parisc@vger.kernel.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	"open list:BROADCOM NVRAM DRIVER" <linux-mips@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux FS-devel Mailing List <linux-fsdevel@vger.kernel.org>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	sparclinux <sparclinux@vger.kernel.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	Christoph Hellwig <hch@lst.de>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/6] exec: simplify the compat syscall handling
Date: Mon, 15 Jun 2020 16:12:39 +0200	[thread overview]
Message-ID: <20200615141239.GA12951@lst.de> (raw)
In-Reply-To: <CAK8P3a0bRD3RzE_X6Tjzu9Tj+OhHhP+S=k6+VYODBGko8oQhew@mail.gmail.com>

On Mon, Jun 15, 2020 at 03:31:35PM +0200, Arnd Bergmann wrote:
> >  #ifdef CONFIG_COMPAT
> > -       if (unlikely(argv.is_compat)) {
> > +       if (in_compat_syscall()) {
> > +               const compat_uptr_t __user *compat_argv =
> > +                       compat_ptr((unsigned long)argv);
> >                 compat_uptr_t compat;
> >
> > -               if (get_user(compat, argv.ptr.compat + nr))
> > +               if (get_user(compat, compat_argv + nr))
> >                         return ERR_PTR(-EFAULT);
> >
> >                 return compat_ptr(compat);
> >         }
> >  #endif
> 
> I would expect that the "#ifdef CONFIG_COMPAT" can be removed
> now, since compat_ptr() and in_compat_syscall() are now defined
> unconditionally. I have not tried that though.

True, I'll give it a spin.

> > +/*
> > + * x32 syscalls are listed in the same table as x86_64 ones, so we need to
> > + * define compat syscalls that are exactly the same as the native version for
> > + * the syscall table machinery to work.  Sigh..
> > + */
> > +#ifdef CONFIG_X86_X32
> >  COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename,
> > -       const compat_uptr_t __user *, argv,
> > -       const compat_uptr_t __user *, envp)
> > +                      const char __user *const __user *, argv,
> > +                      const char __user *const __user *, envp)
> >  {
> > -       return do_compat_execve(AT_FDCWD, getname(filename), argv, envp, 0);
> > +       return do_execveat(AT_FDCWD, getname(filename), argv, envp, 0, NULL);
> >  }
> 
> Maybe move it to arch/x86/kernel/process_64.c or arch/x86/entry/syscall_x32.c
> to keep it out of the common code if this is needed.

I'd rather keep it in common code as that allows all the low-level
exec stuff to be marked static, and avoid us growing new pointless
compat variants through copy and paste.
smart compiler to d

> I don't really understand
> the comment, why can't this just use this?

That errors out with:

ld: arch/x86/entry/syscall_x32.o:(.rodata+0x1040): undefined reference to
`__x32_sys_execve'
ld: arch/x86/entry/syscall_x32.o:(.rodata+0x1108): undefined reference to
`__x32_sys_execveat'
make: *** [Makefile:1139: vmlinux] Error 1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-06-15 14:12 UTC|newest]

Thread overview: 120+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-15 13:00 properly support exec and wait with kernel pointers Christoph Hellwig
2020-06-15 13:00 ` Christoph Hellwig
2020-06-15 13:00 ` Christoph Hellwig
2020-06-15 13:00 ` Christoph Hellwig
2020-06-15 13:00 ` [PATCH 1/6] exec: cleanup the execve wrappers Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00 ` [PATCH 2/6] exec: simplify the compat syscall handling Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:31   ` Arnd Bergmann
2020-06-15 13:31     ` Arnd Bergmann
2020-06-15 13:31     ` Arnd Bergmann
2020-06-15 13:31     ` Arnd Bergmann
2020-06-15 14:12     ` Christoph Hellwig [this message]
2020-06-15 14:12       ` Christoph Hellwig
2020-06-15 14:12       ` Christoph Hellwig
2020-06-15 14:12       ` Christoph Hellwig
2020-06-15 14:40       ` Arnd Bergmann
2020-06-15 14:40         ` Arnd Bergmann
2020-06-15 14:40         ` Arnd Bergmann
2020-06-15 14:40         ` Arnd Bergmann
2020-06-15 14:43         ` Christoph Hellwig
2020-06-15 14:43           ` Christoph Hellwig
2020-06-15 14:43           ` Christoph Hellwig
2020-06-15 14:43           ` Christoph Hellwig
2020-06-15 14:46           ` Arnd Bergmann
2020-06-15 14:46             ` Arnd Bergmann
2020-06-15 14:46             ` Arnd Bergmann
2020-06-15 14:46             ` Arnd Bergmann
2020-06-15 15:09             ` Christoph Hellwig
2020-06-15 15:09               ` Christoph Hellwig
2020-06-15 15:09               ` Christoph Hellwig
2020-06-15 15:09               ` Christoph Hellwig
2020-06-15 15:33               ` Brian Gerst
2020-06-15 15:33                 ` Brian Gerst
2020-06-15 15:33                 ` Brian Gerst
2020-06-15 15:33                 ` Brian Gerst
2020-06-15 15:33                 ` Brian Gerst
2020-06-15 16:41                 ` Christoph Hellwig
2020-06-15 16:41                   ` Christoph Hellwig
2020-06-15 16:41                   ` Christoph Hellwig
2020-06-15 16:41                   ` Christoph Hellwig
2020-06-15 14:48       ` Brian Gerst
2020-06-15 14:48         ` Brian Gerst
2020-06-15 14:48         ` Brian Gerst
2020-06-15 14:48         ` Brian Gerst
2020-06-15 18:47         ` Arnd Bergmann
2020-06-15 18:47           ` Arnd Bergmann
2020-06-15 18:47           ` Arnd Bergmann
2020-06-15 18:47           ` Arnd Bergmann
2020-06-15 19:45           ` Brian Gerst
2020-06-15 19:45             ` Brian Gerst
2020-06-15 19:45             ` Brian Gerst
2020-06-15 19:45             ` Brian Gerst
2020-06-15 13:00 ` [PATCH 3/6] exec: cleanup the count() function Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00 ` [PATCH 4/6] exec: split prepare_arg_pages Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00 ` [PATCH 5/6] exec: add a kernel_execveat helper Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00 ` [PATCH 6/6] kernel: add a kernel_wait helper Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:42 ` properly support exec and wait with kernel pointers Arnd Bergmann
2020-06-15 13:42   ` Arnd Bergmann
2020-06-15 13:42   ` Arnd Bergmann
2020-06-15 13:42   ` Arnd Bergmann
2020-06-18 14:46 properly support exec and wait with kernel pointers v2 Christoph Hellwig
2020-06-18 14:46 ` Christoph Hellwig
2020-06-18 14:46 ` Christoph Hellwig
2020-06-18 14:46 ` Christoph Hellwig
2020-06-18 14:46 ` [PATCH 1/6] exec: cleanup the execve wrappers Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46 ` [PATCH 2/6] exec: simplify the compat syscall handling Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46 ` [PATCH 3/6] exec: cleanup the count() function Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-19  8:28   ` Sergei Shtylyov
2020-06-19  8:28     ` Sergei Shtylyov
2020-06-19  8:28     ` Sergei Shtylyov
2020-06-19  8:28     ` Sergei Shtylyov
2020-06-18 14:46 ` [PATCH 4/6] exec: split prepare_arg_pages Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46 ` [PATCH 5/6] exec: add a kernel_execveat helper Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46 ` [PATCH 6/6] kernel: add a kernel_wait helper Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-19 21:17   ` Luis Chamberlain
2020-06-19 21:17     ` Luis Chamberlain
2020-06-19 21:17     ` Luis Chamberlain
2020-06-20  6:35     ` Christoph Hellwig
2020-06-20  6:35       ` Christoph Hellwig
2020-06-20  6:35       ` Christoph Hellwig
2020-06-20  6:35       ` Christoph Hellwig
2020-06-20 17:02       ` Luis Chamberlain
2020-06-20 17:02         ` Luis Chamberlain
2020-06-20 17:02         ` Luis Chamberlain

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=20200615141239.GA12951@lst.de \
    --to=hch@lst.de \
    --cc=arnd@arndb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.