From: John Stultz <john.stultz@linaro.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: "Riley Andrews" <riandrews@android.com>,
"Colin Cross" <ccross@android.com>,
"Arve Hjønnevåg" <arve@android.com>,
"Dmitry Shmidt" <dimitrysh@google.com>,
"Rom Lemarchand" <romlem@google.com>,
"Serban Constantinescu" <serban.constantinescu@arm.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Android Kernel Team" <kernel-team@android.com>,
"John Stultz" <john.stultz@linaro.org>
Subject: [PATCH 2/2] android: drivers: Avoid debugfs race in binder
Date: Tue, 9 Feb 2016 21:05:33 -0800 [thread overview]
Message-ID: <1455080733-30965-3-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <1455080733-30965-1-git-send-email-john.stultz@linaro.org>
From: Riley Andrews <riandrews@android.com>
If a /d/binder/proc/[pid] entry is kept open after linux has
torn down the associated process, binder_proc_show can deference
an invalid binder_proc that has been stashed in the debugfs
inode. Validate that the binder_proc ptr passed into binder_proc_show
has not been freed by looking for it within the global process list
whilst the global lock is held. If the ptr is not valid, print nothing.
Cc: Colin Cross <ccross@android.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Dmitry Shmidt <dimitrysh@google.com>
Cc: Rom Lemarchand <romlem@google.com>
Cc: Serban Constantinescu <serban.constantinescu@arm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
[jstultz: Minor commit message tweaks]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
drivers/android/binder.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 1db3761..f0ce995 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -3600,13 +3600,24 @@ static int binder_transactions_show(struct seq_file *m, void *unused)
static int binder_proc_show(struct seq_file *m, void *unused)
{
+ struct binder_proc *itr;
struct binder_proc *proc = m->private;
int do_lock = !binder_debug_no_lock;
+ bool valid_proc = false;
if (do_lock)
binder_lock(__func__);
- seq_puts(m, "binder proc state:\n");
- print_binder_proc(m, proc, 1);
+
+ hlist_for_each_entry(itr, &binder_procs, proc_node) {
+ if (itr == proc) {
+ valid_proc = true;
+ break;
+ }
+ }
+ if (valid_proc) {
+ seq_puts(m, "binder proc state:\n");
+ print_binder_proc(m, proc, 1);
+ }
if (do_lock)
binder_unlock(__func__);
return 0;
--
1.9.1
prev parent reply other threads:[~2016-02-10 5:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-10 5:05 [PATCH 0/2] Binder updates from the experiemental/android-4.4 tree John Stultz
2016-02-10 5:05 ` [PATCH 1/2] android: binder: More offset validation John Stultz
2016-02-10 5:05 ` John Stultz [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=1455080733-30965-3-git-send-email-john.stultz@linaro.org \
--to=john.stultz@linaro.org \
--cc=arve@android.com \
--cc=ccross@android.com \
--cc=dimitrysh@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=riandrews@android.com \
--cc=romlem@google.com \
--cc=serban.constantinescu@arm.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
all inboxes | Powered by JetHome®