linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
       [not found] <20190524201817.16509-1-jannh@google.com>
@ 2019-05-25 21:43 ` Andrew Morton
  2019-05-27 13:38   ` Jann Horn
  0 siblings, 1 reply; 16+ messages in thread
From: Andrew Morton @ 2019-05-25 21:43 UTC (permalink / raw)
  To: Jann Horn
  Cc: Alexander Viro, linux-fsdevel, linux-kernel, Kees Cook,
	Nicolas Pitre, Arnd Bergmann, Geert Uytterhoeven, linux-m68k,
	Russell King, linux-arm-kernel

On Fri, 24 May 2019 22:18:17 +0200 Jann Horn <jannh@google.com> wrote:

> load_flat_shared_library() is broken: It only calls load_flat_file() if
> prepare_binprm() returns zero, but prepare_binprm() returns the number of
> bytes read - so this only happens if the file is empty.

ouch.

> Instead, call into load_flat_file() if the number of bytes read is
> non-negative. (Even if the number of bytes is zero - in that case,
> load_flat_file() will see nullbytes and return a nice -ENOEXEC.)
> 
> In addition, remove the code related to bprm creds and stop using
> prepare_binprm() - this code is loading a library, not a main executable,
> and it only actually uses the members "buf", "file" and "filename" of the
> linux_binprm struct. Instead, call kernel_read() directly.
> 
> Cc: stable@vger.kernel.org
> Fixes: 287980e49ffc ("remove lots of IS_ERR_VALUE abuses")
> Signed-off-by: Jann Horn <jannh@google.com>
> ---
> I only found the bug by looking at the code, I have not verified its
> existence at runtime.
> Also, this patch is compile-tested only.
> It would be nice if someone who works with nommu Linux could have a
> look at this patch.

287980e49ffc was three years ago!  Has it really been broken for all
that time?  If so, it seems a good source of freed disk space...

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-25 21:43 ` [PATCH] binfmt_flat: make load_flat_shared_library() work Andrew Morton
@ 2019-05-27 13:38   ` Jann Horn
  2019-05-27 14:37     ` Nicolas Pitre
                       ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Jann Horn @ 2019-05-27 13:38 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Alexander Viro, linux-fsdevel, kernel list, Kees Cook,
	Nicolas Pitre, Arnd Bergmann, Geert Uytterhoeven, linux-m68k,
	Russell King, linux-arm-kernel

On Sat, May 25, 2019 at 11:43 PM Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Fri, 24 May 2019 22:18:17 +0200 Jann Horn <jannh@google.com> wrote:
> > load_flat_shared_library() is broken: It only calls load_flat_file() if
> > prepare_binprm() returns zero, but prepare_binprm() returns the number of
> > bytes read - so this only happens if the file is empty.
>
> ouch.
>
> > Instead, call into load_flat_file() if the number of bytes read is
> > non-negative. (Even if the number of bytes is zero - in that case,
> > load_flat_file() will see nullbytes and return a nice -ENOEXEC.)
> >
> > In addition, remove the code related to bprm creds and stop using
> > prepare_binprm() - this code is loading a library, not a main executable,
> > and it only actually uses the members "buf", "file" and "filename" of the
> > linux_binprm struct. Instead, call kernel_read() directly.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: 287980e49ffc ("remove lots of IS_ERR_VALUE abuses")
> > Signed-off-by: Jann Horn <jannh@google.com>
> > ---
> > I only found the bug by looking at the code, I have not verified its
> > existence at runtime.
> > Also, this patch is compile-tested only.
> > It would be nice if someone who works with nommu Linux could have a
> > look at this patch.
>
> 287980e49ffc was three years ago!  Has it really been broken for all
> that time?  If so, it seems a good source of freed disk space...

Maybe... but I didn't want to rip it out without having one of the
maintainers confirm that this really isn't likely to be used anymore.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-27 13:38   ` Jann Horn
@ 2019-05-27 14:37     ` Nicolas Pitre
  2019-05-28 10:56     ` Greg Ungerer
  2019-05-28 10:56     ` Greg Ungerer
  2 siblings, 0 replies; 16+ messages in thread
From: Nicolas Pitre @ 2019-05-27 14:37 UTC (permalink / raw)
  To: Jann Horn
  Cc: Andrew Morton, Alexander Viro, linux-fsdevel, kernel list,
	Kees Cook, Arnd Bergmann, Geert Uytterhoeven, linux-m68k,
	Russell King, linux-arm-kernel

On Mon, 27 May 2019, Jann Horn wrote:

> On Sat, May 25, 2019 at 11:43 PM Andrew Morton
> <akpm@linux-foundation.org> wrote:
> > On Fri, 24 May 2019 22:18:17 +0200 Jann Horn <jannh@google.com> wrote:
> > > load_flat_shared_library() is broken: It only calls load_flat_file() if
> > > prepare_binprm() returns zero, but prepare_binprm() returns the number of
> > > bytes read - so this only happens if the file is empty.
> >
> > ouch.
> >
> > > Instead, call into load_flat_file() if the number of bytes read is
> > > non-negative. (Even if the number of bytes is zero - in that case,
> > > load_flat_file() will see nullbytes and return a nice -ENOEXEC.)
> > >
> > > In addition, remove the code related to bprm creds and stop using
> > > prepare_binprm() - this code is loading a library, not a main executable,
> > > and it only actually uses the members "buf", "file" and "filename" of the
> > > linux_binprm struct. Instead, call kernel_read() directly.
> > >
> > > Cc: stable@vger.kernel.org
> > > Fixes: 287980e49ffc ("remove lots of IS_ERR_VALUE abuses")
> > > Signed-off-by: Jann Horn <jannh@google.com>
> > > ---
> > > I only found the bug by looking at the code, I have not verified its
> > > existence at runtime.
> > > Also, this patch is compile-tested only.
> > > It would be nice if someone who works with nommu Linux could have a
> > > look at this patch.
> >
> > 287980e49ffc was three years ago!  Has it really been broken for all
> > that time?  If so, it seems a good source of freed disk space...
> 
> Maybe... but I didn't want to rip it out without having one of the
> maintainers confirm that this really isn't likely to be used anymore.

Last time I played with this, I couldn't figure out the toolchain to 
produce shared libs. Only static executables worked fine. If I recall, 
existing binfmt_flat distros don't use shared libs either.

For shared lib support on no-MMU target, binfmt_elf_fdpic is a much 
saner choice.


Nicolas

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-27 13:38   ` Jann Horn
  2019-05-27 14:37     ` Nicolas Pitre
@ 2019-05-28 10:56     ` Greg Ungerer
  2019-05-29 11:52       ` Arnd Bergmann
  2019-05-28 10:56     ` Greg Ungerer
  2 siblings, 1 reply; 16+ messages in thread
