Bug 1934162

Summary: glibc: ldconfig segfaults when dynamic tokens are in LD_LIBRARY_PATH
Product: Red Hat Enterprise Linux 8 Reporter: Sebastien Aime <saime>
Component: glibcAssignee: DJ Delorie <dj>
Status: CLOSED ERRATA QA Contact: Sergey Kolosov <skolosov>
Severity: medium Docs Contact: Petr Hybl <phybl>
Priority: unspecified    
Version: 8.3CC: ashankar, codonell, dj, fweimer, jvaldez, mnewsome, pfrankli, phybl, sipoyare
Target Milestone: rcKeywords: Patch, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: glibc-2.28-171.el8 Doc Type: Bug Fix
Doc Text:
.Statically linked applications no longer crash Previously, the initialization code of the dynamic loader, which is linked into statically linked binaries, did not initialize a link map variable correctly. Consequently, statically linked applications crashed if `LD_LIBRABY__PATH` contained a dynamic token string. With this update statically linked applications no longer crash.
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 15:17:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Sebastien Aime 2021-03-02 15:57:07 UTC
Using a syntax such as the examples below segfaults on RHEL8:

$ LD_LIBRARY_PATH=\$LIB ldconfig -p >/dev/null
Segmentation fault (core dumped)

$ LD_LIBRARY_PATH='$LIB' ldconfig -p >/dev/null
Segmentation fault (core dumped)

I have found a similar bug report for Fedora 30: https://bugzilla.redhat.com/show_bug.cgi?id=1609351

Comment 1 Florian Weimer 2021-03-05 15:25:26 UTC
Thanks for the report. As a first step, we are going to revive the upstream patch and get it fixed there.

Comment 3 Florian Weimer 2021-04-16 14:09:19 UTC
Upstream commits to backport:

commit 4e6db99c665d3b82a70a3e218860ef087b1555b4
Author: Florian Weimer <fweimer>
Date:   Mon Mar 15 10:33:43 2021 +0100

    elf: ld.so --help calls _dl_init_paths without a main map [BZ #27577]
    
    In this case, use the link map of the dynamic loader itself as
    a replacement.  This is more than just a hack: if we ever support
    DT_RUNPATH/DT_RPATH for the dynamic loader, reporting it for
    ld.so --help (without further command line arguments) would be the
    right thing to do.
    
    Fixes commit 332421312576bd7095e70589154af99b124dd2d1 ("elf: Always
    set l in _dl_init_paths (bug 23462)").

commit 332421312576bd7095e70589154af99b124dd2d1
Author: Carlos O'Donell <carlos>
Date:   Fri Mar 12 16:44:47 2021 +0100

    elf: Always set l in _dl_init_paths (bug 23462)
    
    After d1d5471579eb0426671bf94f2d71e61dfb204c30 ("Remove dead
    DL_DST_REQ_STATIC code.") we always setup the link map l to make the
    static and shared cases the same.  The bug is that in elf/dl-load.c
    (_dl_init_paths) we conditionally set l only in the #ifdef SHARED
    case, but unconditionally use it later.  The simple solution is to
    remove the #ifdef SHARED conditional, because it's no longer needed,
    and unconditionally setup l for both the static and shared cases. A
    regression test is added to run a static binary with
    LD_LIBRARY_PATH='$ORIGIN' which crashes before the fix and runs after
    the fix.
    
    Co-Authored-By: Florian Weimer <fweimer>

Comment 13 errata-xmlrpc 2022-05-10 15:17:34 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (glibc bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2005