Release 4.11 mm/page_poison.c
#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
Person | Tokens | Prop | Commits | CommitProp |
Laura Abbott | 16 | 57.14% | 1 | 25.00% |
JoonSoo Kim | 9 | 32.14% | 2 | 50.00% |
Minfei Huang | 3 | 10.71% | 1 | 25.00% |
Total | 28 | 100.00% | 4 | 100.00% |
early_param("page_poison", early_page_poison_param);
bool page_poisoning_enabled(void)
{
return __page_poisoning_enabled;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Laura Abbott | 9 | 90.00% | 1 | 50.00% |
JoonSoo Kim | 1 | 10.00% | 1 | 50.00% |
Total | 10 | 100.00% | 2 | 100.00% |
static bool need_page_poisoning(void)
{
return want_page_poisoning;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Laura Abbott | 9 | 81.82% | 1 | 50.00% |
JoonSoo Kim | 2 | 18.18% | 1 | 50.00% |
Total | 11 | 100.00% | 2 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Laura Abbott | 24 | 57.14% | 1 | 33.33% |
JoonSoo Kim | 18 | 42.86% | 2 | 66.67% |
Total | 42 | 100.00% | 3 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Akinobu Mita | 19 | 44.19% | 1 | 33.33% |
JoonSoo Kim | 15 | 34.88% | 1 | 33.33% |
Yang Shi | 9 | 20.93% | 1 | 33.33% |
Total | 43 | 100.00% | 3 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Akinobu Mita | 19 | 44.19% | 1 | 33.33% |
JoonSoo Kim | 15 | 34.88% | 1 | 33.33% |
Yang Shi | 9 | 20.93% | 1 | 33.33% |
Total | 43 | 100.00% | 3 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Akinobu Mita | 17 | 38.64% | 1 | 25.00% |
JoonSoo Kim | 15 | 34.09% | 1 | 25.00% |
Laura Abbott | 9 | 20.45% | 1 | 25.00% |
Yang Shi | 3 | 6.82% | 1 | 25.00% |
Total | 44 | 100.00% | 4 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Akinobu Mita | 39 | 100.00% | 2 | 100.00% |
Total | 39 | 100.00% | 2 | 100.00% |
static void poison_pages(struct page *page, int n)
{
int i;
for (i = 0; i < n; i++)
poison_page(page + i);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Akinobu Mita | 37 | 100.00% | 1 | 100.00% |
Total | 37 | 100.00% | 1 | 100.00% |
static bool single_bit_flip(unsigned char a, unsigned char b)
{
unsigned char error = a ^ b;
return error && !(error & (error - 1));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Akinobu Mita | 36 | 100.00% | 1 | 100.00% |
Total | 36 | 100.00% | 1 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Akinobu Mita | 140 | 93.33% | 3 | 75.00% |
Laura Abbott | 10 | 6.67% | 1 | 25.00% |
Total | 150 | 100.00% | 4 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Akinobu Mita | 47 | 97.92% | 2 | 66.67% |
Laura Abbott | 1 | 2.08% | 1 | 33.33% |
Total | 48 | 100.00% | 3 | 100.00% |
static void unpoison_pages(struct page *page, int n)
{
int i;
for (i = 0; i < n; i++)
unpoison_page(page + i);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Akinobu Mita | 37 | 100.00% | 1 | 100.00% |
Total | 37 | 100.00% | 1 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Akinobu Mita | 34 | 80.95% | 1 | 33.33% |
JoonSoo Kim | 6 | 14.29% | 1 | 33.33% |
Laura Abbott | 2 | 4.76% | 1 | 33.33% |
Total | 42 | 100.00% | 3 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Laura Abbott | 17 | 100.00% | 1 | 100.00% |
Total | 17 | 100.00% | 1 | 100.00% |
#endif
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Akinobu Mita | 445 | 64.87% | 4 | 40.00% |
Laura Abbott | 113 | 16.47% | 2 | 20.00% |
JoonSoo Kim | 104 | 15.16% | 2 | 20.00% |
Yang Shi | 21 | 3.06% | 1 | 10.00% |
Minfei Huang | 3 | 0.44% | 1 | 10.00% |
Total | 686 | 100.00% | 10 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.