Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm, kasan: use KASAN_TAG_KERNEL instead of 0xff

Use the KASAN_TAG_KERNEL marco instead of open-coding 0xff in the mm code.
This macro is provided by include/linux/kasan-tags.h, which does not
include any other headers, so it's safe to include it into mm.h without
causing circular include dependencies.

Link: https://lkml.kernel.org/r/71db9087b0aebb6c4dccbc609cc0cd50621533c7.1703188911.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Marco Elver <elver@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Andrey Konovalov and committed by
Andrew Morton
5cb6674b 27232ba9

+4 -3
+1
include/linux/kasan.h
··· 4 4 5 5 #include <linux/bug.h> 6 6 #include <linux/kasan-enabled.h> 7 + #include <linux/kasan-tags.h> 7 8 #include <linux/kernel.h> 8 9 #include <linux/static_key.h> 9 10 #include <linux/types.h>
+2 -2
include/linux/mm.h
··· 1815 1815 1816 1816 static inline u8 page_kasan_tag(const struct page *page) 1817 1817 { 1818 - u8 tag = 0xff; 1818 + u8 tag = KASAN_TAG_KERNEL; 1819 1819 1820 1820 if (kasan_enabled()) { 1821 1821 tag = (page->flags >> KASAN_TAG_PGSHIFT) & KASAN_TAG_MASK; ··· 1844 1844 static inline void page_kasan_tag_reset(struct page *page) 1845 1845 { 1846 1846 if (kasan_enabled()) 1847 - page_kasan_tag_set(page, 0xff); 1847 + page_kasan_tag_set(page, KASAN_TAG_KERNEL); 1848 1848 } 1849 1849 1850 1850 #else /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */
+1 -1
mm/page_alloc.c
··· 1059 1059 if (IS_ENABLED(CONFIG_KASAN_GENERIC)) 1060 1060 return deferred_pages_enabled(); 1061 1061 1062 - return page_kasan_tag(page) == 0xff; 1062 + return page_kasan_tag(page) == KASAN_TAG_KERNEL; 1063 1063 } 1064 1064 1065 1065 static void kernel_init_pages(struct page *page, int numpages)