All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Ungerer <gerg@linux-m68k.org>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: Rich Felker <dalias@libc.org>,
	linux-c6x-dev@linux-c6x.org,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Nicolas Pitre <nico@fluxnic.net>,
	Linux-sh list <linux-sh@vger.kernel.org>,
	Jann Horn <jannh@google.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Oleg Nesterov <oleg@redhat.com>, Linux-MM <linux-mm@kvack.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Mark Salter <msalter@redhat.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Aurelien Jacquiot <jacquiot.aurelien@gmail.com>,
	Christoph Hellwig <hch@lst.de>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	"Eric W . Biederman" <ebiederm@xmission.com>
Subject: Re: [PATCH v2 0/5] Fix ELF / FDPIC ELF core dumping, and use mmap_sem properly in there
Date: Thu, 30 Apr 2020 14:10:05 +0000	[thread overview]
Message-ID: <31196268-2ff4-7a1d-e9df-6116e92d2190@linux-m68k.org> (raw)
In-Reply-To: <CAHk-=wgpoEr33NJwQ+hqK1dz3Rs9jSw+BGotsSdt2Kb3HqLV7A@mail.gmail.com>



On 30/4/20 9:03 am, Linus Torvalds wrote:
> On Wed, Apr 29, 2020 at 2:57 PM Russell King - ARM Linux admin
> <linux@armlinux.org.uk> wrote:
>>
>> I've never had any reason to use FDPIC, and I don't have any binaries
>> that would use it.  Nicolas Pitre added ARM support, so I guess he
>> would be the one to talk to about it.  (Added Nicolas.)
> 
> While we're at it, is there anybody who knows binfmt_flat?
> 
> It might be Nicolas too.
> 
> binfmt_flat doesn't do core-dumping, but it has some other oddities.
> In particular, I'd like to bring sanity to the installation of the new
> creds, and all the _normal_ binfmt cases do it largely close together
> with setup_new_exec().
> 
> binfmt_flat is doing odd things. It's doing this:
> 
>          /* Flush all traces of the currently running executable */
>          if (id = 0) {
>                  ret = flush_old_exec(bprm);
>                  if (ret)
>                          goto err;
> 
>                  /* OK, This is the point of no return */
>                  set_personality(PER_LINUX_32BIT);
>                  setup_new_exec(bprm);
>          }
> 
> in load_flat_file() - which is also used to loading _libraries_. Where
> it makes no sense at all.

I haven't looked at the shared lib support in there for a long time,
but I thought that "id" is only 0 for the actual final program.
Libraries have a slot or id number associated with them.

> It does the
> 
>          install_exec_creds(bprm);
> 
> in load_flat_binary() (which makes more sense: that is only for actual
> binary loading, no library case).
> 
> I would _like_ for every binfmt loader to do
> 
>          /* Flush all traces of the currently running executable */
>          retval = flush_old_exec(bprm);
>          if (retval)
>                  return retval;
> 
>     .. possibly set up personalities here ..
> 
>          setup_new_exec(bprm);
>          install_exec_creds(bprm);
> 
> all together, and at least merge 'setup_new_exec()' with 'install_exec_creds()'.
> 
> And I think all the binfmt handlers would be ok with that, but the
> flat one in particular is really oddly set up.
> 
> *Particularly* with that flush_old_exec/setup_new_exec() being done by
> the same routine that is also loading libraries (and called from
> 'calc_reloc()' from binary loading too).
> 
> Adding Greg Ungerer for m68knommu. Can somebody sort out why that
> flush_old_exec/setup_new_exec() isn't in load_flat_binary() like
> install_exec_creds() is?
> 
> Most of that file goes back to pre-git days. And most of the commits
> since are not so much about binfmt_flat, as they are about cleanups or
> changes elsewhere where binfmt_flat was just a victim.

I'll have a look at this.

Quick hack test shows moving setup_new_exec(bprm) to be just before
install_exec_creds(bprm) works fine for the static binaries case.
Doing the flush_old_exec(bprm) there too crashed out - I'll need to
dig into that to see why.

Regards
Greg

WARNING: multiple messages have this Message-ID (diff)
From: Greg Ungerer <gerg@linux-m68k.org>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: Jann Horn <jannh@google.com>, Nicolas Pitre <nico@fluxnic.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	Christoph Hellwig <hch@lst.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux-MM <linux-mm@kvack.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	"Eric W . Biederman" <ebiederm@xmission.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Mark Salter <msalter@redhat.com>,
	Aurelien Jacquiot <jacquiot.aurelien@gmail.com>,
	linux-c6x-dev@linux-c6x.org,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Rich Felker <dalias@libc.org>,
	Linux-sh list <linux-sh@vger.kernel.org>
