[TUTORIAL] hvpatch – kernel live patching for Proxmox VE 9 (early release, feedback and testers wanted)

CSakel

Active Member
Aug 4, 2020
13
8
43
24
prepaid-host.com

hvpatch: kernel live patching for Proxmox VE​


Hi all,

I'm Christopher from Prepaid-Host, a hoster running Proxmox VE 9 for customer VMs. We built an open-source tool that applies kernel security fixes to running PVE hosts without a reboot, and we'd like your feedback before taking it further.

GitHub: https://github.com/prepaid-host/hvpatch · GPL-2.0 · early release

Why​

  • Each one means drain, reboot, refill. Passthrough VMs and single nodes get real downtime.
  • Until the reboot, hosts with customer VMs stay exposed to guest-to-host bugs.
  • KernelCare doesn't support PVE 9, and Proxmox will "re-evaluate" livepatching, without promises.

How it works​

  • Build: the kernel's own klp-build (mainline since 6.19), against the exact Proxmox source, config and toolchain. Any mismatch stops the build.
  • Checks: every module is verified against the shipped kernel and booted in QEMU before it is signed.
  • Catalog: one reviewed entry per CVE, saying clearly "fixed live" or "reboot required".
  • Agent: a small Rust binary (.deb). It verifies signature, kernel build-id and hash, loads the patch, reverses instead of forcing when something goes wrong, and reloads it after a reboot before the guests start.
  • No central server: a static HTTPS repo, nodes pull, your Ansible decides the order. Bring your own keys.

Tested so far​

Nested PVE 9.2 on a real host, kernels 7.3.4-1 and 7.3.5-1:

TestResult
3 real CVE fixes (mm/gup.c, overlayfs) as livepatchExploit blocked, works again after revert
20 apply/revert cycles, guests under load (memory with checksums, 15 Gbit/s)No errors, no kernel warnings, ~1.6 s per transition
Transition blocked by a sleeping taskReversed after timeout, no force
Secure Boot with MOK, legacy BIOS, reload after rebootOK
Module rebuildBit-identical

Not yet: bare metal and a multi-node rollout. That's next.

Limits​

  • A bridge to your next maintenance window, not a replacement for kernel updates.
  • Opt-in 7.3 kernels only for now. The 7.0 tree lacks the objtool support klp-build needs.
  • Data structure changes, ZFS and QEMU fixes still need a reboot; hvpatch status tells you which.
  • No prebuilt modules yet: you build your own (~2 h and ~60 GB per kernel).
  • Independent project, not affiliated with Proxmox.

Try it (test hosts only)​

Bash:
wget https://github.com/prepaid-host/hvpatch/releases/latest/download/hvpatch_amd64.deb
apt install ./hvpatch_amd64.deb
hvpatch setup --repository https://your.repo --key manifest.pub
hvpatch check
Building your own modules: self-hosting guide

Questions to you​

  1. Is the opt-in 7.3 kernel fine for you, or is 7.0 support a must?
  2. Own builds with your own keys, or signed modules built by the project?
  3. Anyone up for reviewing catalog entries? Each needs two reviewers.

Thanks for reading, happy to answer questions!
Christopher
 
Last edited:
As you know, 7.3 is just for testing at the moment and not suggested for production, so 7.0 would be great or we all just wait.

I really appreciate what you want to create for PVE users and look forward to use it in production.
Thanks, that's a fair point, and I agree: for production, 7.0 is what matters.

The reason 7.3 came first is technical, not a preference. The 7.0 kernel is built from the Ubuntu-based tree, and since 7.0.14-25 Proxmox builds objtool there without the livepatch support (HAVE_XXHASH=n in this commit). The Ubuntu base carries objtool/klp changes from 7.2.y without some helpers they need, and klp-build isn't used there, so it was simply switched off. 7.3 is plain upstream stable and works out of the box.

What I'm working on for 7.0:
  • take objtool and klp-build consistently from a 7.2.y release and build with them against the 7.0 tree
  • keep the existing check that our own build of the unpatched kernel matches the one Proxmox ships, so a different objtool can't sneak in a difference
  • run the same test chain as on 7.3 (Gate A, QEMU stage, real host)

No date promises, but I'll post here when 7.0 builds pass the tests.
 
Update: hvpatch 0.3.0 supports the default 7.0 kernel

Thanks for the feedback so far, especially @LnxBil for pushing for 7.0. hvpatch 0.3.0 is out, and livepatches now work for the default kernel series 7.0 of PVE 9 (tested with 7.0.14-30-pve). Support is still marked experimental.

Release: https://github.com/prepaid-host/hvpatch/releases/tag/v0.3.0

What was needed for 7.0
  • The 7.0 tree is built from pve-kernel.git exactly as Proxmox prepares it, pinned to a commit in builder/kernels.lock.
  • klp-build in 7.0 needs six upstream objtool commits. Proxmox builds objtool without xxhash, and klp-build needs xxhash for its checksums. The commits are vendored in builder/kernel-7.0/, and everything else in the tree stays as shipped.
  • Config and toolchain match the shipped kernel. The build checks this before it starts.

How it was tested
Three-node PVE 9.2 cluster on 7.0.14-30-pve, two guests per node with CPU, memory, disk and network load (iperf between the guests).
  • QEMU stage on the shipped kernel. The reproducer shows vulnerable, fixed, vulnerable again after unloading, and fixed again. The new level replaces the previous one under load, then 5 patch/unpatch cycles run, and the kernel log stays clean.
  • hvpatch apply on all three nodes under load: 12–16 s per node (download, signature checks, post-check). The transition itself took 1.5–5 s. Guests were pinged every 100 ms, with no lost packets and a longest gap of 0.11 s. No warnings in the kernel log.
  • Revert and re-apply, and the timer respects the hold after a revert.
  • Reboot with the repository unreachable: the boot unit reloads the cached level about 7 s after boot.
  • Concurrent apply on two nodes: the second waits for the cluster lock in pmxcfs.
  • Revocation: a revoked level is taken out of service on the next run. If the revocation list is withheld after one was accepted, nothing new is loaded.

Also new in 0.3.0
Signed revocation list, states for fixes with callbacks or shadow variables, hvpatch-tool cve-scan against the kernel CNA data, the build split into four isolated containers, and integrations (Checkmk check, Ansible role, notification hook).

Limits
  • Experimental. Run it on a test cluster first.
  • There are no prebuilt modules from the project yet. You build and sign with your own keys (docs/self-hosting.md and docs/kernel-7.0.md). The first build of a kernel release takes about 3 hours on 4 cores, and later levels reuse it (about 35 minutes).
  • Livepatches bridge the time to the next maintenance window. They do not replace rebooting into a fixed kernel.

Feedback from anyone who tries it on a 7.0 test node is very welcome, especially on other hardware.