public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "paul at vineyardnetworks dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sources.redhat.com Subject: [Bug dynamic-link/13862] Reuse of cached stack can cause bounds overrun of thread DTV Date: Fri, 16 Mar 2012 23:02:00 -0000 [thread overview] Message-ID: <bug-13862-131-CpKDOQoIBb@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-13862-131@http.sourceware.org/bugzilla/> http://sourceware.org/bugzilla/show_bug.cgi?id=13862 --- Comment #1 from Paul Archard <paul at vineyardnetworks dot com> 2012-03-16 23:01:57 UTC --- An alternative fix would be the following - it is possibly a more complete fix but it does break encapsulation a little. The previous suggested fix relies on the dtv being fixed up later. *** dl-tls.c 2011-05-30 21:12:33.000000000 -0700 --- ../../glibc-2.14.orig/elf/dl-tls.c 2012-03-12 14:37:27.422794007 -0700 *************** *** 35,48 **** /* Out-of-memory handler. */ - #ifdef SHARED static void __attribute__ ((__noreturn__)) oom (void) { _dl_fatal_printf ("cannot allocate memory for thread-local data: ABORT\n"); } - #endif size_t --- 35,46 ---- *************** *** 388,393 **** --- 386,437 ---- TLS. For those which are dynamically loaded we add the values indicating deferred allocation. */ listp = GL(dl_tls_dtv_slotinfo_list); + + /* check if current dtv is big enough */ + if (dtv[-1].counter < GL(dl_tls_max_dtv_idx)) + { + dtv_t *newp; + size_t newsize = GL(dl_tls_max_dtv_idx) + DTV_SURPLUS; + size_t oldsize = dtv[-1].counter; + + if ( + #ifdef SHARED + dtv == GL(dl_initial_dtv) + #else + 0 + #endif + ) + { + /* This is the initial dtv that was allocated + during rtld startup using the dl-minimal.c + malloc instead of the real malloc. We can't + free it, we have to abandon the old storage. */ + newp = malloc ((2 + newsize) * sizeof (dtv_t)); + if (newp == NULL) + oom (); + memcpy (newp, &dtv[-1], (2 + oldsize) * sizeof (dtv_t)); + } + else + { + newp = realloc(&dtv[-1], (2 + newsize) * sizeof (dtv_t)); + if (newp == NULL) + oom(); + } + + newp[0].counter = newsize; + + /* Clear the newly allocated part. */ + memset (newp + 2 + oldsize, '\0', (newsize - oldsize) * sizeof (dtv_t)); + + /* Point dtv to the generation counter. */ + dtv = &newp[1]; + + /* Install this new dtv in the given thread */ + INSTALL_DTV (result, newp); + + assert(dtv[-1].counter >= GL(dl_tls_max_dtv_idx)); + } + while (1) { size_t cnt; -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
next prev parent reply other threads:[~2012-03-16 23:02 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-03-16 22:47 [Bug dynamic-link/13862] New: " paul at vineyardnetworks dot com 2012-03-16 23:02 ` paul at vineyardnetworks dot com [this message] 2012-03-18 0:02 ` [Bug dynamic-link/13862] " ppluzhnikov at google dot com 2012-05-01 0:02 ` foelsche at sbcglobal dot net 2012-06-14 23:59 ` paul at vineyardnetworks dot com 2012-10-19 11:48 ` siddhesh at redhat dot com 2013-10-03 7:26 ` neleai at seznam dot cz 2013-11-26 8:14 ` myungjoo.ham at samsung dot com 2014-06-06 22:09 ` david.abdurachmanov at gmail dot com 2014-06-06 22:12 ` david.abdurachmanov at gmail dot com 2014-06-07 8:12 ` david.abdurachmanov at gmail dot com 2014-06-18 7:35 ` giulio.eulisse at gmail dot com 2014-06-26 13:49 ` fweimer at redhat dot com 2014-10-10 16:27 ` trt at alumni dot duke.edu 2014-10-10 16:47 ` david.abdurachmanov at gmail dot com 2014-10-10 17:29 ` paul at vineyardnetworks dot com 2014-11-26 17:39 ` hjl.tools at gmail dot com 2014-11-27 14:06 ` cvs-commit at gcc dot gnu.org 2014-11-27 15:22 ` david.abdurachmanov at gmail dot com 2014-11-27 15:27 ` hjl.tools at gmail dot com 2014-11-27 15:34 ` cvs-commit at gcc dot gnu.org 2014-11-27 16:40 ` david.abdurachmanov at gmail dot com 2014-11-27 21:45 ` cvs-commit at gcc dot gnu.org 2014-11-27 22:43 ` hjl.tools at gmail dot com 2014-11-27 23:56 ` cvs-commit at gcc dot gnu.org 2014-11-28 15:58 ` cvs-commit at gcc dot gnu.org 2014-11-28 16:00 ` cvs-commit at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-13862-131-CpKDOQoIBb@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sources.redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).