kasan: slab: always reset the tag in get_freepointer_safe()
Subsystems (2)
PATCH 1/1 kasan: slab: always reset the tag in get_freepointer_safe()
With CONFIG_DEBUG_PAGEALLOC enabled, the kernel should also untag the object pointer, as done in get_freepointer().
Failing to do so reportedly leads to SLUB freelist corruptions that manifest as boot-time crashes.
Cc Andrew Morton <[email protected]>
Cc Marco Elver <[email protected]>
Cc Vincenzo Frascino <[email protected]>
Cc Andrey Ryabinin <[email protected]>
Cc Andrey Konovalov <[email protected]>
Cc Elliot Berman <[email protected]>
Signed-off-by Alexander Potapenko <[email protected]>
--- mm/slub.c | 1 + 1 file changed, 1 insertion(+)
mm/slub.c +1 -0
@@ -301,6 +301,7 @@ static inline void *get_freepointer_safe(struct kmem_cache *s, void *object)if (!debug_pagealloc_enabled_static ())return get_freepointer (s, object); + object =kasan_reset_tag (object); freepointer_addr = (unsigned long )object + s->offset;copy_from_kernel_nofault (&p, (void **)freepointer_addr,sizeof (p));return freelist_ptr (s, p, freepointer_addr);
Signature · 1 line
2.31.1.751.gd2f1c929bd-goog
Quoted 34 lines · Alexander Potapenko
With
CONFIG_DEBUG_PAGEALLOCenabled, the kernel should also untag the object pointer, as done inget_freepointer().Failing to do so reportedly leads to SLUB freelist corruptions that manifest as boot-time crashes.
Cc Andrew Morton <[email protected]>Cc Marco Elver <[email protected]>Cc Vincenzo Frascino <[email protected]>Cc Andrey Ryabinin <[email protected]>Cc Andrey Konovalov <[email protected]>Cc Elliot Berman <[email protected]>Signed-off-by Alexander Potapenko <[email protected]>--- mm/slub.c | 1 + 1 file changed, 1 insertion(+)mm/slub.c +1
-1@@ -301,6 +301,7 @@ static inline void *get_freepointer_safe(struct kmem_cache *s, void *object)if (!debug_pagealloc_enabled_static ())return get_freepointer (s, object); + object =kasan_reset_tag (object); freepointer_addr = (unsigned long )object + s->offset;copy_from_kernel_nofault (&p, (void **)freepointer_addr,sizeof (p));return freelist_ptr (s, p, freepointer_addr); --2.31.1.751.gd2f1c929bd-goog
Signature · 10 lines
Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Straße, 33 80636 München Geschäftsführer: Paul Manicle, Halimah DeLaine Prado Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg