These functions are page_alloc lifecycle hooks, called exclusively from __free_pages_prepare() and post_alloc_hook(), and are more than raw page-poisoning primitives, as their name would suggest by analogy with kasan_[un]poison(). Therefore, rename them to kasan_page_{alloc,free}(), matching kasan_slab_{alloc,free}() and page_table_check_{alloc,free}(), which clarifies their allocator-hook semantics and frees up their previous names for upcoming page-granularity tagging helpers. Signed-off-by: Pierre-Clément Tosi --- include/linux/kasan.h | 24 ++++++++++++------------ mm/kasan/common.c | 8 ++++---- mm/page_alloc.c | 6 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/linux/kasan.h b/include/linux/kasan.h index c1ac7971601e..d1a7bbb8c217 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -110,20 +110,20 @@ static __always_inline void kasan_unpoison_range(const void *addr, size_t size) __kasan_unpoison_range(addr, size); } -void __kasan_poison_pages(struct page *page, unsigned int order, bool init); -static __always_inline void kasan_poison_pages(struct page *page, - unsigned int order, bool init) +void __kasan_page_free(struct page *page, unsigned int order, bool init); +static __always_inline void kasan_page_free(struct page *page, + unsigned int order, bool init) { if (kasan_enabled()) - __kasan_poison_pages(page, order, init); + __kasan_page_free(page, order, init); } -bool __kasan_unpoison_pages(struct page *page, unsigned int order, bool init); -static __always_inline bool kasan_unpoison_pages(struct page *page, - unsigned int order, bool init) +bool __kasan_page_alloc(struct page *page, unsigned int order, bool init); +static __always_inline bool kasan_page_alloc(struct page *page, + unsigned int order, bool init) { if (kasan_enabled()) - return __kasan_unpoison_pages(page, order, init); + return __kasan_page_alloc(page, order, init); return false; } @@ -410,10 +410,10 @@ static __always_inline bool kasan_check_byte(const void *addr) #else /* CONFIG_KASAN */ static inline void kasan_unpoison_range(const void *address, size_t size) {} -static inline void kasan_poison_pages(struct page *page, unsigned int order, - bool init) {} -static inline bool kasan_unpoison_pages(struct page *page, unsigned int order, - bool init) +static inline void kasan_page_free(struct page *page, unsigned int order, + bool init) {} +static inline bool kasan_page_alloc(struct page *page, unsigned int order, + bool init) { return false; } diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 0c198ad895b4..b9f58320eff1 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -150,7 +150,7 @@ static void unpoison_page_alloc(struct page *page, unsigned int order, page_kasan_tag_set(page + i, tag); } -bool __kasan_unpoison_pages(struct page *page, unsigned int order, bool init) +bool __kasan_page_alloc(struct page *page, unsigned int order, bool init) { if (unlikely(PageHighMem(page))) return false; @@ -163,7 +163,7 @@ bool __kasan_unpoison_pages(struct page *page, unsigned int order, bool init) return true; } -void __kasan_poison_pages(struct page *page, unsigned int order, bool init) +void __kasan_page_free(struct page *page, unsigned int order, bool init) { if (likely(!PageHighMem(page))) kasan_poison(page_address(page), PAGE_SIZE << order, @@ -343,7 +343,7 @@ void __kasan_kfree_large(void *ptr, unsigned long ip) { check_page_allocation(ptr, ip); - /* The object will be poisoned by kasan_poison_pages(). */ + /* The object will be poisoned by kasan_page_free(). */ } static inline void unpoison_slab_object(struct kmem_cache *cache, void *object, @@ -469,7 +469,7 @@ void * __must_check __kasan_kmalloc_large(const void *ptr, size_t size, if (unlikely(ptr == NULL)) return NULL; - /* The object has already been unpoisoned by kasan_unpoison_pages(). */ + /* The object has already been unpoisoned by kasan_page_alloc(). */ poison_kmalloc_large_redzone(ptr, size, flags); /* Keep the tag that was set by alloc_pages(). */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index aa1ed599c7c6..24a4d8f10de9 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1192,7 +1192,7 @@ static int free_tail_page_prepare(struct page *head_page, struct page *page) * 2. The allocation was not unpoisoned due to __GFP_SKIP_KASAN, with the * exception of pages unpoisoned by kasan_unpoison_vmalloc. * 3. The allocation was excluded from being checked due to sampling, - * see the call to kasan_unpoison_pages. + * see the call to kasan_page_alloc. * * Poisoning pages during deferred memory init will greatly lengthen the * process and cause problem in large memory systems as the deferred pages @@ -1433,7 +1433,7 @@ static __always_inline bool __free_pages_prepare(struct page *page, * page becomes unavailable via debug_pagealloc or arch_free_page. */ if (!skip_kasan_poison) { - kasan_poison_pages(page, order, init); + kasan_page_free(page, order, init); /* Memory is already initialized if KASAN did it internally. */ if (kasan_has_integrated_init()) @@ -1853,7 +1853,7 @@ inline void post_alloc_hook(struct page *page, unsigned int order, init = tag_clear_highpages(page, 1 << order, /* clear_pages= */init); if (!should_skip_kasan_unpoison(gfp_flags) && - kasan_unpoison_pages(page, order, init)) { + kasan_page_alloc(page, order, init)) { /* Take note that memory was initialized by KASAN. */ if (kasan_has_integrated_init()) init = false; -- 2.56.1.839.g22a8290db9-goog