Bug 1774115

Summary: glibc: dlopen failure (e.g. of executable) should not corrupt TLS modid
Product: Red Hat Enterprise Linux 8 Reporter: Florian Weimer <fweimer>
Component: glibcAssignee: Florian Weimer <fweimer>
Status: CLOSED ERRATA QA Contact: Sergey Kolosov <skolosov>
Severity: unspecified Docs Contact: Zuzana Zoubkova <zzoubkov>
Priority: unspecified    
Version: 8.2CC: ashankar, codonell, dj, fweimer, lmanasko, mcermak, mnewsome, pfrankli, sipoyare
Target Milestone: rcKeywords: Patch, Triaged
Target Release: 8.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glibc-2.28-121.el8 Doc Type: Bug Fix
Doc Text:
.Assertion failures no longer occur during `pthread_create` Previously, the `glibc` dynamic loader did not roll back changes to the internal Thread Local Storage (TLS) module ID counter. As a consequence, an assertion failure in the `pthread_create` function could occur after the `dlopen` function had failed in certain ways. With this fix, the `glibc` dynamic loader updates the TLS module ID counter at a later point in time, after certain failures can no longer happen. As a result, the assertion failures no longer occur.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 01:32:42 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:
Embargoed:
Bug Depends On:    
Bug Blocks: 1819986    

Description Florian Weimer 2019-11-19 16:02:05 UTC
We should backport the final upstream fix for bug 1740039:

commit 77523d5e43cb5721c23855eb6045b0607a3b30a0
Author: Florian Weimer <fweimer>
Date:   Fri Oct 4 21:23:51 2019 +0200

    elf: Assign TLS modid later during dlopen [BZ #24930]
    
    Commit a42faf59d6d9f82e5293a9ebcc26d9c9e562b12b ("Fix BZ #16634.")
    attempted to fix a TLS modid consistency issue by adding additional
    checks to the open_verify function.  However, this is fragile
    because open_verify cannot reliably predict whether
    _dl_map_object_from_fd will later fail in the more complex cases
    (such as memory allocation failures).  Therefore, this commit
    assigns the TLS modid as late as possible.  At that point, the link
    map pointer will eventually be passed to _dl_close, which will undo
    the TLS modid assignment.
    
    Reviewed-by: Gabriel F. T. Gomes <gabrielftg.com>

And:

commit 7d3db434f910c23591f748a6d0ac3548af1048bb
Author: Florian Weimer <fweimer>
Date:   Thu Oct 17 08:51:21 2019 +0200

    Rename and split elf/tst-dlopen-aout collection of tests
    
    From the beginning, elf/tst-dlopen-aout has exercised two different
    bugs: (a) failure to report errors for a dlopen of the executable
    itself in some cases (bug 24900) and (b) incorrect rollback of the
    TLS modid allocation in case of a dlopen failure (bug 16634).
    
    This commit replaces the test with elf/tst-dlopen-self for (a) and
    elf/tst-dlopen-tlsmodid for (b).  The latter tests use the
    elf/tst-dlopen-self binaries (or iconv) with dlopen, so they are
    no longer self-dlopen tests.
    
    Tested on x86_64-linux-gnu and i686-linux-gnu, with a toolchain that
    does not default to PIE.

The test has a bit of a checkered history; we need to disentangle this and perhaps backport more changes.

Comment 5 Sergey Kolosov 2020-09-24 12:49:26 UTC
Verified with the reproducer from https://bugzilla.redhat.com/show_bug.cgi?id=1740039#c0

Comment 8 errata-xmlrpc 2020-11-04 01:32:42 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 (Moderate: glibc security, 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/RHSA-2020:4444