From: "Lee, Chun-Yi" <joeyli.kernel@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: linux-efi@vger.kernel.org, linux-pm@vger.kernel.org,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Matthew Garrett <matthew.garrett@nebula.com>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
Josh Boyer <jwboyer@redhat.com>, Vojtech Pavlik <vojtech@suse.cz>,
Matt Fleming <matt.fleming@intel.com>,
Jiri Kosina <jkosina@suse.cz>, "H. Peter Anvin" <hpa@zytor.com>,
Ingo Molnar <mingo@redhat.com>, "Lee, Chun-Yi" <jlee@suse.com>
Subject: [PATCH v2 16/16] PM / hibernate: Document signature verification of hibernate snapshot
Date: Tue, 11 Aug 2015 14:16:36 +0800 [thread overview]
Message-ID: <1439273796-25359-17-git-send-email-jlee@suse.com> (raw)
In-Reply-To: <1439273796-25359-1-git-send-email-jlee@suse.com>
Reviewed-by: Jiri Kosina <jkosina@suse.com>
Tested-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
---
Documentation/power/swsusp-signature-verify.txt | 86 +++++++++++++++++++++++++
1 file changed, 86 insertions(+)
create mode 100644 Documentation/power/swsusp-signature-verify.txt
diff --git a/Documentation/power/swsusp-signature-verify.txt b/Documentation/power/swsusp-signature-verify.txt
new file mode 100644
index 0000000..7ba4a3f
--- /dev/null
+++ b/Documentation/power/swsusp-signature-verify.txt
@@ -0,0 +1,86 @@
+Signature verification of hibernate snapshot
+============================================
+
+1) Introduction
+2) How to enable
+3) How does it work
+4) Trigger key re-generate
+
+1) Introduction
+---------------------
+
+The hibernate function provided by kernel was used to snapshot memory
+to be a image for keeping in storage, then restored in appropriate time.
+There have potential threat from hacking the memory snapshot image.
+Cracker may triggers hibernating process through ioctl to grab snapshot
+image, then restoring modified image back to memory. Another situation
+is booting to other hacked OS to modify the snapshot image in swap
+partition or file, then user may runs malware after image restored to
+memory. In addition, the above weakness cause kernel is not fully trusted
+in EFI secure boot environment.
+
+So, kernel hibernate function needs a mechanism to verify integrity of
+hibernate snapshot image.
+
+The origin idea is from Jiri Kosina: Let EFI bootloader generates key-pair
+in UEFI secure boot environment, then forwarding keys to boot kernel for
+signing/verifying snapshot image.
+
+
+2) How to enable
+-----------------
+
+If the HIBERNATE_VERIFICATION compile option is true, kernel hibernate code
+will generating and verifying the signature of memory snapshot image by
+HMAC-SHA1 algorithm. Current solution relies on EFI stub on x86 architecture,
+so the signature verification logic will be bypassed on legacy BIOS.
+
+When the snapshot image unsigned or signed with an unknown key, the signature
+verification will be failed. The default behavior of verifying failed is
+accept restoring image but tainting kernel with H taint flag.
+
+Like kernel module signature checking, there's both a config option and
+a boot parameter which control whether we accept or stop whole recovery
+process when verification failed. Using HIBERNATE_VERIFICATION_FORCE kernel
+compile option or "sigenforce" kernel parameter to force hibernate recovery
+process stop when verification failed.
+
+
+3) How does it work
+-------------------
+
+For signing hibernate image, kernel need a key for generating signature of
+image. The origin idea is using PKI, the EFI bootloader, shim generates key
+pair and forward to boot kernel for signing/verifying image. In Linux Plumbers
+Conference 2013, we got response from community experts for just using
+symmetric key algorithm to generate signature, that's simpler and no EFI
+bootloader's involving.
+
+Current solution is using HMAC-SHA1 algorithm, it generating HMAC key in EFI
+stub by using RDRAND, RDTSC and EFI RNG protocol to grab random number to be
+the entropy of key. Then the HMAC key stored in efi boot service variable,
+key's security relies on EFI secure boot: When EFI secure boot enabled, only
+trusted efi program allowed accessing boot service variables.
+
+In every EFI stub booting stage, it loads key from variable then forward key
+to boot kernel for waiting to sign snapshot image by user trigger hibernating.
+The HMAC-SHA1 algorithm generates signature then kernel put signature to the
+header with the memory snapshot image. The signature with image is delivered
+to userspace hibernating application or direct stored in swap partition.
+
+When hibernate recovering, kernel will verify the image signature before
+switch whole system to image kernel and image memory space. When verifying
+failed, kernel is tainted or stop recovering and discarding image.
+
+
+4) Trigger key re-generate
+--------------------------
+
+The hibernate signature verifying function allows user to trigger the key
+re-generating process in EFI stub through SNAPSHOT_REGENERATE_KEY ioctl.
+
+User can raise a key-regen flag in kernel through ioctl. When system runs
+normal shutdown or reboot, kernel writes a efi runtime variable as a flag
+then EFI stub will query the flag in next boot cycle. To avoid the hibernation
+key changes in hibernating cycle that causes hibernate restoring failed,
+the regen flag will be clear in a hibernate cycle.
--
2.1.4
prev parent reply other threads:[~2015-08-11 6:19 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-11 6:16 [PATCH v2 00/16] Signature verification of hibernate snapshot Lee, Chun-Yi
2015-08-11 6:16 ` [PATCH v2 01/16] PM / hibernate: define HMAC algorithm and digest size of hibernation Lee, Chun-Yi
2015-08-11 6:16 ` [PATCH v2 02/16] x86/efi: Add get and set variable to EFI services pointer table Lee, Chun-Yi
2015-08-19 16:35 ` Matt Fleming
2015-08-11 6:16 ` [PATCH v2 03/16] x86/boot: Public getting random boot function Lee, Chun-Yi
2015-08-11 6:16 ` [PATCH v2 04/16] x86/efi: Generating random number in EFI stub Lee, Chun-Yi
2015-08-20 14:12 ` Matt Fleming
2015-08-27 4:06 ` joeyli
2015-08-11 6:16 ` [PATCH v2 05/16] x86/efi: Get entropy through EFI random number generator protocol Lee, Chun-Yi
2015-08-20 14:47 ` Matt Fleming
2015-08-27 4:51 ` joeyli
2015-08-20 20:26 ` Matt Fleming
2015-08-27 6:17 ` joeyli
2015-08-11 6:16 ` [PATCH v2 06/16] x86/efi: Generating random HMAC key for siging hibernate image Lee, Chun-Yi
2015-08-20 20:40 ` Matt Fleming
2015-08-27 9:04 ` joeyli
2015-09-09 12:15 ` Matt Fleming
2015-09-13 2:47 ` joeyli
2015-08-11 6:16 ` [PATCH v2 07/16] efi: Make efi_status_to_err() public Lee, Chun-Yi
2015-08-20 15:07 ` Matt Fleming
2015-08-27 9:06 ` joeyli
2015-08-11 6:16 ` [PATCH v2 08/16] x86/efi: Carrying hibernation key by setup data Lee, Chun-Yi
2015-08-15 17:07 ` Pavel Machek
2015-08-16 5:28 ` joeyli
2015-08-16 21:23 ` Jiri Kosina
2015-08-17 6:54 ` Nigel Cunningham
2015-08-21 12:40 ` Matt Fleming
2015-08-27 9:28 ` joeyli
2015-08-11 6:16 ` [PATCH v2 09/16] PM / hibernate: Reserve hibernation key and erase footprints Lee, Chun-Yi
2015-08-13 2:45 ` Chen, Yu C
2015-08-13 3:25 ` joeyli
2015-08-13 14:33 ` joeyli
2015-08-21 13:27 ` Matt Fleming
2015-08-27 10:21 ` joeyli
2015-09-09 12:24 ` Matt Fleming
2015-09-13 2:58 ` joeyli
2015-08-11 6:16 ` [PATCH v2 10/16] PM / hibernate: Generate and verify signature of hibernate snapshot Lee, Chun-Yi
2015-08-11 6:16 ` [PATCH v2 11/16] PM / hibernate: Avoid including hibernation key to hibernate image Lee, Chun-Yi
2015-08-11 6:16 ` [PATCH v2 12/16] PM / hibernate: Forward signature verifying result and key to image kernel Lee, Chun-Yi
2015-08-11 6:16 ` [PATCH v2 13/16] PM / hibernate: Add configuration to enforce signature verification Lee, Chun-Yi
2015-08-11 6:16 ` [PATCH v2 14/16] PM / hibernate: Allow user trigger hibernation key re-generating Lee, Chun-Yi
2015-08-11 6:16 ` [PATCH v2 15/16] PM / hibernate: Bypass verification logic on legacy BIOS Lee, Chun-Yi
2015-08-11 6:16 ` Lee, Chun-Yi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439273796-25359-17-git-send-email-jlee@suse.com \
--to=joeyli.kernel@gmail.com \
--cc=hpa@zytor.com \
--cc=jkosina@suse.cz \
--cc=jlee@suse.com \
--cc=jwboyer@redhat.com \
--cc=len.brown@intel.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=matt.fleming@intel.com \
--cc=matthew.garrett@nebula.com \
--cc=mingo@redhat.com \
--cc=pavel@ucw.cz \
--cc=rjw@rjwysocki.net \
--cc=vojtech@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).