Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 326239
b: refs/heads/master
c: 40d3cd6
h: refs/heads/master
i:
  326237: e802d0b
  326235: 400c410
  326231: a70bbe6
  326223: d1cff23
  326207: 3e79982
v: v3
  • Loading branch information
H. Peter Anvin committed Sep 21, 2012
1 parent a08319e commit 69149e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 52b6179ac87d33c2eeaff5292786a10fe98cff64
refs/heads/master: 40d3cd6695014bf3c44e2ca66b610b18acaf923d
18 changes: 18 additions & 0 deletions trunk/arch/x86/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,17 @@ static int fault_in_kernel_space(unsigned long address)
return address >= TASK_SIZE_MAX;
}

static inline bool smap_violation(int error_code, struct pt_regs *regs)
{
if (error_code & PF_USER)
return false;

if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
return false;

return true;
}

/*
* This routine handles page faults. It determines the address,
* and the problem, and then passes it off to one of the appropriate
Expand Down Expand Up @@ -1088,6 +1099,13 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
if (unlikely(error_code & PF_RSVD))
pgtable_bad(regs, error_code, address);

if (static_cpu_has(X86_FEATURE_SMAP)) {
if (unlikely(smap_violation(error_code, regs))) {
bad_area_nosemaphore(regs, error_code, address);
return;
}
}

perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);

/*
Expand Down

0 comments on commit 69149e6

Please sign in to comment.