Re: [PATCH 08/11] Creation of "pagefault_handler_x86" LSM hook

From: Salvatore Mesoraca
Date: Tue Jun 13 2017 - 03:41:40 EST


2017-06-12 19:32 GMT+02:00 Thomas Gleixner <tglx@xxxxxxxxxxxxx>:
> That explains, what you could do with it, but it completely lacks any
> rationale WHY this is desired and good behaviour and how that is a security
> feature.

You are right, I could have been more descriptive.
This is not a security feature "per se", it's a way to soften some
unwanted side-effects of restrictive security features.
In particular I'm trying to introduce a feature that will prevent
the runtime creation of executable code in user-space programs:
it's something like the PaX's MPROTECT feature.
This hook is used to implement what PaX call "trampoline
emulation" that, in practice, allow for some specific code
sequences to be executed even if they are in non executable memory.
This may look like a bad thing at first, but you have to consider
that:
- This allows for "memory restriction" features to stay on even
when they should be turned off. And, even if this emulation
makes the feature less effective, it's still better than having
it turned off completely
- The only code sequences emulated are trampolines used to make
function calls. In many cases, when you have the chance to
make arbitrary memory writes, you can already manipulate the
control flow of the program by overwriting function pointers or
return values. So, in many cases, the "trampoline emulation"
doesn't introduce new exploit vectors.
- It's a feature that can be turned on only if needed, on a per
executable file basis.

Thank your for taking the time to review this.