Skip to content

Commit

Permalink
mm, page_poison: remove CONFIG_PAGE_POISONING_ZERO
Browse files Browse the repository at this point in the history
CONFIG_PAGE_POISONING_ZERO uses the zero pattern instead of 0xAA.  It was
introduced by commit 1414c7f ("mm/page_poisoning.c: allow for zero
poisoning"), noting that using zeroes retains the benefit of sanitizing
content of freed pages, with the benefit of not having to zero them again
on alloc, and the downside of making some forms of corruption (stray
writes of NULLs) harder to detect than with the 0xAA pattern.  Together
with CONFIG_PAGE_POISONING_NO_SANITY it made possible to sanitize the
contents on free without checking it back on alloc.

These days we have the init_on_free() option to achieve sanitization with
zeroes and to save clearing on alloc (and without checking on alloc).
Arguably if someone does choose to check the poison for corruption on
alloc, the savings of not clearing the page are secondary, and it makes
sense to always use the 0xAA poison pattern.  Thus, remove the
CONFIG_PAGE_POISONING_ZERO option for being redundant.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Vlastimil Babka <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
Cc: Mike Rapoport <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Laura Abbott <[email protected]>
Cc: Mateusz Nosek <[email protected]>
Cc: Michal Hocko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
tehcaster authored and torvalds committed Dec 15, 2020
1 parent 8f42475 commit f289041
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 28 deletions.
4 changes: 0 additions & 4 deletions include/linux/poison.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
#define TIMER_ENTRY_STATIC ((void *) 0x300 + POISON_POINTER_DELTA)

/********** mm/page_poison.c **********/
#ifdef CONFIG_PAGE_POISONING_ZERO
#define PAGE_POISON 0x00
#else
#define PAGE_POISON 0xaa
#endif

/********** mm/page_alloc.c ************/

Expand Down
12 changes: 0 additions & 12 deletions mm/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,6 @@ config PAGE_POISONING

If unsure, say N

config PAGE_POISONING_ZERO
bool "Use zero for poisoning instead of debugging value"
depends on PAGE_POISONING
help
Instead of using the existing poison value, fill the pages with
zeros. This makes it harder to detect when errors are occurring
due to sanitization but the zeroing at free means that it is
no longer necessary to write zeros when GFP_ZERO is used on
allocation.

If unsure, say N

config DEBUG_PAGE_REF
bool "Enable tracepoint to track down page reference manipulation"
depends on DEBUG_KERNEL
Expand Down
8 changes: 1 addition & 7 deletions mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2228,12 +2228,6 @@ static inline int check_new_page(struct page *page)
return 1;
}

static inline bool free_pages_prezeroed(void)
{
return (IS_ENABLED(CONFIG_PAGE_POISONING_ZERO) &&
page_poisoning_enabled_static()) || want_init_on_free();
}

#ifdef CONFIG_DEBUG_VM
/*
* With DEBUG_VM enabled, order-0 pages are checked for expected state when
Expand Down Expand Up @@ -2296,7 +2290,7 @@ inline void post_alloc_hook(struct page *page, unsigned int order,
kernel_unpoison_pages(page, 1 << order);
set_page_owner(page, order, gfp_flags);

if (!free_pages_prezeroed() && want_init_on_alloc(gfp_flags))
if (!want_init_on_free() && want_init_on_alloc(gfp_flags))
kernel_init_free_pages(page, 1 << order);
}

Expand Down
6 changes: 1 addition & 5 deletions tools/include/linux/poison.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@
*/
#define TIMER_ENTRY_STATIC ((void *) 0x300 + POISON_POINTER_DELTA)

/********** mm/debug-pagealloc.c **********/
#ifdef CONFIG_PAGE_POISONING_ZERO
#define PAGE_POISON 0x00
#else
/********** mm/page_poison.c **********/
#define PAGE_POISON 0xaa
#endif

/********** mm/page_alloc.c ************/

Expand Down

0 comments on commit f289041

Please sign in to comment.