diff options
Diffstat (limited to 'mm/slub.c')
-rw-r--r-- | mm/slub.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/mm/slub.c b/mm/slub.c index 191bbc3378d3..716b794f3679 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -333,11 +333,13 @@ static inline int oo_objects(struct kmem_cache_order_objects x) */ static __always_inline void slab_lock(struct page *page) { + VM_BUG_ON_PAGE(PageTail(page), page); bit_spin_lock(PG_locked, &page->flags); } static __always_inline void slab_unlock(struct page *page) { + VM_BUG_ON_PAGE(PageTail(page), page); __bit_spin_unlock(PG_locked, &page->flags); } @@ -685,11 +687,21 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) dump_stack(); } +#ifdef CONFIG_SLUB_DEBUG_PANIC_ON +static void slab_panic(const char *cause) +{ + panic("%s\n", cause); +} +#else +static inline void slab_panic(const char *cause) {} +#endif + void object_err(struct kmem_cache *s, struct page *page, u8 *object, char *reason) { slab_bug(s, "%s", reason); print_trailer(s, page, object); + slab_panic(reason); } static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page, @@ -704,6 +716,7 @@ static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page, slab_bug(s, "%s", buf); print_page_info(page); dump_stack(); + slab_panic("slab error"); } static void init_object(struct kmem_cache *s, void *object, u8 val) @@ -725,6 +738,7 @@ static void init_object(struct kmem_cache *s, void *object, u8 val) static void restore_bytes(struct kmem_cache *s, char *message, u8 data, void *from, void *to) { + slab_panic("object poison overwritten"); slab_fix(s, "Restoring 0x%p-0x%p=0x%x\n", from, to - 1, data); memset(from, data, to - from); } @@ -1577,6 +1591,7 @@ static void __free_slab(struct kmem_cache *s, struct page *page) page_mapcount_reset(page); if (current->reclaim_state) current->reclaim_state->reclaimed_slab += pages; + kasan_alloc_pages(page, order); __free_kmem_pages(page, order); } @@ -3743,6 +3758,7 @@ void kfree(const void *x) if (unlikely(!PageSlab(page))) { BUG_ON(!PageCompound(page)); kfree_hook(x); + kasan_alloc_pages(page, compound_order(page)); __free_kmem_pages(page, compound_order(page)); return; } |