linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] arm64: fault: Don't populate ESR context for user fault on kernel VA
@ 2018-03-05 10:31 Will Deacon
  2018-03-05 13:27 ` Robin Murphy
  2018-03-05 14:05 ` Dave Martin
  0 siblings, 2 replies; 12+ messages in thread
From: Will Deacon @ 2018-03-05 10:31 UTC (permalink / raw)
  To: linux-arm-kernel

User faults on kernel addresses are a good sign that the faulting task
is either up to no good or is in deep trouble. In such situations,
exposing the optional ESR context on the sigframe as part of the
delivered signal is only useful to attackers who are using information
about underlying hardware fault (e.g. translation vs permission) as a
mechanism to defeat KASLR.

Remove the ESR context from the sigframe for user faults on kernel
addresses.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---

Here's another one that doesn't make a huge amount of difference when
kpti is enabled, but I think is a change worth making all the same.

 arch/arm64/mm/fault.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 49dfb08a6c4d..b9800395788e 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -292,8 +292,10 @@ static void __do_kernel_fault(unsigned long addr, unsigned int esr,
 
 static void __do_user_fault(struct siginfo *info, unsigned int esr)
 {
-	current->thread.fault_address = (unsigned long)info->si_addr;
-	current->thread.fault_code = esr;
+	unsigned long addr = (unsigned long)info->si_addr;
+
+	current->thread.fault_address = addr;
+	current->thread.fault_code = addr < TASK_SIZE ? esr : 0;
 	arm64_force_sig_info(info, esr_to_fault_info(esr)->name, current);
 }
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-03-07 10:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-05 10:31 [RFC PATCH] arm64: fault: Don't populate ESR context for user fault on kernel VA Will Deacon
2018-03-05 13:27 ` Robin Murphy
2018-03-05 15:56   ` Will Deacon
2018-03-05 14:05 ` Dave Martin
2018-03-05 17:24   ` Will Deacon
2018-03-06 15:59     ` Peter Maydell
2018-03-06 16:05       ` Dave Martin
2018-03-06 17:54         ` Will Deacon
2018-03-07 10:50           ` Dave P Martin
2018-03-06 17:59         ` James Morse
2018-03-06 18:16           ` James Morse
2018-03-06 14:49   ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).