From: Yao Zi <ziyao@disroot.org>
To: musl@lists.openwall.com
Cc: Yao Zi <ziyao@disroot.org>
Subject: [musl] [PATCH] ldso: don't reclaim zero-memory-sized segments
Date: Sun, 15 Sep 2024 21:37:50 +0000 [thread overview]
Message-ID: <20240915213750.4853-1-ziyao@disroot.org> (raw)
Some weird linkers may emit PT_LOAD segments with memsz = 0. ELF
specification does not forbid this, but such a segment with non-zero
p_vaddr will result in reclaiming of invalid memory address.
This patch skips such segments during reclaiming for better
compatibility.
Signed-off-by: Yao Zi <ziyao@disroot.org>
---
ldso/dynlink.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index 3b57c07f..715948f4 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -616,6 +616,7 @@ static void reclaim_gaps(struct dso *dso)
for (; phcnt--; ph=(void *)((char *)ph+dso->phentsize)) {
if (ph->p_type!=PT_LOAD) continue;
if ((ph->p_flags&(PF_R|PF_W))!=(PF_R|PF_W)) continue;
+ if (ph->p_memsz == 0) continue;
reclaim(dso, ph->p_vaddr & -PAGE_SIZE, ph->p_vaddr);
reclaim(dso, ph->p_vaddr+ph->p_memsz,
ph->p_vaddr+ph->p_memsz+PAGE_SIZE-1 & -PAGE_SIZE);
--
2.46.0
reply other threads:[~2024-09-15 21:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240915213750.4853-1-ziyao@disroot.org \
--to=ziyao@disroot.org \
--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).