From: Peter Zijlstra <peterz@infradead.org>
To: Yunfeng Cui <cui.yunfeng@zte.com.cn>
Cc: christian@brauner.io, keescook@chromium.org, luto@amacapital.net,
wad@chromium.org, akpm@linux-foundation.org, mingo@kernel.org,
mhocko@suse.com, elena.reshetova@intel.com, aarcange@redhat.com,
ldv@altlinux.org, arunks@codeaurora.org, guro@fb.com,
joel@joelfernandes.org, viro@zeniv.linux.org.uk,
linux-kernel@vger.kernel.org, xue.zhihong@zte.com.cn,
wang.yi59@zte.com.cn, jiang.xuexin@zte.com.cn,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] futex: robust futex maybe never be awaked, on rare situation.
Date: Mon, 23 Sep 2019 15:05:19 +0200 [thread overview]
Message-ID: <20190923130519.GH2332@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <1569208700-24044-1-git-send-email-cui.yunfeng@zte.com.cn>
On Mon, Sep 23, 2019 at 11:18:20AM +0800, Yunfeng Cui wrote:
> I use model checker find a issue of robust and pi futex. On below
> situation, the owner can't find something in pi_state_list, while
> the requester will be blocked, never be awaked.
>
> CPU0 CPU1
> futex_lock_pi
> /*some cs code*/
> futex_lock_pi
> futex_lock_pi_atomic
> ...
> newval = uval | FUTEX_WAITERS;
> ret = lock_pi_update_atomic(uaddr, uval, newval);
> ...
> attach_to_pi_owner
> ....
> p = find_get_task_by_vpid(pid);
> if (!p)
> return handle_exit_race(uaddr, uval, NULL);
> ....
> raw_spin_lock_irq(&p->pi_lock);
> ....
> pi_state = alloc_pi_state();
> ....
> do_exit->mm_release
> if (unlikely(tsk->robust_list)) {
> exit_robust_list(tsk);
> tsk->robust_list = NULL;
> }
> if (unlikely(!list_empty(&tsk->pi_state_list)))
> exit_pi_state_list(tsk); /*WILL MISS*/
> list_add(&pi_state->list, &p->pi_state_list);
> WILL BLOCKED, NEVER WAKEUP!
Did you forget/overlook the pi_lock fiddling in do_exit() ? I'm thinking
that would make the above impossible.
> Signed-off-by: Yunfeng Cui <cui.yunfeng@zte.com.cn>
> Reviewed-by: Bo Wang <wang.bo116@zte.com.cn>
> Reviewed-by: Yi Wang <wang.yi59@zte.com.cn>
> ---
> kernel/fork.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 53e780748fe3..58b90f21dac4 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -1277,15 +1277,16 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
> if (unlikely(tsk->robust_list)) {
> exit_robust_list(tsk);
> tsk->robust_list = NULL;
> + /*Check pi_state_list of task on pi_lock be acquired*/
> + exit_pi_state_list(tsk);
> }
> #ifdef CONFIG_COMPAT
> if (unlikely(tsk->compat_robust_list)) {
> compat_exit_robust_list(tsk);
> tsk->compat_robust_list = NULL;
> + exit_pi_state_list(tsk);
> }
> #endif
> - if (unlikely(!list_empty(&tsk->pi_state_list)))
> - exit_pi_state_list(tsk);
> #endif
I'm also thinking this breaks all sorts by not unconditionally calling
exit_pi_state_list(). Specifically, it could leak PI-state for !robust
futexes.
>
> uprobe_free_utask(tsk);
next prev parent reply other threads:[~2019-09-23 13:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-23 3:18 Yunfeng Cui
2019-09-23 10:55 ` Michal Hocko
2019-09-23 13:05 ` Peter Zijlstra [this message]
2019-09-23 14:09 ` Thomas Gleixner
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=20190923130519.GH2332@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=arunks@codeaurora.org \
--cc=christian@brauner.io \
--cc=cui.yunfeng@zte.com.cn \
--cc=elena.reshetova@intel.com \
--cc=guro@fb.com \
--cc=jiang.xuexin@zte.com.cn \
--cc=joel@joelfernandes.org \
--cc=keescook@chromium.org \
--cc=ldv@altlinux.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mhocko@suse.com \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
--cc=wad@chromium.org \
--cc=wang.yi59@zte.com.cn \
--cc=xue.zhihong@zte.com.cn \
/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®