From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 4A3481584AD for ; Mon, 14 Apr 2025 22:24:22 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 0DCC7342FF9 for ; Mon, 14 Apr 2025 22:24:22 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 05B501104B0; Mon, 14 Apr 2025 22:24:21 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id EFB951104B0 for ; Mon, 14 Apr 2025 22:24:20 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9D042342FF9 for ; Mon, 14 Apr 2025 22:24:20 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id ED419181E for ; Mon, 14 Apr 2025 22:24:18 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1744669426.c1078bc34bba21a2ff31289744e17f5addc07c89.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/musl/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-libs/musl/musl-1.2.5-r3.ebuild sys-libs/musl/musl-9999.ebuild X-VCS-Directories: sys-libs/musl/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: c1078bc34bba21a2ff31289744e17f5addc07c89 X-VCS-Branch: master Date: Mon, 14 Apr 2025 22:24:18 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 3e339410-835a-477c-bde5-5c89dd475f56 X-Archives-Hash: bfaf33de797a0dfe4dc37f2e07e600fb commit: c1078bc34bba21a2ff31289744e17f5addc07c89 Author: Sam James gentoo org> AuthorDate: Mon Apr 14 22:22:40 2025 +0000 Commit: Sam James gentoo org> CommitDate: Mon Apr 14 22:23:46 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c1078bc3 sys-libs/musl: add sanity check to pkg_preinst, like sys-libs/glibc awilfox reported hitting a miscompilation with trunk GCC (long-fixed) in December. I've been meaning to add a sanity check to sys-libs/musl just before merging like we do in sys-libs/glibc, and this is good motivation to do that. Tested by adding some __builtin_abort into a few functions in ldso/*.c. Signed-off-by: Sam James gentoo.org> sys-libs/musl/musl-1.2.5-r3.ebuild | 47 ++++++++++++++++++++++++++++++++++++++ sys-libs/musl/musl-9999.ebuild | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/sys-libs/musl/musl-1.2.5-r3.ebuild b/sys-libs/musl/musl-1.2.5-r3.ebuild index 559077077d00..90e86cef2f07 100644 --- a/sys-libs/musl/musl-1.2.5-r3.ebuild +++ b/sys-libs/musl/musl-1.2.5-r3.ebuild @@ -193,12 +193,59 @@ src_install() { fi } +# Simple test to make sure our new musl isn't completely broken. +# Make sure we don't test with statically built binaries since +# they will fail. Also, skip if this musl is a cross compiler. +# +# If coreutils is built with USE=multicall, some of these files +# will just be wrapper scripts, not actual ELFs we can test. +musl_sanity_check() { + cd / #228809 + + # We enter ${ED} so to avoid trouble if the path contains + # special characters; for instance if the path contains the + # colon character (:), then the linker will try to split it + # and look for the libraries in an unexpected place. This can + # lead to unsafe code execution if the generated prefix is + # within a world-writable directory. + # (e.g. /var/tmp/portage:${HOSTNAME}) + pushd "${ED}"/usr/$(get_libdir) >/dev/null + + # first let's find the actual dynamic linker here + # symlinks may point to the wrong abi + local newldso=$(find . -maxdepth 1 -name 'libc.so' -type f -print -quit) + + einfo Last-minute run tests with ${newldso} in /usr/$(get_libdir) ... + + local x striptest + for x in cal date env free ls true uname uptime ; do + x=$(type -p ${x}) + [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue + striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue + case ${striptest} in + *"statically linked"*) continue;; + *"ASCII text"*) continue;; + esac + # We need to clear the locale settings as the upgrade might want + # incompatible locale data. This test is not for verifying that. + LC_ALL=C \ + ${newldso} --library-path . ${x} > /dev/null \ + || die "simple run test (${x}) failed" + done + + popd >/dev/null +} + pkg_preinst() { # Nothing to do if just installing headers just_headers && return # Prepare /etc/ld.so.conf.d/ for files mkdir -p "${EROOT}"/etc/ld.so.conf.d + + [[ -n ${ROOT} ]] && return 0 + [[ -d ${ED}/$(get_libdir) ]] || return 0 + musl_sanity_check } pkg_postinst() { diff --git a/sys-libs/musl/musl-9999.ebuild b/sys-libs/musl/musl-9999.ebuild index 3839dbffc355..bd3a60ef270f 100644 --- a/sys-libs/musl/musl-9999.ebuild +++ b/sys-libs/musl/musl-9999.ebuild @@ -187,12 +187,59 @@ src_install() { fi } +# Simple test to make sure our new musl isn't completely broken. +# Make sure we don't test with statically built binaries since +# they will fail. Also, skip if this musl is a cross compiler. +# +# If coreutils is built with USE=multicall, some of these files +# will just be wrapper scripts, not actual ELFs we can test. +musl_sanity_check() { + cd / #228809 + + # We enter ${ED} so to avoid trouble if the path contains + # special characters; for instance if the path contains the + # colon character (:), then the linker will try to split it + # and look for the libraries in an unexpected place. This can + # lead to unsafe code execution if the generated prefix is + # within a world-writable directory. + # (e.g. /var/tmp/portage:${HOSTNAME}) + pushd "${ED}"/usr/$(get_libdir) >/dev/null + + # first let's find the actual dynamic linker here + # symlinks may point to the wrong abi + local newldso=$(find . -maxdepth 1 -name 'libc.so' -type f -print -quit) + + einfo Last-minute run tests with ${newldso} in /usr/$(get_libdir) ... + + local x striptest + for x in cal date env free ls true uname uptime ; do + x=$(type -p ${x}) + [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue + striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue + case ${striptest} in + *"statically linked"*) continue;; + *"ASCII text"*) continue;; + esac + # We need to clear the locale settings as the upgrade might want + # incompatible locale data. This test is not for verifying that. + LC_ALL=C \ + ${newldso} --library-path . ${x} > /dev/null \ + || die "simple run test (${x}) failed" + done + + popd >/dev/null +} + pkg_preinst() { # Nothing to do if just installing headers just_headers && return # Prepare /etc/ld.so.conf.d/ for files mkdir -p "${EROOT}"/etc/ld.so.conf.d + + [[ -n ${ROOT} ]] && return 0 + [[ -d ${ED}/$(get_libdir) ]] || return 0 + musl_sanity_check } pkg_postinst() {