<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/futex.c, branch v2.6.34</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v2.6.34</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v2.6.34'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2010-02-03T14:13:22Z</updated>
<entry>
<title>futex: Handle futex value corruption gracefully</title>
<updated>2010-02-03T14:13:22Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2010-02-03T08:33:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=59647b6ac3050dd964bc556fe6ef22f4db5b935c'/>
<id>urn:sha1:59647b6ac3050dd964bc556fe6ef22f4db5b935c</id>
<content type='text'>
The WARN_ON in lookup_pi_state which complains about a mismatch
between pi_state-&gt;owner-&gt;pid and the pid which we retrieved from the
user space futex is completely bogus.

The code just emits the warning and then continues despite the fact
that it detected an inconsistent state of the futex. A conveniant way
for user space to spam the syslog.

Replace the WARN_ON by a consistency check. If the values do not match
return -EINVAL and let user space deal with the mess it created.

This also fixes the missing task_pid_vnr() when we compare the
pi_state-&gt;owner pid with the futex value.

Reported-by: Jermome Marchand &lt;jmarchan@redhat.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Darren Hart &lt;dvhltc@us.ibm.com&gt;
Acked-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: &lt;stable@kernel.org&gt;
</content>
</entry>
<entry>
<title>futex: Handle user space corruption gracefully</title>
<updated>2010-02-03T14:13:22Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2010-02-02T10:40:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=51246bfd189064079c54421507236fd2723b18f3'/>
<id>urn:sha1:51246bfd189064079c54421507236fd2723b18f3</id>
<content type='text'>
If the owner of a PI futex dies we fix up the pi_state and set
pi_state-&gt;owner to NULL. When a malicious or just sloppy programmed
user space application sets the futex value to 0 e.g. by calling
pthread_mutex_init(), then the futex can be acquired again. A new
waiter manages to enqueue itself on the pi_state w/o damage, but on
unlock the kernel dereferences pi_state-&gt;owner and oopses.

Prevent this by checking pi_state-&gt;owner in the unlock path. If
pi_state-&gt;owner is not current we know that user space manipulated the
futex value. Ignore the mess and return -EINVAL.

This catches the above case and also the case where a task hijacks the
futex by setting the tid value and then tries to unlock it.

Reported-by: Jermome Marchand &lt;jmarchan@redhat.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Darren Hart &lt;dvhltc@us.ibm.com&gt;
Acked-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: &lt;stable@kernel.org&gt;

</content>
</entry>
<entry>
<title>futex_lock_pi() key refcnt fix</title>
<updated>2010-02-03T14:13:22Z</updated>
<author>
<name>Mikael Pettersson</name>
<email>mikpe@it.uu.se</email>
</author>
<published>2010-01-23T21:36:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5ecb01cfdf96c5f465192bdb2a4fd4a61a24c6cc'/>
<id>urn:sha1:5ecb01cfdf96c5f465192bdb2a4fd4a61a24c6cc</id>
<content type='text'>
This fixes a futex key reference count bug in futex_lock_pi(),
where a key's reference count is incremented twice but decremented
only once, causing the backing object to not be released.

If the futex is created in a temporary file in an ext3 file system,
this bug causes the file's inode to become an "undead" orphan,
which causes an oops from a BUG_ON() in ext3_put_super() when the
file system is unmounted. glibc's test suite is known to trigger this,
see &lt;http://bugzilla.kernel.org/show_bug.cgi?id=14256&gt;.

The bug is a regression from 2.6.28-git3, namely Peter Zijlstra's
38d47c1b7075bd7ec3881141bb3629da58f88dab "[PATCH] futex: rely on
get_user_pages() for shared futexes". That commit made get_futex_key()
also increment the reference count of the futex key, and updated its
callers to decrement the key's reference count before returning.
Unfortunately the normal exit path in futex_lock_pi() wasn't corrected:
the reference count is incremented by get_futex_key() and queue_lock(),
but the normal exit path only decrements once, via unqueue_me_pi().
The fix is to put_futex_key() after unqueue_me_pi(), since 2.6.31
this is easily done by 'goto out_put_key' rather than 'goto out'.

