kasan-page_alloc-deduplicate-should_skip_kasan_poison.patch removed from -mm tree
The patch titled
Subject: kasan, page_alloc: deduplicate should_skip_kasan_poison
has been removed from the -mm tree. Its filename was
kasan-page_alloc-deduplicate-should_skip_kasan_poison.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Andrey Konovalov <[email protected]>
Subject: kasan, page_alloc: deduplicate should_skip_kasan_poison
Patch series "kasan, vmalloc, arm64: add vmalloc tagging support for SW/HW_TAGS", v6.
This patchset adds vmalloc tagging support for SW_TAGS and HW_TAGS KASAN modes.
About half of patches are cleanups I went for along the way. None of them seem to be important enough to go through stable, so I decided not to split them out into separate patches/series.
The patchset is partially based on an early version of the HW_TAGS patchset by Vincenzo that had vmalloc support. Thus, I added a Co-developed-by tag into a few patches.
SW_TAGS vmalloc tagging support is straightforward. It reuses all of the generic KASAN machinery, but uses shadow memory to store tags instead of magic values. Naturally, vmalloc tagging requires adding a few kasan_reset_tag() annotations to the vmalloc code.
HW_TAGS vmalloc tagging support stands out. HW_TAGS KASAN is based on Arm MTE, which can only assigns tags to physical memory. As a result, HW_TAGS KASAN only tags vmalloc() allocations, which are backed by page_alloc memory. It ignores vmap() and others.
This patch (of 39):
Currently, should_skip_kasan_poison() has two definitions: one for when CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled, one for when it's not.
Instead of duplicating the checks, add a deferred_pages_enabled() helper and use it in a single should_skip_kasan_poison() definition.
Also move should_skip_kasan_poison() closer to its caller and clarify all conditions in the comment.
---
mm/page_alloc.c | 55 +++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 22 deletions(-)
mm/page_alloc.c renamed from mm/page_alloc.c~kasan-page_alloc-deduplicate-should_skip_kasan_poison +33 -22
@@ -378,25 +378,9 @@ int page_group_by_mobility_disabled __re*/ static DEFINE_STATIC_KEY_TRUE (deferred_pages); -/* -* Calling kasan_poison_pages() only after deferred memory initialization -* has completed. Poisoning pages during deferred memory init will greatly -* lengthen the process and cause problem in large memory systems as the -* deferred pages initialization is done with interrupt disabled. -* -* Assuming that there will be no reference to those newly initialized -* pages before they are ever allocated, this should have no effect on -* KASAN memory tracking as the poison will be properly inserted at page -* allocation time. The only corner case is when pages are allocated by -* on-demand allocation and then freed again before the deferred pages -* initialization is done, but this is not likely to happen. -*/ -static inline bool should_skip_kasan_poison (struct page *page,fpi_t fpi_flags) +static inline bool deferred_pages_enabled (void ) { -return static_branch_unlikely (&deferred_pages) || - (!IS_ENABLED (CONFIG_KASAN_GENERIC ) && - (fpi_flags &FPI_SKIP_KASAN_POISON )) || -PageSkipKASanPoison (page); +return static_branch_unlikely (&deferred_pages); }/* Returns true if the struct page for the pfn is uninitialised */
@@ -447,11 +431,9 @@ defer_init(int nid, unsigned long pfn, u return false; }#else -static inline bool should_skip_kasan_poison (struct page *page,fpi_t fpi_flags) +static inline bool deferred_pages_enabled (void ) { -return (!IS_ENABLED (CONFIG_KASAN_GENERIC ) && - (fpi_flags &FPI_SKIP_KASAN_POISON )) || -PageSkipKASanPoison (page); +return false; }static inline bool early_page_uninitialised (unsigned long pfn)
@@ -1267,6 +1249,35 @@ out:return ret; } +/* +* Skip KASAN memory poisoning when either: +* +* 1. Deferred memory initialization has not yet completed, +* see the explanation below. +* 2. Skipping poisoning is requested via FPI_SKIP_KASAN_POISON, +* see the comment next to it. +* 3. Skipping poisoning is requested via __GFP_SKIP_KASAN_POISON, +* see the comment next to it. +* +* Poisoning pages during deferred memory init will greatly lengthen the +* process and cause problem in large memory systems as the deferred pages +* initialization is done with interrupt disabled. +* +* Assuming that there will be no reference to those newly initialized +* pages before they are ever allocated, this should have no effect on +* KASAN memory tracking as the poison will be properly inserted at page +* allocation time. The only corner case is when pages are allocated by +* on-demand allocation and then freed again before the deferred pages +* initialization is done, but this is not likely to happen. +*/ +static inline bool should_skip_kasan_poison (struct page *page,fpi_t fpi_flags) +{ +return deferred_pages_enabled () || + (!IS_ENABLED (CONFIG_KASAN_GENERIC ) && + (fpi_flags &FPI_SKIP_KASAN_POISON )) || +PageSkipKASanPoison (page); +} +static void kernel_init_free_pages (struct page *page,int numpages,bool zero_tags) {int i;
_
Patches currently in -mm which might be from [email protected] are
stacktrace-add-interface-based-on-shadow-call-stack.patch arm64-scs-save-scs_sp-values-per-cpu-when-switching-stacks.patch arm64-implement-stack_trace_save_shadow.patch kasan-use-stack_trace_save_shadow.patch