CrOS: Add a swap storage interface/implementation.
This adds a Swap File interface which is a generic interface which contains operations to write to, read from, and drop contents from a swap file. We also add three different swap file implementations on top of the standard swap file, which include a compressed, encrypted, and compressed + encrypted swap file. The compressed swap file implementation is a standard gzip implementation. The encrypted swap file uses AES 256 GCM SIV mode with a 256bit ephemeral key which is randomly generated and a randomly generated nonce. All swap files will write to /mnt/stateful_partition/unencrypted/swap if it exists otherwise swap file creation will fail. The key never leaves the internal EncryptedSwapFile implementation. The swap files are created as O_TMPFILE | O_EXCL meaning they do not actually link and O_EXCL prevents them being linked to the file system, so all space is reclaimed when the file descriptor is closed. Disk space can be incrementally reclaimed after memory has been read out of the swap file using the DropFromSwap API. It uses fallocate(2) with FALLOC_FL_PUNCH_HOLE. Bug: 1067833 Change-Id: Ifeacec0ed5571507f80add2cf43fdd4063478459 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2142474Reviewed-by:Ilya Sherman <isherman@chromium.org> Reviewed-by:
Steven Bennetts <stevenjb@chromium.org> Reviewed-by:
Robert Sesek <rsesek@chromium.org> Reviewed-by:
Matthew Denton <mpdenton@chromium.org> Commit-Queue: Brian Geffon <bgeffon@chromium.org> Cr-Commit-Position: refs/heads/master@{#759044}
Showing
chromeos/memory/DEPS
0 → 100644
This diff is collapsed.
Please register or sign in to comment