From: Greg Ungerer @ 2019-05-28 10:56 UTC (permalink / raw)
  To: Jann Horn, Andrew Morton
  Cc: Nicolas Pitre, linux-m68k, Kees Cook, Arnd Bergmann, kernel list,
	Russell King, Geert Uytterhoeven, Alexander Viro, linux-fsdevel,
	linux-arm-kernel


On 27/5/19 11:38 pm, Jann Horn wrote:
> On Sat, May 25, 2019 at 11:43 PM Andrew Morton
> <akpm@linux-foundation.org> wrote:
>> On Fri, 24 May 2019 22:18:17 +0200 Jann Horn <jannh@google.com> wrote:
>>> load_flat_shared_library() is broken: It only calls load_flat_file() if
>>> prepare_binprm() returns zero, but prepare_binprm() returns the number of
>>> bytes read - so this only happens if the file is empty.
>>
>> ouch.
>>
>>> Instead, call into load_flat_file() if the number of bytes read is
>>> non-negative. (Even if the number of bytes is zero - in that case,
>>> load_flat_file() will see nullbytes and return a nice -ENOEXEC.)
>>>
>>> In addition, remove the code related to bprm creds and stop using
>>> prepare_binprm() - this code is loading a library, not a main executable,
>>> and it only actually uses the members "buf", "file" and "filename" of the
>>> linux_binprm struct. Instead, call kernel_read() directly.
>>>
>>> Cc: stable@vger.kernel.org
>>> Fixes: 287980e49ffc ("remove lots of IS_ERR_VALUE abuses")
>>> Signed-off-by: Jann Horn <jannh@google.com>
>>> ---
>>> I only found the bug by looking at the code, I have not verified its
>>> existence at runtime.
>>> Also, this patch is compile-tested only.
>>> It would be nice if someone who works with nommu Linux could have a
>>> look at this patch.
>>
>> 287980e49ffc was three years ago!  Has it really been broken for all
>> that time?  If so, it seems a good source of freed disk space...
> 
> Maybe... but I didn't want to rip it out without having one of the
> maintainers confirm that this really isn't likely to be used anymore.

I have not used shared libraries on m68k non-mmu setups for
a very long time. At least 10 years I would think.

