public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH v4] elf: Only allow execute libc.so.6 directly [BZ #28453]
Date: Fri, 10 Dec 2021 17:06:39 +0100	[thread overview]
Message-ID: <87a6h878c0.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <CAMe9rOrAcKQ89Sa+GSwS0Em5CHGzKvPBUGG3rwKBXok-P6QCnw@mail.gmail.com> (H. J. Lu's message of "Fri, 10 Dec 2021 07:26:06 -0800")

* H. J. Lu:

> On Fri, Dec 10, 2021 at 6:59 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> > +  /* With DT_NEEDED dependencies, it is a shared library.  Only allow
>> > +     execute libc.so directly.  */
>> > +  if (__glibc_unlikely (main_map->l_info[DT_NEEDED] != NULL))
>> > +    return (main_map->l_info[DT_SONAME] != NULL
>> > +         && strncmp ("libc.so.6",
>> > +                     ((const char *) D_PTR (main_map, l_info[DT_STRTAB])
>> > +                      + main_map->l_info[DT_SONAME]->d_un.d_val),
>> > +                     sizeof ("libc.so.6") - 1) == 0);
>>
>> I don't think this works.  See /usr/bin/npc in Fedora, it has a soname.
>
> It should work:
>
> $ readelf -l /usr/bin/npc
>
> Elf file type is DYN (Position-Independent Executable file)
> Entry point 0x2a5c0
> There are 14 program headers, starting at offset 64
>
> Program Headers:
>   Type           Offset             VirtAddr           PhysAddr
>                  FileSiz            MemSiz              Flags  Align
>   PHDR           0x0000000000000040 0x0000000000000040 0x0000000000000040
>                  0x0000000000000310 0x0000000000000310  R      0x8
>   INTERP         0x0000000000000350 0x0000000000000350 0x0000000000000350
>                  0x000000000000001c 0x000000000000001c  R      0x1
>       [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
>
> My patch checks PT_INTERP first.

But libc.so.6 has a program interpreter?  Why do we need to flag it
separately?

I'm really confused now. 8-(

Thanks,
Florian


  reply	other threads:[~2021-12-10 16:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10 14:52 H.J. Lu
2021-12-10 14:58 ` Florian Weimer
2021-12-10 15:26   ` H.J. Lu
2021-12-10 16:06     ` Florian Weimer [this message]
2021-12-10 18:37       ` H.J. Lu

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=87a6h878c0.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).