The patch titled Subject: kasan, slab: make freelist stored without tags has been added to the -mm tree. Its filename is kasan-slab-make-freelist-stored-without-tags.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/kasan-slab-make-freelist-stored-without-tags.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/kasan-slab-make-freelist-stored-without-tags.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Subject: kasan, slab: make freelist stored without tags Similarly to 680c37ae ("kasan, slub: move kasan_poison_slab hook before page_address"), move kasan_poison_slab() before alloc_slabmgmt(), which calls page_address(), to make page_address() return value to be non-tagged. This, combined with calling kasan_reset_tag() for off-slab slab management object, leads to freelist being stored non-tagged. Link: http://lkml.kernel.org/r/dfb53b44a4d00de3879a05a9f04c1f55e584f7a1.1550602886.git.andreyknvl@xxxxxxxxxx Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Tested-by: Qian Cai <cai@xxxxxx> Cc: Alexander Potapenko <glider@xxxxxxxxxx> Cc: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx> Cc: Evgeniy Stepanov <eugenis@xxxxxxxxxx> Cc: Kostya Serebryany <kcc@xxxxxxxxxx> Cc: Vincenzo Frascino <vincenzo.frascino@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/mm/slab.c~kasan-slab-make-freelist-stored-without-tags +++ a/mm/slab.c @@ -2359,7 +2359,7 @@ static void *alloc_slabmgmt(struct kmem_ void *freelist; void *addr = page_address(page); - page->s_mem = kasan_reset_tag(addr) + colour_off; + page->s_mem = addr + colour_off; page->active = 0; if (OBJFREELIST_SLAB(cachep)) @@ -2368,6 +2368,7 @@ static void *alloc_slabmgmt(struct kmem_ /* Slab management obj is off-slab. */ freelist = kmem_cache_alloc_node(cachep->freelist_cache, local_flags, nodeid); + freelist = kasan_reset_tag(freelist); if (!freelist) return NULL; } else { @@ -2681,6 +2682,13 @@ static struct page *cache_grow_begin(str offset *= cachep->colour_off; + /* + * Call kasan_poison_slab() before calling alloc_slabmgmt(), so + * page_address() in the latter returns a non-tagged pointer, + * as it should be for slab pages. + */ + kasan_poison_slab(page); + /* Get slab management. */ freelist = alloc_slabmgmt(cachep, page, offset, local_flags & ~GFP_CONSTRAINT_MASK, page_node); @@ -2689,7 +2697,6 @@ static struct page *cache_grow_begin(str slab_map_pages(cachep, page, freelist); - kasan_poison_slab(page); cache_init_objs(cachep, page); if (gfpflags_allow_blocking(local_flags)) _ Patches currently in -mm which might be from andreyknvl@xxxxxxxxxx are kasan-fix-assigning-tags-twice.patch kasan-kmemleak-pass-tagged-pointers-to-kmemleak.patch kmemleak-account-for-tagged-pointers-when-calculating-pointer-range-v2.patch kasan-slub-move-kasan_poison_slab-hook-before-page_address.patch kasan-slub-move-kasan_poison_slab-hook-before-page_address-v2.patch kasan-slub-fix-conflicts-with-config_slab_freelist_hardened.patch kasan-slub-fix-more-conflicts-with-config_slab_freelist_hardened.patch kasan-fix-random-seed-generation-for-tag-based-mode.patch kasan-prevent-tracing-of-tagsc.patch kasan-slab-fix-conflicts-with-config_hardened_usercopy.patch kasan-slab-make-freelist-stored-without-tags.patch kasan-slab-remove-redundant-kasan_slab_alloc-hooks.patch