idr-fix-idr_alloc-returning-an-id-out-of-range.patch removed from -mm tree
The quilt patch titled
Subject: idr: fix idr_alloc() returning an ID out of range
has been removed from the -mm tree. Its filename was
idr-fix-idr_alloc-returning-an-id-out-of-range.patch
This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: "Matthew Wilcox (Oracle)" <[email protected]>
Subject: idr: fix idr_alloc() returning an ID out of range
Date: Fri, 28 Nov 2025 16:18:32 +0000
If you use an IDR with a non-zero base, and specify a range that lies entirely below the base, 'max - base' becomes very large and idr_get_free() can return an ID that lies outside of the requested range.
---
lib/idr.c | 2 ++ tools/testing/radix-tree/idr-test.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+)
lib/idr.c renamed from lib/idr.c~idr-fix-idr_alloc-returning-an-id-out-of-range +2 -0
@@ -40,6 +40,8 @@ int idr_alloc_u32(struct idr *idr, voidif (WARN_ON_ONCE (!(idr->idr_rt.xa_flags &ROOT_IS_IDR ))) idr->idr_rt.xa_flags |=IDR_RT_MARKER ; +if (max < base) +return -ENOSPC ; id = (id < base) ?0 : id - base;radix_tree_iter_init (&iter, id);
tools/testing/radix-tree/idr-test.c renamed from tools/testing/radix-tree/idr-test.c~idr-fix-idr_alloc-returning-an-id-out-of-range +21 -0
@@ -57,6 +57,26 @@ void idr_alloc_test(void)idr_destroy (&idr); } +void idr_alloc2_test (void ) +{ +int id; +struct idr idr =IDR_INIT_BASE (idr,1 ); + + id =idr_alloc (&idr, idr_alloc2_test,0 ,1 ,GFP_KERNEL ); +assert (id == -ENOSPC ); + + id =idr_alloc (&idr, idr_alloc2_test,1 ,2 ,GFP_KERNEL ); +assert (id ==1 ); + + id =idr_alloc (&idr, idr_alloc2_test,0 ,1 ,GFP_KERNEL ); +assert (id == -ENOSPC ); + + id =idr_alloc (&idr, idr_alloc2_test,0 ,2 ,GFP_KERNEL ); +assert (id == -ENOSPC ); + +idr_destroy (&idr); +} +void idr_replace_test (void ) {DEFINE_IDR (idr);
@@ -409,6 +429,7 @@ void idr_checks(void)idr_replace_test ();idr_alloc_test (); +idr_alloc2_test ();idr_null_test ();idr_nowait_test ();idr_get_next_test (0 );
_
Patches currently in -mm which might be from [email protected] are