summaryrefslogtreecommitdiffstats
path: root/mm/page_ext.c
diff options
context:
space:
mode:
authorLaura Abbott <labbott@fedoraproject.org>2016-03-15 17:56:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-15 19:55:16 -0400
commit1414c7f4f7d72d138fff35f00151d15749b5beda (patch)
treee742e525f02ae4095e2a907cf8bc5fc29bfbc3dc /mm/page_ext.c
parent8823b1dbc05fab1a8bec275eeae4709257c2661d (diff)
mm/page_poisoning.c: allow for zero poisoning
By default, page poisoning uses a poison value (0xaa) on free. If this is changed to 0, the page is not only sanitized but zeroing on alloc with __GFP_ZERO can be skipped as well. The tradeoff is that detecting corruption from the poisoning is harder to detect. This feature also cannot be used with hibernation since pages are not guaranteed to be zeroed after hibernation. Credit to Grsecurity/PaX team for inspiring this work Signed-off-by: Laura Abbott <labbott@fedoraproject.org> Acked-by: Rafael J. Wysocki <rjw@rjwysocki.net> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Michal Hocko <mhocko@suse.com> Cc: Kees Cook <keescook@chromium.org> Cc: Mathias Krause <minipli@googlemail.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Jianyu Zhan <nasa4836@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_ext.c')
-rw-r--r--mm/page_ext.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/mm/page_ext.c b/mm/page_ext.c
index 292ca7b8debd..2d864e64f7fe 100644
--- a/mm/page_ext.c
+++ b/mm/page_ext.c
@@ -106,12 +106,15 @@ struct page_ext *lookup_page_ext(struct page *page)
106 struct page_ext *base; 106 struct page_ext *base;
107 107
108 base = NODE_DATA(page_to_nid(page))->node_page_ext; 108 base = NODE_DATA(page_to_nid(page))->node_page_ext;
109#ifdef CONFIG_DEBUG_VM 109#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAGE_POISONING)
110 /* 110 /*
111 * The sanity checks the page allocator does upon freeing a 111 * The sanity checks the page allocator does upon freeing a
112 * page can reach here before the page_ext arrays are 112 * page can reach here before the page_ext arrays are
113 * allocated when feeding a range of pages to the allocator 113 * allocated when feeding a range of pages to the allocator
114 * for the first time during bootup or memory hotplug. 114 * for the first time during bootup or memory hotplug.
115 *
116 * This check is also necessary for ensuring page poisoning
117 * works as expected when enabled
115 */ 118 */
116 if (unlikely(!base)) 119 if (unlikely(!base))
117 return NULL; 120 return NULL;
@@ -180,12 +183,15 @@ struct page_ext *lookup_page_ext(struct page *page)
180{ 183{
181 unsigned long pfn = page_to_pfn(page); 184 unsigned long pfn = page_to_pfn(page);
182 struct mem_section *section = __pfn_to_section(pfn); 185 struct mem_section *section = __pfn_to_section(pfn);
183#ifdef CONFIG_DEBUG_VM 186#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAGE_POISONING)
184 /* 187 /*
185 * The sanity checks the page allocator does upon freeing a 188 * The sanity checks the page allocator does upon freeing a
186 * page can reach here before the page_ext arrays are 189 * page can reach here before the page_ext arrays are
187 * allocated when feeding a range of pages to the allocator 190 * allocated when feeding a range of pages to the allocator
188 * for the first time during bootup or memory hotplug. 191 * for the first time during bootup or memory hotplug.
192 *
193 * This check is also necessary for ensuring page poisoning
194 * works as expected when enabled
189 */ 195 */
190 if (!section->page_ext) 196 if (!section->page_ext)
191 return NULL; 197 return NULL;