Re: [PATCH v2 10/20] x86: avoid W^X being broken during modules loading

Nadav Amit
2019-02-11T18:45:33Z

> On Feb 11, 2019, at 10:29 AM, Borislav Petkov <bp@alien8.de> wrote:
>
>> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
>> index 76d482a2b716..69f3e650ada8 100644
>> --- a/arch/x86/kernel/alternative.c
>> +++ b/arch/x86/kernel/alternative.c
>> @@ -667,15 +667,29 @@ void __init alternative_instructions(void)
>> * handlers seeing an inconsistent instruction while you patch.
>> */
>> void *__init_or_module text_poke_early(void *addr, const void *opcode,
>> - size_t len)
>> + size_t len)
>> {
>> unsigned long flags;
>> - local_irq_save(flags);
>> - memcpy(addr, opcode, len);
>> - local_irq_restore(flags);
>> - sync_core();
>> - /* Could also do a CLFLUSH here to speed up CPU recovery; but
>> - that causes hangs on some VIA CPUs. */
>> +
>> + if (static_cpu_has(X86_FEATURE_NX) &&
>
> Not a fast path - boot_cpu_has() is fine here.

Are you sure about that? This path is still used when modules are loaded.