Regards
Greg

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-27 13:38   ` Jann Horn
  2019-05-27 14:37     ` Nicolas Pitre
  2019-05-28 10:56     ` Greg Ungerer
@ 2019-05-28 10:56     ` Greg Ungerer
  2019-05-29 12:05       ` Arnd Bergmann
  2019-05-29 12:32       ` John Paul Adrian Glaubitz
  2 siblings, 2 replies; 16+ messages in thread
From: Greg Ungerer @ 2019-05-28 10:56 UTC (permalink / raw)
  To: Jann Horn, Andrew Morton
  Cc: Nicolas Pitre, linux-m68k, Kees Cook, Arnd Bergmann, kernel list,
	Russell King, Geert Uytterhoeven, Alexander Viro, linux-fsdevel,
	linux-arm-kernel


On 27/5/19 11:38 pm, Jann Horn wrote:
> On Sat, May 25, 2019 at 11:43 PM Andrew Morton
> <akpm@linux-foundation.org> wrote:
>> On Fri, 24 May 2019 22:18:17 +0200 Jann Horn <jannh@google.com> wrote:
>>> load_flat_shared_library() is broken: It only calls load_flat_file() if
>>> prepare_binprm() returns zero, but prepare_binprm() returns the number of
>>> bytes read - so this only happens if the file is empty.
>>
>> ouch.
>>
>>> Instead, call into load_flat_file() if the number of bytes read is
>>> non-negative. (Even if the number of bytes is zero - in that case,
>>> load_flat_file() will see nullbytes and return a nice -ENOEXEC.)
>>>
>>> In addition, remove the code related to bprm creds and stop using
>>> prepare_binprm() - this code is loading a library, not a main executable,
>>> and it only actually uses the members "buf", "file" and "filename" of the
>>> linux_binprm struct. Instead, call kernel_read() directly.
>>>
>>> Cc: stable@vger.kernel.org
>>> Fixes: 287980e49ffc ("remove lots of IS_ERR_VALUE abuses")
>>> Signed-off-by: Jann Horn <jannh@google.com>
>>> ---
>>> I only found the bug by looking at the code, I have not verified its
>>> existence at runtime.
>>> Also, this patch is compile-tested only.
>>> It would be nice if someone who works with nommu Linux could have a
>>> look at this patch.
>>
>> 287980e49ffc was three years ago!  Has it really been broken for all
>> that time?  If so, it seems a good source of freed disk space...
> 
> Maybe... but I didn't want to rip it out without having one of the
> maintainers confirm that this really isn't likely to be used anymore.

I have not used shared libraries on m68k non-mmu setups for
a very long time. At least 10 years I would think.

Regards
Greg

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-28 10:56     ` Greg Ungerer
@ 2019-05-29 11:52       ` Arnd Bergmann
  0 siblings, 0 replies; 16+ messages in thread
From: Arnd Bergmann @ 2019-05-29 11:52 UTC (permalink / raw)
  To: Greg Ungerer
  Cc: Jann Horn, Andrew Morton, Alexander Viro, linux-fsdevel,
	kernel list, Kees Cook, Nicolas Pitre, Geert Uytterhoeven,
	Linux/m68k, Russell King, Linux ARM

