public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Akira Kawata <akirakawata1@gmail.com>
Cc: akpm@linux-foundation.org, adobriyan@gmail.com,
	viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
	lukas.bulwahn@gmail.com, kernel test robot <lkp@intel.com>,
	Eric Biederman <ebiederm@xmission.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/2] fs/binfmt_elf: Fix AT_PHDR for unusual ELF files
Date: Thu, 27 Jan 2022 08:23:51 -0800	[thread overview]
Message-ID: <202201270816.5030A2A4B5@keescook> (raw)
In-Reply-To: <20220127125643.cifk2ihnbnxo5wcl@gmail.com>

On Thu, Jan 27, 2022 at 09:56:43PM +0900, Akira Kawata wrote:
> On Wed, Jan 26, 2022 at 09:01:30PM -0800, Kees Cook wrote:
> > [...]
> > 1) The ELF spec says e_phoff is 0 if there's no program header table.
> > 
> > The old code would just pass the load_addr as a result. This patch will
> > now retain the same result (phdr_addr defaults to 0). I wonder if there
> > is a bug in this behavior, though? (To be addressed in a different patch
> > if needed...)
> >
> 
> It is better to return NULL from load_elf_phdrs when e_phoff == 0, I
> think.

Yeah, right now it just returns a pointer to file offset 0.

I also wonder if we should sanity-check e_phoff vs PT_PHDR? Right now
Linux ignores PT_PHDR. Should we reject loading when e_phoff != PT_PHDR
file offset? (And I wonder if there are "broken" binaries right now that
have bad PT_PHDR segments that have gone unnoticed...)

And now I'm thinking about the excellent ELF loading analysis at:
https://nathanotterness.com/2021/10/tiny_elf_modernized.html

;)

-- 
Kees Cook

  reply	other threads:[~2022-01-27 16:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-12 23:24 [PATCH v4 0/2] [PATCH v4 0/2] fs/binfmt_elf: Fix AT_PHDR for unusual ELF files Akira Kawata
2021-12-12 23:24 ` [PATCH v4 1/2] " Akira Kawata
2022-01-27  5:01   ` Kees Cook
2022-01-27 12:56     ` Akira Kawata
2022-01-27 16:23       ` Kees Cook [this message]
2022-01-28 11:10         ` Akira Kawata
2022-01-28 19:56           ` Kees Cook
2021-12-12 23:24 ` [PATCH v4 2/2] fs/binfmt_elf: Refactor load_elf_binary function Akira Kawata
2022-01-27  5:11   ` Kees Cook
2021-12-12 23:24 ` [PATCH v4 0/2] [PATCH v4 0/2] fs/binfmt_elf: Fix AT_PHDR for unusual ELF files Akira Kawata
2021-12-12 23:35   ` Akira Kawata
2021-12-12 23:24 ` [PATCH v4 1/2] " Akira Kawata
2021-12-12 23:24 ` [PATCH v4 2/2] fs/binfmt_elf: Refactor load_elf_binary function Akira Kawata

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202201270816.5030A2A4B5@keescook \
    --to=keescook@chromium.org \
    --cc=adobriyan@gmail.com \
    --cc=akirakawata1@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=lukas.bulwahn@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox