Commit 3dc12dfe authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/mm: Move the WARN() out of bad_kuap_fault()

In order to prepare the removal of calls to
search_exception_tables() on the fast path, move the
WARN() out of bad_kuap_fault().
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/9501311014bd6507e04b27a0c3035186ccf65cd5.1607491748.git.christophe.leroy@csgroup.eu
parent 5250d026
...@@ -183,11 +183,7 @@ bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write) ...@@ -183,11 +183,7 @@ bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
unsigned long begin = regs->kuap & 0xf0000000; unsigned long begin = regs->kuap & 0xf0000000;
unsigned long end = regs->kuap << 28; unsigned long end = regs->kuap << 28;
if (!is_write) return is_write && (address < begin || address >= end);
return false;
return WARN(address < begin || address >= end,
"Bug: write fault blocked by segment registers !");
} }
#endif /* CONFIG_PPC_KUAP */ #endif /* CONFIG_PPC_KUAP */
......
...@@ -371,11 +371,9 @@ static inline bool bad_kuap_fault(struct pt_regs *regs, unsigned long address, ...@@ -371,11 +371,9 @@ static inline bool bad_kuap_fault(struct pt_regs *regs, unsigned long address,
* the AMR. Hence check for BLOCK_WRITE/READ against AMR. * the AMR. Hence check for BLOCK_WRITE/READ against AMR.
*/ */
if (is_write) { if (is_write) {
return WARN(((regs->amr & AMR_KUAP_BLOCK_WRITE) == AMR_KUAP_BLOCK_WRITE), return (regs->amr & AMR_KUAP_BLOCK_WRITE) == AMR_KUAP_BLOCK_WRITE;
"Bug: Write fault blocked by AMR!");
} }
return WARN(((regs->amr & AMR_KUAP_BLOCK_READ) == AMR_KUAP_BLOCK_READ), return (regs->amr & AMR_KUAP_BLOCK_READ) == AMR_KUAP_BLOCK_READ;
"Bug: Read fault blocked by AMR!");
} }
static __always_inline void allow_user_access(void __user *to, const void __user *from, static __always_inline void allow_user_access(void __user *to, const void __user *from,
......
...@@ -63,8 +63,7 @@ static inline void restore_user_access(unsigned long flags) ...@@ -63,8 +63,7 @@ static inline void restore_user_access(unsigned long flags)
static inline bool static inline bool
bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write) bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
{ {
return WARN(!((regs->kuap ^ MD_APG_KUAP) & 0xff000000), return !((regs->kuap ^ MD_APG_KUAP) & 0xff000000);
"Bug: fault blocked by AP register !");
} }
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
......
...@@ -228,7 +228,7 @@ static bool bad_kernel_fault(struct pt_regs *regs, unsigned long error_code, ...@@ -228,7 +228,7 @@ static bool bad_kernel_fault(struct pt_regs *regs, unsigned long error_code,
// Read/write fault in a valid region (the exception table search passed // Read/write fault in a valid region (the exception table search passed
// above), but blocked by KUAP is bad, it can never succeed. // above), but blocked by KUAP is bad, it can never succeed.
if (bad_kuap_fault(regs, address, is_write)) if (bad_kuap_fault(regs, address, is_write))
return true; return WARN(true, "Bug: %s fault blocked by KUAP!", is_write ? "Write" : "Read");
// What's left? Kernel fault on user in well defined regions (extable // What's left? Kernel fault on user in well defined regions (extable
// matched), and allowed by KUAP in the faulting context. // matched), and allowed by KUAP in the faulting context.
......
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