diff options
| author | Carlos Llamas <cmllamas@google.com> | 2026-01-28 02:55:11 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-02-11 15:40:18 +0300 |
| commit | ee5e42e9a59ac02e82ff79fe3d67705f5d3787d1 (patch) | |
| tree | 80aa6c0da0c640a1ee0569b8b2d590bd9140ee9c /drivers/android | |
| parent | 9eec6f49d3fae873d9416a622356707b37d0be12 (diff) | |
| download | linux-ee5e42e9a59ac02e82ff79fe3d67705f5d3787d1.tar.xz | |
binderfs: fix ida_alloc_max() upper bound
commit ec4ddc90d201d09ef4e4bef8a2c6d9624525ad68 upstream.
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: 3ad20fe393b3 ("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>
Diffstat (limited to 'drivers/android')
| -rw-r--r-- | drivers/android/binderfs.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c index ad1fa7abc323..797faeac20f2 100644 --- a/drivers/android/binderfs.c +++ b/drivers/android/binderfs.c @@ -131,8 +131,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; @@ -422,8 +422,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) { |
