Re: [PATCH v3 6/7] x86/alternatives: use temporary mm for text poking

2018-11-06 Thread Peter Zijlstra
On Tue, Nov 06, 2018 at 06:11:18PM +, Nadav Amit wrote: > From: Peter Zijlstra > > On Tue, Nov 06, 2018 at 09:20:19AM +0100, Peter Zijlstra wrote: > > > >> By our current way of thinking, kmap_atomic simply is not correct. > > > > Something like the below; which weirdly builds an x86_32 kerne

Re: [PATCH v3 6/7] x86/alternatives: use temporary mm for text poking

2018-11-06 Thread Nadav Amit
: Re: [PATCH v3 6/7] x86/alternatives: use temporary mm for text poking > > > On Tue, Nov 06, 2018 at 09:20:19AM +0100, Peter Zijlstra wrote: > >> By our current way of thinking, kmap_atomic simply is not correct. > > Something like the below; which weirdly builds an x8

Re: [PATCH v3 6/7] x86/alternatives: use temporary mm for text poking

2018-11-06 Thread Peter Zijlstra
On Tue, Nov 06, 2018 at 09:20:19AM +0100, Peter Zijlstra wrote: > By our current way of thinking, kmap_atomic simply is not correct. Something like the below; which weirdly builds an x86_32 kernel. Although I imagine a very sad one. --- diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ba7

Re: [PATCH v3 6/7] x86/alternatives: use temporary mm for text poking

2018-11-06 Thread Peter Zijlstra
Borislav Petkov , Dave Hansen > > , Andy Lutomirski , Kees Cook > > , Dave Hansen , Masami > > Hiramatsu > > Subject: Re: [PATCH v3 6/7] x86/alternatives: use temporary mm for text > > poking > > > > > > On Fri, Nov 02, 2018 at 04:29:45PM -0700, Nadav

Re: [PATCH v3 6/7] x86/alternatives: use temporary mm for text poking

2018-11-05 Thread Nadav Amit
asami > Hiramatsu > Subject: Re: [PATCH v3 6/7] x86/alternatives: use temporary mm for text poking > > > On Fri, Nov 02, 2018 at 04:29:45PM -0700, Nadav Amit wrote: >> +unuse_temporary_mm(prev); >> + >> +pte_unmap_unlock(ptep, ptl); > > That; that does k

Re: [PATCH v3 6/7] x86/alternatives: use temporary mm for text poking

2018-11-05 Thread Peter Zijlstra
On Fri, Nov 02, 2018 at 04:29:45PM -0700, Nadav Amit wrote: > + unuse_temporary_mm(prev); > + > + pte_unmap_unlock(ptep, ptl); That; that does kunmap_atomic() on 32bit. I've been thinking that the whole kmap_atomic thing on x86_32 is terminally broken, and with that most of x86_32 is. km

Re: [PATCH v3 6/7] x86/alternatives: use temporary mm for text poking

2018-11-05 Thread Peter Zijlstra
On Fri, Nov 02, 2018 at 04:29:45PM -0700, Nadav Amit wrote: > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c > index 9ceae28db1af..1a40df4db450 100644 > --- a/arch/x86/kernel/alternative.c > +++ b/arch/x86/kernel/alternative.c > @@ -699,41 +700,110 @@ __ro_after_init un

[PATCH v3 6/7] x86/alternatives: use temporary mm for text poking

2018-11-02 Thread Nadav Amit
text_poke() can potentially compromise the security as it sets temporary PTEs in the fixmap. These PTEs might be used to rewrite the kernel code from other cores accidentally or maliciously, if an attacker gains the ability to write onto kernel memory. Moreover, since remote TLBs are not flushed a