Commit 4c3c4b45 authored by Andi Kleen's avatar Andi Kleen Committed by Ingo Molnar

x86: clean up pte_exec

- Rename it to pte_exec() from pte_exec_kernel(). There is nothing
kernel specific in there.
- Move it into the common file because _PAGE_NX is 0 on !PAE and then
pte_exec() will be always evaluate to true.
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarHarvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent e66a9512
...@@ -615,7 +615,7 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) ...@@ -615,7 +615,7 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
if (error_code & PF_INSTR) { if (error_code & PF_INSTR) {
pte_t *pte = lookup_address(address); pte_t *pte = lookup_address(address);
if (pte && pte_present(*pte) && !pte_exec_kernel(*pte)) if (pte && pte_present(*pte) && !pte_exec(*pte))
printk(KERN_CRIT "kernel tried to execute " printk(KERN_CRIT "kernel tried to execute "
"NX-protected page - exploit attempt? " "NX-protected page - exploit attempt? "
"(uid: %d)\n", current->uid); "(uid: %d)\n", current->uid);
......
...@@ -542,7 +542,7 @@ int __init set_kernel_exec(unsigned long vaddr, int enable) ...@@ -542,7 +542,7 @@ int __init set_kernel_exec(unsigned long vaddr, int enable)
pte = lookup_address(vaddr); pte = lookup_address(vaddr);
BUG_ON(!pte); BUG_ON(!pte);
if (!pte_exec_kernel(*pte)) if (!pte_exec(*pte))
ret = 0; ret = 0;
if (enable) if (enable)
......
...@@ -55,14 +55,6 @@ static inline pte_t native_ptep_get_and_clear(pte_t *xp) ...@@ -55,14 +55,6 @@ static inline pte_t native_ptep_get_and_clear(pte_t *xp)
#define pte_none(x) (!(x).pte_low) #define pte_none(x) (!(x).pte_low)
#define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT) #define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT)
/*
* All present pages are kernel-executable:
*/
static inline int pte_exec_kernel(pte_t pte)
{
return 1;
}
/* /*
* Bits 0, 6 and 7 are taken, split up the 29 bits of offset * Bits 0, 6 and 7 are taken, split up the 29 bits of offset
* into this range: * into this range:
......
...@@ -19,14 +19,6 @@ ...@@ -19,14 +19,6 @@
#define pud_bad(pud) 0 #define pud_bad(pud) 0
#define pud_present(pud) 1 #define pud_present(pud) 1
/*
* All present pages with !NX bit are kernel-executable:
*/
static inline int pte_exec_kernel(pte_t pte)
{
return !(pte_val(pte) & _PAGE_NX);
}
/* Rules for using set_pte: the pte being assigned *must* be /* Rules for using set_pte: the pte being assigned *must* be
* either not present or in a state where the hardware will * either not present or in a state where the hardware will
* not attempt to update the pte. In places where this is * not attempt to update the pte. In places where this is
......
...@@ -139,6 +139,7 @@ static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; ...@@ -139,6 +139,7 @@ static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED;
static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; } static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; }
static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_PSE; } static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_PSE; }
static inline int pte_exec(pte_t pte) { return !(pte_val(pte) & _PAGE_NX); }
static inline int pmd_large(pmd_t pte) { static inline int pmd_large(pmd_t pte) {
return (pmd_val(pte) & (_PAGE_PSE|_PAGE_PRESENT)) == return (pmd_val(pte) & (_PAGE_PSE|_PAGE_PRESENT)) ==
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment