]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
idr: fix idr_alloc() returning an ID out of range
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 28 Nov 2025 16:18:32 +0000 (16:18 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 23 Dec 2025 19:23:11 +0000 (11:23 -0800)
commitc6e8e595a0798ad67da0f7bebaf69c31ef70dfff
treed4bf2129652036385fbe32715a6c2c358c8fe6ef
parent87726567d83df9c006d506a201c3c78c3cda76ed
idr: fix idr_alloc() returning an ID out of range

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.

Link: https://lkml.kernel.org/r/20251128161853.3200058-1-willy@infradead.org
Fixes: 6ce711f27500 ("idr: Make 1-based IDRs more efficient")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reported-by: Jan Sokolowski <jan.sokolowski@intel.com>
Reported-by: Koen Koning <koen.koning@intel.com>
Reported-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/6449
Reviewed-by: Christian König <christian.koenig@amd.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/idr.c
tools/testing/radix-tree/idr-test.c