Linux Kernel Runtime Guard (LKRG) is a loadable kernel module that performs runtime integrity checking of the Linux kernel and detection of security vulnerability exploits against the kernel. As controversial as this concept is, LKRG attempts to post-detect and hopefully promptly respond to unauthorized modifications to the running Linux kernel (integrity checking) or to credentials (such as user IDs) of the running processes (exploit detection). For process credentials, LKRG attempts to detect the exploit and take action before the kernel would grant the process access (such as open a file) based on the unauthorized credentials.
Download (release notes, previous release notes):
These and older versions of LKRG are also available from the Openwall file archive. The source code and revision history of LKRG may be browsed on Bitbucket.
Follow this link for information on verifying the signatures.
There's a mailing list where you can share your experience with LKRG and ask questions. Please be sure to specify an informative message subject whenever you post to the list (that is, something better than "question" or "problem"). To subscribe, enter your e-mail address below or send an empty message to <lkrg-users-subscribe at lists.openwall.com>. You will be required to confirm your subscription by "replying" to the automated confirmation request that will be sent to you. You will be able to unsubscribe at any time and we will not use your e-mail address for any other purpose or share it with a third party. However, if you post to the list, other subscribers and those viewing the archives may see your address(es) as specified on your message.
While LKRG defeats many pre-existing exploits of Linux kernel vulnerabilities, and will likely defeat many future exploits (including of yet unknown vulnerabilities) that do not specifically attempt to bypass LKRG, it is bypassable by design (albeit sometimes at the expense of more complicated and/or less reliable exploits). Thus, it can be said that LKRG provides security through diversity, much like running an uncommon OS kernel would, yet without the usability drawbacks of actually running an uncommon OS. As free LKRG becomes somewhat popular and maybe a target of some exploits, we might introduce paid LKRG Pro as a means to fund the project and provide further diversity (with Pro's smaller userbase being beneficial), extra and specialized functionality (e.g., detection of container escapes), and maybe distro-specific binary builds.
Like any software, LKRG may contain bugs and some of those might even be new security vulnerabilities. You need to weigh the benefits vs. risks of using LKRG, considering that LKRG is most useful for systems that realistically, despite of this being a best practice for security, won't be promptly rebooted into new kernels (nor live-patched) whenever a new kernel vulnerability is discovered.
Being a kernel module (not a kernel patch), LKRG can be built for and loaded on top of a wide range of mainline and distros' kernels, without needing to patch those. We currently support kernel versions ranging from RHEL7 (and some of its clones/revisions, including even the heavily modified OpenVZ/Virtuozzo 7, albeit not trying to detect container escapes yet) and Ubuntu 16.04 to latest mainline.
LKRG is currently in an early experimental stage. We expect occasional false positives (integrity violations and/or exploits detected when there aren't ones). LKRG's current response to kernel integrity violations is merely reporting those in kernel messages (which obviously doesn't mitigate attacks when those are for real) and its current response to unauthorized process credentials is killing the process (which does defeat many exploits, but is a rather mild response nevertheless). This will likely change as LKRG becomes more mature.
To illustrate LKRG's exploit detection capabilities, in our testing on vulnerable distro kernels LKRG successfully detected certain pre-existing exploits of CVE-2014-9322 (BadIRET), CVE-2017-5123 (waitid(2) missing access_ok), CVE-2017-6074 (use-after-free in DCCP protocol). However, it wouldn't be expected to detect exploits of CVE-2016-5195 (Dirty COW) since those directly target the userspace even if via the kernel. While in case of Dirty COW the LKRG "bypass" happened due to the nature of the bug and this being the way to exploit it, it's also a way for future exploits to bypass LKRG by similarly directly targeting userspace. It remains to be seen whether such exploits become common (unlikely unless LKRG or similar become popular?) and what (negative?) effect on their reliability this will have (for kernel vulnerabilities where directly targeting the userspace isn't essential and possibly not straightforward).
We did not run many benchmarks yet, but to give a rough idea the performance impact of LKRG 0.2 on building John the Ripper 1.8.0-jumbo-1 with "./configure CFLAGS='-O0'" (that is, with compiler optimizations disabled in order to artificially reduce the amount of processing in userspace and increase the frequency of syscalls, thereby exposing LKRG's possible performance impact more) and "make -j8" on an Atom C2750 machine (8 Silvermont cores) running VzLinux (Virtuozzo 7) appears to be around 2.5% for fully enabled LKRG, or around 0.7% for LKRG with code integrity checks on random events disabled with the corresponding sysctl.
More information on LKRG is available on our wiki, and you're welcome to support the project on Patreon. If you support LKRG on Patreon now and we ever introduce a LKRG Pro, we intend to offer to credit twice the amount of your Patreon support up to that point (as long as it's at least $100) towards your LKRG Pro licensing and/or subscription (excluding our customer support and professional services, if you require any, since those don't scale).