From: Hui Peng <benquike@gmail.com>
To: gregkh@linuxfoundation.org, arve@android.com, tkjos@android.com,
brauner@kernel.org, cmllamas@google.com, aliceryhl@google.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] binder: restrict BINDER_NLGRP_REPORT to CAP_NET_ADMIN and fix binderfs minor leak
Date: Sat, 19 Sep 2026 21:36:54 +0000 [thread overview]
Message-ID: <20260919213654.3317464-1-benquike@gmail.com> (raw)
Fix three security and resource-accounting issues in `binder_netlink.c`
and `binderfs.c`:
1. In `drivers/android/binder_netlink.c`,
`binder_nl_mcgrps[BINDER_NLGRP_REPORT]` is declared without `.flags =
GENL_MCAST_CAP_NET_ADMIN`, allowing any unprivileged local user to
subscribe to the `BINDER_NLGRP_REPORT` Generic Netlink multicast
group and monitor system-wide binder transaction error reports
(including sender/target PIDs and transaction metadata).
2. In `drivers/android/binderfs.c`, `binderfs_binder_ctl_create()`
allocates an IDA minor via `ida_alloc_max(&binderfs_minors, ...)`,
and if `d_alloc_name(root, "binder-control")` fails, jumps to `out:`
(which calls `kfree(device)`) without freeing `minor` from
`binderfs_minors`.
3. When the `binder-control` inode (`device->context.name == NULL`) is
evicted in `binderfs_evict_inode()`, `--info->device_count` is
decremented even though `binderfs_binder_ctl_create()` never
incremented `info->device_count`, underflowing `info->device_count`.
Only decrement `info->device_count` when `device->context.name` is
non-NULL.
Fixes: 63740349eba7 ("binder: introduce transaction reports via netlink")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
drivers/android/binder_netlink.c | 2 +-
drivers/android/binderfs.c | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/android/binder_netlink.c b/drivers/android/binder_netlink.c
index 81e8432b5904..3f1a4210aa52 100644
--- a/drivers/android/binder_netlink.c
+++ b/drivers/android/binder_netlink.c
@@ -16,7 +16,7 @@ static const struct genl_split_ops binder_nl_ops[] = {
};
static const struct genl_multicast_group binder_nl_mcgrps[] = {
- [BINDER_NLGRP_REPORT] = { "report", },
+ [BINDER_NLGRP_REPORT] = { "report", .flags = GENL_MCAST_CAP_NET_ADMIN },
};
struct genl_family binder_nl_family __ro_after_init = {
diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index 361d69f756f5..661fda3ecb59 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -258,7 +258,8 @@ static void binderfs_evict_inode(struct inode *inode)
return;
mutex_lock(&binderfs_minors_mutex);
- --info->device_count;
+ if (device->context.name)
+ --info->device_count;
ida_free(&binderfs_minors, device->miscdev.minor);
mutex_unlock(&binderfs_minors_mutex);
@@ -430,8 +431,12 @@ static int binderfs_binder_ctl_create(struct super_block *sb)
device->miscdev.minor = minor;
dentry = d_alloc_name(root, "binder-control");
- if (!dentry)
+ if (!dentry) {
+ mutex_lock(&binderfs_minors_mutex);
+ ida_free(&binderfs_minors, minor);
+ mutex_unlock(&binderfs_minors_mutex);
goto out;
+ }
inode->i_private = device;
info->control_dentry = dentry;
next reply other threads:[~2026-09-19 21:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 21:36 Hui Peng [this message]
2026-09-20 5:01 ` [PATCH] binder: restrict BINDER_NLGRP_REPORT to CAP_NET_ADMIN and fix binderfs minor leak Greg KH
2026-09-23 20:52 ` Carlos Llamas
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=20260919213654.3317464-1-benquike@gmail.com \
--to=benquike@gmail.com \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.