Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-12 Thread Peter Zijlstra
On Mon, Nov 12, 2018 at 04:46:46AM +0100, Ingo Molnar wrote: > > * Peter Zijlstra wrote: > > > On Sun, Nov 11, 2018 at 08:53:07PM +, Nadav Amit wrote: > > > > > >> + /* > > > >> + * The lock is not really needed, but this allows to avoid > > > >> open-coding. > > > >> +

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-12 Thread Peter Zijlstra
On Mon, Nov 12, 2018 at 04:46:46AM +0100, Ingo Molnar wrote: > > * Peter Zijlstra wrote: > > > On Sun, Nov 11, 2018 at 08:53:07PM +, Nadav Amit wrote: > > > > > >> + /* > > > >> + * The lock is not really needed, but this allows to avoid > > > >> open-coding. > > > >> +

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Ingo Molnar
* Peter Zijlstra wrote: > On Sun, Nov 11, 2018 at 08:53:07PM +, Nadav Amit wrote: > > > >> +/* > > >> + * The lock is not really needed, but this allows to avoid > > >> open-coding. > > >> + */ > > >> +ptep = get_locked_pte(poking_mm, poking_addr, ); > >

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Ingo Molnar
* Peter Zijlstra wrote: > On Sun, Nov 11, 2018 at 08:53:07PM +, Nadav Amit wrote: > > > >> +/* > > >> + * The lock is not really needed, but this allows to avoid > > >> open-coding. > > >> + */ > > >> +ptep = get_locked_pte(poking_mm, poking_addr, ); > >

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Peter Zijlstra
On Mon, Nov 12, 2018 at 12:09:32AM +, Nadav Amit wrote: > > On Sun, Nov 11, 2018 at 08:53:07PM +, Nadav Amit wrote: > > > +/* > + * The lock is not really needed, but this allows to avoid > open-coding. > + */ > +ptep =

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Peter Zijlstra
On Mon, Nov 12, 2018 at 12:09:32AM +, Nadav Amit wrote: > > On Sun, Nov 11, 2018 at 08:53:07PM +, Nadav Amit wrote: > > > +/* > + * The lock is not really needed, but this allows to avoid > open-coding. > + */ > +ptep =

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Peter Zijlstra
On Mon, Nov 12, 2018 at 12:52:20AM +0100, Peter Zijlstra wrote: > On Sun, Nov 11, 2018 at 08:53:07PM +, Nadav Amit wrote: > > > >> +/* > > >> + * The lock is not really needed, but this allows to avoid > > >> open-coding. > > >> + */ > > >> +ptep =

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Peter Zijlstra
On Mon, Nov 12, 2018 at 12:52:20AM +0100, Peter Zijlstra wrote: > On Sun, Nov 11, 2018 at 08:53:07PM +, Nadav Amit wrote: > > > >> +/* > > >> + * The lock is not really needed, but this allows to avoid > > >> open-coding. > > >> + */ > > >> +ptep =

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Nadav Amit
From: Peter Zijlstra Sent: November 11, 2018 at 11:52:20 PM GMT > To: Nadav Amit > Cc: Ingo Molnar , LKML , X86 > ML , H. Peter Anvin , Thomas Gleixner > , Borislav Petkov , Dave Hansen > , Andy Lutomirski , Kees Cook > , Dave Hansen , Masami > Hiramatsu > Subject:

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Nadav Amit
From: Peter Zijlstra Sent: November 11, 2018 at 11:52:20 PM GMT > To: Nadav Amit > Cc: Ingo Molnar , LKML , X86 > ML , H. Peter Anvin , Thomas Gleixner > , Borislav Petkov , Dave Hansen > , Andy Lutomirski , Kees Cook > , Dave Hansen , Masami > Hiramatsu > Subject:

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Peter Zijlstra
On Sun, Nov 11, 2018 at 08:53:07PM +, Nadav Amit wrote: > >> + /* > >> + * The lock is not really needed, but this allows to avoid open-coding. > >> + */ > >> + ptep = get_locked_pte(poking_mm, poking_addr, ); > >> + > >> + /* > >> + * If we failed to allocate a PTE, fail. This

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Peter Zijlstra
On Sun, Nov 11, 2018 at 08:53:07PM +, Nadav Amit wrote: > >> + /* > >> + * The lock is not really needed, but this allows to avoid open-coding. > >> + */ > >> + ptep = get_locked_pte(poking_mm, poking_addr, ); > >> + > >> + /* > >> + * If we failed to allocate a PTE, fail. This

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Nadav Amit
asami > Hiramatsu > Subject: Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text > poking > > > On Sat, Nov 10, 2018 at 03:17:28PM -0800, Nadav Amit wrote: >> @@ -683,43 +684,108 @@ __ro_after_init unsigned long poking_addr; >> >> static int

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Nadav Amit
asami > Hiramatsu > Subject: Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text > poking > > > On Sat, Nov 10, 2018 at 03:17:28PM -0800, Nadav Amit wrote: >> @@ -683,43 +684,108 @@ __ro_after_init unsigned long poking_addr; >> >> static int

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Nadav Amit
r Zijlstra , Dave Hansen > , Masami Hiramatsu > Subject: Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text > poking > > > On Sa, 10. Nov 15:17, Nadav Amit wrote: >> text_poke() can potentially compromise the security as it sets temporary >> PTEs in the fixma

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Nadav Amit
r Zijlstra , Dave Hansen > , Masami Hiramatsu > Subject: Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text > poking > > > On Sa, 10. Nov 15:17, Nadav Amit wrote: >> text_poke() can potentially compromise the security as it sets temporary >> PTEs in the fixma

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Damian Tometzki
On Sa, 10. Nov 15:17, Nadav Amit wrote: > 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

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Damian Tometzki
On Sa, 10. Nov 15:17, Nadav Amit wrote: > 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

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Peter Zijlstra
On Sat, Nov 10, 2018 at 03:17:28PM -0800, Nadav Amit wrote: > @@ -683,43 +684,108 @@ __ro_after_init unsigned long poking_addr; > > static int __text_poke(void *addr, const void *opcode, size_t len) > { > + bool cross_page_boundary = offset_in_page(addr) + len > PAGE_SIZE; > +

Re: [PATCH v4 06/10] x86/alternative: use temporary mm for text poking

2018-11-11 Thread Peter Zijlstra
On Sat, Nov 10, 2018 at 03:17:28PM -0800, Nadav Amit wrote: > @@ -683,43 +684,108 @@ __ro_after_init unsigned long poking_addr; > > static int __text_poke(void *addr, const void *opcode, size_t len) > { > + bool cross_page_boundary = offset_in_page(addr) + len > PAGE_SIZE; > +