From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 071E83858C60; Fri, 22 Dec 2023 17:00:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 071E83858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1703264412; bh=xcDI1/UY+3OYaafotUx2HxLB5hsV4TgnjpYUst/UlYY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VdvfmLVnGd1+L4lBBmXdRo7rlGOv/cQZMINMbj0PMOJzj/nFwdNzMuJoBu03toTpM cydPmYwbzLh/Omvjmk4pJBGVn57PbUmuDRDHniZjqwE3e9ugkjw6+7vE8Nkj4iY82L 51/V/FIBXmx/GUMk1VwtNY/xpxQ2WwiNFK8ewgB8= From: "cvs-commit at gcc dot gnu.org" To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/29039] Corrupt DTV after reuse of a TLS module ID following dlclose with unused TLS Date: Fri, 22 Dec 2023 17:00:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: dynamic-link X-Bugzilla-Version: 2.35 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: 2.39 X-Bugzilla-Flags: security- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29039 --- Comment #11 from Sourceware Commits --- The release/2.35/master branch has been updated by Szabolcs Nagy : https://sourceware.org/git/gitweb.cgi?p=3Dglibc.git;h=3D5f08ec08d03930050be= fec16fcc6264fa00c66fe commit 5f08ec08d03930050befec16fcc6264fa00c66fe Author: Hector Martin Date: Tue Nov 28 15:23:07 2023 +0900 elf: Fix TLS modid reuse generation assignment (BZ 29039) _dl_assign_tls_modid() assigns a slotinfo entry for a new module, but does *not* do anything to the generation counter. The first time this happens, the generation is zero and map_generation() returns the current generation to be used during relocation processing. However, if a slotinfo entry is later reused, it will already have a generation assigned. If this generation has fallen behind the current global max generation, then this causes an obsolete generation to be assigned during relocation processing, as map_generation() returns this generation if nonzero. _dl_add_to_slotinfo() eventually resets the generation, but by then it is too late. This causes DTV updates to be skipped, leading to NULL or broken TLS slot pointers and segfaults. Fix this by resetting the generation to zero in _dl_assign_tls_modid(), so it behaves the same as the first time a slot is assigned. _dl_add_to_slotinfo() will still assign the correct static generation later during module load, but relocation processing will no longer use an obsolete generation. Note that slotinfo entry (aka modid) reuse typically happens after a dlclose and only TLS access via dynamic tlsdesc is affected. Because tlsdesc is optimized to use the optional part of static TLS, dynamic tlsdesc can be avoided by increasing the glibc.rtld.optional_static_tls tunable to a large enough value, or by LD_PRELOAD-ing the affected modules. Fixes bug 29039. Reviewed-by: Szabolcs Nagy (cherry picked from commit 3921c5b40f293c57cb326f58713c924b0662ef59) --=20 You are receiving this mail because: You are on the CC list for the bug.=