mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Markus Wichmann <nullplan@gmx.net>
To: musl@lists.openwall.com
Subject: [musl] Invalid page size reference in __dls2
Date: Mon, 28 Nov 2022 20:47:40 +0100	[thread overview]
Message-ID: <20221128194740.GA23755@voyager> (raw)

Hi all,

__dls2 calls kernel_mapped_dso(), and that one uses the PAGE_SIZE macro.
Whenever <bits/limits.h> does not define PAGESIZE, PAGE_SIZE is defined
as libc.page_size. That variable is only initialized at the start of
__dls3, so the DSO descriptor for libc ends up being wrong.

Since the libc object has static storage duration, page_size is
initialized with zero. So at least nothing undefined happens. The impact
is, it will calculate the relro pointers as being zero, so no relro will
happen, and it will calculate maximum and minimum addresses as being
zero, therefore setting map to base and map_len to zero. This will cause
dladdr() not to find the libc. Yeah, not the biggest of impacts.

This, again, affects all architectures that don't define PAGESIZE, so at
this time those are

aarch64
arm
m68k
microblaze
mips
mips64
mipsn32
powerpc
powerpc64
riscv64

I don't know whether references to libc are even valid in __dls2, but it
is defined as "hidden", so that ought to be good enough. In that case it
may be enough to just move the initialization. Otherwise it may be
necessary to add page size as parameter to kernel_mapped_dso(). Then
__dls2 can look it up in the aux vector at its leisure.

Ciao,
Markus

             reply	other threads:[~2022-11-28 19:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28 19:47 Markus Wichmann [this message]
2022-11-30 15:12 ` Rich Felker
2022-11-30 23:28   ` A. Wilcox
2022-12-01  0:09     ` Rich Felker
2022-12-01  0:19       ` A. Wilcox

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=20221128194740.GA23755@voyager \
    --to=nullplan@gmx.net \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).