Linux Kernel

From Kicksecure
Jump to navigation Jump to search

Newer Kernel Versions for Better Security Hardening / Kernel Issues

Introduction[edit]

Kernel Options[edit]

GNU/Linux provides a wide variety of possible kernel optionsarchive.org for individual users. Active kernel releases fall into several main categories: [1]

  • Prepatch (RC) kernels: these "release candidate" kernels are pre-releases of the mainline kernel that are intended for developers and Linux enthusiasts. [2] They contain new features and must be tested before they are put into a stable release.
  • Mainline: the mainline tree is where all new features are introduced and where new development occurs. Every 2-3 months, a new mainline kernel is released.
  • Stable: After a mainline kernel is released, it is classified as stable. Bug fixes for the stable kernel are backported from the mainline tree. On approximately a weekly basis, stable kernel updates are released. Normally only a few bug fix kernel releases are available before the next mainline kernel is released.
  • Long-term (LTS): At any time there are usually several "long-term maintenance" kernel releases available. Bug fixes are backported for older kernels, but these are focused on the most important issues and releases are not very frequent (particularly for older trees).
  • Distribution kernels: A number of Linux distributions provide long-term maintenance kernels, which are sometimes not based on those maintained by kernel developers. This is the case for Debian upon which Kicksecure is based. [3]

Interested readers can refer to The Linux Kernel Archivesarchive.org to see the prepatch, mainline, stable and long-term kernels that are currently available.

Recommended Kernel[edit]

For the vast majority of Kicksecure users, there is simply no reason to change from the distribution kernel that is in use.

The general expert consensus is that while LTS kernels have less hardening features and not all bug fixes are backported, they have less attack surface and potentially less chance of having new bugs. In comparison, stable kernels have more hardening features and all known bug fixes to date, but a higher attack surface and a greater potential for new bugs. [4] The grsecurity development team has also noted that the majority of Linux kernel vulnerabilities are those that have most recently been introduced (released) in newer versions. [5] [6]

The developer who is responsible for stable Linux kernel releases (Greg Kroah-Hartman), has also confirmed this viewpoint. His recommendation of what kernel should be used (ranked from best to worst) is as follows: [7] [8]

  1. Supported kernel from your favorite Linux distribution.
  2. Latest stable release.
  3. Latest LTS release.
  4. Older LTS release that is still being maintained.

In Debian's case, it is noted that the distribution kernel is not based on the latest stable upstream kernel release, but they still ensure that any necessary bug fixes are applied on a regular basis.

Kicksecure developers have also noted there is a risk of instability and breakage when utilizing kernels from Debian backports. [9] For instance, this had previously resulted in Qubes breakage [10] and caused mismatches in the kernel image versus kernel headers.

One possible exception to the recommendation in this section concerns Kicksecure-Qubes users, since the dom0 kernel applies to all qubes by default. To benefit from a number of recent security developments, the use of in-VM kernelsarchive.org is a prerequisite.

TODO: This wiki page needs an update due to article: Are all Linux vendor kernels insecure? A new study says yes, but there's a fixarchive.org

  • It may not be actionable by users or developers. Stable kernels from kernel.org are not packaged for Debian. Even if they were, they are probably not suitable for installation by default due to issues with maintainability.

Kernel Parameter[edit]

illegal hardware instruction[edit]

gather_data_sampling=force - Enable Gather Data Sampling (GDS) mitigation - related to CPU AVX instruction; More CPU Mitigations and Additional Referencesarchive.org

Kernel Issues[edit]

Sometimes updated kernel versions can cause issues. This has only been an issue for major kernel upgrades such as when performing instructions below. This has never been an issue when performing standard ("everyday") updates.

Host kernel version 5.15 was reportedarchive.org to cause many unrelated, strange issues inside VirtualBox VMs because that kernel version was still unsupported by VirtualBox. [11]

  • host freezearchive.org
  • segmentation faults in many applications
  • SIGSEGV errors in all chromium based browsers
  • broken sdwdate
  • broken swap-file-creator
  • broken update and upgrades with bizarre unusual otherwise never seen errors such as Hash Sum Mismatch
  • Tor Browser was reportedarchive.org to have crashed inside VirtualBox with Segmentation fault (core dumped).
  • msgcollectorarchive.org issue was reportedarchive.org error_text: ‘exit_code: 0 | text: Failed to set up inotifywait! inotifywait_folder: /run/msgcollector | wait_exit_code: 141’

