mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/4] PM: hibernate: encrypted snapshots under lockdown
@ 2026-09-17 13:26 Sean Rhodes
  2026-09-17 13:26 ` [PATCH v3 1/4] PM: hibernate: add seed-wrapped encrypted snapshots Sean Rhodes
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sean Rhodes @ 2026-09-17 13:26 UTC (permalink / raw)
  To: linux-pm
  Cc: Rafael J. Wysocki, Len Brown, Pavel Machek, Sean Rhodes,
	Evan Green, linux-kernel, Jens Axboe, Andrew Morton, Chris Li,
	Kairui Song, Kemeng Shi, Nhat Pham, Baoquan He, Barry Song,
	Youngjun Park, linux-block, linux-mm, Xueqin Luo,
	Nicolas Bouchinet

PM: hibernate: encrypted snapshots under lockdown

This is v3 of the encrypted userspace hibernation series. It protects
userspace-driven hibernation images against modification before resume,
including when the kernel is locked down.

The kernel encrypts and authenticates snapshot data and wraps the randomly
generated image key using a seed supplied by trusted early userspace. TPM
policy remains outside the kernel PM code: early userspace is responsible for
unsealing the seed under the intended PCR policy and writing it to the
write-only snapshot_seed interface. The series therefore provides the kernel
mechanism needed by a TPM-backed design; it does not itself configure or
enforce TPM policy.

The kernel accepts the first valid seed written after boot and does not
authenticate its writer or enforce image freshness. Trusted early userspace
must provision the seed before untrusted privileged code can run and must
provide the required TPM policy, rollback protection and recovery handling.

Patch 2 confines direct block-device write() calls to the active swap backend
to the process which owns the encrypted snapshot, its allocated swap extents,
the recorded swap-header page and the number of pages allocated through the
snapshot API. The userspace writer must use synchronous buffered I/O.

On a StarFighter MTL with Secure Boot disabled and integrity lockdown selected
manually, the encrypted userspace snapshot path completed full S4 and resume
cycles both without and with an additional user key. In each case the original
process and boot ID resumed and the swap header was restored. Corrupted wrapped
data, invalid wrapped-data magic, a corrupted complete-chunk authentication
tag and an incorrect user key were rejected.

The late user-key transition exercised by those tests is retained. This
revision also validates that a userspace-supplied encrypted metadata boundary
matches the authenticated image header; that mismatch rejection has not been
exercised on hardware. The encrypted S4 paths were tested on the prior
candidate; the revised allocated-page accounting and active-backend handling
have not been rerun on hardware.

The deliberately corrupted complete on-disk image case was not run because
the test system did not have a reviewed pre-root recovery mechanism for
restoring its swap header.

Previous version:
https://lore.kernel.org/all/cover.1785838445.git.sean@starlabs.systems/

Changes in v3:
- Rebase on current upstream master.
- Complete both keyless and user-key hardware S4/resume cycles.
- Exercise rejection of corrupted wrapped data, invalid blob magic, a
  corrupted complete-chunk tag and an incorrect user key.
- Preserve and validate the saved encrypted metadata boundary on resume.
- Drain buffered metadata before a late user-key transition.
- Reserve enough encrypted image space if userspace adds a user key after
  querying the image size.
- Apply swap-write confinement before enabling the lockdown exception, while
  preserving the ordinary availability check which routes lockdown writes to
  the confined path.
- Account the pages actually allocated through the snapshot API instead of
  assuming a userspace swap-map format.
- Document the first-writer, anti-replay and userspace I/O requirements.
- Remove an unused swap reverse-mapping helper and tighten local naming.

Changes in v2:
- Keep raw writes to active swap blocked under lockdown.
- Track encrypted snapshot bytes and header writes before allowing
  lockdown-time image writes.
- Split the encrypted stream at the metadata boundary only when a user-key
  transition is used.
- Return -EFAULT for userspace copy failures.
- Document resume meta_size handling.

Evan Green (1):
  PM: hibernate: add seed-wrapped encrypted snapshots

Sean Rhodes (3):
  PM: hibernate: confine encrypted snapshot writes
  PM: hibernate: permit encrypted snapshot device under lockdown
  PM: hibernate: document encrypted snapshot seed ABI

 Documentation/ABI/testing/sysfs-power   |  18 +
 Documentation/power/userland-swsusp.rst |  33 +
 block/fops.c                            |  58 +-
 include/linux/suspend.h                 |  24 +
 include/linux/swap.h                    |   9 +
 include/uapi/linux/suspend_ioctls.h     |  31 +-
 kernel/power/Kconfig                    |  15 +
 kernel/power/Makefile                   |   1 +
 kernel/power/hibernate.c                |  32 +
 kernel/power/power.h                    |   3 +
 kernel/power/snapenc.c                  | 952 ++++++++++++++++++++++++
 kernel/power/snapshot.c                 |   5 +
 kernel/power/swap.c                     |  87 +++
 kernel/power/user.c                     | 272 ++++++-
 kernel/power/user.h                     | 150 ++++
 mm/swapfile.c                           |  25 +
 16 files changed, 1683 insertions(+), 32 deletions(-)
 create mode 100644 kernel/power/snapenc.c
 create mode 100644 kernel/power/user.h


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-17 13:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 13:26 [PATCH v3 0/4] PM: hibernate: encrypted snapshots under lockdown Sean Rhodes
2026-09-17 13:26 ` [PATCH v3 1/4] PM: hibernate: add seed-wrapped encrypted snapshots Sean Rhodes
2026-09-17 13:26 ` [PATCH v3 2/4] PM: hibernate: confine encrypted snapshot writes Sean Rhodes
2026-09-17 13:26 ` [PATCH v3 3/4] PM: hibernate: permit encrypted snapshot device under lockdown Sean Rhodes
2026-09-17 13:26 ` [PATCH v3 4/4] PM: hibernate: document encrypted snapshot seed ABI Sean Rhodes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®