@@ -2359,7 +2359,7 @@ static void *alloc_slabmgmt(struct kmem_cache *cachep,
2359
2359
void * freelist ;
2360
2360
void * addr = page_address (page );
2361
2361
2362
- page -> s_mem = kasan_reset_tag ( addr ) + colour_off ;
2362
+ page -> s_mem = addr + colour_off ;
2363
2363
page -> active = 0 ;
2364
2364
2365
2365
if (OBJFREELIST_SLAB (cachep ))
@@ -2368,6 +2368,7 @@ static void *alloc_slabmgmt(struct kmem_cache *cachep,
2368
2368
/* Slab management obj is off-slab. */
2369
2369
freelist = kmem_cache_alloc_node (cachep -> freelist_cache ,
2370
2370
local_flags , nodeid );
2371
+ freelist = kasan_reset_tag (freelist );
2371
2372
if (!freelist )
2372
2373
return NULL ;
2373
2374
} else {
@@ -2681,6 +2682,13 @@ static struct page *cache_grow_begin(struct kmem_cache *cachep,
2681
2682
2682
2683
offset *= cachep -> colour_off ;
2683
2684
2685
+ /*
2686
+ * Call kasan_poison_slab() before calling alloc_slabmgmt(), so
2687
+ * page_address() in the latter returns a non-tagged pointer,
2688
+ * as it should be for slab pages.
2689
+ */
2690
+ kasan_poison_slab (page );
2691
+
2684
2692
/* Get slab management. */
2685
2693
freelist = alloc_slabmgmt (cachep , page , offset ,
2686
2694
local_flags & ~GFP_CONSTRAINT_MASK , page_node );
@@ -2689,7 +2697,6 @@ static struct page *cache_grow_begin(struct kmem_cache *cachep,
2689
2697
2690
2698
slab_map_pages (cachep , page , freelist );
2691
2699
2692
- kasan_poison_slab (page );
2693
2700
cache_init_objs (cachep , page );
2694
2701
2695
2702
if (gfpflags_allow_blocking (local_flags ))
0 commit comments