Add default binder devices through binderfs when configured
PATCH 1/1 Add default binder devices through binderfs when configured
If 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.
--- drivers/android/binder.c | 3 ++- drivers/android/binderfs.c | 46 ++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 5 deletions(-)
drivers/android/binder.c +2 -1
@@ -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.
drivers/android/binderfs.c +42 -4
82 lines not on this page · raw message
Signature · 1 line
2.22.0.770.g0f2c4a37fd-goog
Greg Kroah-Hartman
maintainerQuoted 32 lines · Hridya Valsaraju
If
CONFIG_ANDROID_BINDERFSis set, the default binder devices specified byCONFIG_ANDROID_BINDER_DEVICESare created in each binderfs instance instead of global devices being created by the binder driver.Co-developed-by Christian Brauner <[email protected]>Signed-off-by Christian Brauner <[email protected]>Signed-off-by Hridya Valsaraju <[email protected]>--- drivers/android/binder.c | 3 ++- drivers/android/binderfs.c | 46 ++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 5 deletions(-)drivers/android/binder.c +2
-1@@ -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. drivers/android/binderfs.c +0
-0
drivers/android/binderfs.c static dev_t binderfs_dev; · line 54
Quoted 7 lines
drivers/android/binderfs.c +4
-0@@ -48,6 +48,10 @@ static dev_t binderfs_dev;static DEFINE_MUTEX (binderfs_minors_mutex);static DEFINE_IDA (binderfs_minors); +static char *binder_devices_param =CONFIG_ANDROID_BINDER_DEVICES ; +module_param_named (devices, binder_devices_param, charp,0444 ); +MODULE_PARM_DESC (devices,"Binder devices to be created by default" ); +
Why are you creating a module parameter? That was not in your changelog :(
Quoted 67 lines
drivers/android/binderfs.c +28
-4/** * binderfs_mount_opts - mount options for binderfs * @max: maximum number of allocatable binderfs binder devices @@ -135,7 +139,6 @@ static int binderfs_binder_device_create(struct inode *ref_inode,#else bool use_reserve = true;#endif -/* Reserve new minor number for the new device. */ mutex_lock (&binderfs_minors_mutex);if (++info->device_count <= info->mount_opts.max)@@ -186,8 +189,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 &©_to_user (userp, req,sizeof (*req))) { ret = -EFAULT ; goto err; }@@ -467,6 +469,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 +526,28 @@ 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,"," )) { +/* +* init_binderfs() has already checked that the length of +* device_name_entry->name is not greater than device_info.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,@@ -553,6 +579,18 @@ static struct file_system_type binder_fs_type = {int __init init_binderfs (void ) {int ret; +const char *name; +size_t len;
drivers/android/binderfs.c static struct file_system_type binder_fs_type = { · line 593
Quoted 10 lines
drivers/android/binderfs.c +10
-0+ +/* Verify that the default binderfs device names are valid. */ + name = binder_devices_param; +for (len =strcspn (name,"," ); len >0 ; len =strcspn (name,"," )) { +if (len >BINDERFS_MAX_NAME ) +return -E2BIG ; + name += len; +if (*name ==',' ) + name++; + }
This verification should be a separate patch, right?
But the real issue here is I have no idea _why_ you are wanting this patch. The changelog text says _what_ you are doing only, which isn't ok.
Please provide more information as to why this is needed, what problem it is solving, and break this up into a patch series and resend.
thanks,
greg k-h
Christian Brauner
maintainerQuoted 36 lines · Greg Kroah-Hartman
Quoted 35 lines · Hridya Valsaraju
If
CONFIG_ANDROID_BINDERFSis set, the default binder devices specified byCONFIG_ANDROID_BINDER_DEVICESare created in each binderfs instance instead of global devices being created by the binder driver.Co-developed-by Christian Brauner <[email protected]>Signed-off-by Christian Brauner <[email protected]>Signed-off-by Hridya Valsaraju <[email protected]>--- drivers/android/binder.c | 3 ++- drivers/android/binderfs.c | 46 ++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 5 deletions(-)drivers/android/binder.c +2
-1@@ -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. drivers/android/binderfs.c +0
-0@@ -48,6 +48,10 @@ static dev_t binderfs_dev;static DEFINE_MUTEX (binderfs_minors_mutex);static DEFINE_IDA (binderfs_minors);
Quoted 7 lines
drivers/android/binderfs.c static dev_t binderfs_dev; · line 54
Quoted 4 lines
drivers/android/binderfs.c +4
-0+static char *binder_devices_param =CONFIG_ANDROID_BINDER_DEVICES ; +module_param_named (devices, binder_devices_param, charp,0444 ); +MODULE_PARM_DESC (devices,"Binder devices to be created by default" ); +Why are you creating a module parameter? That was not in your changelog :(
Yeah, you don't need an additional module parameter. You can just move
static char *binder_devices_param = CONFIG_ANDROID_BINDER_DEVICES; module_param_named(devices, binder_devices_param, charp, 0444);
from binder.c to binder_internal.h and expose it to binder.c and binderfs.c this way. This will work just fine since binderfs.c doesn't modify the parameter and binder.c makes a copy of it before doing so.
Quoted 93 lines
Quoted 70 lines
drivers/android/binderfs.c +28
-4/** * binderfs_mount_opts - mount options for binderfs * @max: maximum number of allocatable binderfs binder devices @@ -135,7 +139,6 @@ static int binderfs_binder_device_create(struct inode *ref_inode,#else bool use_reserve = true;#endif -/* Reserve new minor number for the new device. */ mutex_lock (&binderfs_minors_mutex);if (++info->device_count <= info->mount_opts.max)@@ -186,8 +189,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 &©_to_user (userp, req,sizeof (*req))) { ret = -EFAULT ; goto err; }@@ -467,6 +469,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 +526,28 @@ 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,"," )) { +/* +* init_binderfs() has already checked that the length of +* device_name_entry->name is not greater than device_info.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,@@ -553,6 +579,18 @@ static struct file_system_type binder_fs_type = {int __init init_binderfs (void ) {int ret; +const char *name; +size_t len;drivers/android/binderfs.c static struct file_system_type binder_fs_type = { · line 593
Quoted 10 lines
drivers/android/binderfs.c +10
-0+ +/* Verify that the default binderfs device names are valid. */ + name = binder_devices_param; +for (len =strcspn (name,"," ); len >0 ; len =strcspn (name,"," )) { +if (len >BINDERFS_MAX_NAME ) +return -E2BIG ; + name += len; +if (*name ==',' ) + name++; + }This verification should be a separate patch, right?
But the real issue here is I have no idea _why_ you are wanting this patch. The changelog text says _what_ you are doing only, which isn't ok.
Please provide more information as to why this is needed, what problem it is solving, and break this up into a patch series and resend.
thanks,
greg k-h
Quoted 46 lines · Christian Brauner
Quoted 36 lines · Greg Kroah-Hartman
Quoted 35 lines · Hridya Valsaraju
If
CONFIG_ANDROID_BINDERFSis set, the default binder devices specified byCONFIG_ANDROID_BINDER_DEVICESare created in each binderfs instance instead of global devices being created by the binder driver.Co-developed-by Christian Brauner <[email protected]>Signed-off-by Christian Brauner <[email protected]>Signed-off-by Hridya Valsaraju <[email protected]>--- drivers/android/binder.c | 3 ++- drivers/android/binderfs.c | 46 ++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 5 deletions(-)drivers/android/binder.c +2
-1@@ -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. drivers/android/binderfs.c +0
-0@@ -48,6 +48,10 @@ static dev_t binderfs_dev;static DEFINE_MUTEX (binderfs_minors_mutex);static DEFINE_IDA (binderfs_minors);Quoted 7 lines
drivers/android/binderfs.c static dev_t binderfs_dev; · line 54
Quoted 4 lines
drivers/android/binderfs.c +4
-0+static char *binder_devices_param =CONFIG_ANDROID_BINDER_DEVICES ; +module_param_named (devices, binder_devices_param, charp,0444 ); +MODULE_PARM_DESC (devices,"Binder devices to be created by default" ); +Why are you creating a module parameter? That was not in your changelog :(
Quoted 98 lines
Yeah, you don't need an additional module parameter. You can just move
static char
*binder_devices_param=CONFIG_ANDROID_BINDER_DEVICES;module_param_named(devices, binder_devices_param, charp, 0444);from
binder.ctobinder_internal.hand expose it tobinder.candbinderfs.cthis way. This will work just fine sincebinderfs.cdoesn't modify the parameter andbinder.cmakes a copy of it before doing so.Quoted 89 lines
Quoted 70 lines
drivers/android/binderfs.c +28
-4/** * binderfs_mount_opts - mount options for binderfs * @max: maximum number of allocatable binderfs binder devices @@ -135,7 +139,6 @@ static int binderfs_binder_device_create(struct inode *ref_inode,#else bool use_reserve = true;#endif -/* Reserve new minor number for the new device. */ mutex_lock (&binderfs_minors_mutex);if (++info->device_count <= info->mount_opts.max)@@ -186,8 +189,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 &©_to_user (userp, req,sizeof (*req))) { ret = -EFAULT ; goto err; }@@ -467,6 +469,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 +526,28 @@ 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,"," )) { +/* +* init_binderfs() has already checked that the length of +* device_name_entry->name is not greater than device_info.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,@@ -553,6 +579,18 @@ static struct file_system_type binder_fs_type = {int __init init_binderfs (void ) {int ret; +const char *name; +size_t len;drivers/android/binderfs.c static struct file_system_type binder_fs_type = { · line 593
Quoted 10 lines
drivers/android/binderfs.c +10
-0+ +/* Verify that the default binderfs device names are valid. */ + name = binder_devices_param; +for (len =strcspn (name,"," ); len >0 ; len =strcspn (name,"," )) { +if (len >BINDERFS_MAX_NAME ) +return -E2BIG ; + name += len; +if (*name ==',' ) + name++; + }This verification should be a separate patch, right?
But the real issue here is I have no idea _why_ you are wanting this patch. The changelog text says _what_ you are doing only, which isn't ok.
Please provide more information as to why this is needed, what problem it is solving, and break this up into a patch series and resend.
Thank you Greg and Christian, I will address all issues in v2 and resend.
Quoted 8 lines
Quoted 4 lines
thanks,
greg k-h
--
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].