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

From: Linus Torvalds
Date: Sun Dec 12 2021 - 14:33:26 EST


On Sun, Dec 12, 2021 at 11:15 AM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> I'm not sure this can happen currently (maybe all tools effectively
> make it so that the ELF headers etc are part of the loaded image).

Side note: if that ends up being the case (ie e_entry always
effectively relative to the head of the image), then I think a better
fix would be to make that explicit, something like

if (elf_ex->e_entry < header_sizes)
goto out;

but the logic on exactly how things get loaded is so messy that I'm
not sure just what the situation is.

We've had things like old tool chains generate messy binaries before,
to the point where we've had to revert much more important changes (ie
the whole mess with MAP_FIXED_NOREPLACE and overlapping sections).

Linus