linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/16] Signature verification of hibernate snapshot
@ 2015-07-16 14:25 Lee, Chun-Yi
  2015-07-16 14:25 ` [RFC PATCH 02/16] x86/efi: Add get and set variable to EFI services pointer table Lee, Chun-Yi
                   ` (13 more replies)
  0 siblings, 14 replies; 52+ messages in thread
From: Lee, Chun-Yi @ 2015-07-16 14:25 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA, linux-pm-u79uwXL29TY76Z2rM5mHXA,
	Rafael J. Wysocki, Matthew Garrett, Len Brown, Pavel Machek,
	Josh Boyer, Vojtech Pavlik, Matt Fleming, Jiri Kosina,
	H. Peter Anvin, Lee, Chun-Yi

Hi experts,

This patchset is the implementation of signature verification of hibernate
snapshot image. The origin idea is from Jiri Kosina: Let EFI bootloader
generate key-pair in UEFI secure boot environment, then forward it to kernel
for sign/verify hibernate image.

The first patchset for this function was sent in Sep. 2013, the implementation
is base on PKI. This new patchset is base on HMAC-SHA1. 

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.

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, the HMAC key stored in efi boot service variable, 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.

Set HIBERNATE_VERIFICATION compile option to true for enabling hibernate
verification. The default behavior of verifying failed is accept restoring
image but tainting kernel with H taint flag. Using HIBERNATE_VERIFICATION_FORCE
kernel compile option or "sigenforce" kernel parameter to force hibernate
recovery process stop when verification failed. It allows user to trigger the
key re-generating process in EFI stub through SNAPSHOT_REGENERATE_KEY ioctl.


Lee, Chun-Yi (16):
  PM / hibernate: define HMAC algorithm and digest size of swsusp
  x86/efi: Add get and set variable to EFI services pointer table
  x86/boot: Public getting random boot function
  x86/efi: Generating random number in EFI stub
  x86/efi: Get entropy through EFI random number generator protocol
  x86/efi: Generating random HMAC key for siging hibernate image
  efi: Public the function of transferring EFI status to kernel error
  x86/efi: Carrying swsusp key by setup data
  PM / hibernate: Reserve swsusp key and earse footprints
  PM / hibernate: Generate and verify signature of hibernate snapshot
  PM / hibernate: Avoid including swsusp key to hibernate image
  PM / hibernate: Forward signature verifying result and key to image
    kernel
  PM / hibernate: Add configuration to enforce signature verification
  PM / hibernate: Allow user trigger swsusp key re-generating
  PM / hibernate: Bypass verification logic on legacy BIOS
  PM / hibernate: Document signature verification of hibernate snapshot

 Documentation/kernel-parameters.txt             |   5 +
 Documentation/power/swsusp-signature-verify.txt |  86 +++++++
 arch/x86/boot/compressed/Makefile               |   1 +
 arch/x86/boot/compressed/aslr.c                 |  55 +----
 arch/x86/boot/compressed/eboot.c                |  94 ++++++++
 arch/x86/boot/compressed/efi_random.c           | 281 +++++++++++++++++++++++
 arch/x86/boot/compressed/head_32.S              |   6 +-
 arch/x86/boot/compressed/head_64.S              |   8 +-
 arch/x86/boot/compressed/misc.c                 |  55 +++++
 arch/x86/boot/compressed/misc.h                 |   4 +
 arch/x86/include/asm/efi.h                      |   2 +
 arch/x86/include/asm/suspend.h                  |  13 ++
 arch/x86/include/uapi/asm/bootparam.h           |   1 +
 arch/x86/kernel/setup.c                         |  21 +-
 arch/x86/power/Makefile                         |   1 +
 arch/x86/power/hibernate_keys.c                 | 173 ++++++++++++++
 drivers/firmware/Makefile                       |   1 +
 drivers/firmware/efi/Kconfig                    |   4 +
 drivers/firmware/efi/Makefile                   |   1 +
 drivers/firmware/efi/efi-hibernate_keys.c       |  46 ++++
 drivers/firmware/efi/vars.c                     |  33 ---
 include/linux/efi.h                             |  79 +++++++
 include/linux/kernel.h                          |   1 +
 include/linux/suspend.h                         |  26 +++
 include/uapi/linux/suspend_ioctls.h             |   3 +-
 kernel/panic.c                                  |   2 +
 kernel/power/Kconfig                            |  23 ++
 kernel/power/hibernate.c                        |  10 +
 kernel/power/power.h                            |  20 ++
 kernel/power/snapshot.c                         | 293 ++++++++++++++++++++++--
 kernel/power/swap.c                             |   4 +
 kernel/power/user.c                             |  16 ++
 kernel/reboot.c                                 |   3 +
 33 files changed, 1260 insertions(+), 111 deletions(-)
 create mode 100644 Documentation/power/swsusp-signature-verify.txt
 create mode 100644 arch/x86/boot/compressed/efi_random.c
 create mode 100644 arch/x86/power/hibernate_keys.c
 create mode 100644 drivers/firmware/efi/efi-hibernate_keys.c

-- 
1.8.4.5

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

