cregit-Linux how code gets into the kernel

Release 4.14 mm/page_poison.c

Directory: mm
// SPDX-License-Identifier: GPL-2.0
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/highmem.h>
#include <linux/page_ext.h>
#include <linux/poison.h>
#include <linux/ratelimit.h>


static bool want_page_poisoning __read_mostly;


static int early_page_poison_param(char *buf) { if (!buf) return -EINVAL; return strtobool(buf, &want_page_poisoning); }

Contributors

PersonTokensPropCommitsCommitProp
Laura Abbott1657.14%125.00%
JoonSoo Kim932.14%250.00%
Minfei Huang310.71%125.00%
Total28100.00%4100.00%

early_param("page_poison", early_page_poison_param);
bool page_poisoning_enabled(void) { /* * Assumes that debug_pagealloc_enabled is set before * free_all_bootmem. * Page poisoning is debug page alloc for some arches. If * either of those options are enabled, enable poisoning. */ return (want_page_poisoning || (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC) && debug_pagealloc_enabled())); }

Contributors

PersonTokensPropCommitsCommitProp
Laura Abbott1354.17%120.00%
Vinayak Menon625.00%120.00%
JoonSoo Kim312.50%240.00%
Akinobu Mita28.33%120.00%
Total24100.00%5100.00%


static void poison_page(struct page *page) { void *addr = kmap_atomic(page); memset(addr, PAGE_POISON, PAGE_SIZE); kunmap_atomic(addr); }

Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita34100.00%2100.00%
Total34100.00%2100.00%


static void poison_pages(struct page *page, int n) { int i; for (i = 0; i < n; i++) poison_page(page + i); }

Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita37100.00%1100.00%
Total37100.00%1100.00%


static bool single_bit_flip(unsigned char a, unsigned char b) { unsigned char error = a ^ b; return error && !(error & (error - 1)); }

Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita36100.00%1100.00%
Total36100.00%1100.00%


static void check_poison_mem(unsigned char *mem, size_t bytes) { static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 10); unsigned char *start; unsigned char *end; if (IS_ENABLED(CONFIG_PAGE_POISONING_NO_SANITY)) return; start = memchr_inv(mem, PAGE_POISON, bytes); if (!start) return; for (end = mem + bytes - 1; end > start; end--) { if (*end != PAGE_POISON) break; } if (!__ratelimit(&ratelimit)) return; else if (start == end && single_bit_flip(*start, PAGE_POISON)) pr_err("pagealloc: single bit error\n"); else pr_err("pagealloc: memory corruption\n"); print_hex_dump(KERN_ERR, "", DUMP_PREFIX_ADDRESS, 16, 1, start, end - start + 1, 1); dump_stack(); }

Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita14093.33%375.00%
Laura Abbott106.67%125.00%
Total150100.00%4100.00%


static void unpoison_page(struct page *page) { void *addr; addr = kmap_atomic(page); /* * Page poisoning when enabled poisons each and every page * that is freed to buddy. Thus no extra check is done to * see if a page was posioned. */ check_poison_mem(addr, PAGE_SIZE); kunmap_atomic(addr); }

Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita3497.14%266.67%
Vinayak Menon12.86%133.33%
Total35100.00%3100.00%


static void unpoison_pages(struct page *page, int n) { int i; for (i = 0; i < n; i++) unpoison_page(page + i); }

Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita37100.00%1100.00%
Total37100.00%1100.00%


void kernel_poison_pages(struct page *page, int numpages, int enable) { if (!page_poisoning_enabled()) return; if (enable) unpoison_pages(page, numpages); else poison_pages(page, numpages); }

Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita3480.95%133.33%
JoonSoo Kim614.29%133.33%
Laura Abbott24.76%133.33%
Total42100.00%3100.00%

#ifndef CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC
void __kernel_map_pages(struct page *page, int numpages, int enable) { /* This function does nothing, all work is done via poison pages */ }

Contributors

PersonTokensPropCommitsCommitProp
Laura Abbott17100.00%1100.00%
Total17100.00%1100.00%

#endif

Overall Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita37478.08%440.00%
Laura Abbott7315.24%110.00%
JoonSoo Kim214.38%220.00%
Vinayak Menon71.46%110.00%
Minfei Huang30.63%110.00%
Greg Kroah-Hartman10.21%110.00%
Total479100.00%10100.00%
Directory: mm
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.