aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/android
diff options
context:
space:
mode:
authorRiley Andrews <riandrews@android.com>2016-02-10 00:05:33 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-11 23:06:46 -0500
commit83050a4e21979fe1821916fce2fca36255569ed3 (patch)
tree12535881c698ecdaef2085f530668de0cd96db25 /drivers/android
parent212265e5ad726ed7fd2ec7d61d36d9e0b0d3e655 (diff)
android: drivers: Avoid debugfs race in binder
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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/android')
-rw-r--r--drivers/android/binder.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 1db376184955..f0ce9959d14d 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)
3600 3600
3601static int binder_proc_show(struct seq_file *m, void *unused) 3601static int binder_proc_show(struct seq_file *m, void *unused)
3602{ 3602{
3603 struct binder_proc *itr;
3603 struct binder_proc *proc = m->private; 3604 struct binder_proc *proc = m->private;
3604 int do_lock = !binder_debug_no_lock; 3605 int do_lock = !binder_debug_no_lock;
3606 bool valid_proc = false;
3605 3607
3606 if (do_lock) 3608 if (do_lock)
3607 binder_lock(__func__); 3609 binder_lock(__func__);
3608 seq_puts(m, "binder proc state:\n"); 3610
3609 print_binder_proc(m, proc, 1); 3611 hlist_for_each_entry(itr, &binder_procs, proc_node) {
3612 if (itr == proc) {
3613 valid_proc = true;
3614 break;
3615 }
3616 }
3617 if (valid_proc) {
3618 seq_puts(m, "binder proc state:\n");
3619 print_binder_proc(m, proc, 1);
3620 }
3610 if (do_lock) 3621 if (do_lock)
3611 binder_unlock(__func__); 3622 binder_unlock(__func__);
3612 return 0; 3623 return 0;