Sponsored By

Torvalds Gives In, Linux Kernel Gets Locked Down Early

After years of efforts and rewrites, Linus Torvalds has signed off on a new optional feature for Linux that locks down the kernel much earlier in the boot process than was previously the case.

Larry Loeb

October 1, 2019

3 Min Read

It finally happened. After years of efforts and rewrites, Linus Torvalds has signed offon a new optional feature for Linux that locks down the kernel much earlier in the boot process than was previously being done. Matthew Garrett, David Howells and others bear the honor (aggravation?) for seeing this one through.

Torvalds has long been a critic of this kind of kernel hardening. But many distros of Linux made their own lockdown patches nevertheless, and he finally acquiesced.

"The majority of mainstream distributions have been carrying variants of this patchset for many years now, so there's value in providing a [patchset which] doesn't meet every distribution requirement, but gets us much closer to not requiring external patches," he noted in posting the code to GitHub.

The enclosed description of the new patchset is not sanguine. "This patchset introduces an optional kernel lockdown feature, intended to strengthen the boundary between UID 0 and the kernel." The document goes on to warn that, "When enabled, various pieces of kernel functionality are restricted. Applications that rely on low-level access to either hardware or the kernel may cease working as a result -- therefore this should not be enabled without appropriate evaluation beforehand." So, this may not be everyone's magic wand for security.

The wall between userland processes and the kernel is made higher with these patches. When enabled, the root user will not be able to affect the kernel the same way it currently can. This means that a compromised Linux root user account will then lose much of its luster to attackers. It won't be able to do those "special" things that attackers want to do.

The new module LSM (Linux Security Module) has two lockdown modes, which are called "integrity" and "confidentiality." Each restricts access to a different portion of the kernel's functionality.

If set to integrity, kernel features that allow userland to modify the running kernel are disabled. If set to confidentiality, kernel features that allow userland to extract confidential information from the kernel are also disabled.

This can be controlled via /sys/kernel/security/lockdown and overriden by kernel configuration. This allows the lockdown feature to be policy-driven, rather than encoding an implicit policy within the mechanism. One size (or feature) does not fit every situation.

The LSM was designed so that new or existing LSMs may implement finer-grained controls of the lockdown features. If you need to know the gory details of how this works, check out the lockdown_reason documentation which has been crammed into include/linux/security.h for the skinny about it.

Matthew Garret has also released some LSM information and code. It deals mostly with the "early loading" LSM implementations.

Garret's latest code adds support for early initialization of some LSMs, and then adds them to the list of names when full initialization is done later.

Early LSMs are initialized in link order and cannot be overridden via boot parameters, and cannot make use of kmalloc() (since the allocator isn't initialized yet).

The Linux kernel 5.4 branch should be the first to have the LSM show up.

— Larry Loeb has written for many of the last century's major "dead tree" computer magazines, having been, among other things, a consulting editor for BYTE magazine and senior editor for the launch of WebWeek.

Read more about:

Security Now

About the Author(s)

Larry Loeb

Blogger, Informationweek

Larry Loeb has written for many of the last century's major "dead tree" computer magazines, having been, among other things, a consulting editor for BYTE magazine and senior editor for the launch of WebWeek. He has written a book on the Secure Electronic Transaction Internet protocol. His latest book has the commercially obligatory title of Hack Proofing XML. He's been online since uucp "bang" addressing (where the world existed relative to !decvax), serving as editor of the Macintosh Exchange on BIX and the VARBusiness Exchange. His first Mac had 128 KB of memory, which was a big step up from his first 1130, which had 4 KB, as did his first 1401. You can e-mail him at [email protected].

Keep up with the latest cybersecurity threats, newly discovered vulnerabilities, data breach information, and emerging trends. Delivered daily or weekly right to your email inbox.

You May Also Like


More Insights