feat(kernel): the live patches the running kernel carries, in the kernel facts, 4.52.0 (NetOrk/netork#2701) #139

Merged
christianmanivong merged 6 commits from feature/live-kernel-patches into main 2026-11-28 09:59:40 +00:00
Owner

Stacked on #138 (feature/host-logins, now 4.51.0 on main's 4.50.0): this branch starts at its head. Merge #138 first; then this PR's diff is the live patch change alone.

get_kernel_facts() adds a live_patches key (NetOrk/netork#2701, decided 2026-11-28: A, then B for Canonical Livepatch first). Its parts:

  • loaded: every patch under /sys/kernel/livepatch, with enabled and transition. Generic, no package needed. None on a kernel built without live patching.
  • kpatch: kpatch list, the loaded modules with their state and the installed ones with their kernel. None without kpatch.
  • canonical: Canonical Livepatch's status for the running kernel, from canonical-livepatch status --format json. It has the kernel as Canonical names it, state, check_state, version, and the CVEs with whether each is patched. Both client formats are parsed: the 10.x list of fixes and the 9.x text, with keys in either case. None when the client is not installed or its status was not read. canonical_installed tells the two apart.
  • No network call: only status is run, which returns the daemon's last state. refresh (what contacts Canonical) is never run. Note: this is from the client's documented behaviour and the Ubuntu Pro client's use of the same command; it was not verified on a live Livepatch host.
  • Root: where the client is installed and its status does not read without root, a driver that supplies _run_livepatch_status_command(command) has LIVEPATCH_STATUS_COMMAND read again as root. This is one fixed, read-only command. A refusal leaves the status unread.
  • Exported: parse_canonical_status, canonical_release (Canonical's 5.15.0-91.101-generic as uname -r names it), LIVEPATCH_STATUS_COMMAND, LivePatchesDict, CanonicalLivepatchDict. KernelFactsDict.live_patches is NotRequired.

Tests: tests/test_live_patches.py with fixtures for sysfs, kpatch list, the 10.x and 9.x Canonical JSON, and the root fallback. tests/test_kernel_facts.py is unchanged and green. ruff and mypy are clean.

Version: 4.52.0, the next after this stack's 4.51.0 (v4.50.0 is #140's, merged into the stack).

**Stacked on #138** (`feature/host-logins`, now 4.51.0 on main's 4.50.0): this branch starts at its head. Merge #138 first; then this PR's diff is the live patch change alone. `get_kernel_facts()` adds a `live_patches` key (NetOrk/netork#2701, decided 2026-11-28: A, then B for Canonical Livepatch first). Its parts: - `loaded`: every patch under `/sys/kernel/livepatch`, with `enabled` and `transition`. Generic, no package needed. `None` on a kernel built without live patching. - `kpatch`: `kpatch list`, the loaded modules with their state and the installed ones with their kernel. `None` without kpatch. - `canonical`: Canonical Livepatch's status for the running kernel, from `canonical-livepatch status --format json`. It has the kernel as Canonical names it, `state`, `check_state`, `version`, and the CVEs with whether each is patched. Both client formats are parsed: the 10.x list of fixes and the 9.x text, with keys in either case. `None` when the client is not installed or its status was not read. `canonical_installed` tells the two apart. - **No network call:** only `status` is run, which returns the daemon's last state. `refresh` (what contacts Canonical) is never run. Note: this is from the client's documented behaviour and the Ubuntu Pro client's use of the same command; it was not verified on a live Livepatch host. - **Root:** where the client is installed and its status does not read without root, a driver that supplies `_run_livepatch_status_command(command)` has `LIVEPATCH_STATUS_COMMAND` read again as root. This is one fixed, read-only command. A refusal leaves the status unread. - Exported: `parse_canonical_status`, `canonical_release` (Canonical's `5.15.0-91.101-generic` as `uname -r` names it), `LIVEPATCH_STATUS_COMMAND`, `LivePatchesDict`, `CanonicalLivepatchDict`. `KernelFactsDict.live_patches` is `NotRequired`. Tests: `tests/test_live_patches.py` with fixtures for sysfs, `kpatch list`, the 10.x and 9.x Canonical JSON, and the root fallback. `tests/test_kernel_facts.py` is unchanged and green. ruff and mypy are clean. Version: 4.52.0, the next after this stack's 4.51.0 (v4.50.0 is #140's, merged into the stack).
christianmanivong added 4 commits 2026-11-28 04:02:21 +00:00
LoginAccountsMixin.get_login_accounts: root and UID 1000 on with a login
shell, from /etc/passwd without the comment field; the newest last login of
lastlog2, lastlog, wtmpdb last and last, with where it came from; the
password state and expiry from passwd -S and chage -l; the failed attempts
since the last login from lastb, else faillock. Root first, the login user
where root is refused, when what needs root is None.
chore(release): 4.50.0
driver / lint (pull_request) Successful in 16s
driver / standard (pull_request) Successful in 20s
driver / types (pull_request) Successful in 1m3s
driver / test (3.13) (pull_request) Successful in 1m19s
driver / test (3.12) (pull_request) Successful in 1m24s
driver / lowest (pull_request) Successful in 45s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Failing after 1m2s
CI / driver (pull_request) Failing after 2m41s
driver / publish (pull_request) Skipped
14217b6eeb
/sys/kernel/livepatch with each patch's enabled and transition, kpatch
list, and Canonical Livepatch's status for the running kernel with the
CVEs it names. status reads the daemon's last state; refresh is never run.
Where the client is installed and its status needs root, a driver that
supplies _run_livepatch_status_command reads it again as root.
chore(release): 4.51.0
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Failing after 18s
driver / types (pull_request) Successful in 1m2s
driver / test (3.13) (pull_request) Successful in 1m18s
driver / test (3.12) (pull_request) Successful in 1m27s
driver / lowest (pull_request) Successful in 43s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Failing after 1m0s
CI / driver (pull_request) Failing after 2m36s
driver / publish (pull_request) Skipped
61b7b68626
christianmanivong changed title from feat(kernel): the live patches the running kernel carries, in the kernel facts, 4.51.0 (NetOrk/netork#2701) to feat(kernel): the live patches the running kernel carries, in the kernel facts, 4.52.0 (NetOrk/netork#2701) 2026-11-28 07:28:13 +00:00
christianmanivong added 2 commits 2026-11-28 07:35:10 +00:00
Merge NAPALM/napalm-device-types main (4.50.0) into feature/host-logins
driver / lint (pull_request) Successful in 17s
driver / standard (pull_request) Successful in 21s
driver / types (pull_request) Successful in 59s
driver / test (3.13) (pull_request) Successful in 1m19s
driver / test (3.12) (pull_request) Successful in 1m26s
driver / lowest (pull_request) Successful in 47s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Failing after 1m5s
CI / driver (pull_request) Failing after 2m45s
driver / publish (pull_request) Skipped
4b4797e383
v4.50.0 went to #140, so this branch's release is 4.51.0 now.
Merge feature/host-logins (4.51.0, on main's 4.50.0) into feature/live-kernel-patches
driver / standard (pull_request) Failing after 18s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m1s
driver / test (3.12) (pull_request) Successful in 1m22s
driver / lowest (pull_request) Successful in 41s
driver / test (3.13) (pull_request) Successful in 1m13s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Failing after 58s
CI / driver (pull_request) Failing after 2m52s
driver / publish (pull_request) Skipped
780e4247a1
The live patches are 4.52.0 now.
christianmanivong added 3 commits 2026-11-28 09:48:07 +00:00
models.py had grown past its recorded size with the live patches;
KernelFactsDict moves to kernel_models, re-exported by models, and the
record shrinks to what is left (1336). The root read of Canonical's status
returns on a refusal instead of passing (bandit B110).
Merge remote-tracking branch 'origin/main' into feature/live-kernel-patches
driver / lint (pull_request) Successful in 12s
driver / standard (pull_request) Successful in 15s
driver / types (pull_request) Successful in 58s
driver / test (3.13) (pull_request) Successful in 1m8s
driver / test (3.12) (pull_request) Successful in 1m22s
driver / lowest (pull_request) Successful in 38s
driver / build (pull_request) Successful in 28s
driver / security (pull_request) Successful in 1m3s
CI / driver (pull_request) Successful in 2m26s
driver / publish (pull_request) Skipped
b8a50fffab
christianmanivong merged commit 5faf9a1021 into main 2026-11-28 09:59:40 +00:00
Sign in to join this conversation.