end of thread, other threads:[~2015-08-02  0:23 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-16 14:25 [RFC PATCH 00/16] Signature verification of hibernate snapshot Lee, Chun-Yi
2015-07-16 14:25 ` [RFC PATCH 02/16] x86/efi: Add get and set variable to EFI services pointer table Lee, Chun-Yi
2015-07-30 15:19   ` Matt Fleming
     [not found]     ` <1438269598.11322.2.camel-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-07-31 10:14       ` joeyli
2015-07-16 14:25 ` [RFC PATCH 03/16] x86/boot: Public getting random boot function Lee, Chun-Yi
2015-07-28 12:21   ` Pavel Machek
2015-07-31 10:52     ` joeyli
2015-07-31 12:50       ` Pavel Machek
2015-07-16 14:25 ` [RFC PATCH 04/16] x86/efi: Generating random number in EFI stub Lee, Chun-Yi
     [not found]   ` <1437056730-15247-5-git-send-email-jlee-IBi9RG/b67k@public.gmane.org>
2015-07-28 12:01     ` Pavel Machek
2015-07-31  9:06       ` joeyli
2015-07-30 15:37     ` Matt Fleming
2015-07-31  9:12       ` joeyli
2015-07-16 14:25 ` [RFC PATCH 05/16] x86/efi: Get entropy through EFI random number generator protocol Lee, Chun-Yi
2015-07-28 12:28   ` Pavel Machek
2015-07-31  9:58     ` joeyli
     [not found]       ` <20150731095854.GC13113-empE8CJ7fzk2xCFIczX1Fw@public.gmane.org>
2015-07-31 12:01         ` Matt Fleming
2015-07-31 16:05           ` joeyli
     [not found]   ` <1437056730-15247-6-git-send-email-jlee-IBi9RG/b67k@public.gmane.org>
2015-07-30 16:11     ` Matt Fleming
     [not found]       ` <1438272704.11322.13.camel-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-07-31 14:59         ` joeyli
2015-07-31 15:01           ` joeyli
2015-07-16 14:25 ` [RFC PATCH 06/16] x86/efi: Generating random HMAC key for siging hibernate image Lee, Chun-Yi
2015-07-28 12:30   ` Pavel Machek
2015-07-31 10:56     ` joeyli
2015-07-30 16:20   ` Matt Fleming
2015-07-31 15:09     ` joeyli
2015-07-16 14:25 ` [RFC PATCH 07/16] efi: Public the function of transferring EFI status to kernel error Lee, Chun-Yi
     [not found]   ` <1437056730-15247-8-git-send-email-jlee-IBi9RG/b67k@public.gmane.org>
2015-07-30 16:23     ` Matt Fleming
2015-07-31 15:11       ` joeyli
2015-08-02  0:23       ` Valdis.Kletnieks
2015-07-16 14:25 ` [RFC PATCH 08/16] x86/efi: Carrying swsusp key by setup data Lee, Chun-Yi
2015-07-30 16:30   ` Matt Fleming
2015-07-31 15:31     ` joeyli
2015-07-16 14:25 ` [RFC PATCH 10/16] PM / hibernate: Generate and verify signature of hibernate snapshot Lee, Chun-Yi
2015-07-16 14:25 ` [RFC PATCH 11/16] PM / hibernate: Avoid including swsusp key to hibernate image Lee, Chun-Yi
2015-07-16 14:25 ` [RFC PATCH 12/16] PM / hibernate: Forward signature verifying result and key to image kernel Lee, Chun-Yi
2015-07-16 14:25 ` [RFC PATCH 13/16] PM / hibernate: Add configuration to enforce signature verification Lee, Chun-Yi
2015-07-16 14:25 ` [RFC PATCH 14/16] PM / hibernate: Allow user trigger swsusp key re-generating Lee, Chun-Yi
2015-07-16 14:25 ` [RFC PATCH 16/16] PM / hibernate: Document signature verification of hibernate snapshot Lee, Chun-Yi
     [not found] ` <1437056730-15247-1-git-send-email-jlee-IBi9RG/b67k@public.gmane.org>
2015-07-16 14:25   ` [RFC PATCH 01/16] PM / hibernate: define HMAC algorithm and digest size of swsusp Lee, Chun-Yi
2015-07-28 12:01     ` Pavel Machek
2015-07-31 10:08       ` joeyli
2015-07-31 12:49         ` Pavel Machek
2015-07-31 15:46           ` joeyli
2015-07-16 14:25   ` [RFC PATCH 09/16] PM / hibernate: Reserve swsusp key and earse footprints Lee, Chun-Yi
     [not found]     ` <1437056730-15247-10-git-send-email-jlee-IBi9RG/b67k@public.gmane.org>
2015-07-28 12:35       ` Pavel Machek
2015-07-31 15:43         ` joeyli
2015-07-16 14:25   ` [RFC PATCH 15/16] PM / hibernate: Bypass verification logic on legacy BIOS Lee, Chun-Yi
2015-07-24 17:08   ` [RFC PATCH 00/16] Signature verification of hibernate snapshot Jiri Kosina
2015-07-24 20:08     ` Rafael J. Wysocki
2015-07-28 12:09       ` Matt Fleming
     [not found]     ` <alpine.LNX.2.00.1507241527410.1141-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2015-07-25 14:32       ` joeyli

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).