Skip to content

Commit f289041

Browse files
tehcastertorvalds
authored andcommitted
mm, page_poison: remove CONFIG_PAGE_POISONING_ZERO
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/20201113104033.22907-6-vbabka@suse.cz Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: David Hildenbrand <david@redhat.com> Cc: Mike Rapoport <rppt@linux.ibm.com> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: Alexander Potapenko <glider@google.com> Cc: Kees Cook <keescook@chromium.org> Cc: Laura Abbott <labbott@kernel.org> Cc: Mateusz Nosek <mateusznosek0@gmail.com> Cc: Michal Hocko <mhocko@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 8f42475 commit f289041

4 files changed

Lines changed: 2 additions & 28 deletions

File tree

‎include/linux/poison.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@
2727
#define TIMER_ENTRY_STATIC ((void *) 0x300 + POISON_POINTER_DELTA)
2828

2929
/********** mm/page_poison.c **********/
30-
#ifdef CONFIG_PAGE_POISONING_ZERO
31-
#define PAGE_POISON 0x00
32-
#else
3330
#define PAGE_POISON 0xaa
34-
#endif
3531

3632
/********** mm/page_alloc.c ************/
3733

‎mm/Kconfig.debug‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,6 @@ config PAGE_POISONING
8080

8181
If unsure, say N
8282

83-
config PAGE_POISONING_ZERO
84-
bool "Use zero for poisoning instead of debugging value"
85-
depends on PAGE_POISONING
86-
help
87-
Instead of using the existing poison value, fill the pages with
88-
zeros. This makes it harder to detect when errors are occurring
89-
due to sanitization but the zeroing at free means that it is
90-
no longer necessary to write zeros when GFP_ZERO is used on
91-
allocation.
92-
93-
If unsure, say N
94-
9583
config DEBUG_PAGE_REF
9684
bool "Enable tracepoint to track down page reference manipulation"
9785
depends on DEBUG_KERNEL

‎mm/page_alloc.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,12 +2228,6 @@ static inline int check_new_page(struct page *page)
22282228
return 1;
22292229
}
22302230

2231-
static inline bool free_pages_prezeroed(void)
2232-
{
2233-
return (IS_ENABLED(CONFIG_PAGE_POISONING_ZERO) &&
2234-
page_poisoning_enabled_static()) || want_init_on_free();
2235-
}
2236-
22372231
#ifdef CONFIG_DEBUG_VM
22382232
/*
22392233
* With DEBUG_VM enabled, order-0 pages are checked for expected state when
@@ -2296,7 +2290,7 @@ inline void post_alloc_hook(struct page *page, unsigned int order,
22962290
kernel_unpoison_pages(page, 1 << order);
22972291
set_page_owner(page, order, gfp_flags);
22982292

2299-
if (!free_pages_prezeroed() && want_init_on_alloc(gfp_flags))
2293+
if (!want_init_on_free() && want_init_on_alloc(gfp_flags))
23002294
kernel_init_free_pages(page, 1 << order);
23012295
}
23022296

‎tools/include/linux/poison.h‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@
3535
*/
3636
#define TIMER_ENTRY_STATIC ((void *) 0x300 + POISON_POINTER_DELTA)
3737

38-
/********** mm/debug-pagealloc.c **********/
39-
#ifdef CONFIG_PAGE_POISONING_ZERO
40-
#define PAGE_POISON 0x00
41-
#else
38+
/********** mm/page_poison.c **********/
4239
#define PAGE_POISON 0xaa
43-
#endif
4440

4541
/********** mm/page_alloc.c ************/
4642

0 commit comments

Comments
 (0)