Re: [PATCH 26/26] x86, pkeys: Documentation

From: Ingo Molnar
Date: Thu Sep 24 2015 - 05:50:09 EST



* Dave Hansen <dave@xxxxxxxx> wrote:

> > Another question, related to enumeration as well: I'm wondering whether
> > there's any way for the kernel to allocate a bit or two for its own purposes -
> > such as protecting crypto keys? Or is the facility fundamentally intended for
> > user-space use only?
>
> No, that's not possible with the current setup.

Ok, then another question, have you considered the following usecase:

AFAICS pkeys only affect data loads and stores. Instruction fetches are notably
absent from the documentation. Can you clarify that instructions can be fetched
and executed from PTE_READ but pkeys-all-access-disabled pags?

If yes then this could be a significant security feature / usecase for pkeys:
executable sections of shared libraries and binaries could be mapped with pkey
access disabled. If I read the Intel documentation correctly then that should be
possible.

The advantage of doing that is that an existing attack method to circumvent ASLR
(or to scout out an unknown binary) is to use an existing (user-space) information
leak to read the address space of a server process - and to use that to figure out
the actual code present at that address.

The code signature can then be be used to identify the precise layout of the
binary, and/or to create ROP gadgets - to escallate permissions using an otherwise
not exploitable buffer overflow.

I.e. AFAICS pkeys could be used to create true '--x' permissions for executable
(user-space) pages.

But I might be reading it wrong ...

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/