Signed-off-by: Mikael Pettersson &lt;mikpe@it.uu.se&gt;
Acked-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Acked-by: Darren Hart &lt;dvhltc@us.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: &lt;stable@kernel.org&gt;
</content>
</entry>
<entry>
<title>futexes: Remove rw parameter from get_futex_key()</title>
<updated>2010-01-13T08:17:36Z</updated>
<author>
<name>KOSAKI Motohiro</name>
<email>kosaki.motohiro@jp.fujitsu.com</email>
</author>
<published>2010-01-05T07:32:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7485d0d3758e8e6491a5c9468114e74dc050785d'/>
<id>urn:sha1:7485d0d3758e8e6491a5c9468114e74dc050785d</id>
<content type='text'>
Currently, futexes have two problem:

A) The current futex code doesn't handle private file mappings properly.

get_futex_key() uses PageAnon() to distinguish file and
anon, which can cause the following bad scenario:

  1) thread-A call futex(private-mapping, FUTEX_WAIT), it
     sleeps on file mapping object.
  2) thread-B writes a variable and it makes it cow.
  3) thread-B calls futex(private-mapping, FUTEX_WAKE), it
     wakes up blocked thread on the anonymous page. (but it's nothing)

B) Current futex code doesn't handle zero page properly.

Read mode get_user_pages() can return zero page, but current
futex code doesn't handle it at all. Then, zero page makes
infinite loop internally.

The solution is to use write mode get_user_page() always for
page lookup. It prevents the lookup of both file page of private
mappings and zero page.

Performance concerns:

Probaly very little, because glibc always initialize variables
for futex before to call futex(). It means glibc users never see
the overhead of this patch.

Compatibility concerns:

This patch has few compatibility issues. After this patch,
FUTEX_WAIT require writable access to futex variables (read-only
mappings makes EFAULT). But practically it's not a problem,
glibc always initalizes variables for futexes explicitly - nobody
uses read-only mappings.

Reported-by: Hugh Dickins &lt;hugh.dickins@tiscali.co.uk&gt;
Signed-off-by: KOSAKI Motohiro &lt;kosaki.motohiro@jp.fujitsu.com&gt;
Acked-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Acked-by: Darren Hart &lt;dvhltc@us.ibm.com&gt;
Cc: &lt;stable@kernel.org&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
Cc: Nick Piggin &lt;npiggin@suse.de&gt;
Cc: Ulrich Drepper &lt;drepper@gmail.com&gt;
LKML-Reference: &lt;20100105162633.45A2.A69D9226@jp.fujitsu.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>rtmutes: Convert rtmutex.lock to raw_spinlock</title>
<updated>2009-12-14T22:55:33Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2009-11-17T17:22:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d209d74d52ab39dc071656533cac095294f70de7'/>
<id>urn:sha1:d209d74d52ab39dc071656533cac095294f70de7</id>
<content type='text'>
Convert locks which cannot be sleeping locks in preempt-rt to
raw_spinlocks.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Acked-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>sched: Convert pi_lock to raw_spinlock</title>
<updated>2009-12-14T22:55:33Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2009-11-17T13:54:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1d615482547584b9a8bb6316a58fed6ce90dd9ff'/>
<id>urn:sha1:1d615482547584b9a8bb6316a58fed6ce90dd9ff</id>
<content type='text'>
Convert locks which cannot be sleeping locks in preempt-rt to
raw_spinlocks.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Acked-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>plist: Make plist debugging raw_spinlock aware</title>
<updated>2009-12-14T22:55:33Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2009-11-17T13:46:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a26724591edba5acc528d41f3906a972590e8f54'/>
<id>urn:sha1:a26724591edba5acc528d41f3906a972590e8f54</id>
<content type='text'>
plists are used with spinlocks and raw_spinlocks. Change the plist
debugging to handle both types.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Acked-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>futex: Take mmap_sem for get_user_pages in fault_in_user_writeable</title>
<updated>2009-12-08T13:59:36Z</updated>
<author>
<name>Andi Kleen</name>
<email>andi@firstfloor.org</email>
</author>
<published>2009-12-08T12:19:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=722d0172377a5697919b9f7e5beb95165b1dec4e'/>
<id>urn:sha1:722d0172377a5697919b9f7e5beb95165b1dec4e</id>
<content type='text'>
get_user_pages() must be called with mmap_sem held.

