linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Todd Kjos <tkjos@google.com>
To: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	arve@android.com, tkjos@android.com, maco@android.com,
	joel@joelfernandes.org, christian@brauner.io, hridya@google.com,
	surenb@google.com, linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] android: possible ABBA deadlock in print_binder_proc() and binder_get_txn_from_and_acq_inner()
Date: Tue, 7 Sep 2021 12:29:59 -0700	[thread overview]
Message-ID: <CAHRSSEy9cYk2cUSQku5fsOjBErj9eEhMuMDQP8SJPJU9UhNOPw@mail.gmail.com> (raw)
In-Reply-To: <303401d0-25c9-d04b-e96d-3ca2aa0a616d@gmail.com>

On Mon, Sep 6, 2021 at 7:30 PM Jia-Ju Bai <baijiaju1990@gmail.com> wrote:
>
> Hello,
>
> My static analysis tool reports a possible ABBA deadlock in the android
> driver in Linux 5.10:
>
> print_binder_proc()
>    binder_inner_proc_lock()
>      _binder_inner_proc_lock()
>        spin_lock(&proc->inner_lock); --> Line 662 (Lock A)
>    print_binder_thread_ilocked()
>      print_binder_transaction_ilocked()
>        spin_lock(&t->lock); --> Line 5531 (Lock B)
>
> binder_get_txn_from_and_acq_inner()
>    binder_get_txn_from()
>      spin_lock(&t->lock); --> Line 1833 (Lock B)
>    binder_inner_proc_lock()
>      _binder_inner_proc_lock()
>        spin_lock(&proc->inner_lock); --> Line 662 (Lock A)

Hmm. What kernel version are you looking at? These line numbers don't
match what I see in mainline. Also, the sequence for
binder_get_txn_from_and_acq_inner() looks like this for me:

binder_get_txn_from_and_acq_inner()
    binder_get_txn_from()
      spin_lock(&t->lock); --> Line 1427 (Lock B)
      spin_unlock(&t->lock); --> Line 1431 (Lock B)
    binder_inner_proc_lock()
      _binder_inner_proc_lock()
         spin_lock(&proc->inner_lock); --> Line 256 (Lock A)

Which doesn't have the deadlock hazard.

>
> When print_binder_proc() and binder_get_txn_from_and_acq_inner() are
> concurrently executed, the deadlock can occur.
>
> I am not quite sure whether this possible deadlock is real and how to
> fix it if it is real.
> Any feedback would be appreciated, thanks :)
>
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
>
>
> Best wishes,
> Jia-Ju Bai

  reply	other threads:[~2021-09-07 19:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07  2:29 [BUG] android: possible ABBA deadlock in print_binder_proc() and binder_get_txn_from_and_acq_inner() Jia-Ju Bai
2021-09-07 19:29 ` Todd Kjos [this message]
2021-09-14 10:10   ` Jia-Ju Bai

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=CAHRSSEy9cYk2cUSQku5fsOjBErj9eEhMuMDQP8SJPJU9UhNOPw@mail.gmail.com \
    --to=tkjos@google.com \
    --cc=arve@android.com \
    --cc=baijiaju1990@gmail.com \
    --cc=christian@brauner.io \
    --cc=gregkh@linuxfoundation.org \
    --cc=hridya@google.com \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maco@android.com \
    --cc=surenb@google.com \
    --cc=tkjos@android.com \
    /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;
as well as URLs for NNTP newsgroup(s).