[PATCH v2] pstore: add a KHO backend

Kees Cook kees at kernel.org
Wed Jun 10 13:34:10 PDT 2026


On Fri, Jun 05, 2026 at 02:10:40PM +0200, Michal Clapinski wrote:
> Up to this point to preserve late shutdown logs in memory, users had to
> predefine a memory region using ramoops. This commit changes this by
> preserving a buffer using kexec-handover.
> 
> pstore_kho supports preserving only 1 dmesg buffer.
> It gets replaced with the new buffer on every kexec, so the user has to
> copy the file out of pstore after every kexec.
> There is no erase() support.
> 
> Signed-off-by: Michal Clapinski <mclapinski at google.com>

I'm a fan of the idea! I'd love to see a selftest added for this
backend, since it should be possible to do a direct tests for dmesg
preservation across a kexec in tools/testing/selftests/pstore/

There is still good feedback from sashiko, which caught everything I was going
to mention and then some:
https://sashiko.dev/#/patchset/20260605121040.1177072-1-mclapinski%40google.com

> ---
> v2:
> - Added a comment explaining the benefits of pstore_kho.
> - Created include/linux/kho/abi/pstore.h.
> - Got rid of the KHO subtree.
> - Made sure never to free incoming kho data.
>   This way the module can be safely reloaded.
> - Sashiko complained that I trust the data coming from the old kernel.
>   I ignored it. LMK if I shouldn't trust the old kernel.

We shouldn't trust the old kernel. :) Sashiko's suggestion here seems
reasonable which is to at least bounds-check the size against
RECORD_MAX_SIZE since that's the largest it should ever be.

-Kees

-- 
Kees Cook



More information about the kexec mailing list