lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220128111034.jf3i4arhahfwwd6n@gmail.com>
Date:   Fri, 28 Jan 2022 20:10:34 +0900
From:   Akira Kawata <akirakawata1@...il.com>
To:     Kees Cook <keescook@...omium.org>
Cc:     akpm@...ux-foundation.org, adobriyan@...il.com,
        viro@...iv.linux.org.uk, linux-fsdevel@...r.kernel.org,
        lukas.bulwahn@...il.com, kernel test robot <lkp@...el.com>,
        Eric Biederman <ebiederm@...ssion.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 1/2] fs/binfmt_elf: Fix AT_PHDR for unusual ELF files

On Thu, Jan 27, 2022 at 08:23:51AM -0800, Kees Cook wrote:
> 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...)

I agree that unnoticed broken binaries exist. I checked glibc rtld and
there is no check of e_phoff != PT_PHDR file offset.

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

I think you have interested in https://shinh.skr.jp/obf/bingolf.html
also.

> 
> -- 
> Kees Cook

Akira Kawata

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