Skip to content

mm: memfd_luo: pick up seals added after preserve at freeze

Long Wei kexec linux-kselftest linux-mm lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesNew
  2. v12 patches 1 replySuperseded

Changes in v2 from the cover letter

- Add an __NR_fcntl64 fallback to LUO_FCNTL_NR in the selftest so it also builds on 32-bit architectures using the generic syscall table (riscv32, csky, nios2), where __NR_fcntl does not exist.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2mm: memfd_luo: pick up seals added after preserve at freezemm/memfd_luo.c+25 -20 replies
2/2selftests/liveupdate: add seal-after-preserve kexec testtools/testing/selftests/liveupdate/Makefile tools/testing/selftests/liveupdate/luo_seal_after_preserve.c tools/testing/selftests/liveupdate/run-vmtests.sh+172 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] mm: memfd_luo: pick up seals added after preserve at freeze

A seal added to a memfd after the memfd was preserved with a liveupdate session is accepted without any error, but the seal is silently gone once the kexec handover is over: the retrieved memfd no longer has it.

memfd_luo_preserve() snapshots the file seals, but userspace may keep operating on the memfd until the handover, so the preserve-time snapshot is naturally incomplete. memfd_luo_freeze() never re-read the seals and memfd_luo_retrieve() replays the stale snapshot, so seals added in the window between preserve() and kexec were dropped without any notice.

Patch 1 re-reads the seals at freeze time, mirroring the file position
handling: freeze is the last snapshot point before kexec and the only place where the final value can still be sampled and, when it diverged from the preserve-time snapshot, validated while the live update can still be aborted.

Patch 2 adds a kexec round-trip selftest that adds F_SEAL_GROW after preserve and asserts that the seal survives the handover.

Tested on arm64 and x86_64 with two consecutive kexec handovers each:
with the fix the seal survives and dmesg stays free of new warnings.

This series applies on the current next branch of liveupdate.git, where the file is still named memfd_luo.c. I am aware of the pending "mm: Rename memfd_luo to shmem_luo" series. If that series lands first, a trivial s/memfd_luo/shmem_luo/ rebase will be needed, which I am happy to provide.

Changes in v2:
- Add an __NR_fcntl64 fallback to LUO_FCNTL_NR in the selftest so it also builds on 32-bit architectures using the generic syscall table (riscv32, csky, nios2), where __NR_fcntl does not exist.

Long Wei (2):
mm: memfd_luo: pick up seals added after preserve at freeze selftests/liveupdate: add seal-after-preserve kexec test

 mm/memfd_luo.c                                |  27 ++-
 tools/testing/selftests/liveupdate/Makefile   |   1 +
 .../liveupdate/luo_seal_after_preserve.c      | 170 ++++++++++++++++++
 .../selftests/liveupdate/run-vmtests.sh       |   1 +
 4 files changed, 197 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/liveupdate/luo_seal_after_preserve.c
Signature · 1 line
2.43.0