Subject: Re: [PATCH v2 0/5] Fix ELF / FDPIC ELF core dumping, and use mmap_sem properly in there
Date: Fri, 1 May 2020 00:10:05 +1000	[thread overview]
Message-ID: <31196268-2ff4-7a1d-e9df-6116e92d2190@linux-m68k.org> (raw)
In-Reply-To: <CAHk-=wgpoEr33NJwQ+hqK1dz3Rs9jSw+BGotsSdt2Kb3HqLV7A@mail.gmail.com>



On 30/4/20 9:03 am, Linus Torvalds wrote:
> On Wed, Apr 29, 2020 at 2:57 PM Russell King - ARM Linux admin
> <linux@armlinux.org.uk> wrote:
>>
>> I've never had any reason to use FDPIC, and I don't have any binaries
>> that would use it.  Nicolas Pitre added ARM support, so I guess he
>> would be the one to talk to about it.  (Added Nicolas.)
> 
> While we're at it, is there anybody who knows binfmt_flat?
> 
> It might be Nicolas too.
> 
> binfmt_flat doesn't do core-dumping, but it has some other oddities.
> In particular, I'd like to bring sanity to the installation of the new
> creds, and all the _normal_ binfmt cases do it largely close together
> with setup_new_exec().
> 
> binfmt_flat is doing odd things. It's doing this:
> 
>          /* Flush all traces of the currently running executable */
>          if (id == 0) {
>                  ret = flush_old_exec(bprm);
>                  if (ret)
>                          goto err;
> 
>                  /* OK, This is the point of no return */
>                  set_personality(PER_LINUX_32BIT);
>                  setup_new_exec(bprm);
>          }
> 
> in load_flat_file() - which is also used to loading _libraries_. Where
> it makes no sense at all.

I haven't looked at the shared lib support in there for a long time,
but I thought that "id" is only 0 for the actual final program.
Libraries have a slot or id number associated with them.

> It does the
> 
>          install_exec_creds(bprm);
> 
> in load_flat_binary() (which makes more sense: that is only for actual
> binary loading, no library case).
> 
> I would _like_ for every binfmt loader to do
> 
>          /* Flush all traces of the currently running executable */
>          retval = flush_old_exec(bprm);
>          if (retval)
>                  return retval;
> 
>     .. possibly set up personalities here ..
> 
>          setup_new_exec(bprm);
>          install_exec_creds(bprm);
> 
> all together, and at least merge 'setup_new_exec()' with 'install_exec_creds()'.
> 
> And I think all the binfmt handlers would be ok with that, but the
> flat one in particular is really oddly set up.
> 
> *Particularly* with that flush_old_exec/setup_new_exec() being done by
> the same routine that is also loading libraries (and called from
> 'calc_reloc()' from binary loading too).
> 
> Adding Greg Ungerer for m68knommu. Can somebody sort out why that
> flush_old_exec/setup_new_exec() isn't in load_flat_binary() like
> install_exec_creds() is?
> 
> Most of that file goes back to pre-git days. And most of the commits
> since are not so much about binfmt_flat, as they are about cleanups or
> changes elsewhere where binfmt_flat was just a victim.

I'll have a look at this.

Quick hack test shows moving setup_new_exec(bprm) to be just before
install_exec_creds(bprm) works fine for the static binaries case.
Doing the flush_old_exec(bprm) there too crashed out - I'll need to
dig into that to see why.

Regards
Greg



WARNING: multiple messages have this Message-ID (diff)
From: Greg Ungerer <gerg@linux-m68k.org>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: Rich Felker <dalias@libc.org>,
	linux-c6x-dev@linux-c6x.org,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Nicolas Pitre <nico@fluxnic.net>,
	Linux-sh list <linux-sh@vger.kernel.org>,
	Jann Horn <jannh@google.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Oleg Nesterov <oleg@redhat.com>, Linux-MM <linux-mm@kvack.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Mark Salter <msalter@redhat.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Aurelien Jacquiot <jacquiot.aurelien@gmail.com>,
	Christoph Hellwig <hch@lst.de>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	"Eric W . Biederman" <ebiederm@xmission.com>
