mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ChenJingwen <chenjingwen6@huawei.com>
To: <keescook@chromium.org>
Cc: <akpm@linux-foundation.org>, <avagin@openvz.org>,
	<chenjingwen6@huawei.com>, <khalid.aziz@oracle.com>,
	<linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<mhocko@suse.com>, <mpe@ellerman.id.au>,
	<torvalds@linux-foundation.org>, <viro@zeniv.linux.org.uk>
Subject: [PATCH] elf: don't use MAP_FIXED_NOREPLACE for elf interpreter mappings
Date: Mon, 18 Oct 2021 14:51:12 +0800	[thread overview]
Message-ID: <20211018065112.170631-1-chenjingwen6@huawei.com> (raw)
In-Reply-To: <202110041255.83A6616D9@keescook>

> >  The reason is that the elf interpreter (ld.so) has overlapping segments.
> >
> Ewww. What toolchain generated this (and what caused it to just start
> happening)? (This was added in v4.17; it's been 3 years.)

gcc 7.3.0 for powerpc Book3E (e5500).

I wonder if there are some linker options related to the overlapping segments.
I tried to find it out why but I failed. And I also didn't see the answer in the
previous discussion yet (Maybe I missed it).

What confuses me is why the other reports only have overlapping sections for
executable binaries or dynamic libraries, but not for their ld.so.
I can keep looking for the reason but it may take a longe time for me.

> > readelf -l ld-2.31.so
> > Program Headers:
> >   Type           Offset             VirtAddr           PhysAddr
> >                  FileSiz            MemSiz              Flags  Align
> >   LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
> >                  0x000000000002c94c 0x000000000002c94c  R E    0x10000
> >   LOAD           0x000000000002dae0 0x000000000003dae0 0x000000000003dae0
> >                  0x00000000000021e8 0x0000000000002320  RW     0x10000
> >   LOAD           0x000000000002fe00 0x000000000003fe00 0x000000000003fe00
> >                  0x00000000000011ac 0x0000000000001328  RW     0x10000
> > 
> > The reason for this problem is the same as described in
> > commit ad55eac74f20 ("elf: enforce MAP_FIXED on overlaying elf segments").
> > Not only executable binaries, elf interpreters (e.g. ld.so) can have
> > overlapping elf segments, so we better drop MAP_FIXED_NOREPLACE and go
> > back to MAP_FIXED in load_elf_interp.
>
> We could also just expand the logic that fixed[1] this for ELF, yes?
>
> Andrew, are you able to pick up [1], BTW? It seems to have fallen
> through the cracks.
>
> [1] https://lore.kernel.org/all/20210916215947.3993776-1-keescook@chromium.org/T/#u

Yes, I expand the logic[1] to load_elf_interp and "init" succeeds to start.
Should I submit another patch?

      parent reply	other threads:[~2021-10-18  6:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 12:56 Chen Jingwen
2021-09-28 22:21 ` Andrew Morton
2021-10-04 20:00 ` Kees Cook
2021-10-05 23:12   ` Andrew Morton
2021-10-05 23:27     ` Kees Cook
2021-10-18  6:51   ` ChenJingwen [this message]

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=20211018065112.170631-1-chenjingwen6@huawei.com \
    --to=chenjingwen6@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=avagin@openvz.org \
    --cc=keescook@chromium.org \
    --cc=khalid.aziz@oracle.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@suse.com \
    --cc=mpe@ellerman.id.au \
    --cc=torvalds@linux-foundation.org \
    --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

all inboxes | Powered by JetHome®