All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Landley <rob@landley.net>
To: Greg Ungerer <gerg@linux-m68k.org>, Rich Felker <dalias@libc.org>
Cc: Mark Salter <msalter@redhat.com>,
	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>,
	Russell King - ARM Linux admin <linux@armlinux.org.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux-MM <linux-mm@kvack.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Oleg Nesterov <oleg@redhat.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Aurelien Jacquiot <jacquiot.aurelien@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	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, 01 May 2020 19:09:56 +0000	[thread overview]
Message-ID: <cff13fb7-5045-4afd-e1d3-58af99d81d5a@landley.net> (raw)
In-Reply-To: <6dd187b4-1958-fc40-73c4-3de53ed69a1e@linux-m68k.org>

On 5/1/20 1:00 AM, Greg Ungerer wrote:
>> This sounds correct. My understanding of FLAT shared library support
>> is that it's really bad and based on having preassigned slot indices
>> for each library on the system, and a global array per-process to give
>> to data base address for each library. Libraries are compiled to know
>> their own slot numbers so that they just load from fixed_reg[slot_id]
>> to get what's effectively their GOT pointer.

fdpic is to elf what binflt is to a.out, and a.out shared libraries were never
pretty. Or easy.

>> I'm not sure if anybody has actually used this in over a decade. Last
>> time I looked the tooling appeared broken, but in this domain lots of
>> users have forked private tooling that's not publicly available or at
>> least not publicly indexed, so it's hard to say for sure.
> 
> Be at least 12 or 13 years since I last had a working shared library
> build for m68knommu. I have not bothered with it since then, not that I
> even used it much when it worked. Seemed more pain than it was worth.

Shared libraries worked fine with fdpic on sh2 last I checked, it's basically
just ELF PIC with the ability to move the 4 segments (text/rodata/bss/data)
independently of each other. (4 base pointers, no waiting.)

I don't think I've _ever_ used shared binflt libraries. I left myself
breadcrumbs back when I was wrestling with that stuff:

  https://landley.net/notes-2014.html#07-12-2014

But it looks like that last time I touched anything using elf2flt was:

  https://landley.net/notes-2018.html#08-05-2018

And that was just because arm's fdpic support stayed out of tree for years so I
dug up binflt and gave it another go. (It sucked so much I wound up building
static pie for cortex-m, taking the efficiency hit, and moving on. Running pie
binaries on nommu _works_, it's just incredibly inefficient. Since the writeable
and readable segments of the ELF are all relative to the same single base
pointer, you can't share the read-only parts of the binaries without address
remapping, so if you launch 4 instances of PIE bash on nommu you've loaded 4
instances of the bash text and rodata, and of course none of it can even be
demand faulted. In theory shared libraries _do_ help there but I hit some ld.so
bug and didn't want to debug a half-assed solution, so big hammer and moved on
until arm fdpic got merged and fixed it _properly_...)

Rob

P.S. The reason for binflt is bare metal hardware engineers who are conceptually
uncomfortable with software love them, because it's as close to "objcopy -O
binary" as they can get. Meanwhile on j-core we've had an 8k ROM boot loader
that loads vmlinux images and does the ELF relocations for 5 years now, and ever
since the switch to device tree that's our _only_ way to feed a dtb to the
kernel without statically linking it in, so it's ELF all the way down for us.

WARNING: multiple messages have this Message-ID (diff)
From: Rob Landley <rob@landley.net>
To: Greg Ungerer <gerg@linux-m68k.org>, Rich Felker <dalias@libc.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Russell King - ARM Linux admin <linux@armlinux.org.uk>,
	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>,
	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 14:09:56 -0500	[thread overview]
Message-ID: <cff13fb7-5045-4afd-e1d3-58af99d81d5a@landley.net> (raw)
In-Reply-To: <6dd187b4-1958-fc40-73c4-3de53ed69a1e@linux-m68k.org>

On 5/1/20 1:00 AM, Greg Ungerer wrote:
>> This sounds correct. My understanding of FLAT shared library support
>> is that it's really bad and based on having preassigned slot indices
>> for each library on the system, and a global array per-process to give
>> to data base address for each library. Libraries are compiled to know
>> their own slot numbers so that they just load from fixed_reg[slot_id]
>> to get what's effectively their GOT pointer.

fdpic is to elf what binflt is to a.out, and a.out shared libraries were never
pretty. Or easy.

>> I'm not sure if anybody has actually used this in over a decade. Last
>> time I looked the tooling appeared broken, but in this domain lots of
>> users have forked private tooling that's not publicly available or at
>> least not publicly indexed, so it's hard to say for sure.
> 
> Be at least 12 or 13 years since I last had a working shared library
> build for m68knommu. I have not bothered with it since then, not that I
> even used it much when it worked. Seemed more pain than it was worth.

Shared libraries worked fine with fdpic on sh2 last I checked, it's basically
just ELF PIC with the ability to move the 4 segments (text/rodata/bss/data)
independently of each other. (4 base pointers, no waiting.)