Installation of Newer Kernels[edit]

Preparation[edit]

Kicksecure[edit]

Kicksecure: No preparation is required.

Kicksecure for Qubes[edit]

Kicksecure-Qubes: A Qubes VM kernel is required.

  1. Follow the Qubes OS Installing kernel in Debian VMarchive.org instructions.
  2. Ensure the Qubes VM kernel is functional before proceeding -- Qubes VM kernel issues should be raised at Qubes supportarchive.org and not in Kicksecure forums. [12] [13]
  3. Reboot dom0 with Qubes VM kernel. This is because Qubes VM kernel might break unrelated things such as the USB VM. [14]
  4. Once the Qubes VM kernel is functional, proceed with the following instructions.


Package Installation[edit]

Testers only! Warning: This is for testers-only!

[15]

linux-image-$(dpkg --print-architecture) linux-headers-$(dpkg --print-architecture) can be installed from Debian backports. This is non-ideal, see footnote. [16]

1. Boot Kicksecure (kicksecure-17) Template.

2. Add the current Debian stable backports codename bookworm-backports to Debian apt sources.

Note: this applies to Kicksecure 17.2.8.0. Later Kicksecure versions may use a codename different to bookworm.

In Kicksecure (kicksecure-17) Template, run.

sudo su -c "echo -e 'deb tor+https://deb.debian.org/debian bookworm-backports main contrib non-free' > /etc/apt/sources.list.d/backports.list"

Alternatively, users who like Onionizing Repositories can set the .onion mirror.

sudo su -c "echo -e 'deb tor+http://2s4yqjx5ul6okpp3f2gaunr2syex5jgbfpfvhxxbbjwnrsvbk5v3qbid.onion/debian bookworm-backports main contrib non-free' > /etc/apt/sources.list.d/backports.list"

3. Update the package lists.

sudo apt update

4. Install the select software.

sudo apt -t bookworm-backports install linux-image-$(dpkg --print-architecture) linux-headers-$(dpkg --print-architecture)

The procedure is now complete.

5. Undo.

On occasion it is necessary to undo this configuration, for example when upgrading from Debian bookworm to trixie. [17] To proceed, run.

sudo rm /etc/apt/sources.list.d/backports.list

These steps can be repeated for any other host operating system installations or other VMs.

See Also[edit]

Footnotes[edit]

  1. https://www.kernel.org/category/releases.htmlarchive.org
  2. These must be compiled from source.
  3. To tell if you are running a distribution kernel, in a terminal run: uname -r. If anything appears after the dash, then a distribution kernel is in use. At the time of writing, Debian is utilizing the following distribution kernelarchive.org: 4.19.98-1+deb10u1.
  4. https://forums.whonix.org/t/kernel-recompilation-for-better-hardening/7598?page=11archive.org
  5. https://www.grsecurity.net/the_truth_about_linux_4_6archive.org
  6. See also: Debian wiki Kernel FAQarchive.org.
  7. http://kroah.com/log/blog/2018/08/24/what-stable-kernel-should-i-use/archive.org
  8. He also notes that an unmaintained kernel release should never be used.
  9. https://forums.whonix.org/t/kernel-versions-and-security-debian-backports/5791archive.org
  10. See: https://github.com/QubesOS/qubes-issues/issues/4443archive.org
  11. https://www.virtualbox.org/ticket/17055#comment:3archive.org
  12. https://forums.whonix.org/t/what-to-post-in-this-qubes-whonix-forum-and-what-not/2275archive.org
  13. Qubes feature request: Simplify and promote using in-vm kernelarchive.org
  14. As experienced firsthand by Kicksecure developer Patrick Schleizer.
  15. Past Debian issue: linux-image-amd64 vs linux-headers-amd64 Debian buster-backports version mismatch bpo.2 vs bpo.3archive.org
  16. Users should Prefer Packages from Debian Stable Repository, but using backports is better than manual software installation or using third party package managers since this prefers APT. To contain the risk,
  17. Most often this step applies before attempting major Kicksecure upgrades; upgrade instructions are also made available at that time (see Stay Tuned).

We believe security software like Kicksecure needs to remain Open Source and independent. Would you help sustain and grow the project? Learn more about our 12 year success story and maybe DONATE!