Skip to content

fix(watchdog): arm pre-pivot and inherit the fd across the pivot#15

Open
ananthb wants to merge 1 commit into
mainfrom
fix/watchdog-pre-pivot-fd
Open

fix(watchdog): arm pre-pivot and inherit the fd across the pivot#15
ananthb wants to merge 1 commit into
mainfrom
fix/watchdog-pre-pivot-fd

Conversation

@ananthb

@ananthb ananthb commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Bug

Post-pivot, the supervisor reopened /dev/watchdog by path, but xmorph's pivoted /dev doesn't expose the watchdog node, so arming failed and fell back to modprobe softdog — which also can't work: pivot_root keeps the running host kernel, and the in-RAM rootfs has no softdog.ko for it. On a box with a perfectly good wdat_wdt (ACPI WDAT) hardware watchdog, this aborted the run before flatcar-install ever executed (found dogfooding the enterprise→pwu1 reprovision; the pre-fix run died at watchdog: cannot arm post-pivot).

Fix

pivot_root doesn't change the kernel, so a watchdog opened before the pivot keeps ticking after it. So:

  • ArmWatchdogPrePivot opens + arms /dev/watchdog on the host /dev, sets the timeout, and clears FD_CLOEXEC.
  • The fd rides across pivot_root and the exec into the supervisor via XMORPH_WATCHDOG_FD.
  • The supervisor AdoptWatchdogs that same live fd and pets it — no reopen by path, no softdog.
  • Armed immediately before the pivot so the un-petted window is just the mount sequence + exec; disarmed on any abort before exec.

The pre-pivot EnsureWatchdogAvailable fail-fast check stays (validates while the old OS is fully alive). softdog remains only as a pre-pivot fallback, where it can load.

Test

GOOS=linux go build ./..., go vet ./..., gofmt, native postpivot/config/log tests — all clean. Real-kernel behavior exercised on the enterprise reprovision.

The post-pivot supervisor reopened /dev/watchdog by path, but the pivoted
rootfs's /dev doesn't expose the node, so arming failed and fell back to
modprobe softdog — which also can't work: pivot_root keeps the running host
kernel and the in-RAM rootfs has no softdog.ko for it. Seen on a box with a
working wdat_wdt (ACPI WDAT) watchdog: post-pivot 'watchdog: cannot arm'
aborted before the entrypoint (flatcar-install) ever ran.

pivot_root doesn't change the kernel, so a watchdog opened before the pivot
keeps ticking after it. ArmWatchdogPrePivot opens+arms /dev/watchdog on the
host, clears FD_CLOEXEC, and the fd is handed to the supervisor across the
exec via XMORPH_WATCHDOG_FD; the supervisor pets that same live device
(AdoptWatchdog) instead of reopening by path. Armed right before the pivot
so the un-petted window is just the mount sequence + exec, and disarmed on
any abort before exec. Non-linux stubs added.

Found dogfooding the enterprise->pwu1 Flatcar reprovision.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant