lkml.org 
[lkml]   [2015]   [Oct]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] x86/mm: warn on W+x mappings

* Matt Fleming <matt@codeblueprint.co.uk> wrote:

> > > Right, we could do that, but then we wouldn't be able to support
> > > creation/updating variables at runtime, such as when you install a
> > > distribution for the first time, or want to boot a new kernel filename
> > > directly from the firmware without a boot loader (and need to modify the
> > > BootXXXX variables).
> >
> > Do we know the precise position and address range of these variables?
> >
> > We could map them writable (but not executable), and the rest executable (but
> > not writable).
>
> The variables are stored in NVRAM, which we don't map into the kernel virtual
> address space. [...]

Just curious: is there firmware that memory maps those variables privately?

> [...] We have to initiate the transaction of writing to the variables by
> executing EFI runtime services.
>
> We obviously have buffers that we pass to the BIOS that contain variable data,
> but these should be NX anyway because they're regular kernel allocations.
>
> > That raises the question whether the same physical page ever mixes variables
> > and actual code - but the hope would be that it's suffiently page granular for
> > this to work.
>
> I don't think that would ever happen.

Ok, that's promising, so how about this then to solve the security weakness the
new warning unearthed: map the whole EFI range as 'r-x (NX)', but detect writes
from the page fault handler and transparently allow them to flip over the range to
'rw-'.

Note that for security reasons we don't allow a subsequent flipping back to NX if
there's an NX fault on the same page, i.e. this new mechanism is a monotonic
one-way process that should dynamically 'map out' data pages versus executable
pages.

It should also be pretty robust, assuming we can take page faults while EFI code
is executing and is trying to modify EFI data: is that the case?

Thanks,

Ingo


\
 
 \ /
  Last update: 2015-10-21 12:01    [W:0.097 / U:1.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site