From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id DDF792620B for ; Mon, 18 Nov 2024 04:45:32 +0100 (CET) Received: (qmail 5963 invoked by uid 550); 18 Nov 2024 03:45:26 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com x-ms-reactions: disallow Received: (qmail 5922 invoked from network); 18 Nov 2024 03:45:26 -0000 X-Virus-Scanned: SPAM Filter at disroot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1731901518; bh=Ey2hUNIOpfGyJxVxgvfenHRWESftZ91fLPGSMKT9E0U=; h=From:To:Cc:Subject:Date; b=i+D63LIiqc6z7OUd34GYqTvc3++UXNrUiJI2Bb4cHmQiCHQ1u/j55LEmoeHD7CBj1 5qeH4k9vOTaG3jZqgBZFzuLtEZQG2+2ukMFUBNgYBsj5o+tHJO/1xkzT/zctET//0h eH0M5vv/OT3mDsD1Fiih26384YMXDSUNYnWDjZ6xRx9kqRq32sc3JEJZ9A0KAf/Xld G8TngGajIZRX7mqsCShS0qUqnb3qfaL7ATBtP82iaJtwqPSoyelNsrnQH5JcWlqWrP BD8Llq6g2GhWSKMY4bMwWoIBsHUGgZpbyUCaFfODcqPFDEEn8LrBdKRVgRF5YBwp1S UBO3+4LVMymag== From: Yao Zi To: musl@lists.openwall.com Cc: Yao Zi Date: Mon, 18 Nov 2024 03:44:47 +0000 Message-ID: <20241118034446.14072-2-ziyao@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [musl] [RESEND PATCH] ldso: don't reclaim zero-memory-sized segments 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 --- 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