From: Darren Hart <dvhart@linux.intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Dave Jones <davej@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>, John Kacur <jkacur@redhat.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] futex: Avoid wake_futex for a PI futex_q
Date: Wed, 21 Nov 2012 15:35:31 -0800 [thread overview]
Message-ID: <50AD6543.1050501@linux.intel.com> (raw)
In-Reply-To: <20121121143454.d72866e8.akpm@linux-foundation.org>
On 11/21/2012 02:34 PM, Andrew Morton wrote:
> On Tue, 20 Nov 2012 23:36:45 -0800
> Darren Hart <dvhart@linux.intel.com> wrote:
>
>> Dave Jones reported a bug with futex_lock_pi() that his trinity test
>> exposed. Sometime between queue_me() and taking the q.lock_ptr, the
>> lock_ptr became NULL, resulting in a crash.
>>
>> While futex_wake() is careful to not call wake_futex() on futex_q's with
>> a pi_state or an rt_waiter (which are either waiting for a
>> futex_unlock_pi() or a PI futex_requeue()), futex_wake_op() and
>> futex_requeue() do not perform the same test.
>>
>> Update futex_wake_op() and futex_requeue() to test for q.pi_state and
>> q.rt_waiter and abort with -EINVAL if detected. To ensure any future
>> breakage is caught, add a WARN() to wake_futex() if the same condition
>> is true.
>>
>> This fix has seen 3 hours of testing with "trinity -c futex" on an
>> x86_64 VM with 4 CPUS.
>>
>> ...
>>
>> --- a/kernel/futex.c
>> +++ b/kernel/futex.c
>> @@ -840,6 +840,11 @@ static void wake_futex(struct futex_q *q)
>> {
>> struct task_struct *p = q->task;
>>
>> + if (q->pi_state || q->rt_waiter) {
>> + WARN(1, "%s: refusing to wake PI futex\n", __FUNCTION__);
>> + return;
>> + }
>
> There's no need to display __FUNCTION__ because WARN() gives a
> backtrace, and we can more neatly use the WARN() return value:
>
> --- a/kernel/futex.c~futex-avoid-wake_futex-for-a-pi-futex_q-fix
> +++ a/kernel/futex.c
> @@ -843,10 +843,8 @@ static void wake_futex(struct futex_q *q
> {
> struct task_struct *p = q->task;
>
> - if (q->pi_state || q->rt_waiter) {
> - WARN(1, "%s: refusing to wake PI futex\n", __FUNCTION__);
> + if (WARN(q->pi_state || q->rt_waiter, "refusing to wake PI futex\n"))
> return;
> - }
Thanks, that's better. Duh. That block of code used to be a lot more
complex during my debug sessions, I should have caught that and boiled
it down one step further.
--
Darren
>
> /*
> * We set q->lock_ptr = NULL _before_ we wake up the task. If
> _
>
>>
>> ...
>>
--
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
prev parent reply other threads:[~2012-11-22 19:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 7:36 Darren Hart
2012-11-21 20:16 ` [tip:core/locking] " tip-bot for Darren Hart
[not found] ` <20121121143454.d72866e8.akpm@linux-foundation.org>
2012-11-21 23:35 ` Darren Hart [this message]
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=50AD6543.1050501@linux.intel.com \
--to=dvhart@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=davej@redhat.com \
--cc=jkacur@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
/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: link
Be 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
Powered by JetHome