freenode
Kernel & Low-Level

RISC-V livepatch still waiting as unwinder series hits v7

Shuai Xue's frame-pointer work would let RISC-V apply kernel fixes without a reboot, and it now includes fixes for traces that have been wrong since Linux 6.8.

Linux still cannot live-patch a running RISC-V kernel. A seventh revision of the work that would change that was posted to the kernel mailing list on 10 November, with its author asking maintainers to consider it for the 7.4 merge window.

Livepatch, the mechanism other architectures use to apply security fixes without a reboot, needs a stack unwinder that can say with certainty which functions sit on a task's stack. RISC-V has not had one. The patches, started by Wang Han at Alibaba and now carried by colleague Shuai Xue after Wang left the team, add explicit frame-record metadata and a conservative frame-pointer unwinder, then turn livepatch on. The work has been under review since late May.

Review has also exposed bugs in the unwinder RISC-V already ships. Karl Mehltretter showed that, with frame pointers enabled, saved stack traces start one frame too early, so tools such as page_owner record the wrong caller, and that return-address lookups used by the irqsoff tracer skip a real caller. His fix and a KUnit test are folded into this revision.

A separate change, marked for stable, fixes the function-graph tracer's return-address cookie. On the dynamic ftrace path that distribution kernels actually use, that cookie has never matched anything the unwinder can reproduce, a mismatch dating to Linux 6.8. While the tracer is running, stack dumps, perf callchains and the scheduler's wchan reporting show the tracer's own return handler instead of the real caller.

Martin Kaiser tested the carried-over patches on RISC-V QEMU and on a CHERI RISC-V system and reported livepatch working on both. The CHERI adjustments, he wrote, are "simple fixups of data types and assembly instructions" and "isn't something that can be upstreamed at this point." Miroslav Benes has acked the patch that enables livepatch. Palmer Dabbelt and Paul Walmsley have been asked to take the work for 7.4. It is not merged.