On Tue, May 28, 2019 at 12:56 PM Greg Ungerer
<gregungerer@westnet.com.au> wrote:
> On 27/5/19 11:38 pm, Jann Horn wrote:
> > On Sat, May 25, 2019 at 11:43 PM Andrew Morton
> > <akpm@linux-foundation.org> wrote:
> >> On Fri, 24 May 2019 22:18:17 +0200 Jann Horn <jannh@google.com> wrote:
> >>> load_flat_shared_library() is broken: It only calls load_flat_file() if
> >>> prepare_binprm() returns zero, but prepare_binprm() returns the number of
> >>> bytes read - so this only happens if the file is empty.
> >>
> >>> Instead, call into load_flat_file() if the number of bytes read is
> >>> non-negative. (Even if the number of bytes is zero - in that case,
> >>> load_flat_file() will see nullbytes and return a nice -ENOEXEC.)
> >>>
> >>> In addition, remove the code related to bprm creds and stop using
> >>> prepare_binprm() - this code is loading a library, not a main executable,
> >>> and it only actually uses the members "buf", "file" and "filename" of the
> >>> linux_binprm struct. Instead, call kernel_read() directly.
> >>>
> >>> Cc: stable@vger.kernel.org
> >>> Fixes: 287980e49ffc ("remove lots of IS_ERR_VALUE abuses")
> >>> Signed-off-by: Jann Horn <jannh@google.com>
> >>> ---
> >>> I only found the bug by looking at the code, I have not verified its
> >>> existence at runtime.
> >>> Also, this patch is compile-tested only.
> >>> It would be nice if someone who works with nommu Linux could have a
> >>> look at this patch.
> >>
> >> 287980e49ffc was three years ago!  Has it really been broken for all
> >> that time?  If so, it seems a good source of freed disk space...
> >
> > Maybe... but I didn't want to rip it out without having one of the
> > maintainers confirm that this really isn't likely to be used anymore.
>
> I have not used shared libraries on m68k non-mmu setups for
> a very long time. At least 10 years I would think.
>
> Regards
> Greg
>
>
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-28 10:56     ` Greg Ungerer
@ 2019-05-29 12:05       ` Arnd Bergmann
  2019-05-29 12:29         ` Greg Ungerer
  2019-06-02  7:21         ` Sergei Poselenov
  2019-05-29 12:32       ` John Paul Adrian Glaubitz
  1 sibling, 2 replies; 16+ messages in thread
From: Arnd Bergmann @ 2019-05-29 12:05 UTC (permalink / raw)
  To: Greg Ungerer
  Cc: Jann Horn, Andrew Morton, Alexander Viro, linux-fsdevel,
	kernel list, Kees Cook, Nicolas Pitre, Geert Uytterhoeven,
	Linux/m68k, Russell King, Linux ARM, Sergei Poselenov

On Tue, May 28, 2019 at 12:56 PM Greg Ungerer <gerg@linux-m68k.org> wrote:
> On 27/5/19 11:38 pm, Jann Horn wrote:
> > On Sat, May 25, 2019 at 11:43 PM Andrew Morton
> > <akpm@linux-foundation.org> wrote:
> >> On Fri, 24 May 2019 22:18:17 +0200 Jann Horn <jannh@google.com> wrote:
> >>> load_flat_shared_library() is broken: It only calls load_flat_file() if
> >>> prepare_binprm() returns zero, but prepare_binprm() returns the number of
> >>> bytes read - so this only happens if the file is empty.
> >>
> >> ouch.
> >>
> >>> Instead, call into load_flat_file() if the number of bytes read is
> >>> non-negative. (Even if the number of bytes is zero - in that case,
> >>> load_flat_file() will see nullbytes and return a nice -ENOEXEC.)
> >>>
> >>> In addition, remove the code related to bprm creds and stop using
> >>> prepare_binprm() - this code is loading a library, not a main executable,
> >>> and it only actually uses the members "buf", "file" and "filename" of the
> >>> linux_binprm struct. Instead, call kernel_read() directly.
> >>>
> >>> Cc: stable@vger.kernel.org
> >>> Fixes: 287980e49ffc ("remove lots of IS_ERR_VALUE abuses")
> >>> Signed-off-by: Jann Horn <jannh@google.com>
> >>> ---
> >>> I only found the bug by looking at the code, I have not verified its
> >>> existence at runtime.
> >>> Also, this patch is compile-tested only.
> >>> It would be nice if someone who works with nommu Linux could have a
> >>> look at this patch.
> >>
> >> 287980e49ffc was three years ago!  Has it really been broken for all
> >> that time?  If so, it seems a good source of freed disk space...
> >
> > Maybe... but I didn't want to rip it out without having one of the
> > maintainers confirm that this really isn't likely to be used anymore.
>
> I have not used shared libraries on m68k non-mmu setups for
> a very long time. At least 10 years I would think.

I think Emcraft have a significant customer base running ARM NOMMU
Linux, I wonder whether they would have run into this (adding
Sergei to Cc).
My suspicion is that they use only binfmt-elf-fdpic, not binfmt-flat.

The only architectures I see that enable binfmt-flat are sh, xtensa
and h8300, but only arch/sh uses CONFIG_BINFMT_SHARED_FLAT
for a few machine specific configurations, and I'm in turn fairly sure
those machines have not run a recent kernel in many years.

The one SH nommu platform likely to have users is j2, and that is
probably always used with musl-libc with elf-fdpic (given that
Rich Felker maintains both the kernel port and the library).

      Arnd

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-29 12:05       ` Arnd Bergmann
@ 2019-05-29 12:29         ` Greg Ungerer
  2019-05-29 13:41           ` Arnd Bergmann
  2019-06-02  7:21         ` Sergei Poselenov
  1 sibling, 1 reply; 16+ messages in thread
From: Greg Ungerer @ 2019-05-29 12:29 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jann Horn, Andrew Morton, Alexander Viro, linux-fsdevel,
	kernel list, Kees Cook, Nicolas Pitre, Geert Uytterhoeven,
	Linux/m68k, Russell King, Linux ARM, Sergei Poselenov


On 29/5/19 10:05 pm, Arnd Bergmann wrote:
> On Tue, May 28, 2019 at 12:56 PM Greg Ungerer <gerg@linux-m68k.org> wrote:
>> On 27/5/19 11:38 pm, Jann Horn wrote:
>>> On Sat, May 25, 2019 at 11:43 PM Andrew Morton
>>> <akpm@linux-foundation.org> wrote:
>>>> On Fri, 24 May 2019 22:18:17 +0200 Jann Horn <jannh@google.com> wrote:
>>>>> load_flat_shared_library() is broken: It only calls load_flat_file() if
>>>>> prepare_binprm() returns zero, but prepare_binprm() returns the number of
>>>>> bytes read - so this only happens if the file is empty.
>>>>
>>>> ouch.
>>>>
>>>>> Instead, call into load_flat_file() if the number of bytes read is
>>>>> non-negative. (Even if the number of bytes is zero - in that case,
>>>>> load_flat_file() will see nullbytes and return a nice -ENOEXEC.)
>>>>>
>>>>> In addition, remove the code related to bprm creds and stop using
>>>>> prepare_binprm() - this code is loading a library, not a main executable,
>>>>> and it only actually uses the members "buf", "file" and "filename" of the
>>>>> linux_binprm struct. Instead, call kernel_read() directly.
>>>>>
>>>>> Cc: stable@vger.kernel.org
>>>>> Fixes: 287980e49ffc ("remove lots of IS_ERR_VALUE abuses")
>>>>> Signed-off-by: Jann Horn <jannh@google.com>
>>>>> ---
>>>>> I only found the bug by looking at the code, I have not verified its
>>>>> existence at runtime.
>>>>> Also, this patch is compile-tested only.
>>>>> It would be nice if someone who works with nommu Linux could have a
>>>>> look at this patch.
>>>>
>>>> 287980e49ffc was three years ago!  Has it really been broken for all
>>>> that time?  If so, it seems a good source of freed disk space...
>>>
>>> Maybe... but I didn't want to rip it out without having one of the
>>> maintainers confirm that this really isn't likely to be used anymore.
>>
>> I have not used shared libraries on m68k non-mmu setups for
>> a very long time. At least 10 years I would think.
> 
> I think Emcraft have a significant customer base running ARM NOMMU
> Linux, I wonder whether they would have run into this (adding
> Sergei to Cc).
> My suspicion is that they use only binfmt-elf-fdpic, not binfmt-flat.
> 
> The only architectures I see that enable binfmt-flat are sh, xtensa
> and h8300, but only arch/sh uses CONFIG_BINFMT_SHARED_FLAT

m68k uses enables it too. It is the only binary format supported
when running no-mmu on m68k. (You can use it with MMU enabled too
if you really want too).

The shared flat format has been used on m68k in the past (it was
originally developed on m68k platforms). But I haven't used them
for a long time (probably 10 years at least) on m68k.

Regards
Greg

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-28 10:56     ` Greg Ungerer
  2019-05-29 12:05       ` Arnd Bergmann
@ 2019-05-29 12:32       ` John Paul Adrian Glaubitz
  2019-05-29 12:38         ` Jann Horn
                           ` (2 more replies)
  1 sibling, 3 replies; 16+ messages in thread
