Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 903782 - sys-devel/mold: building sys-libs/musl produces corrupted libc.so that causes boot failure
Summary: sys-devel/mold: building sys-libs/musl produces corrupted libc.so that causes...
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sam James
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-04 17:42 UTC by Andrew Athalye
Modified: 2023-10-01 06:07 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Athalye 2023-04-04 17:42:06 UTC
As the title explains, trying to build musl using mold as the linker results in a corrupted shared library that causes SIGSEGV and general issues when trying to use it. A typical manifestation of the bug is as follows:

1. LDFLAGS="-fuse-ld=mold" emerge -1 sys-libs/musl
2. (as a normal user) ls /root/
3. The symptoms:
(null): Permission denied

(in dmesg)
ls: SIGSEGV in libc.so etc.

To be sure that this wasn’t because of SELinux or my custom GCC version I built musl with clang and SELinux permissive as well, and the same issue persisted. I am sorry if this is reported elsewhere, I couldn’t find it in the issues list.

Boot fails if you reboot after installing the corrupted musl version, and the only way to recover is to copy a working libc.so from a backup (or a local musl build). The specific issue appears to be some sort of corruption wrt argv that results in some arguments being null pointers.

emerge --info:
Portage 3.0.38.1 (python 3.10.10-final-0, default/linux/amd64/17.0/musl/hardened/selinux, gcc-12.2.0, musl-1.2.3-r7, 6.1.7-gentoo x86_64)
=================================================================
System uname: Linux-6.1.7-gentoo-x86_64-12th_Gen_Intel-R-_Core-TM-_i7-1260P-with-libc
KiB Mem:    32578008 total,  30520848 free
KiB Swap:    8388288 total,   8388288 free
Timestamp of repository gentoo: Fri, 31 Mar 2023 20:17:03 +0000
Head commit of repository gentoo: 486b0664724be9448345d4dbf52930f6527f49d9

Timestamp of repository guru: Fri, 31 Mar 2023 10:31:49 +0000
Head commit of repository guru: 1b1dc01fb6b95242edbaa8014b8e17948b9aac76

Timestamp of repository musl: Wed, 29 Mar 2023 02:16:58 +0000
Head commit of repository musl: d8b226cc41e7402a7f35e9330c7e6984852e7db4

Timestamp of repository science: Mon, 03 Apr 2023 03:01:54 +0000
Head commit of repository science: 5559670afeaacb11896dafdaf1e82fa1ce35fd3a

Timestamp of repository wayland-desktop: Sun, 26 Mar 2023 12:47:20 +0000
Head commit of repository wayland-desktop: 1406f5528b26e38e8a1ae65005d178dea8046c11

sh bash 5.1_p16-r2
ld GNU ld (Gentoo 2.39 p5) 2.39.0
app-misc/pax-utils:        1.3.5::gentoo
app-shells/bash:           5.1_p16-r2::gentoo
dev-lang/perl:             5.36.0-r2::gentoo
dev-lang/python:           3.10.10_p3::gentoo, 3.11.2_p2::gentoo
dev-lang/rust:             1.66.1::gentoo
dev-util/cmake:            3.25.2::gentoo
dev-util/meson:            1.0.1::gentoo
sec-policy/selinux-base:   2.20220520-r1::gentoo, 2.20221101-r3::gentoo
sys-apps/baselayout:       2.13-r1::gentoo
sys-apps/openrc:           0.46::gentoo
sys-apps/sandbox:          2.29::gentoo
sys-devel/autoconf:        2.13-r2::gentoo, 2.13-r7::gentoo, 2.71-r1::gentoo, 2.71-r5::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.39-r4::gentoo
sys-devel/binutils-config: 5.4.1::gentoo
sys-devel/clang:           15.0.7-r1::gentoo
sys-devel/gcc:             12.2.0::gentoo
sys-devel/gcc-config:      2.8::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/lld:             15.0.7::gentoo
sys-devel/llvm:            15.0.7::gentoo
sys-devel/make:            4.3::gentoo
sys-kernel/linux-headers:  6.1::gentoo (virtual/os-headers)
sys-libs/libselinux:       3.4::gentoo
sys-libs/musl:             1.2.3-r7::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gentoo.git
    priority: -1000

guru
    location: /var/db/repos/guru
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/guru.git
    masters: gentoo

local
    location: /var/db/repos/local
    masters: gentoo

musl
    location: /var/db/repos/musl
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/musl.git
    masters: gentoo

science
    location: /var/db/repos/science
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/science.git
    masters: gentoo

wayland-desktop
    location: /var/db/repos/wayland-desktop
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/wayland-desktop.git
    masters: gentoo

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE @BINARY-REDISTRIBUTABLE MSttfEULA"
CBUILD="x86_64-gentoo-linux-musl"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-gentoo-linux-musl"
CONFIG_PROTECT="/etc /usr/lib/libreoffice/program/sofficerc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-march=native -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync network-sandbox news parallel-fetch preserve-libs protect-owned qa-unresolved-soname-deps sandbox selinux sesandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O2 -pipe"
GENTOO_MIRRORS="rsync://mirror.bytemark.co.uk/gentoo/ rsync://rsync.mirrorservice.org/distfiles.gentoo.org/ rsync://rsync.gtlib.gatech.edu/gentoo rsync://mirrors.rit.edu/gentoo/"
INSTALL_MASK="charset.alias /usr/share/locale/locale.alias"
LANG="ru.UTF-8"
LDFLAGS="-fuse-ld=mold -Wl,-O1 -Wl,--as-needed"
LEX="flex"
MAKEOPTS="-j4"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/fish"
USE="X acl ada alsa amd64 audit bluetooth branding bzip2 cairo caps cet cli crypt cups dbus dri dvd egl elogind flac gif gles2 gnome-keyring gtk gtk3 hardened iconv icu ipv6 jack jpeg kms lcms libglvnd libnotify libtirpc mp3 mpeg ncurses nls nptl ogg opengl openmp opus pam pcre pdf peer_perms pie pipewire png policykit pulseaudio readline sdl seccomp selinux spell split-usr ssl ssp svg test-rust text tiff truetype ubac udisks unicode usb v4l vaapi vorbis vulkan wayland x264 xattr xml xtpax xvid zlib zstd" ABI_X86="64" ADA_TARGET="gcc_12 gcc_12_2_0" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="musl" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" L10N="ru ru-RU fr fr-FRE en en-US" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" RUBY_TARGETS="ruby30" USERLAND="GNU" VIDEO_CARDS="intel" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-10-01 06:07:07 UTC
I'm sorry, I missed this at the time.

If it's still happening, please do report it upstream and link it here.