[PATCH 4/8] x86/mm: add clarifying comments for user addr space

From: Dave Hansen
Date: Fri Sep 28 2018 - 12:06:41 EST



From: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>

The SMAP and Reserved checking do not have nice comments. Add
some to clarify and make it match everything else.

Signed-off-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Cc: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
Cc: "Peter Zijlstra (Intel)" <peterz@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: x86@xxxxxxxxxx
Cc: Andy Lutomirski <luto@xxxxxxxxxx>
Cc: Jann Horn <jannh@xxxxxxxxxx>
Cc: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
---

b/arch/x86/mm/fault.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff -puN arch/x86/mm/fault.c~pkeys-fault-warnings-02 arch/x86/mm/fault.c
--- a/arch/x86/mm/fault.c~pkeys-fault-warnings-02 2018-09-27 10:17:22.992343568 -0700
+++ b/arch/x86/mm/fault.c 2018-09-27 10:17:22.996343568 -0700
@@ -1278,9 +1278,17 @@ void do_user_addr_fault(struct pt_regs *
if (unlikely(kprobes_fault(regs)))
return;

+ /*
+ * Reserved bits are never expected to be set on
+ * entries in the user portion of the page tables.
+ */
if (unlikely(hw_error_code & X86_PF_RSVD))
pgtable_bad(regs, hw_error_code, address);

+ /*
+ * Check for invalid kernel (supervisor) access to user
+ * pages in the user address space.
+ */
if (unlikely(smap_violation(hw_error_code, regs))) {
bad_area_nosemaphore(regs, hw_error_code, address, NULL);
return;
_