aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/android/binderfs.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2020-03-08 10:49:44 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2020-03-08 10:49:44 -0500
commit378fee2e6b12f31ab3749e0aa4ed0a63be23e822 (patch)
tree52d797529a29c17afa6715125fb047851c749456 /drivers/android/binderfs.c
parentMerge tag 'driver-core-5.6-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core (diff)
parentbinder: prevent UAF for binderfs devices II (diff)
downloadwireguard-linux-378fee2e6b12f31ab3749e0aa4ed0a63be23e822.tar.xz
wireguard-linux-378fee2e6b12f31ab3749e0aa4ed0a63be23e822.zip
Merge tag 'char-misc-5.6-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc fixes from Greg KH: "Here are four small char/misc driver fixes for reported issues for 5.6-rc5. These fixes are: - binder fix for a potential use-after-free problem found (took two tries to get it right) - interconnect core fix - altera-stapl driver fix All four of these have been in linux-next for a while with no reported issues" * tag 'char-misc-5.6-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: binder: prevent UAF for binderfs devices II interconnect: Handle memory allocation errors altera-stapl: altera_get_note: prevent write beyond end of 'key' binder: prevent UAF for binderfs devices
Diffstat (limited to 'drivers/android/binderfs.c')
-rw-r--r--drivers/android/binderfs.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index e2580e5316a2..110e41f920c2 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -154,6 +154,7 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
if (!name)
goto err;
+ refcount_set(&device->ref, 1);
device->binderfs_inode = inode;
device->context.binder_context_mgr_uid = INVALID_UID;
device->context.name = name;
@@ -257,8 +258,10 @@ static void binderfs_evict_inode(struct inode *inode)
ida_free(&binderfs_minors, device->miscdev.minor);
mutex_unlock(&binderfs_minors_mutex);
- kfree(device->context.name);
- kfree(device);
+ if (refcount_dec_and_test(&device->ref)) {
+ kfree(device->context.name);
+ kfree(device);
+ }
}
/**