|| ||Kees Cook <email@example.com> |
|| ||firstname.lastname@example.org |
|| ||[Security] proactive defense: using read-only memory |
|| ||Sun, 7 Nov 2010 11:35:20 -0800|
|| ||Article, Thread
While Dan Rosenberg is working to make things harder to locate potential
targets in the kernel through fixing kernel address leaks, I'd like
to approach a related proactive security measure: enforcing read-only
memory for things that would make good targets.
The proposal is simple: as much of the kernel should be read-only as
possible, most especially function pointers and other execution control
points, which are the easiest target to exploit when an arbitrary kernel
memory write becomes available to an attacker. There has been past work
to "const"ify function pointer tables, and this should continue. However,
there are a few things that need further attention:
- Modules need to be correctly marked RO/NX. This patch exists, but is
not in mainline. It needs to be in mainline.
- Pointers to function table also need to be marked read-only after
they are set. An example of this is the security_ops table pointer. It
gets set once at boot, and never changes again. These need to be handled
so it isn't possible to just trivially reaim the entire security_ops
table lookup somewhere else.
- Architectures besides just x86 need to be considered.
- Entry points to set_kernel_text_rw() and similar need to be blockable.
Having these symbols available make kernel memory modification trivial;
there needs to be a way to disable these features for people that want
to harden their kernel further (though it obviously breaks things like
ftrace, ksplice, etc, but that should be the admin's choice).
The PaX solution to most of this is to rearrange the loader and memory
sections of the kernel to make use of .rodata fully. For function table
pointers (and other critical things like GDT) that are less commonly
changed, PaX uses a simple approach of just disabling write-protection
when changing variables. For example:
security_ops = &default_security_ops;
And pax_(open|close)_kernel() are _inline_ functions so that
return-oriented-programming attacks cannot leave the system with
static inline unsigned long native_pax_open_kernel(void)
unsigned long cr0;
cr0 = read_cr0() ^ X86_CR0_WP;
BUG_ON(unlikely(cr0 & X86_CR0_WP));
return cr0 ^ X86_CR0_WP;
And finally, we'll need to go through and address the remaining missing
"const" needs. My intention is to try to get through all these kinds of
changes, but it is going to need the help and understanding of many
subsystem maintainers. Hardening the kernel against manipulation is a win
for everyone. I'd like to try to move this forward, but I'd really
appreciate getting help with it; this will only be successful if people are
on board with it.
P.S. If anyone would like to help us try to get more pieces of PaX and
grsecurity into mainline, please choose a thing you'd like to drive
forward, sign up for it, and get to working on it.
 proactive security assumes there will be future kernel security
vulnerabilities and seeks to harden the system against exploitation.
For evidence of the steady stream of vulnerabilities, see:
This feature is specifically "CONFIG_PAX_KERNEXEC".
Ubuntu Security Team
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to email@example.com
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/