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

2019-03-07 Thread Borislav Petkov
On Thu, Mar 07, 2019 at 12:02:13PM -0800, Andy Lutomirski wrote: > Should we maybe rename these functions? static_cpu_has() is at least > reasonably obvious. But cpu_feature_enabled() is different for > reasons I've never understood, and boot_cpu_has() is IMO terribly > named. It's not about

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

2019-03-07 Thread Andy Lutomirski
On Thu, Mar 7, 2019 at 9:06 AM Borislav Petkov wrote: > > On Thu, Mar 07, 2019 at 08:53:34AM -0800, h...@zytor.com wrote: > > If we *do*, what is the issue here? Although boot_cpu_has() isn't > > slow (it should in general be possible to reduce to one testb > > instruction followed by a

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

2019-03-07 Thread Borislav Petkov
On Thu, Mar 07, 2019 at 08:53:34AM -0800, h...@zytor.com wrote: > If we *do*, what is the issue here? Although boot_cpu_has() isn't > slow (it should in general be possible to reduce to one testb > instruction followed by a conditional jump) it seems that "avoiding an > alternatives slot" *should*

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

2019-03-07 Thread hpa
On March 6, 2019 11:29:47 PM PST, Borislav Petkov wrote: >On Mon, Feb 11, 2019 at 08:42:51PM +0100, Borislav Petkov wrote: >> On Mon, Feb 11, 2019 at 11:27:03AM -0800, Nadav Amit wrote: >> > Is there any comment over static_cpu_has()? ;-) >> >> Almost: >> >> /* >> * Static testing of CPU

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

2019-03-06 Thread Borislav Petkov
On Mon, Feb 11, 2019 at 08:42:51PM +0100, Borislav Petkov wrote: > On Mon, Feb 11, 2019 at 11:27:03AM -0800, Nadav Amit wrote: > > Is there any comment over static_cpu_has()? ;-) > > Almost: > > /* > * Static testing of CPU features. Used the same as boot_cpu_has(). > * These will statically

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

2019-02-11 Thread Nadav Amit
> On Feb 11, 2019, at 11:42 AM, Borislav Petkov wrote: > > On Mon, Feb 11, 2019 at 11:27:03AM -0800, Nadav Amit wrote: >> Is there any comment over static_cpu_has()? ;-) > > Almost: > > /* > * Static testing of CPU features. Used the same as boot_cpu_has(). > * These will statically patch the

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

2019-02-11 Thread Borislav Petkov
On Mon, Feb 11, 2019 at 11:27:03AM -0800, Nadav Amit wrote: > Is there any comment over static_cpu_has()? ;-) Almost: /* * Static testing of CPU features. Used the same as boot_cpu_has(). * These will statically patch the target code for additional * performance. */ static __always_inline

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

2019-02-11 Thread Nadav Amit
> On Feb 11, 2019, at 11:10 AM, Borislav Petkov wrote: > > On Mon, Feb 11, 2019 at 11:09:25AM -0800, Nadav Amit wrote: >> It is just that I find the use of static_cpu_has()/boot_cpu_has() to be very >> inconsistent. I doubt that show_cpuinfo_misc(), copy_fpstate_to_sigframe(), >> or

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

2019-02-11 Thread Borislav Petkov
On Mon, Feb 11, 2019 at 11:09:25AM -0800, Nadav Amit wrote: > It is just that I find the use of static_cpu_has()/boot_cpu_has() to be very > inconsistent. I doubt that show_cpuinfo_misc(), copy_fpstate_to_sigframe(), > or i915_memcpy_init_early() that use static_cpu_has() are any hotter than >

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

2019-02-11 Thread Nadav Amit
> On Feb 11, 2019, at 11:01 AM, Borislav Petkov wrote: > > On Mon, Feb 11, 2019 at 10:45:26AM -0800, Nadav Amit wrote: >> Are you sure about that? This path is still used when modules are loaded. > > Yes, I'm sure. Loading a module does a gazillion things so saving a > couple of insns - yes,

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

2019-02-11 Thread Borislav Petkov
On Mon, Feb 11, 2019 at 10:45:26AM -0800, Nadav Amit wrote: > Are you sure about that? This path is still used when modules are loaded. Yes, I'm sure. Loading a module does a gazillion things so saving a couple of insns - yes, boot_cpu_has() is usually a RIP-relative MOV and a TEST - doesn't show

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

2019-02-11 Thread Nadav Amit
> On Feb 11, 2019, at 10:29 AM, Borislav Petkov 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

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

2019-02-11 Thread Borislav Petkov
> Subject: Re: [PATCH v2 10/20] x86: avoid W^X being broken during modules > loading For your next submission, please fix all your subjects: The tip tree preferred format for patch subject prefixes is 'subsys/component:', e.g. 'x86/apic:', 'x86/mm/fault:', 'sched/fair:', 'genirq/core:'.

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

2019-01-28 Thread Rick Edgecombe
From: Nadav Amit When modules and BPF filters are loaded, there is a time window in which some memory is both writable and executable. An attacker that has already found another vulnerability (e.g., a dangling pointer) might be able to exploit this behavior to overwrite kernel code. Prevent