public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug linuxthreads/3318] New: Overriding free which clobbers data and calls pthread_getspecific can get bad value (linuxthreads)
@ 2006-10-07  1:52 ian at airs dot com
  2006-10-07  1:56 ` [Bug linuxthreads/3318] " ian at airs dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ian at airs dot com @ 2006-10-07  1:52 UTC (permalink / raw)
  To: glibc-bugs

This is the linuxthreads version of bugzilla PR 3317, which I reported for NPTL.

If I override the libc free() function, and change that function to clobber some
bytes of the data, and then call pthread_getspecific from that function,
pthread_getspecific can return bad data.  This is because
__pthread_destroy_specifics frees memory before clearing the pointer to it. 
This happens around line 200:

    if (THREAD_GETMEM_NC(self, p_specific[i]) != NULL) {
      free(THREAD_GETMEM_NC(self, p_specific[i]));
      THREAD_SETMEM_NC(self, p_specific[i], NULL);
    }

This should be rewritten to call THREAD_GETMEM_NC, then THREAD_SETMEM_NC, then free.

I will attach a test case which shows the problem on i686-pc-linux-gnu using
Fedora Core 4 with glibc-2.3.6-3 when setting the environment variable
LD_ASSUME_KERNEL to 2.4.19.

-- 
           Summary: Overriding free which clobbers data and calls
                    pthread_getspecific can get bad value (linuxthreads)
           Product: glibc
           Version: 2.3.6
            Status: NEW
          Severity: normal
          Priority: P2
         Component: linuxthreads
        AssignedTo: drow at false dot org
        ReportedBy: ian at airs dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=3318

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug linuxthreads/3318] Overriding free which clobbers data and calls pthread_getspecific can get bad value (linuxthreads)
  2006-10-07  1:52 [Bug linuxthreads/3318] New: Overriding free which clobbers data and calls pthread_getspecific can get bad value (linuxthreads) ian at airs dot com
@ 2006-10-07  1:56 ` ian at airs dot com
  2006-10-31 15:31 ` drow at sources dot redhat dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: ian at airs dot com @ 2006-10-07  1:56 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From ian at airs dot com  2006-10-07 01:56 -------
Created an attachment (id=1357)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=1357&action=view)
Test case

This test case crashes for me on i686-pc-linux-gnu running Fedora Core 4 with
glibc-2.3.6-3 when I set the environment variable LD_ASSUME_KERNEL to 2.4.19. 
In the __libc_free routine, pthread_getspecific returns garbage.

This isn't the simplest possible test case--it's a modification of the NPTL
test case.  The call to abort winds up hanging as the pthread code waits for a
lock, so I put in an alarm to get the program to actually exit.  The hang is
probably due to the bug I reported in bugzilla PR 2948, which has been fixed in
the mainline sources.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=3318

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug linuxthreads/3318] Overriding free which clobbers data and calls pthread_getspecific can get bad value (linuxthreads)
  2006-10-07  1:52 [Bug linuxthreads/3318] New: Overriding free which clobbers data and calls pthread_getspecific can get bad value (linuxthreads) ian at airs dot com
  2006-10-07  1:56 ` [Bug linuxthreads/3318] " ian at airs dot com
@ 2006-10-31 15:31 ` drow at sources dot redhat dot com
  2006-10-31 21:49 ` drow at sources dot redhat dot com
  2006-10-31 21:50 ` drow at sources dot redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: drow at sources dot redhat dot com @ 2006-10-31 15:31 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drow at sources dot redhat dot com  2006-10-31 15:31 -------
Sorry, but I don't think there's any point in diverging from NPTL on this point;
LinuxThreads is strictly end of life now.  It's reasonably easy to work around
this bug and in fact I'm not sure how you ever encountered it; the sequence
number is first, and if you clobber that, pthread_getspecific will return NULL.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


http://sourceware.org/bugzilla/show_bug.cgi?id=3318

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug linuxthreads/3318] Overriding free which clobbers data and calls pthread_getspecific can get bad value (linuxthreads)
  2006-10-07  1:52 [Bug linuxthreads/3318] New: Overriding free which clobbers data and calls pthread_getspecific can get bad value (linuxthreads) ian at airs dot com
  2006-10-07  1:56 ` [Bug linuxthreads/3318] " ian at airs dot com
  2006-10-31 15:31 ` drow at sources dot redhat dot com
@ 2006-10-31 21:49 ` drow at sources dot redhat dot com
  2006-10-31 21:50 ` drow at sources dot redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: drow at sources dot redhat dot com @ 2006-10-31 21:49 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drow at sources dot redhat dot com  2006-10-31 21:49 -------
After talking to Ian...

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |


http://sourceware.org/bugzilla/show_bug.cgi?id=3318

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug linuxthreads/3318] Overriding free which clobbers data and calls pthread_getspecific can get bad value (linuxthreads)
  2006-10-07  1:52 [Bug linuxthreads/3318] New: Overriding free which clobbers data and calls pthread_getspecific can get bad value (linuxthreads) ian at airs dot com
                   ` (2 preceding siblings ...)
  2006-10-31 21:49 ` drow at sources dot redhat dot com
@ 2006-10-31 21:50 ` drow at sources dot redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: drow at sources dot redhat dot com @ 2006-10-31 21:50 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drow at sources dot redhat dot com  2006-10-31 21:50 -------
... I checked in a fix for this, in case LinuxThreads ever builds again.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


http://sourceware.org/bugzilla/show_bug.cgi?id=3318

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

end of thread, other threads:[~2006-10-31 21:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-07  1:52 [Bug linuxthreads/3318] New: Overriding free which clobbers data and calls pthread_getspecific can get bad value (linuxthreads) ian at airs dot com
2006-10-07  1:56 ` [Bug linuxthreads/3318] " ian at airs dot com
2006-10-31 15:31 ` drow at sources dot redhat dot com
2006-10-31 21:49 ` drow at sources dot redhat dot com
2006-10-31 21:50 ` drow at sources dot redhat dot com

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).