diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2017-03-14 15:32:03 -0400 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-10-14 16:01:53 +0200 |
| commit | 51853318e8e9e33bef8c03e8964d91a18f1acb1c (patch) | |
| tree | e81cae81283b06f471e963c0976bfd684b376dac /mm | |
| parent | b4fd8bc5f2633dde2a15804ad746a630151eb1b2 (diff) | |
gather extra early boot entropy like PaX
Diffstat (limited to 'mm')
| -rw-r--r-- | mm/page_alloc.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2678bb9ab..5612a5f20 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -61,6 +61,7 @@ #include <linux/page-debug-flags.h> #include <linux/hugetlb.h> #include <linux/sched/rt.h> +#include <linux/random.h> #include <asm/tlbflush.h> #include <asm/div64.h> @@ -929,6 +930,16 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order) set_page_count(p, 0); } + if (!PageHighMem(page) && page_to_pfn(page) < 0x100000) { + unsigned long hash = 0; + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash; + const unsigned long *data = lowmem_page_address(page); + + for (index = 0; index < end; index++) + hash ^= hash + data[index]; + add_device_randomness((const void *)&hash, sizeof(hash)); + } + page_zone(page)->managed_pages += 1 << order; set_page_refcounted(page); __free_pages(page, order); |
