lkml.org 
[lkml]   [2010]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 8/8] hwpoison: prevent /dev/kcore from accessing hwpoison pages
Silently fill buffer with zeros when encounter hwpoison pages
(accessing the hwpoison page content is deadly).

This patch does not cover X86_32 - which has a dumb kern_addr_valid().
It is unlikely anyone run a 32bit kernel will care about the hwpoison
feature - its usable memory is limited.

CC: Ingo Molnar <mingo@elte.hu>
CC: Andi Kleen <andi@firstfloor.org>
CC: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
arch/x86/mm/init_64.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
--- linux-mm.orig/arch/x86/mm/init_64.c 2010-01-13 21:23:04.000000000 +0800
+++ linux-mm/arch/x86/mm/init_64.c 2010-01-13 21:25:32.000000000 +0800
@@ -825,6 +825,7 @@ int __init reserve_bootmem_generic(unsig
int kern_addr_valid(unsigned long addr)
{
unsigned long above = ((long)addr) >> __VIRTUAL_MASK_SHIFT;
+ unsigned long pfn;
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
@@ -845,14 +846,23 @@ int kern_addr_valid(unsigned long addr)
if (pmd_none(*pmd))
return 0;

- if (pmd_large(*pmd))
- return pfn_valid(pmd_pfn(*pmd));
+ if (pmd_large(*pmd)) {
+ pfn = pmd_pfn(*pmd);
+ pfn += pte_index(addr);
+ goto check_pfn;
+ }

pte = pte_offset_kernel(pmd, addr);
if (pte_none(*pte))
return 0;

- return pfn_valid(pte_pfn(*pte));
+ pfn = pte_pfn(*pte);
+check_pfn:
+ if (!pfn_valid(pfn))
+ return 0;
+ if (PageHWPoison(pfn_to_page(pfn)))
+ return 0;
+ return 1;
}

/*



\
 
 \ /
  Last update: 2010-01-13 15:03    [from the cache]
©2003-2011 Jasper Spaans