rust_binderfs: fix ida_alloc_max() upper bound
Subsystems (2)
Carlos Llamas
maintainerPATCH 1/2 rust_binderfs: fix ida_alloc_max() upper bound
The 'max' argument of ida_alloc_max() takes the maximum valid ID and not the "count". Using an ID of BINDERFS_MAX_MINOR (1 << 20) for dev->minor would exceed the limits of minor numbers (20-bits). Fix this off-by-one error by subtracting 1 from the 'max'.
--- drivers/android/binder/rust_binderfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/android/binder/rust_binderfs.c +4 -4
@@ -132,8 +132,8 @@ static int binderfs_binder_device_create(struct inode *ref_inode,mutex_lock (&binderfs_minors_mutex);if (++info->device_count <= info->mount_opts.max) minor =ida_alloc_max (&binderfs_minors, - use_reserve ?BINDERFS_MAX_MINOR : -BINDERFS_MAX_MINOR_CAPPED , + use_reserve ?BINDERFS_MAX_MINOR -1 : +BINDERFS_MAX_MINOR_CAPPED -1 ,GFP_KERNEL );else minor = -ENOSPC ;
@@ -405,8 +405,8 @@ static int binderfs_binder_ctl_create(struct super_block *sb)/* Reserve a new minor number for the new device. */ mutex_lock (&binderfs_minors_mutex); minor =ida_alloc_max (&binderfs_minors, - use_reserve ?BINDERFS_MAX_MINOR : -BINDERFS_MAX_MINOR_CAPPED , + use_reserve ?BINDERFS_MAX_MINOR -1 : +BINDERFS_MAX_MINOR_CAPPED -1 ,GFP_KERNEL );mutex_unlock (&binderfs_minors_mutex);if (minor <0 ) {
Signature · 1 line
2.52.0.457.g6b5491de43-goog
Carlos Llamas
maintainerPATCH 2/2 binderfs: fix ida_alloc_max() upper bound
The 'max' argument of ida_alloc_max() takes the maximum valid ID and not the "count". Using an ID of BINDERFS_MAX_MINOR (1 << 20) for dev->minor would exceed the limits of minor numbers (20-bits). Fix this off-by-one error by subtracting 1 from the 'max'.
--- drivers/android/binderfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/android/binderfs.c +4 -4
@@ -132,8 +132,8 @@ static int binderfs_binder_device_create(struct inode *ref_inode,mutex_lock (&binderfs_minors_mutex);if (++info->device_count <= info->mount_opts.max) minor =ida_alloc_max (&binderfs_minors, - use_reserve ?BINDERFS_MAX_MINOR : -BINDERFS_MAX_MINOR_CAPPED , + use_reserve ?BINDERFS_MAX_MINOR -1 : +BINDERFS_MAX_MINOR_CAPPED -1 ,GFP_KERNEL );else minor = -ENOSPC ;
@@ -408,8 +408,8 @@ static int binderfs_binder_ctl_create(struct super_block *sb)/* Reserve a new minor number for the new device. */ mutex_lock (&binderfs_minors_mutex); minor =ida_alloc_max (&binderfs_minors, - use_reserve ?BINDERFS_MAX_MINOR : -BINDERFS_MAX_MINOR_CAPPED , + use_reserve ?BINDERFS_MAX_MINOR -1 : +BINDERFS_MAX_MINOR_CAPPED -1 ,GFP_KERNEL );mutex_unlock (&binderfs_minors_mutex);if (minor <0 ) {
Signature · 1 line
2.52.0.457.g6b5491de43-goog
Quoted 10 lines · Carlos Llamas
The 'max' argument of
ida_alloc_max()takes the maximum valid ID and not the "count". Using an ID ofBINDERFS_MAX_MINOR(1 << 20) fordev->minorwould exceed the limits of minor numbers (20-bits). Fix this off-by-one error by subtracting 1 from the 'max'.Fixes eafedbc7c050 ("rust_binder: add Rust Binder driver")Reported-by kernel test robot <[email protected]>Signed-off-by Carlos Llamas <[email protected]>
For both patches: