From: Damian Tometzki
Sent: November 11, 2018 at 7:11:42 PM GMT
> To: Nadav Amit <[email protected]>
> Cc: Ingo Molnar <[email protected]>, [email protected]>, 
> [email protected]>, H. Peter Anvin <[email protected]>, Thomas Gleixner 
> <[email protected]>, Borislav Petkov <[email protected]>, Dave Hansen 
> <[email protected]>, Andy Lutomirski <[email protected]>, Kees Cook 
> <[email protected]>, Peter Zijlstra <[email protected]>, Dave Hansen 
> <[email protected]>, Masami Hiramatsu <[email protected]>
> 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 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 after the temporary PTEs are
>> removed, the time-window in which the code is writable is not limited if
>> the fixmap PTEs - maliciously or accidentally - are cached in the TLB.
>> To address these potential security hazards, we use a temporary mm for
>> patching the code.
>> 
>> Finally, text_poke() is also not conservative enough when mapping pages,
>> as it always tries to map 2 pages, even when a single one is sufficient.
>> So try to be more conservative, and do not map more than needed.
>> 
>> Cc: Andy Lutomirski <[email protected]>
>> Cc: Kees Cook <[email protected]>
>> Cc: Peter Zijlstra <[email protected]>
>> Cc: Dave Hansen <[email protected]>
>> Cc: Masami Hiramatsu <[email protected]>
>> Signed-off-by: Nadav Amit <[email protected]>
>> ---
>> arch/x86/include/asm/fixmap.h |   2 -
>> arch/x86/kernel/alternative.c | 112 +++++++++++++++++++++++++++-------
>> 2 files changed, 89 insertions(+), 25 deletions(-)
>> 
>> diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
>> index 50ba74a34a37..9da8cccdf3fb 100644
>> --- a/arch/x86/include/asm/fixmap.h
>> +++ b/arch/x86/include/asm/fixmap.h
>> @@ -103,8 +103,6 @@ enum fixed_addresses {
>> #ifdef CONFIG_PARAVIRT
>>      FIX_PARAVIRT_BOOTMAP,
>> #endif
> 
> Hello Nadav,
> 
> with the remove of FIX_TEXT_POKE1 and FIX_TEXT_POKE0 i get the following
> build error:
> 
> /home/damian/kernel/linux/arch/x86/xen/mmu_pv.c:2321:7: Fehler: 
> »FIX_TEXT_POKE0« nicht deklariert (erstmalige Verwendung in dieser Funktion); 
> meinten Sie »FIX_TBOOT_BASE«?
>  case FIX_TEXT_POKE0:
>       ^~~~~~~~~~~~~~
>       FIX_TBOOT_BASE
> /home/damian/kernel/linux/arch/x86/xen/mmu_pv.c:2321:7: Anmerkung: jeder 
> nicht deklarierte Bezeichner wird nur einmal für jede Funktion, in der er 
> vorkommt, gemeldet
> /home/damian/kernel/linux/arch/x86/xen/mmu_pv.c:2322:7: Fehler: 
> »FIX_TEXT_POKE1« nicht deklariert (erstmalige Verwendung in dieser Funktion); 
> meinten Sie »FIX_TBOOT_BASE«?
>  case FIX_TEXT_POKE1:
>       ^~~~~~~~~~~~~~
>       FIX_TBOOT_BASE

Thanks for letting me know. I’ll simply remove them in v5.

Regards,
Nadav

Reply via email to