Re: [PATCH] fs/binfmt_elf.c: disallow zero entry point address

From: H.J. Lu
Date: Sun Dec 12 2021 - 15:45:12 EST


On Sun, Dec 12, 2021 at 11:35:56AM -0800, Linus Torvalds wrote:
> [ Crossed emails ]
>
> On Sun, Dec 12, 2021 at 11:30 AM H.J. Lu <hjl.tools@xxxxxxxxx> wrote:
> >
> > On Linux, the start of the first PT_LOAD segment is the ELF
> > header and the address 0 points to the ELF magic bytes which
> > isn't a valid code sequence.
>
> Yeah, then I think a much more valid argument (and patch) is _that_ argument.
>
> So that kind of explanation, along with a patch more along the line of that
>
> if (elf_ex->e_entry < header_sizes)
> goto out;
>
> I suggested, and not talking about paper standards that may or may not
> be relevant.
>
> That would be much more palatable to me - it's a _technical_ argument,
> not a "some paper standard that we clearly have never followed"
> argument.
>
> Linus

I sent out the v2 patch with

if (elf_ex->e_entry < sizeof(*elf_ex))
goto out;


H.J.