Subject: Re: [PATCH v2 0/5] Fix ELF / FDPIC ELF core dumping, and use mmap_sem properly in there
Date: Fri, 1 May 2020 00:10:05 +1000	[thread overview]
Message-ID: <31196268-2ff4-7a1d-e9df-6116e92d2190@linux-m68k.org> (raw)
In-Reply-To: <CAHk-=wgpoEr33NJwQ+hqK1dz3Rs9jSw+BGotsSdt2Kb3HqLV7A@mail.gmail.com>



On 30/4/20 9:03 am, Linus Torvalds wrote:
> On Wed, Apr 29, 2020 at 2:57 PM Russell King - ARM Linux admin
> <linux@armlinux.org.uk> wrote:
>>
>> I've never had any reason to use FDPIC, and I don't have any binaries
>> that would use it.  Nicolas Pitre added ARM support, so I guess he
>> would be the one to talk to about it.  (Added Nicolas.)
> 
> While we're at it, is there anybody who knows binfmt_flat?
> 
> It might be Nicolas too.
> 
> binfmt_flat doesn't do core-dumping, but it has some other oddities.
> In particular, I'd like to bring sanity to the installation of the new
> creds, and all the _normal_ binfmt cases do it largely close together
> with setup_new_exec().
> 
> binfmt_flat is doing odd things. It's doing this:
> 
>          /* Flush all traces of the currently running executable */
>          if (id == 0) {
>                  ret = flush_old_exec(bprm);
>                  if (ret)
>                          goto err;
> 
>                  /* OK, This is the point of no return */
>                  set_personality(PER_LINUX_32BIT);
>                  setup_new_exec(bprm);
>          }
> 
> in load_flat_file() - which is also used to loading _libraries_. Where
> it makes no sense at all.

I haven't looked at the shared lib support in there for a long time,
but I thought that "id" is only 0 for the actual final program.
Libraries have a slot or id number associated with them.

> It does the
> 
>          install_exec_creds(bprm);
> 
> in load_flat_binary() (which makes more sense: that is only for actual
> binary loading, no library case).
> 
> I would _like_ for every binfmt loader to do
> 
>          /* Flush all traces of the currently running executable */
>          retval = flush_old_exec(bprm);
>          if (retval)
>                  return retval;
> 
>     .. possibly set up personalities here ..
> 
>          setup_new_exec(bprm);
>          install_exec_creds(bprm);
> 
> all together, and at least merge 'setup_new_exec()' with 'install_exec_creds()'.
> 
> And I think all the binfmt handlers would be ok with that, but the
> flat one in particular is really oddly set up.
> 
> *Particularly* with that flush_old_exec/setup_new_exec() being done by
> the same routine that is also loading libraries (and called from
> 'calc_reloc()' from binary loading too).
> 
> Adding Greg Ungerer for m68knommu. Can somebody sort out why that
> flush_old_exec/setup_new_exec() isn't in load_flat_binary() like
> install_exec_creds() is?
> 
> Most of that file goes back to pre-git days. And most of the commits
> since are not so much about binfmt_flat, as they are about cleanups or
> changes elsewhere where binfmt_flat was just a victim.

I'll have a look at this.

Quick hack test shows moving setup_new_exec(bprm) to be just before
install_exec_creds(bprm) works fine for the static binaries case.
Doing the flush_old_exec(bprm) there too crashed out - I'll need to
dig into that to see why.

