From patchwork Thu Jul 16 14:25:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yi Lee X-Patchwork-Id: 6807281 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D3CAAC05AC for ; Thu, 16 Jul 2015 14:26:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0EACF206FD for ; Thu, 16 Jul 2015 14:26:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 26336206D6 for ; Thu, 16 Jul 2015 14:26:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755661AbbGPO0V (ORCPT ); Thu, 16 Jul 2015 10:26:21 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:32925 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753712AbbGPO0U (ORCPT ); Thu, 16 Jul 2015 10:26:20 -0400 Received: by padck2 with SMTP id ck2so43550678pad.0; Thu, 16 Jul 2015 07:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2fi+hSMo+L25CeppI40BpXTx46jzJl5Sh78E29SfWOI=; b=0XfZlHDM/80r6+hsgpBmKGBRdiLZ5OoNWueVvJF4pTUCI1+Yf8oy5p5j+6zrGnz5hN stILKzb0PZFMIO6BpSIIrxL02DPytkBZ91pEESxL3s4klyDdjHIwbMgi1JGe+7sD5/7b bABmzZB44aw20GrnagcGlSi8w/O0GJKmcsgh/RQWT11mNqSsav7LPzeDoB0q3aSkyp2Z euDR/cMcm9G2BcQdtD7D4BEdUKiQt9b8RHm03PAkS2iUYhDvJFoARglyInXErlC9Gxp0 RnVgytgfeNhGLVynGsronuZ0soq3oVtkpgXVfiBYCMUum+onLt8WgofyBDXBnRXCHy0c eUkg== X-Received: by 10.66.65.228 with SMTP id a4mr19164926pat.65.1437056780189; Thu, 16 Jul 2015 07:26:20 -0700 (PDT) Received: from linux-rxt1.site.site ([124.11.22.254]) by smtp.gmail.com with ESMTPSA id r4sm8219910pap.8.2015.07.16.07.26.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 07:26:19 -0700 (PDT) From: "Lee, Chun-Yi" X-Google-Original-From: "Lee, Chun-Yi" To: linux-kernel@vger.kernel.org Cc: linux-efi@vger.kernel.org, linux-pm@vger.kernel.org, "Rafael J. Wysocki" , Matthew Garrett , Len Brown , Pavel Machek , Josh Boyer , Vojtech Pavlik , Matt Fleming , Jiri Kosina , "H. Peter Anvin" , "Lee, Chun-Yi" Subject: [RFC PATCH 01/16] PM / hibernate: define HMAC algorithm and digest size of swsusp Date: Thu, 16 Jul 2015 22:25:15 +0800 Message-Id: <1437056730-15247-2-git-send-email-jlee@suse.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1437056730-15247-1-git-send-email-jlee@suse.com> References: <1437056730-15247-1-git-send-email-jlee@suse.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using HMAC-SHA1 to be the HMAC algorithm of signing hibernate snapshot image. The digest size of HMAC-SHA1 is 160 bits (20 bytes), this size will be also applied to the length of HMAC key. In addition, add HIBERNATE_VERIFICATION kernel config. Signed-off-by: Lee, Chun-Yi --- include/linux/suspend.h | 5 +++++ kernel/power/Kconfig | 13 +++++++++++++ kernel/power/power.h | 1 + 3 files changed, 19 insertions(+) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 5efe743..6cd2a48 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -327,6 +327,11 @@ struct platform_hibernation_ops { }; #ifdef CONFIG_HIBERNATION + +/* HMAC Algorithm of Hibernate Signature */ +#define SWSUSP_HMAC "hmac(sha1)" +#define SWSUSP_DIGEST_SIZE 20 + /* kernel/power/snapshot.c */ extern void __register_nosave_region(unsigned long b, unsigned long e, int km); static inline void __init register_nosave_region(unsigned long b, unsigned long e) diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig index 9e30231..8608b3b 100644 --- a/kernel/power/Kconfig +++ b/kernel/power/Kconfig @@ -66,6 +66,19 @@ config HIBERNATION For more information take a look at . +config HIBERNATE_VERIFICATION + bool "Hibernate verification" + depends on HIBERNATION + depends on EFI_STUB + depends on X86 + select CRYPTO_HMAC + select CRYPTO_SHA1 + help + This option provides support for generating and verifying the + signature of memory snapshot image by HMAC-SHA1. Current mechanism + relies on UEFI secure boot environment, EFI stub generates HMAC + key for hibernate verification. + config ARCH_SAVE_PAGE_KEYS bool diff --git a/kernel/power/power.h b/kernel/power/power.h index caadb56..f65fcf7 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h @@ -12,6 +12,7 @@ struct swsusp_info { unsigned long image_pages; unsigned long pages; unsigned long size; + u8 signature[SWSUSP_DIGEST_SIZE]; } __aligned(PAGE_SIZE); #ifdef CONFIG_HIBERNATION