Skip to content

Commit ec4ddc9

Browse files
Carlos Llamasgregkh
authored andcommitted
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'. Cc: stable@vger.kernel.org Fixes: 3ad20fe ("binder: implement binderfs") Signed-off-by: Carlos Llamas <cmllamas@google.com> Link: https://patch.msgid.link/20260127235545.2307876-2-cmllamas@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d6ba734 commit ec4ddc9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/android/binderfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
132132
mutex_lock(&binderfs_minors_mutex);
133133
if (++info->device_count <= info->mount_opts.max)
134134
minor = ida_alloc_max(&binderfs_minors,
135-
use_reserve ? BINDERFS_MAX_MINOR :
136-
BINDERFS_MAX_MINOR_CAPPED,
135+
use_reserve ? BINDERFS_MAX_MINOR - 1 :
136+
BINDERFS_MAX_MINOR_CAPPED - 1,
137137
GFP_KERNEL);
138138
else
139139
minor = -ENOSPC;
@@ -408,8 +408,8 @@ static int binderfs_binder_ctl_create(struct super_block *sb)
408408
/* Reserve a new minor number for the new device. */
409409
mutex_lock(&binderfs_minors_mutex);
410410
minor = ida_alloc_max(&binderfs_minors,
411-
use_reserve ? BINDERFS_MAX_MINOR :
412-
BINDERFS_MAX_MINOR_CAPPED,
411+
use_reserve ? BINDERFS_MAX_MINOR - 1 :
412+
BINDERFS_MAX_MINOR_CAPPED - 1,
413413
GFP_KERNEL);
414414
mutex_unlock(&binderfs_minors_mutex);
415415
if (minor < 0) {

0 commit comments

Comments
 (0)