mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: mingo@kernel.org, dvyukov@google.com, hpa@zytor.com,
	linux-kernel@vger.kernel.org,
	bot+2af19c9e1ffe4d4ee1d16c56ae7580feaee75765@syzkaller.appspotmail.com,
	torvalds@linux-foundation.org, peterz@infradead.org,
	gratian.crisan@ni.com
Cc: linux-tip-commits@vger.kernel.org
Subject: Re: [tip:core/urgent] futex: Fix more put_pi_state() vs. exit_pi_state_list() races
Date: Tue, 31 Oct 2017 23:11:10 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1710312310270.1942@nanos> (raw)
In-Reply-To: <tip-d5f6ac33189af48a0dc011190af5144947a30a76@git.kernel.org>

On Tue, 31 Oct 2017, tip-bot for Peter Zijlstra wrote:
> Commit-ID:  d5f6ac33189af48a0dc011190af5144947a30a76
> Gitweb:     https://git.kernel.org/tip/d5f6ac33189af48a0dc011190af5144947a30a76
> Author:     Peter Zijlstra <peterz@infradead.org>
> AuthorDate: Tue, 31 Oct 2017 11:18:53 +0100
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Tue, 31 Oct 2017 11:54:52 +0100
> 
> futex: Fix more put_pi_state() vs. exit_pi_state_list() races
> 
> Dmitry (through syzbot) reported being able to trigger the WARN in
> get_pi_state() and a use-after-free on:
> 
> 	raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);
> 
> Both are due to this race:
> 
>   exit_pi_state_list()				put_pi_state()
> 
>   lock(&curr->pi_lock)
>   while() {
> 	pi_state = list_first_entry(head);
> 	hb = hash_futex(&pi_state->key);
> 	unlock(&curr->pi_lock);
> 
> 						dec_and_test(&pi_state->refcount);
> 
> 	lock(&hb->lock)
> 	lock(&pi_state->pi_mutex.wait_lock)	// uaf if pi_state free'd
> 	lock(&curr->pi_lock);
> 
> 	....
> 
> 	unlock(&curr->pi_lock);
> 	get_pi_state();				// WARN; refcount==0
> 
> The problem is we take the reference count too late, and don't allow it
> being 0. Fix it by using inc_not_zero() and simply retrying the loop
> when we fail to get a refcount. In that case put_pi_state() should
> remove the entry from the list.
> 
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc: Gratian Crisan <gratian.crisan@ni.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: dvhart@infradead.org
> Cc: syzbot <bot+2af19c9e1ffe4d4ee1d16c56ae7580feaee75765@syzkaller.appspotmail.com>
> Cc: syzkaller-bugs@googlegroups.com
> Fixes: c74aef2d06a9 ("futex: Fix pi_state->owner serialization")
> Link: http://lkml.kernel.org/r/20171031101853.xpfh72y643kdfhjs@hirez.programming.kicks-ass.net
> Signed-off-by: Ingo Molnar <mingo@kernel.org>

That lacks a stable tag.

Other than that a late:

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

  reply	other threads:[~2017-10-31 22:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-30 19:44 WARNING in get_pi_state syzbot
2017-10-30 19:53 ` Dmitry Vyukov
2017-10-31  8:36 ` Peter Zijlstra
2017-10-31 10:18   ` Peter Zijlstra
2017-10-31 10:31     ` Peter Zijlstra
2017-10-31 10:38       ` Peter Zijlstra
2017-11-01  8:45         ` Peter Zijlstra
2017-11-07 16:16         ` Dmitry Vyukov
2017-10-31 12:06     ` [tip:core/urgent] futex: Fix more put_pi_state() vs. exit_pi_state_list() races tip-bot for Peter Zijlstra
2017-10-31 22:11       ` Thomas Gleixner [this message]
2017-11-01  8:05         ` Ingo Molnar
2017-11-01  8:09     ` tip-bot for Peter Zijlstra
2017-10-31  9:16 ` WARNING in get_pi_state Peter Zijlstra
2017-10-31  9:29   ` Dmitry Vyukov
2017-10-31 10:08     ` Peter Zijlstra
2017-10-31 10:21       ` Dmitry Vyukov
2017-10-31 10:23         ` Dmitry Vyukov
2017-10-31 10:36           ` Peter Zijlstra
2017-11-07 14:50       ` Dmitry Vyukov

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=alpine.DEB.2.20.1710312310270.1942@nanos \
    --to=tglx@linutronix.de \
    --cc=bot+2af19c9e1ffe4d4ee1d16c56ae7580feaee75765@syzkaller.appspotmail.com \
    --cc=dvyukov@google.com \
    --cc=gratian.crisan@ni.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.org \
    /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

all inboxes | Powered by JetHome®