Operating System Linux

Patch Kernel Vulnerabilities on AlmaLinux 9 and Rocky Linux 9 (Dirty COW and Later)

How to check a RHEL 9 family server for Dirty COW or any newer kernel CVE, install the fixed kernel with DNF, reboot, verify, and automate security updates.

Dirty COW (CVE-2016-5195) was a race condition in the Linux kernel's copy-on-write handling that let any local user gain root. It affected the kernels shipped with RHEL and CentOS 5, 6 and 7 and was fixed upstream in October 2016. This guide shows how to find out whether a server is affected by Dirty COW or by any later kernel vulnerability, and how to patch it, on AlmaLinux 9, Rocky Linux 9 and the rest of the RHEL 9 family. The same four steps work for every kernel CVE: identify the running kernel, look the CVE up, install the fixed kernel, reboot.

Is your server still affected by Dirty COW?

Almost certainly not, unless it runs an operating system that is itself out of support.

  • AlmaLinux 9, Rocky Linux 9, CentOS Stream 9, RHEL 9: not affected. Their kernel is based on Linux 5.14, which contains the 2016 fix.
  • CentOS 7: fixed kernels were released in 2016, so a fully updated system is safe from this bug. CentOS 7 reached end of life on 30 June 2024, however, and receives no fixes for anything discovered since.
  • CentOS 5 and 6: end of life since 2017 and 2020. Updates are no longer published on the regular mirrors, so an unpatched machine cannot simply be updated.

For an end-of-life release the answer is migration, not patching: move the workload to AlmaLinux 9 or Rocky Linux 9 (a new server is cleaner than an in-place conversion). Older tutorials suggest a SystemTap script as a manual workaround; it was only ever a temporary mitigation that disappears on reboot and is not a substitute for a fixed kernel.

Step 1: Identify the running kernel

A fixed kernel that is installed but not booted does not protect you, so always compare the running kernel with the installed ones:

cat /etc/redhat-release
uname -r
rpm -q kernel --last

uname -r prints the kernel in memory; rpm -q kernel --last lists installed kernels, newest first. If the first line of the list is newer than the running kernel, the server is waiting for a reboot.

Step 2: Check whether a CVE is fixed

Search the kernel package changelog

Red Hat records the CVE identifiers of backported fixes in the kernel package changelog, and AlmaLinux and Rocky Linux rebuild the same sources. To check the running kernel for a given CVE:

rpm -q --changelog kernel-core-$(uname -r) | grep -i CVE-2016-5195

Output means the fix is in that build. No output means either that the kernel is not fixed or that the kernel line was never affected (Dirty COW on a 9.x system is the second case, because the fix predates the 5.14 code base). The vendor's CVE page tells you which it is: look the identifier up at https://access.redhat.com/security/cve/CVE-2016-5195, which lists the affected products and the advisory that fixed each one.

Ask DNF about pending security advisories

The repositories carry advisory metadata, so DNF can tell you whether an available update fixes a specific CVE:

sudo dnf updateinfo list --cve CVE-2016-5195
sudo dnf updateinfo info --cve CVE-2016-5195

Replace the identifier with the CVE you are investigating. An empty result means that no pending update on this system addresses it. To see every outstanding security advisory, or only those for the kernel:

sudo dnf updateinfo list --security
sudo dnf updateinfo list --security kernel\*

CPU and hardware vulnerabilities

For processor flaws such as Spectre and its successors, the kernel reports its own mitigation status:

grep -r . /sys/devices/system/cpu/vulnerabilities/

Each line reads Not affected, Mitigation: … or Vulnerable. Fixing a Vulnerable entry usually takes a kernel update and often a microcode update as well (the microcode_ctl and linux-firmware packages).

Step 3: Install the fixed kernel

The simplest and safest fix is a full update:

sudo dnf upgrade --refresh

If you must limit the change, DNF can apply security updates only, or only the packages that fix one CVE:

sudo dnf upgrade --security
sudo dnf upgrade --cve CVE-2016-5195

A new kernel is installed alongside the old one and becomes the default boot entry; the previous kernels stay in the boot menu as a fallback. Confirm the default before rebooting:

sudo grubby --default-kernel

Step 4: Reboot and verify

DNF can tell you whether a reboot is needed for the installed updates to take effect:

sudo dnf needs-restarting -r

Reboot, then repeat the checks from steps 1 and 2:

sudo systemctl reboot
uname -r
sudo dnf updateinfo list --security kernel\*

The running kernel should now match the newest installed one, and the advisory list for the kernel should be empty. If the server does not come back up, pick the previous kernel from the boot menu in your provider's web console and investigate from there.

Keep kernels patched automatically

Install dnf-automatic so that security updates are downloaded and applied without waiting for you:

sudo dnf install -y dnf-automatic

In /etc/dnf/automatic.conf, set upgrade_type = security and apply_updates = yes, then enable the timer:

sudo systemctl enable --now dnf-automatic.timer

Automatic updates install the new kernel but do not load it unless you also configure a reboot, so keep checking dnf needs-restarting -r or schedule a regular maintenance reboot.

Live patching without a reboot

RHEL 9 can apply fixes for selected Critical and Important kernel CVEs to the running kernel with kpatch. On a subscribed RHEL system:

sudo dnf install -y kpatch-dnf
sudo dnf kpatch auto
sudo kpatch list

The live patches themselves are kpatch-patch packages built for one exact kernel version and delivered through Red Hat subscriptions. On AlmaLinux and Rocky Linux, check whether your repositories offer any before planning around them:

dnf list --available 'kpatch-patch*'

If nothing is listed, live patching on those distributions means a third-party commercial service, and the regular update-and-reboot cycle described above remains the standard method. Live patches cover only part of all kernel fixes, so even with them you still need periodic reboots into a new kernel.

Frequently asked questions

Why does my kernel version look older than the version that fixed a CVE upstream?

Enterprise distributions backport fixes instead of moving to newer upstream kernels. A 9.x system always reports a 5.14.0-…el9 kernel, no matter how many later fixes it contains. Compare the package release (the part after the dash) with the vendor advisory, never the upstream version number.

Do containers need to be patched separately for kernel bugs?

No. Containers share the host's kernel, so updating and rebooting the host fixes kernel vulnerabilities for every container on it. Userspace libraries inside the images are a separate matter and need their own updates.

On a VPS, who is responsible for the kernel?

On KVM and other fully virtualised servers the kernel is yours: you update and reboot it as shown here. On container-based plans (OpenVZ, LXC) the kernel belongs to the host node, uname -r shows the provider's kernel, and only the provider can patch it.

Can I avoid updating by blocking the exploit some other way?

Vendors sometimes publish temporary mitigations, such as disabling a module or a sysctl setting, for the days before a fixed kernel is available. Use them only as a stopgap. Dirty COW, like most privilege escalation bugs, needs local code execution, so limiting shell access reduces exposure but does not remove the flaw.

Share story:

Continue reading other guides on How VPS.