From: John Paul Adrian Glaubitz @ 2019-05-29 12:32 UTC (permalink / raw)
  To: Greg Ungerer, Jann Horn, Andrew Morton
  Cc: Nicolas Pitre, linux-m68k, Kees Cook, Arnd Bergmann, kernel list,
	Russell King, Geert Uytterhoeven, Alexander Viro, linux-fsdevel,
	linux-arm-kernel

On 5/28/19 12:56 PM, Greg Ungerer wrote:
>> Maybe... but I didn't want to rip it out without having one of the
>> maintainers confirm that this really isn't likely to be used anymore.
> 
> I have not used shared libraries on m68k non-mmu setups for
> a very long time. At least 10 years I would think.
We use shared libraries in Debian on m68k and Andreas Schwab uses them
on openSUSE/m68k.

So, they should keep working.

Thanks,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-29 12:32       ` John Paul Adrian Glaubitz
@ 2019-05-29 12:38         ` Jann Horn
  2019-05-29 12:47           ` John Paul Adrian Glaubitz
  2019-05-29 12:40         ` Greg Ungerer
  2019-05-29 13:16         ` Andreas Schwab
  2 siblings, 1 reply; 16+ messages in thread
From: Jann Horn @ 2019-05-29 12:38 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz
  Cc: Greg Ungerer, Andrew Morton, Alexander Viro, linux-fsdevel,
	kernel list, Kees Cook, Nicolas Pitre, Arnd Bergmann,
	Geert Uytterhoeven, linux-m68k, Russell King, linux-arm-kernel

On Wed, May 29, 2019 at 2:32 PM John Paul Adrian Glaubitz
<glaubitz@physik.fu-berlin.de> wrote:
> On 5/28/19 12:56 PM, Greg Ungerer wrote:
> >> Maybe... but I didn't want to rip it out without having one of the
> >> maintainers confirm that this really isn't likely to be used anymore.
> >
> > I have not used shared libraries on m68k non-mmu setups for
> > a very long time. At least 10 years I would think.
> We use shared libraries in Debian on m68k and Andreas Schwab uses them
> on openSUSE/m68k.

And you're using FLAT shared libraries, not ELF / FDPIC ELF shared
libraries? See <https://lore.kernel.org/lkml/20190524201817.16509-1-jannh@google.com/>
for context - this thread is about CONFIG_BINFMT_SHARED_FLAT.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-29 12:32       ` John Paul Adrian Glaubitz
  2019-05-29 12:38         ` Jann Horn
@ 2019-05-29 12:40         ` Greg Ungerer
  2019-05-29 13:16         ` Andreas Schwab
  2 siblings, 0 replies; 16+ messages in thread
From: Greg Ungerer @ 2019-05-29 12:40 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz, Jann Horn, Andrew Morton
  Cc: Alexander Viro, linux-fsdevel, kernel list, Kees Cook,
	Nicolas Pitre, Arnd Bergmann, Geert Uytterhoeven, linux-m68k,
	Russell King, linux-arm-kernel



On 29/5/19 10:32 pm, John Paul Adrian Glaubitz wrote:
> On 5/28/19 12:56 PM, Greg Ungerer wrote:
>>> Maybe... but I didn't want to rip it out without having one of the
>>> maintainers confirm that this really isn't likely to be used anymore.
>>
>> I have not used shared libraries on m68k non-mmu setups for
>> a very long time. At least 10 years I would think.
> We use shared libraries in Debian on m68k and Andreas Schwab uses them
> on openSUSE/m68k.

When used on no-mmu platforms?

Regards
Greg


> So, they should keep working.
> 
> Thanks,
> Adrian
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-29 12:38         ` Jann Horn
@ 2019-05-29 12:47           ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 16+ messages in thread
From: John Paul Adrian Glaubitz @ 2019-05-29 12:47 UTC (permalink / raw)
  To: Jann Horn
  Cc: Greg Ungerer, Andrew Morton, Alexander Viro, linux-fsdevel,
	kernel list, Kees Cook, Nicolas Pitre, Arnd Bergmann,
	Geert Uytterhoeven, linux-m68k, Russell King, linux-arm-kernel

