From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Carlos Llamas <cmllamas@google.com>
Cc: "Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Martijn Coenen" <maco@android.com>,
"Joel Fernandes" <joel@joelfernandes.org>,
"Christian Brauner" <brauner@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Brian Swetland" <swetland@google.com>,
linux-kernel@vger.kernel.org, kernel-team@android.com,
"Alice Ryhl" <aliceryhl@google.com>,
"Greg Kroah-Hartman" <gregkh@suse.de>,
stable@vger.kernel.org
Subject: Re: [PATCH v2 03/28] binder: fix race between mmput() and do_exit()
Date: Fri, 19 Jan 2024 06:48:43 +0100 [thread overview]
Message-ID: <2024011935-placidly-justifier-4338@gregkh> (raw)
In-Reply-To: <Zal8A95q3jVl4nu5@google.com>
On Thu, Jan 18, 2024 at 07:29:07PM +0000, Carlos Llamas wrote:
> On Fri, Dec 01, 2023 at 05:21:32PM +0000, Carlos Llamas wrote:
> > Task A calls binder_update_page_range() to allocate and insert pages on
> > a remote address space from Task B. For this, Task A pins the remote mm
> > via mmget_not_zero() first. This can race with Task B do_exit() and the
> > final mmput() refcount decrement will come from Task A.
> >
> > Task A | Task B
> > ------------------+------------------
> > mmget_not_zero() |
> > | do_exit()
> > | exit_mm()
> > | mmput()
> > mmput() |
> > exit_mmap() |
> > remove_vma() |
> > fput() |
> >
> > In this case, the work of ____fput() from Task B is queued up in Task A
> > as TWA_RESUME. So in theory, Task A returns to userspace and the cleanup
> > work gets executed. However, Task A instead sleep, waiting for a reply
> > from Task B that never comes (it's dead).
> >
> > This means the binder_deferred_release() is blocked until an unrelated
> > binder event forces Task A to go back to userspace. All the associated
> > death notifications will also be delayed until then.
> >
> > In order to fix this use mmput_async() that will schedule the work in
> > the corresponding mm->async_put_work WQ instead of Task A.
> >
> > Fixes: 457b9a6f09f0 ("Staging: android: add binder driver")
> > Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> > Signed-off-by: Carlos Llamas <cmllamas@google.com>
> > ---
>
> Sorry, I forgot to Cc: stable@vger.kernel.org.
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
next prev parent reply other threads:[~2024-01-19 5:48 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20231201172212.1813387-1-cmllamas@google.com>
2023-12-01 17:21 ` [PATCH v2 01/28] binder: use EPOLLERR from eventpoll.h Carlos Llamas
2023-12-01 17:21 ` [PATCH v2 02/28] binder: fix use-after-free in shinker's callback Carlos Llamas
2023-12-01 17:21 ` [PATCH v2 06/28] binder: fix trivial typo of binder_free_buf_locked() Carlos Llamas
2023-12-01 17:21 ` [PATCH v2 07/28] binder: fix comment on binder_alloc_new_buf() return value Carlos Llamas
[not found] ` <20231201172212.1813387-4-cmllamas@google.com>
2024-01-18 19:29 ` [PATCH v2 03/28] binder: fix race between mmput() and do_exit() Carlos Llamas
2024-01-19 5:48 ` Greg Kroah-Hartman [this message]
2024-01-19 17:06 ` Carlos Llamas
2024-01-19 17:37 ` Carlos Llamas
2024-01-20 6:37 ` Greg Kroah-Hartman
2024-01-22 18:05 ` Carlos Llamas
[not found] ` <20231201172212.1813387-5-cmllamas@google.com>
2024-01-18 19:32 ` [PATCH v2 04/28] binder: fix async space check for 0-sized buffers Carlos Llamas
2024-01-19 5:48 ` Greg Kroah-Hartman
2024-01-19 17:11 ` Carlos Llamas
2024-01-22 15:05 ` Greg Kroah-Hartman
[not found] ` <20231201172212.1813387-6-cmllamas@google.com>
2024-01-18 19:33 ` [PATCH v2 05/28] binder: fix unused alloc->free_async_space Carlos Llamas
2024-01-19 5:49 ` Greg Kroah-Hartman
2024-01-19 17:27 ` Carlos Llamas
2024-01-22 15:04 ` Greg Kroah-Hartman
2024-01-22 15:05 ` Greg Kroah-Hartman
2024-01-22 18:08 ` Carlos Llamas
2024-01-22 18:35 ` Greg Kroah-Hartman
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=2024011935-placidly-justifier-4338@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=gregkh@suse.de \
--cc=joel@joelfernandes.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maco@android.com \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=swetland@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