I don't think I've _ever_ used shared binflt libraries. I left myself
breadcrumbs back when I was wrestling with that stuff:

  https://landley.net/notes-2014.html#07-12-2014

But it looks like that last time I touched anything using elf2flt was:

  https://landley.net/notes-2018.html#08-05-2018

And that was just because arm's fdpic support stayed out of tree for years so I
dug up binflt and gave it another go. (It sucked so much I wound up building
static pie for cortex-m, taking the efficiency hit, and moving on. Running pie
binaries on nommu _works_, it's just incredibly inefficient. Since the writeable
and readable segments of the ELF are all relative to the same single base
pointer, you can't share the read-only parts of the binaries without address
remapping, so if you launch 4 instances of PIE bash on nommu you've loaded 4
instances of the bash text and rodata, and of course none of it can even be
demand faulted. In theory shared libraries _do_ help there but I hit some ld.so
bug and didn't want to debug a half-assed solution, so big hammer and moved on
until arm fdpic got merged and fixed it _properly_...)

Rob

P.S. The reason for binflt is bare metal hardware engineers who are conceptually
uncomfortable with software love them, because it's as close to "objcopy -O
binary" as they can get. Meanwhile on j-core we've had an 8k ROM boot loader
that loads vmlinux images and does the ELF relocations for 5 years now, and ever
since the switch to device tree that's our _only_ way to feed a dtb to the
kernel without statically linking it in, so it's ELF all the way down for us.

WARNING: multiple messages have this Message-ID (diff)
From: Rob Landley <rob@landley.net>
To: Greg Ungerer <gerg@linux-m68k.org>, Rich Felker <dalias@libc.org>
Cc: Mark Salter <msalter@redhat.com>,
	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>,
	Russell King - ARM Linux admin <linux@armlinux.org.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux-MM <linux-mm@kvack.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Oleg Nesterov <oleg@redhat.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Aurelien Jacquiot <jacquiot.aurelien@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	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 14:09:56 -0500	[thread overview]
Message-ID: <cff13fb7-5045-4afd-e1d3-58af99d81d5a@landley.net> (raw)
In-Reply-To: <6dd187b4-1958-fc40-73c4-3de53ed69a1e@linux-m68k.org>

On 5/1/20 1:00 AM, Greg Ungerer wrote:
>> This sounds correct. My understanding of FLAT shared library support
>> is that it's really bad and based on having preassigned slot indices
>> for each library on the system, and a global array per-process to give
>> to data base address for each library. Libraries are compiled to know
>> their own slot numbers so that they just load from fixed_reg[slot_id]
>> to get what's effectively their GOT pointer.

fdpic is to elf what binflt is to a.out, and a.out shared libraries were never
pretty. Or easy.

>> I'm not sure if anybody has actually used this in over a decade. Last
>> time I looked the tooling appeared broken, but in this domain lots of
>> users have forked private tooling that's not publicly available or at
>> least not publicly indexed, so it's hard to say for sure.
> 
> Be at least 12 or 13 years since I last had a working shared library
> build for m68knommu. I have not bothered with it since then, not that I
> even used it much when it worked. Seemed more pain than it was worth.

Shared libraries worked fine with fdpic on sh2 last I checked, it's basically
just ELF PIC with the ability to move the 4 segments (text/rodata/bss/data)
independently of each other. (4 base pointers, no waiting.)

I don't think I've _ever_ used shared binflt libraries. I left myself
breadcrumbs back when I was wrestling with that stuff:

  https://landley.net/notes-2014.html#07-12-2014

But it looks like that last time I touched anything using elf2flt was:

  https://landley.net/notes-2018.html#08-05-2018

And that was just because arm's fdpic support stayed out of tree for years so I
dug up binflt and gave it another go. (It sucked so much I wound up building
static pie for cortex-m, taking the efficiency hit, and moving on. Running pie
binaries on nommu _works_, it's just incredibly inefficient. Since the writeable
and readable segments of the ELF are all relative to the same single base
pointer, you can't share the read-only parts of the binaries without address
remapping, so if you launch 4 instances of PIE bash on nommu you've loaded 4
instances of the bash text and rodata, and of course none of it can even be
demand faulted. In theory shared libraries _do_ help there but I hit some ld.so
bug and didn't want to debug a half-assed solution, so big hammer and moved on
until arm fdpic got merged and fixed it _properly_...)

Rob

P.S. The reason for binflt is bare metal hardware engineers who are conceptually
uncomfortable with software love them, because it's as close to "objcopy -O
binary" as they can get. Meanwhile on j-core we've had an 8k ROM boot loader
that loads vmlinux images and does the ELF relocations for 5 years now, and ever
since the switch to device tree that's our _only_ way to feed a dtb to the
kernel without statically linking it in, so it's ELF all the way down for us.

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

  reply	other threads:[~2020-05-01 19:09 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
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 [this message]
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=cff13fb7-5045-4afd-e1d3-58af99d81d5a@landley.net \
    --to=rob@landley.net \
    --cc=akpm@linux-foundation.org \
    --cc=dalias@libc.org \
    --cc=ebiederm@xmission.com \
    --cc=gerg@linux-m68k.org \
    --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.