On 5/29/19 2:38 PM, Jann Horn wrote:
>>> I have not used shared libraries on m68k non-mmu setups for
>>> a very long time. At least 10 years I would think.
>> We use shared libraries in Debian on m68k and Andreas Schwab uses them
>> on openSUSE/m68k.
> 
> And you're using FLAT shared libraries, not ELF / FDPIC ELF shared
> libraries? See <https://lore.kernel.org/lkml/20190524201817.16509-1-jannh@google.com/>
> for context - this thread is about CONFIG_BINFMT_SHARED_FLAT.

No, we're using ELF binaries only:

root@pacman:~# grep CONFIG_BINFMT /boot/config-$(uname -r)
CONFIG_BINFMT_ELF=y
CONFIG_BINFMT_SCRIPT=y
# CONFIG_BINFMT_FLAT is not set
# CONFIG_BINFMT_AOUT is not set
CONFIG_BINFMT_MISC=m
root@pacman:~#

Thanks,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-29 12:32       ` John Paul Adrian Glaubitz
  2019-05-29 12:38         ` Jann Horn
  2019-05-29 12:40         ` Greg Ungerer
@ 2019-05-29 13:16         ` Andreas Schwab
  2019-05-29 13:18           ` John Paul Adrian Glaubitz
  2 siblings, 1 reply; 16+ messages in thread
From: Andreas Schwab @ 2019-05-29 13:16 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz
  Cc: Greg Ungerer, Jann Horn, Andrew Morton, Alexander Viro,
	linux-fsdevel, kernel list, Kees Cook, Nicolas Pitre,
	Arnd Bergmann, Geert Uytterhoeven, linux-m68k, Russell King,
	linux-arm-kernel

On Mai 29 2019, John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> wrote:

> On 5/28/19 12:56 PM, Greg Ungerer wrote:
>>> Maybe... but I didn't want to rip it out without having one of the
>>> maintainers confirm that this really isn't likely to be used anymore.
>> 
>> I have not used shared libraries on m68k non-mmu setups for
>> a very long time. At least 10 years I would think.
> We use shared libraries in Debian on m68k and Andreas Schwab uses them
> on openSUSE/m68k.

Nope, I don't use non-mmu.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-29 13:16         ` Andreas Schwab
@ 2019-05-29 13:18           ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 16+ messages in thread
From: John Paul Adrian Glaubitz @ 2019-05-29 13:18 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Greg Ungerer, Jann Horn, Andrew Morton, Alexander Viro,
	linux-fsdevel, kernel list, Kees Cook, Nicolas Pitre,
	Arnd Bergmann, Geert Uytterhoeven, linux-m68k, Russell King,
	linux-arm-kernel

