public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug dynamic-link/27136] New: dtv setup at thread creation may leave an entry uninitialized
@ 2020-12-31 14:44 nsz at gcc dot gnu.org
  2021-04-15  8:33 ` [Bug dynamic-link/27136] " cvs-commit at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: nsz at gcc dot gnu.org @ 2020-12-31 14:44 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27136

            Bug ID: 27136
           Summary: dtv setup at thread creation may leave an entry
                    uninitialized
           Product: glibc
           Version: 2.32
            Status: NEW
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: nsz at gcc dot gnu.org
  Target Milestone: ---

dtv setup is supposed to fill in all dtv entries
up to the generation count stored in dtv[0].
otherwise tls access can segfault with null ptr
dereference.

under rare circumstances the last module in the
list may be left uninitialized because of a logic
error in _dl_allocate_tls_init. the fix is

-      if (total >= GL(dl_tls_max_dtv_idx))
+      if (total > GL(dl_tls_max_dtv_idx))
        break;

the max id is a valid index, so it should be
checked and not skipped.

i think the error happens if 64 modules are
loaded with tls and the last one is loaded
as a dependency of the previous module:
mod63 and mod64 have the same tls generation
count but mod64 is on a new slotinfo node.
in that case the generation of the dtv will
be the same as mod64, but dtv[64] will not be
initialized.

if modids are reused (see bug 27135) then
mod64 can have lower generation than mod63
and can be an independently loaded module
so the issue is easier to hit.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-15 10:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-31 14:44 [Bug dynamic-link/27136] New: dtv setup at thread creation may leave an entry uninitialized nsz at gcc dot gnu.org
2021-04-15  8:33 ` [Bug dynamic-link/27136] " cvs-commit at gcc dot gnu.org
2021-04-15  8:33 ` cvs-commit at gcc dot gnu.org
2021-04-15 10:09 ` nsz at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).