aboutsummaryrefslogtreecommitdiff
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2017-03-14 15:32:03 -0400
committerMister Oyster <oysterized@gmail.com>2017-10-14 16:01:53 +0200
commit51853318e8e9e33bef8c03e8964d91a18f1acb1c (patch)
treee81cae81283b06f471e963c0976bfd684b376dac /mm/page_alloc.c
parentb4fd8bc5f2633dde2a15804ad746a630151eb1b2 (diff)
gather extra early boot entropy like PaX
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c11
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);