On 5/29/19 3:16 PM, Andreas Schwab wrote:
>>> I have not used shared libraries on m68k non-mmu setups for
>>> a very long time. At least 10 years I would think.
>> We use shared libraries in Debian on m68k and Andreas Schwab uses them
>> on openSUSE/m68k.
> 
> Nope, I don't use non-mmu.

Sorry, I missed the "non-mmu" part in Greg's mail :).

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-29 12:29         ` Greg Ungerer
@ 2019-05-29 13:41           ` Arnd Bergmann
  0 siblings, 0 replies; 16+ messages in thread
From: Arnd Bergmann @ 2019-05-29 13:41 UTC (permalink / raw)
  To: Greg Ungerer
  Cc: Jann Horn, Andrew Morton, Alexander Viro, linux-fsdevel,
	kernel list, Kees Cook, Nicolas Pitre, Geert Uytterhoeven,
	Linux/m68k, Russell King, Linux ARM, Sergei Poselenov

On Wed, May 29, 2019 at 2:29 PM Greg Ungerer <gregungerer00@gmail.com> wrote:
> On 29/5/19 10:05 pm, Arnd Bergmann wrote:
> > On Tue, May 28, 2019 at 12:56 PM Greg Ungerer <gerg@linux-m68k.org> wrote:
> >> On 27/5/19 11:38 pm, Jann Horn wrote:
> >>> On Sat, May 25, 2019 at 11:43 PM Andrew Morton
> >>> <akpm@linux-foundation.org> wrote:
> >>> Maybe... but I didn't want to rip it out without having one of the
> >>> maintainers confirm that this really isn't likely to be used anymore.
> >>
> >> I have not used shared libraries on m68k non-mmu setups for
> >> a very long time. At least 10 years I would think.
> >
> > I think Emcraft have a significant customer base running ARM NOMMU
> > Linux, I wonder whether they would have run into this (adding
> > Sergei to Cc).
> > My suspicion is that they use only binfmt-elf-fdpic, not binfmt-flat.
> >
> > The only architectures I see that enable binfmt-flat are sh, xtensa
> > and h8300, but only arch/sh uses CONFIG_BINFMT_SHARED_FLAT
>
> m68k uses enables it too. It is the only binary format supported
> when running no-mmu on m68k. (You can use it with MMU enabled too
> if you really want too).

My mistake, I meant to write 'the only architectures /other than m68k/",
which you had already mentioned above.

    Arnd

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] binfmt_flat: make load_flat_shared_library() work
  2019-05-29 12:05       ` Arnd Bergmann
  2019-05-29 12:29         ` Greg Ungerer
