diff options
author | Hridya Valsaraju <hridya@google.com> | 2019-09-04 07:07:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-09-04 07:17:35 -0400 |
commit | ca2864c6e8965c37df97f11e6f99e83e09806b1c (patch) | |
tree | 8f80195ce645022efaa0ec985ee4ad67b5134600 | |
parent | 028fb5822b76bc2e095b5c145d7bd263878d9e27 (diff) |
binder: Add default binder devices through binderfs when configured
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>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Link: https://lore.kernel.org/r/20190808222727.132744-2-hridya@google.com
Link: https://lore.kernel.org/r/20190904110704.8606-2-christian.brauner@ubuntu.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/android/binder.c | 5 | ||||
-rw-r--r-- | drivers/android/binder_internal.h | 2 | ||||
-rw-r--r-- | 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 dc1c83eafc22..ef2d3e582368 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c | |||
@@ -122,7 +122,7 @@ static uint32_t binder_debug_mask = BINDER_DEBUG_USER_ERROR | | |||
122 | BINDER_DEBUG_FAILED_TRANSACTION | BINDER_DEBUG_DEAD_TRANSACTION; | 122 | BINDER_DEBUG_FAILED_TRANSACTION | BINDER_DEBUG_DEAD_TRANSACTION; |
123 | module_param_named(debug_mask, binder_debug_mask, uint, 0644); | 123 | module_param_named(debug_mask, binder_debug_mask, uint, 0644); |
124 | 124 | ||
125 | static char *binder_devices_param = CONFIG_ANDROID_BINDER_DEVICES; | 125 | char *binder_devices_param = CONFIG_ANDROID_BINDER_DEVICES; |
126 | module_param_named(devices, binder_devices_param, charp, 0444); | 126 | module_param_named(devices, binder_devices_param, charp, 0444); |
127 | 127 | ||
128 | static DECLARE_WAIT_QUEUE_HEAD(binder_user_error_wait); | 128 | static DECLARE_WAIT_QUEUE_HEAD(binder_user_error_wait); |
@@ -6131,7 +6131,8 @@ static int __init binder_init(void) | |||
6131 | &transaction_log_fops); | 6131 | &transaction_log_fops); |
6132 | } | 6132 | } |
6133 | 6133 | ||
6134 | if (strcmp(binder_devices_param, "") != 0) { | 6134 | if (!IS_ENABLED(CONFIG_ANDROID_BINDERFS) && |
6135 | strcmp(binder_devices_param, "") != 0) { | ||
6135 | /* | 6136 | /* |
6136 | * Copy the module_parameter string, because we don't want to | 6137 | * Copy the module_parameter string, because we don't want to |
6137 | * tokenize it in-place. | 6138 | * 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 { | |||
37 | 37 | ||
38 | extern const struct file_operations binder_fops; | 38 | extern const struct file_operations binder_fops; |
39 | 39 | ||
40 | extern char *binder_devices_param; | ||
41 | |||
40 | #ifdef CONFIG_ANDROID_BINDERFS | 42 | #ifdef CONFIG_ANDROID_BINDERFS |
41 | extern bool is_binderfs_device(const struct inode *inode); | 43 | extern bool is_binderfs_device(const struct inode *inode); |
42 | #else | 44 | #else |
diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c index d8307cccbef8..55c5adb87585 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, | |||
186 | req->major = MAJOR(binderfs_dev); | 186 | req->major = MAJOR(binderfs_dev); |
187 | req->minor = minor; | 187 | req->minor = minor; |
188 | 188 | ||
189 | ret = copy_to_user(userp, req, sizeof(*req)); | 189 | if (userp && copy_to_user(userp, req, sizeof(*req))) { |
190 | if (ret) { | ||
191 | ret = -EFAULT; | 190 | ret = -EFAULT; |
192 | goto err; | 191 | goto err; |
193 | } | 192 | } |
@@ -467,6 +466,9 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent) | |||
467 | int ret; | 466 | int ret; |
468 | struct binderfs_info *info; | 467 | struct binderfs_info *info; |
469 | struct inode *inode = NULL; | 468 | struct inode *inode = NULL; |
469 | struct binderfs_device device_info = { 0 }; | ||
470 | const char *name; | ||
471 | size_t len; | ||
470 | 472 | ||
471 | sb->s_blocksize = PAGE_SIZE; | 473 | sb->s_blocksize = PAGE_SIZE; |
472 | sb->s_blocksize_bits = PAGE_SHIFT; | 474 | sb->s_blocksize_bits = PAGE_SHIFT; |
@@ -521,7 +523,22 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent) | |||
521 | if (!sb->s_root) | 523 | if (!sb->s_root) |
522 | return -ENOMEM; | 524 | return -ENOMEM; |
523 | 525 | ||
524 | return binderfs_binder_ctl_create(sb); | 526 | ret = binderfs_binder_ctl_create(sb); |
527 | if (ret) | ||
528 | return ret; | ||
529 | |||
530 | name = binder_devices_param; | ||
531 | for (len = strcspn(name, ","); len > 0; len = strcspn(name, ",")) { | ||
532 | strscpy(device_info.name, name, len + 1); | ||
533 | ret = binderfs_binder_device_create(inode, NULL, &device_info); | ||
534 | if (ret) | ||
535 | return ret; | ||
536 | name += len; | ||
537 | if (*name == ',') | ||
538 | name++; | ||
539 | } | ||
540 | |||
541 | return 0; | ||
525 | } | 542 | } |
526 | 543 | ||
527 | static struct dentry *binderfs_mount(struct file_system_type *fs_type, | 544 | static struct dentry *binderfs_mount(struct file_system_type *fs_type, |