Regards
Greg



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

  parent reply	other threads:[~2020-04-30 14:10 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29 21:49 [PATCH v2 0/5] Fix ELF / FDPIC ELF core dumping, and use mmap_sem properly in there Jann Horn
2020-04-29 21:49 ` Jann Horn
2020-04-29 21:49 ` Jann Horn
2020-04-29 21:49 ` Jann Horn
2020-04-29 21:49 ` [PATCH v2 1/5] binfmt_elf_fdpic: Stop using dump_emit() on user pointers on !MMU Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-05-05 10:48   ` Christoph Hellwig
2020-05-05 10:48     ` Christoph Hellwig
2020-05-05 10:48     ` Christoph Hellwig
2020-05-05 11:42     ` Jann Horn
2020-05-05 11:42       ` Jann Horn
2020-05-05 11:42       ` Jann Horn
2020-05-05 11:42       ` Jann Horn
2020-05-05 12:15       ` Christoph Hellwig
2020-05-05 12:15         ` Christoph Hellwig
2020-05-05 12:15         ` Christoph Hellwig
2020-08-11  3:05         ` Jann Horn
2020-08-11  3:05           ` Jann Horn
2020-08-11  3:05           ` Jann Horn
2020-08-11  3:05           ` Jann Horn
2020-04-29 21:49 ` [PATCH v2 2/5] coredump: Let dump_emit() bail out on short writes Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49 ` [PATCH v2 3/5] coredump: Refactor page range dumping into common helper Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-05-05 10:50   ` Christoph Hellwig
2020-05-05 10:50     ` Christoph Hellwig
2020-05-05 10:50     ` Christoph Hellwig
2020-05-05 11:44     ` Jann Horn
2020-05-05 11:44       ` Jann Horn
2020-05-05 11:44       ` Jann Horn
2020-05-05 11:44       ` Jann Horn
2020-04-29 21:49 ` [PATCH v2 4/5] binfmt_elf, binfmt_elf_fdpic: Use a VMA list snapshot Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-05-05 11:03   ` Christoph Hellwig
2020-05-05 11:03     ` Christoph Hellwig
2020-05-05 11:03     ` Christoph Hellwig
2020-05-05 12:11     ` Jann Horn
2020-05-05 12:11       ` Jann Horn
2020-05-05 12:11       ` Jann Horn
2020-05-05 12:11       ` Jann Horn
2020-04-29 21:49 ` [PATCH v2 5/5] mm/gup: Take mmap_sem in get_dump_page() Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:49   ` Jann Horn
2020-04-29 21:56 ` [PATCH v2 0/5] Fix ELF / FDPIC ELF core dumping, and use mmap_sem properly in there Russell King - ARM Linux admin
2020-04-29 21:56   ` Russell King - ARM Linux admin
2020-04-29 21:56   ` Russell King - ARM Linux admin
2020-04-29 23:03   ` Linus Torvalds
2020-04-29 23:03     ` Linus Torvalds
2020-04-29 23:03     ` Linus Torvalds
2020-04-29 23:03     ` Linus Torvalds
2020-04-30  1:27     ` Nicolas Pitre
2020-04-30  1:27       ` Nicolas Pitre
2020-04-30  1:27       ` Nicolas Pitre
2020-04-30  1:27       ` Nicolas Pitre
2020-04-30 14:10     ` Greg Ungerer [this message]
2020-04-30 14:10       ` Greg Ungerer
2020-04-30 14:10       ` Greg Ungerer
2020-04-30 14:51       ` Rich Felker
2020-04-30 14:51         ` Rich Felker
2020-04-30 14:51         ` Rich Felker
2020-04-30 21:13         ` Rob Landley
2020-04-30 21:13           ` Rob Landley
2020-04-30 21:13           ` Rob Landley
2020-05-01  6:00         ` Greg Ungerer
2020-05-01  6:00           ` Greg Ungerer
2020-05-01  6:00           ` Greg Ungerer
2020-05-01 19:09           ` Rob Landley
2020-05-01 19:09             ` Rob Landley
2020-05-01 19:09             ` Rob Landley
2020-04-30 16:54       ` Linus Torvalds
2020-04-30 16:54         ` Linus Torvalds
2020-04-30 16:54         ` Linus Torvalds
2020-04-30 16:54         ` Linus Torvalds
2020-04-30 19:07         ` Eric W. Biederman
2020-04-30 19:07           ` Eric W. Biederman
2020-04-30 19:07           ` Eric W. Biederman
2020-04-30 19:07           ` Eric W. Biederman
2020-05-01  5:44           ` Greg Ungerer
2020-05-01  5:44             ` Greg Ungerer
2020-05-01  5:44             ` Greg Ungerer
2020-05-01 11:13             ` Eric W. Biederman
2020-05-01 11:13               ` Eric W. Biederman
2020-05-01 11:13               ` Eric W. Biederman
2020-05-01 11:13               ` Eric W. Biederman
2020-05-01  7:14         ` Greg Ungerer
2020-05-01  7:14           ` Greg Ungerer
2020-05-01  7:14           ` Greg Ungerer
2020-04-30  1:59   ` Nicolas Pitre
2020-04-30  1:59     ` Nicolas Pitre
2020-04-30  1:59     ` Nicolas Pitre
2020-04-30  1:59     ` Nicolas Pitre

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=31196268-2ff4-7a1d-e9df-6116e92d2190@linux-m68k.org \
    --to=gerg@linux-m68k.org \
    --cc=akpm@linux-foundation.org \
    --cc=dalias@libc.org \
    --cc=ebiederm@xmission.com \
    --cc=hch@lst.de \
    --cc=jacquiot.aurelien@gmail.com \
    --cc=jannh@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-c6x-dev@linux-c6x.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=msalter@redhat.com \
    --cc=nico@fluxnic.net \
    --cc=oleg@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=ysato@users.sourceforge.jp \
    /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.