public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org,  "H . J . Lu" <hjl.tools@gmail.com>
Subject: Re: [RFC] elf: Add elf checks for main executable
Date: Thu, 18 Nov 2021 21:05:54 +0100	[thread overview]
Message-ID: <87o86hcjq5.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <ad4a90cf-612a-f22a-72cd-2c5aa1ac074d@linaro.org> (Adhemerval Zanella's message of "Thu, 18 Nov 2021 17:02:11 -0300")

* Adhemerval Zanella:

> On 18/11/2021 17:00, Florian Weimer wrote:
>> * Adhemerval Zanella:
>> 
>>> +static inline void
>>> +_dl_check_ehdr (struct link_map *main_map)
>>> +{
>>> +  ElfW(Ehdr) *ehdr = (void *) main_map->l_map_start;
>>> +  int err = _dl_elfhdr_check (ehdr);
>>> +  if (err != DL_ELFHDR_OK)
>>> +    _dl_fatal_printf ("program loading error: %s\n", _dl_elfhdr_errstr (err));
>>> +}
>> 
>> I think you need to iterate through the load segments and see if there
>> is one with p_offset == 0 and p_memsz > 0 (the ELF header is smaller
>> than a page).  That's the one to use for this check.  If there is no
>> such segment, we have to skip the check.
>
> Hum, should we set the l_map_start as well only if we found such segment?

No, we need l_map_start in _dl_find_dso_for_object (among other places).

Thanks,
Florian


      reply	other threads:[~2021-11-18 20:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18 19:55 Adhemerval Zanella
2021-11-18 19:58 ` H.J. Lu
2021-11-18 20:00   ` Adhemerval Zanella
2021-11-18 20:01   ` Florian Weimer
2021-11-18 20:03     ` Adhemerval Zanella
2021-11-18 20:08     ` H.J. Lu
2021-11-19  1:06       ` H.J. Lu
2021-11-18 20:00 ` Florian Weimer
2021-11-18 20:02   ` Adhemerval Zanella
2021-11-18 20:05     ` Florian Weimer [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=87o86hcjq5.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --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).