public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/5192] New: Internal lock in pthread struct is vulnerable to priority inversion
@ 2007-10-17 15:11 matt dot hoosier at gmail dot com
  2007-10-17 15:52 ` [Bug nptl/5192] " matt dot hoosier at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: matt dot hoosier at gmail dot com @ 2007-10-17 15:11 UTC (permalink / raw)
  To: glibc-bugs

When most public API operations on pthread_t's execute, the per-thread lock
(struct pthread.lock) is acquired to enforce consistency of the kernel and
userspace data structures.

This can cause a problem when a thread (t1) lowers its own priority and some
other thread (t2, high priority) then immediately becomes runnable as a result
of the priority shift. The scenario would look like this:

* There are three threads: T1 (low prio), T2 (mid prio), T3 (high prio)

* T1 is initially running at some value higher than its permanent priority, to
do some startup work

* T2 is executing some CPU-bound job that is always runnable

* T1 finishes initialization, sets itself to its lower (permanent) priority.
This requires grabbing the locking its own per-thread futex ("lock" in struct
pthread). The syscall to alter scheduling parameters will immediately result in
T2 being put on the CPU, so the lock is not yet dropped.

* T3 eventually needs to do some adjustment of T1's scheduling options. So it
tries to grab T1's per-thread lock, but can't since T1 still holds it because
its scheduling syscall hasn't returned to userspace yet.

* Priority inversion. T2 continues to run unchallenged.

Can the pthread.lock be treated as a PI futex instead of a standard futex, in
order to get priority inheritance and work around this inversion?

I'll attach an example program shortly.

-- 
           Summary: Internal lock in pthread struct is vulnerable to
                    priority inversion
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: drepper at redhat dot com
        ReportedBy: matt dot hoosier at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: arm-none-linux-gnueabi


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

------- 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] 9+ messages in thread
[parent not found: <bug-5192-131@http.sourceware.org/bugzilla/>]

end of thread, other threads:[~2012-12-19 10:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-17 15:11 [Bug nptl/5192] New: Internal lock in pthread struct is vulnerable to priority inversion matt dot hoosier at gmail dot com
2007-10-17 15:52 ` [Bug nptl/5192] " matt dot hoosier at gmail dot com
2007-12-15  9:40 ` ismail at pardus dot org dot tr
2008-04-17 22:55 ` spcurry5 at linux dot vnet dot ibm dot com
2008-04-25  0:28 ` spcurry5 at linux dot vnet dot ibm dot com
2008-04-25  1:27 ` spcurry5 at linux dot vnet dot ibm dot com
2008-04-25 20:15 ` rsa at us dot ibm dot com
2008-12-30 21:23 ` spcurry5 at linux dot vnet dot ibm dot com
     [not found] <bug-5192-131@http.sourceware.org/bugzilla/>
2012-12-19 10:42 ` schwab@linux-m68k.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).