[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YbeSQfdSuo5CmIub@localhost.localdomain>
Date: Mon, 13 Dec 2021 21:34:41 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: "H.J. Lu" <hjl.tools@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH] fs/binfmt_elf.c: disallow zero entry point address
On Sun, Dec 12, 2021 at 05:52:14AM -0800, H.J. Lu wrote:
> On Sat, Dec 11, 2021 at 11:38 PM Alexey Dobriyan <adobriyan@...il.com> wrote:
> >
> > On 12/11/21, H.J. Lu <hjl.tools@...il.com> wrote:
> > > According to gABI, the entry point address in the ELF header gives the
> > > virtual address to which the system first transfers control, thus
> > > starting the process. If the file has no associated entry point, this
> > > member holds zero. Update the ELF loader to disallow an ELF binary
> > > with zero entry point address. This fixes:
> > >
> > > https://bugzilla.kernel.org/show_bug.cgi?id=215303
> > >
> > > Tested by booting Fedora 35 and running a shared library with zero entry
> > > point address:
> > >
> > > $ readelf -h load.so | grep "Entry point address:"
> > > Entry point address: 0x0
> > > $ ./load.so
> > > bash: ./load.so: cannot execute binary file: Exec format error
> >
> > Why not let it segfault?
> >
> > > + if (elf_ex->e_entry == 0)
> > > + goto out;
>
> Why let it segfault?
Such babysitting adds a branch for everyone to catch small number of
binaries.
e_entry can point to kernelspace, and it should segfault on the first
instruction (correctly).
It can iincorrectly point to unmapped area or VMA with wrong permissions,
with the same effect. But now check is more costly.
Powered by blists - more mailing lists