@ 2019-06-02  7:21         ` Sergei Poselenov
  1 sibling, 0 replies; 16+ messages in thread
From: Sergei Poselenov @ 2019-06-02  7:21 UTC (permalink / raw)
  To: Arnd Bergmann, Greg Ungerer
  Cc: arch, Jann Horn, Andrew Morton, Alexander Viro, linux-fsdevel,
	kernel list, Kees Cook, Nicolas Pitre, Geert Uytterhoeven,
	Linux/m68k, Russell King, Linux ARM

Hello Arnd, all,

On Wed, 2019-05-29 at 14:05 +0200, Arnd Bergmann wrote:
> On Tue, May 28, 2019 at 12:56 PM Greg Ungerer <gerg@linux-m68k.org>
> wrote:
> > On 27/5/19 11:38 pm, Jann Horn wrote:
> > > On Sat, May 25, 2019 at 11:43 PM Andrew Morton
> > > <akpm@linux-foundation.org> wrote:
> > > > On Fri, 24 May 2019 22:18:17 +0200 Jann Horn <jannh@google.com>
> > > > wrote:
> > > > > load_flat_shared_library() is broken: It only calls
> > > > > load_flat_file() if
> > > > > prepare_binprm() returns zero, but prepare_binprm() returns
> > > > > the number of
> > > > > bytes read - so this only happens if the file is empty.
> > > > 
> > > > ouch.
> > > > 
> > > > > Instead, call into load_flat_file() if the number of bytes
> > > > > read is
> > > > > non-negative. (Even if the number of bytes is zero - in that
> > > > > case,
> > > > > load_flat_file() will see nullbytes and return a nice
> > > > > -ENOEXEC.)
> > > > > 
> > > > > In addition, remove the code related to bprm creds and stop
> > > > > using
> > > > > prepare_binprm() - this code is loading a library, not a main
> > > > > executable,
> > > > > and it only actually uses the members "buf", "file" and
> > > > > "filename" of the
> > > > > linux_binprm struct. Instead, call kernel_read() directly.
> > > > > 
> > > > > Cc: stable@vger.kernel.org
> > > > > Fixes: 287980e49ffc ("remove lots of IS_ERR_VALUE abuses")
> > > > > Signed-off-by: Jann Horn <jannh@google.com>
> > > > > ---
> > > > > I only found the bug by looking at the code, I have not
> > > > > verified its
> > > > > existence at runtime.
> > > > > Also, this patch is compile-tested only.
> > > > > It would be nice if someone who works with nommu Linux could
> > > > > have a
> > > > > look at this patch.
> > > > 
> > > > 287980e49ffc was three years ago!  Has it really been broken
> > > > for all
> > > > that time?  If so, it seems a good source of freed disk
> > > > space...
> > > 
> > > Maybe... but I didn't want to rip it out without having one of
> > > the
> > > maintainers confirm that this really isn't likely to be used
> > > anymore.
> > 
> > I have not used shared libraries on m68k non-mmu setups for
> > a very long time. At least 10 years I would think.
> 
> I think Emcraft have a significant customer base running ARM NOMMU
> Linux, I wonder whether they would have run into this (adding
> Sergei to Cc).
> My suspicion is that they use only binfmt-elf-fdpic, not binfmt-flat.
> 

We use both, acutally, but all-static. We don't support shared
libraries with bFLT or ELF FDPIC.

Kind regards,
Sergei
> The only architectures I see that enable binfmt-flat are sh, xtensa
> and h8300, but only arch/sh uses CONFIG_BINFMT_SHARED_FLAT
> for a few machine specific configurations, and I'm in turn fairly
> sure
> those machines have not run a recent kernel in many years.
> 
> The one SH nommu platform likely to have users is j2, and that is
> probably always used with musl-libc with elf-fdpic (given that
> Rich Felker maintains both the kernel port and the library).
> 
>       Arnd
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-06-02  7:21 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20190524201817.16509-1-jannh@google.com>
2019-05-25 21:43 ` [PATCH] binfmt_flat: make load_flat_shared_library() work Andrew Morton
2019-05-27 13:38   ` Jann Horn
2019-05-27 14:37     ` Nicolas Pitre
2019-05-28 10:56     ` Greg Ungerer
2019-05-29 11:52       ` Arnd Bergmann
2019-05-28 10:56     ` Greg Ungerer
2019-05-29 12:05       ` Arnd Bergmann
2019-05-29 12:29         ` Greg Ungerer
2019-05-29 13:41           ` Arnd Bergmann
2019-06-02  7:21         ` Sergei Poselenov
2019-05-29 12:32       ` John Paul Adrian Glaubitz
2019-05-29 12:38         ` Jann Horn
2019-05-29 12:47           ` John Paul Adrian Glaubitz
2019-05-29 12:40         ` Greg Ungerer
2019-05-29 13:16         ` Andreas Schwab
2019-05-29 13:18           ` John Paul Adrian Glaubitz

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).