Signed-off-by: Andi Kleen &lt;ak@linux.intel.com&gt;
Cc: stable@kernel.org
Cc: Andrew Morton &lt;akpm@linuxfoundation.org&gt;
Cc: Nick Piggin &lt;npiggin@suse.de&gt;
Cc: Darren Hart &lt;dvhltc@us.ibm.com&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
LKML-Reference: &lt;20091208121942.GA21298@basil.fritz.box&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;

</content>
</entry>
<entry>
<title>futex: Fix spurious wakeup for requeue_pi really</title>
<updated>2009-10-28T19:34:34Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2009-10-28T19:26:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=11df6dddcbc38affb7473aad3d962baf8414a947'/>
<id>urn:sha1:11df6dddcbc38affb7473aad3d962baf8414a947</id>
<content type='text'>
The requeue_pi path doesn't use unqueue_me() (and the racy lock_ptr ==
NULL test) nor does it use the wake_list of futex_wake() which where
the reason for commit 41890f2 (futex: Handle spurious wake up)

See debugging discussing on LKML Message-ID: &lt;4AD4080C.20703@us.ibm.com&gt;

The changes in this fix to the wait_requeue_pi path were considered to
be a likely unecessary, but harmless safety net. But it turns out that
due to the fact that for unknown $@#!*( reasons EWOULDBLOCK is defined
as EAGAIN we built an endless loop in the code path which returns
correctly EWOULDBLOCK.

Spurious wakeups in wait_requeue_pi code path are unlikely so we do
the easy solution and return EWOULDBLOCK^WEAGAIN to user space and let
it deal with the spurious wakeup.

Cc: Darren Hart &lt;dvhltc@us.ibm.com&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Cc: John Stultz &lt;johnstul@linux.vnet.ibm.com&gt;
Cc: Dinakar Guniguntala &lt;dino@in.ibm.com&gt;
LKML-Reference: &lt;4AE23C74.1090502@us.ibm.com&gt;
Cc: stable@kernel.org
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;

</content>
</entry>
<entry>
<title>futex: Move drop_futex_key_refs out of spinlock'ed region</title>
<updated>2009-10-16T08:19:18Z</updated>
<author>
<name>Darren Hart</name>
<email>dvhltc@us.ibm.com</email>
</author>
<published>2009-10-15T22:30:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=89061d3d58e1f0742139605dc6a7950aa1ecc019'/>
<id>urn:sha1:89061d3d58e1f0742139605dc6a7950aa1ecc019</id>
<content type='text'>
When requeuing tasks from one futex to another, the reference held
by the requeued task to the original futex location needs to be
dropped eventually.

Dropping the reference may ultimately lead to a call to
"iput_final" and subsequently call into filesystem- specific code -
which may be non-atomic.

It is therefore safer to defer this drop operation until after the
futex_hash_bucket spinlock has been dropped.

Originally-From: Helge Bahmann &lt;hcb@chaoticmind.net&gt;
Signed-off-by: Darren Hart &lt;dvhltc@us.ibm.com&gt;
Cc: &lt;stable@kernel.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Cc: Dinakar Guniguntala &lt;dino@in.ibm.com&gt;
Cc: John Stultz &lt;johnstul@linux.vnet.ibm.com&gt;
Cc: Sven-Thorsten Dietrich &lt;sdietrich@novell.com&gt;
Cc: John Kacur &lt;jkacur@redhat.com&gt;
LKML-Reference: &lt;4AD7A298.5040802@us.ibm.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
</feed>
