Skip to contentSkip to conversation

mm/vmalloc: fix unsafe dereference of potential null ptr in vmalloc_init()

PATCH In review Alexander Sapozhnikov 2 participants 2 messages Feb 17, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/vmalloc: fix unsafe dereference of potential null ptr in vmalloc_init()

Return value of a function 'kmem_cache_create' is dereferenced at vmalloc.c:2444 without checking for null, but it is usually checked for this function.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 mm/vmalloc.c | 2 ++
 1 file changed, 2 insertions(+)
mm/vmalloc.c +2 -0
index ca71de7c9d77..ed75dfd44b85 100644
@@ -2426,6 +2426,8 @@ void __init vmalloc_init(void)
 	 * Create the cache for vmap_area objects.
 	 */
 	vmap_area_cachep = KMEM_CACHE(vmap_area, SLAB_PANIC);
+	if (!vmap_area_cachep)
+		return;
 
 	for_each_possible_cpu(i) {
 		struct vmap_block_queue *vbq;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 5 lines · Alexander Sapozhnikov

Return value of a function 'kmem_cache_create' is dereferenced at vmalloc.c:2444 without checking for null, but it is usually checked for this function.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

I think that checker needs to learn about SLAB_PANIC..