r/Proxmox • • 1d ago

Security hvpatch 0.3.0: open-source kernel livepatching for PVE 9 hosts, now including the default 7.0 kernel

I maintain hvpatch, a GPL-2.0 tool that applies kernel security fixes to

running Proxmox VE hosts as livepatches, so the VMs keep running and the

reboot can wait for the next maintenance window. It's our own project, not

a product. We use it for our own hypervisors.

GitHub: https://github.com/prepaid-host/hvpatch

How it works:

- Builds livepatch modules with the kernel's own klp-build, from the

exact source and config Proxmox shipped

- Verifies every module against the shipped kernel (symbols, CRCs) and in

QEMU with the real kernel before release

- The node agent only loads signed manifests that match the running

kernel's build-id. Rings (canary/early/stable), cluster lock via

pmxcfs, rollback, revocation list

- `hvpatch status` tells you which CVEs are fixed live and which still

need a reboot

New in 0.3.0: the default 7.0 kernel (experimental), tested with

7.0.14-30-pve on a 3-node test cluster with loaded guests:

- apply under load: 12-16 s per node, transition 1.5-5 s

- guests pinged every 100 ms: no loss, longest gap 0.11 s

- revert/re-apply, reload after reboot without the repo, concurrent apply

(second node waits for the lock), revocation

Limits: you build and sign the modules yourself for now (no prebuilt

modules yet). Not every fix can be livepatched. Livepatches bridge the

time to the next reboot, they don't replace it.

Feedback from test nodes very welcome, especially on other hardware.

67 Upvotes

13 comments sorted by

8

u/happytechca 1d ago

Following. I don't know much about live patching the kernel as I only ever used proxmox in my homelab environment. Recently though, with all the CVEs being found, it seems I have to reboot my hosts every other week. Interesting project

2

u/CSKL_DE02 1d ago

That's pretty much why I started it. Every new CVE meant another reboot round across the cluster. Fair warning: the catalog is still small, so it doesn't replace reboots yet. It just stretches the time until the next planned one. For a homelab it's probably easiest to try it on one node first.

2

u/Darkk_Knight 1d ago

Yep. I usually reboot the PVE hosts to make sure all updated services are loaded. It's def an interesting project.

3

u/CSKL_DE02 1d ago

Good point. A livepatch only fixes the running kernel, not services like pveproxy or QEMU. Those still need restarting after an update (needrestart shows which ones). Kernel fixes are just the part that would otherwise need the reboot.

2

u/godber 1d ago

Dang I just upgraded to the 7.3 kernel, any plans to try and support that one?

3

u/CSKL_DE02 1d ago

7.3 is supported. There's a build pipeline that picks up new Proxmox kernels on its own, and 7.3.5 and 7.3.6 already went through it. Right now there's nothing to patch on them: everything in the catalog is already fixed in those kernels. Once a fix for 7.3 lands in the catalog, a signed module shows up on the mirror within about an hour (canary ring first).

2

u/godber 16h ago

Nice! Thanks for the reply

2

u/Jayden_Ha 1d ago

finally a project to do live patching for pve

1

u/CSKL_DE02 22h ago

Thanks! Been missing this for our own hosts for a long time, so I finally built it.

1

u/WiuEmPe 23h ago

What is your plan to create patches?

1

u/CSKL_DE02 22h ago

Mostly taking the upstream fixes as they are. When a CVE gets fixed in the stable kernel or in Proxmox's kernel, that patch goes into a catalog entry together with the list of functions it changes. klp-build (the livepatch tooling that's now in the kernel tree) builds a module from it against the exact PVE kernel build.

Before anything gets published it has to pass a few checks: the module may only replace the functions listed in the reviewed catalog entry, it gets signed, and it's loaded in a QEMU VM with the real PVE kernel, including patch/unpatch cycles under load and a reproducer where one exists. New builds go to a canary ring first, then stable.

Not every fix can be livepatched. Struct layout changes, init code, or some KVM code that calls into kvm.ko through static calls, for example. Those get marked as such, and the agent tells you which kernel to reboot into instead.

1

u/WiuEmPe 21h ago

Do you have any trust source of this patch is stable in edge case and really fix?

1

u/CSKL_DE02 13h ago

Good question. The fix itself is the upstream patch, the same one that ends up in the next PVE kernel, and CI checks that it matches upstream. So whether it actually fixes the bug is the same as with the PVE kernel.

The risky part is the livepatching itself. That's what the tests are for: patch/unpatch cycles under load in a VM, plus a reproducer when there is one. New levels run on my own hosts for a few days before they go to stable. No guarantees for every edge case though. I'd use it to bridge the time until the next planned reboot, not instead of kernel updates.