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

From: Linus Torvalds
Date: Sun Dec 12 2021 - 14:16:10 EST


On Sun, Dec 12, 2021 at 11:06 AM H.J. Lu <hjl.tools@xxxxxxxxx> wrote:
>
> According to the ELF specification, zero entry point value means
> there is no entry point. Such ELF binary doesn't conform to the
> ELF specification.

Nobody cares about paper specifications.

All that matters is REALITY.

So let me quote my email again, since you clearly didn't actually read
it (read that "maybe it's not supposed to work" part):

> That's not my main worry - what if somebody has a code section with a
> zero vaddr and intentionally put the entry at the beginning?
>
> Maybe it's not supposed to work by some paper standatd, but afaik
> currently it _would_ work.

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

But no, paper specifications have absolutely no meaning if they don't
match realty.

And the reality is that I don't think we've ever checked e_entry being
zero, which means that maybe people have used it.

So convince me that the above cannot happen. I'm perfectly willing to
be convinced, but "some random paper standard that we've never
followed" is not the thing to quote.

Linus