cregit-Linux how code gets into the kernel

Release 4.11 mm/page_poison.c

Directory: mm
#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 __page_poisoning_enabled __read_mostly;

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) { return __page_poisoning_enabled; }

Contributors

PersonTokensPropCommitsCommitProp
Laura Abbott990.00%150.00%
JoonSoo Kim110.00%150.00%
Total10100.00%2100.00%


static bool need_page_poisoning(void) { return want_page_poisoning; }

Contributors

PersonTokensPropCommitsCommitProp
Laura Abbott981.82%150.00%
JoonSoo Kim218.18%150.00%
Total11100.00%2100.00%


static void init_page_poisoning(void) { /* * page poisoning is debug page alloc for some arches. If either * of those options are enabled, enable poisoning */ if (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC)) { if (!want_page_poisoning && !debug_pagealloc_enabled()) return; } else { if (!want_page_poisoning) return; } __page_poisoning_enabled = true; }

Contributors

PersonTokensPropCommitsCommitProp
Laura Abbott2457.14%133.33%
JoonSoo Kim1842.86%266.67%
Total42100.00%3100.00%

struct page_ext_operations page_poisoning_ops = { .need = need_page_poisoning, .init = init_page_poisoning, };
static inline void set_page_poison(struct page *page) { struct page_ext *page_ext; page_ext = lookup_page_ext(page); if (unlikely(!page_ext)) return; __set_bit(PAGE_EXT_DEBUG_POISON, &page_ext->flags); }

Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita1944.19%133.33%
JoonSoo Kim1534.88%133.33%
Yang Shi920.93%133.33%
Total43100.00%3100.00%


static inline void clear_page_poison(struct page *page) { struct page_ext *page_ext; page_ext = lookup_page_ext(page); if (unlikely(!page_ext)) return; __clear_bit(PAGE_EXT_DEBUG_POISON, &page_ext->flags); }

Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita1944.19%133.33%
JoonSoo Kim1534.88%133.33%
Yang Shi920.93%133.33%
Total43100.00%3100.00%


bool page_is_poisoned(struct page *page) { struct page_ext *page_ext; page_ext = lookup_page_ext(page); if (unlikely(!page_ext)) return false; return test_bit(PAGE_EXT_DEBUG_POISON, &page_ext->flags); }

Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita1738.64%125.00%
JoonSoo Kim1534.09%125.00%
Laura Abbott920.45%125.00%
Yang Shi36.82%125.00%
Total44100.00%4100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita39100.00%2100.00%
Total39100.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; if (!page_is_poisoned(page)) return; addr = kmap_atomic(page); check_poison_mem(addr, PAGE_SIZE); clear_page_poison(page); kunmap_atomic(addr); }

Contributors

PersonTokensPropCommitsCommitProp
Akinobu Mita4797.92%266.67%
Laura Abbott12.08%133.33%
Total48100.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 Mita44564.87%440.00%
Laura Abbott11316.47%220.00%
JoonSoo Kim10415.16%220.00%
Yang Shi213.06%110.00%
Minfei Huang30.44%110.00%
Total686100.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.