From: Hridya Valsaraju <hridya@google.com>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Martijn Coenen" <maco@android.com>,
"Joel Fernandes" <joel@joelfernandes.org>,
"Christian Brauner" <christian@brauner.io>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Cc: kernel-team@android.com, Hridya Valsaraju <hridya@google.com>,
Christian Brauner <christian.brauner@ubuntu.com>
Subject: [PATCH v3 1/2] binder: Add default binder devices through binderfs when configured
Date: Thu, 8 Aug 2019 15:27:25 -0700 [thread overview]
Message-ID: <20190808222727.132744-2-hridya@google.com> (raw)
In-Reply-To: <20190808222727.132744-1-hridya@google.com>
Currently, since each binderfs instance needs its own
private binder devices, every time a binderfs instance is
mounted, all the default binder devices need to be created
via the BINDER_CTL_ADD IOCTL. This patch aims to
add a solution to automatically create the default binder
devices for each binderfs instance that gets mounted.
To achieve this goal, when CONFIG_ANDROID_BINDERFS is set,
the default binder devices specified by CONFIG_ANDROID_BINDER_DEVICES
are created in each binderfs instance instead of global devices
being created by the binder driver.
Co-developed-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Hridya Valsaraju <hridya@google.com>
---
Changes in v2:
- Updated commit message as per Greg Kroah-Hartman.
- Removed new module parameter creation as per Greg
Kroah-Hartman/Christian Brauner.
- Refactored device name length check into a new patch as per Greg Kroah-Hartman.
Changes in v3:
-Removed unnecessary empty lines as per Dan Carpenter.
drivers/android/binder.c | 5 +++--
drivers/android/binder_internal.h | 2 ++
drivers/android/binderfs.c | 23 ++++++++++++++++++++---
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 466b6a7f8ab7..ca6b21a53321 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -123,7 +123,7 @@ static uint32_t binder_debug_mask = BINDER_DEBUG_USER_ERROR |
BINDER_DEBUG_FAILED_TRANSACTION | BINDER_DEBUG_DEAD_TRANSACTION;
module_param_named(debug_mask, binder_debug_mask, uint, 0644);
-static char *binder_devices_param = CONFIG_ANDROID_BINDER_DEVICES;
+char *binder_devices_param = CONFIG_ANDROID_BINDER_DEVICES;
module_param_named(devices, binder_devices_param, charp, 0444);
static DECLARE_WAIT_QUEUE_HEAD(binder_user_error_wait);
@@ -6279,7 +6279,8 @@ static int __init binder_init(void)
&transaction_log_fops);
}
- if (strcmp(binder_devices_param, "") != 0) {
+ if (!IS_ENABLED(CONFIG_ANDROID_BINDERFS) &&
+ strcmp(binder_devices_param, "") != 0) {
/*
* Copy the module_parameter string, because we don't want to
* tokenize it in-place.
diff --git a/drivers/android/binder_internal.h b/drivers/android/binder_internal.h
index 045b3e42d98b..fe8c745dc8e0 100644
--- a/drivers/android/binder_internal.h
+++ b/drivers/android/binder_internal.h
@@ -37,6 +37,8 @@ struct binder_device {
extern const struct file_operations binder_fops;
+extern char *binder_devices_param;
+
#ifdef CONFIG_ANDROID_BINDERFS
extern bool is_binderfs_device(const struct inode *inode);
#else
diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index e773f45d19d9..aee46dd1be91 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -186,8 +186,7 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
req->major = MAJOR(binderfs_dev);
req->minor = minor;
- ret = copy_to_user(userp, req, sizeof(*req));
- if (ret) {
+ if (userp && copy_to_user(userp, req, sizeof(*req))) {
ret = -EFAULT;
goto err;
}
@@ -467,6 +466,9 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
int ret;
struct binderfs_info *info;
struct inode *inode = NULL;
+ struct binderfs_device device_info = { 0 };
+ const char *name;
+ size_t len;
sb->s_blocksize = PAGE_SIZE;
sb->s_blocksize_bits = PAGE_SHIFT;
@@ -521,7 +523,22 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
if (!sb->s_root)
return -ENOMEM;
- return binderfs_binder_ctl_create(sb);
+ ret = binderfs_binder_ctl_create(sb);
+ if (ret)
+ return ret;
+
+ name = binder_devices_param;
+ for (len = strcspn(name, ","); len > 0; len = strcspn(name, ",")) {
+ strscpy(device_info.name, name, len + 1);
+ ret = binderfs_binder_device_create(inode, NULL, &device_info);
+ if (ret)
+ return ret;
+ name += len;
+ if (*name == ',')
+ name++;
+ }
+
+ return 0;
}
static struct dentry *binderfs_mount(struct file_system_type *fs_type,
--
2.22.0.770.g0f2c4a37fd-goog
next prev parent reply other threads:[~2019-08-08 22:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-08 22:27 [PATCH v3 0/2] Add default binderfs devices Hridya Valsaraju
2019-08-08 22:27 ` Hridya Valsaraju [this message]
2019-08-09 14:50 ` [PATCH v3 1/2] binder: Add default binder devices through binderfs when configured Greg Kroah-Hartman
2019-08-09 18:22 ` Christian Brauner
2019-08-09 20:08 ` Hridya Valsaraju
2019-08-15 16:28 ` Joel Fernandes
2019-08-15 16:30 ` Joel Fernandes
2019-08-08 22:27 ` [PATCH v3 2/2] binder: Validate the default binderfs device names Hridya Valsaraju
2019-08-09 14:51 ` Greg Kroah-Hartman
2019-08-09 14:55 ` Greg Kroah-Hartman
2019-08-09 18:14 ` Christian Brauner
2019-08-09 18:41 ` Hridya Valsaraju
2019-09-04 7:19 ` Greg Kroah-Hartman
2019-09-04 10:44 ` Christian Brauner
2019-09-04 10:49 ` Greg Kroah-Hartman
2019-09-04 11:07 ` Christian Brauner
2019-08-15 16:31 ` Joel Fernandes
2019-08-15 16:00 ` [PATCH v3 0/2] Add default binderfs devices Greg Kroah-Hartman
2019-09-04 11:07 ` [RESEND PATCH " Christian Brauner
2019-09-04 11:07 ` [RESEND PATCH v3 1/2] binder: Add default binder devices through binderfs when configured Christian Brauner
2019-09-04 11:07 ` [RESEND PATCH v3 2/2] binder: Validate the default binderfs device names Christian Brauner
2019-09-04 11:18 ` [RESEND PATCH v3 0/2] Add default binderfs devices Greg KH
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=20190808222727.132744-2-hridya@google.com \
--to=hridya@google.com \
--cc=arve@android.com \
--cc=christian.brauner@ubuntu.com \
--cc=christian@brauner.io \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=joel@joelfernandes.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maco@android.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;
as well as URLs for NNTP newsgroup(s).