mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Nihal Jere <nihal@nihaljere.xyz>
To: musl@lists.openwall.com
Subject: [musl] Dynamic linker segfault
Date: Tue, 4 Jan 2022 15:27:10 -0600	[thread overview]
Message-ID: <YdS7rrVPInqjpFTu@debussy> (raw)

Hi,

ldd from master segfaults when run on [1] and [2]. It happens on
this[3] line. It seems to happen due to the intersection of a few
factors:

1. The segment at the lowest address is read-only.
2. A segment on the the same page is read/write.
3. The read/write segment has memsz > filesz.

This results in a segfault, as it tries to memset[3] on the mmap
created here[4], which has the same protection as the segment at
the lowest address (i.e. read-only).

As far as I can see, the options are to either:

a. detect this and throw an error.
b. 'or' together the protection flags of all the segments on the page.

I'm not sure what the right behavior is, but I don't think segfaulting
is right, and I'm sure there are people here what's correct.

Best,
Nihal

[1] https://github.com/golang/go/blob/master/src/debug/elf/testdata/go-relocation-test-gcc930-ranges-no-rela-x86-64
[2] https://github.com/golang/go/blob/master/src/debug/elf/testdata/go-relocation-test-gcc930-ranges-with-rela-x86-64
[3] https://git.musl-libc.org/cgit/musl/tree/ldso/dynlink.c#n783
[4] https://git.musl-libc.org/cgit/musl/tree/ldso/dynlink.c#n742

             reply	other threads:[~2022-01-04 21:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-04 21:27 Nihal Jere [this message]
2022-01-04 21:42 ` Rich Felker
2022-01-05  8:56   ` Florian Weimer
2022-01-05 13:49     ` Rich Felker
2022-01-05 14:00       ` Florian Weimer
2022-01-05 15:00         ` Rich Felker
2022-01-07 13:58           ` Florian Weimer
2022-01-07 17:35             ` Rich Felker
2022-01-10 13:30               ` Florian Weimer

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=YdS7rrVPInqjpFTu@debussy \
    --to=nihal@nihaljere.xyz \
    --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).