From patchwork Fri Oct 24 03:13:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 402734 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id D12D7140082; Fri, 24 Oct 2014 14:13:55 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1XhVK6-0005hC-PY; Fri, 24 Oct 2014 03:13:54 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1XhVK1-0005gw-7D for fwts-devel@lists.ubuntu.com; Fri, 24 Oct 2014 03:13:49 +0000 Received: from [175.41.48.77] (helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1XhVK0-00019U-Kg; Fri, 24 Oct 2014 03:13:49 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 02/15][V3] uefirtauthvar: cleanup environment before testing Date: Fri, 24 Oct 2014 11:13:44 +0800 Message-Id: <1414120424-23971-1-git-send-email-ivan.hu@canonical.com> X-Mailer: git-send-email 1.7.9.5 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com Delete the test authenticated variable before starting the test, if exists. Signed-off-by: Ivan Hu Acked-by: Colin Ian King Acked-by: Alex Hung --- src/uefi/uefirtauthvar/authvardefs.h | 121 ++++++++++++++++++++++++++++++++ src/uefi/uefirtauthvar/uefirtauthvar.c | 15 ++++ 2 files changed, 136 insertions(+) diff --git a/src/uefi/uefirtauthvar/authvardefs.h b/src/uefi/uefirtauthvar/authvardefs.h index d74a018..156ece4 100644 --- a/src/uefi/uefirtauthvar/authvardefs.h +++ b/src/uefi/uefirtauthvar/authvardefs.h @@ -145,4 +145,125 @@ static uint8_t AuthVarCreate[] = { static uint8_t AuthVarCreateData[] = {0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66}; +/* + * AuthVarDel, + * timestamp: 2014.09.08:06:10:26 + * GUID: 7f5c5d52-2f14-4f12-967cdb60db05a0fd + * attributes = UEFI_VAR_NON_VOLATILE, UEFI_VAR_BOOTSERVICE_ACCESS, + * UEFI_VAR_RUNTIME_ACCESS, UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS + * Variable name: AuthVarTest + * data content: empty + */ +static uint8_t AuthVarDel[] = { + 0xde, 0x07, 0x09, 0x08, 0x06, 0x0a, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0b, 0x05, 0x00, 0x00, 0x00, 0x02, 0xf1, 0x0e, + 0x9d, 0xd2, 0xaf, 0x4a, 0xdf, 0x68, 0xee, 0x49, 0x8a, 0xa9, 0x34, 0x7d, + 0x37, 0x56, 0x65, 0xa7, 0x30, 0x82, 0x04, 0xef, 0x06, 0x09, 0x2a, 0x86, + 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x82, 0x04, 0xe0, 0x30, + 0x82, 0x04, 0xdc, 0x02, 0x01, 0x01, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x09, + 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x30, + 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, + 0xa0, 0x82, 0x02, 0xfd, 0x30, 0x82, 0x02, 0xf9, 0x30, 0x82, 0x01, 0xe1, + 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xbb, 0x94, 0x92, 0x5f, + 0x3b, 0x5e, 0xd3, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, + 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x13, 0x31, 0x11, 0x30, + 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x08, 0x74, 0x65, 0x73, 0x74, + 0x2d, 0x6b, 0x65, 0x79, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x34, 0x30, 0x38, + 0x31, 0x32, 0x31, 0x30, 0x32, 0x31, 0x33, 0x30, 0x5a, 0x17, 0x0d, 0x31, + 0x34, 0x30, 0x39, 0x31, 0x31, 0x31, 0x30, 0x32, 0x31, 0x33, 0x30, 0x5a, + 0x30, 0x13, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, + 0x08, 0x74, 0x65, 0x73, 0x74, 0x2d, 0x6b, 0x65, 0x79, 0x30, 0x82, 0x01, + 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, + 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, + 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xe5, 0xbf, 0x24, 0xb1, 0x10, 0x46, + 0x55, 0xad, 0x70, 0x77, 0x14, 0xc3, 0x1b, 0x55, 0xa0, 0x72, 0xfa, 0x3c, + 0x3c, 0x44, 0x3e, 0xc3, 0xd7, 0xfa, 0x05, 0x94, 0xeb, 0x70, 0x6a, 0xe3, + 0x47, 0x58, 0xb5, 0xab, 0x83, 0x6e, 0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, 0xcd, 0xd4, 0xf4, 0x2d, + 0x7d, 0x37, 0x5a, 0xcb, 0xbc, 0xae, 0xdc, 0x77, 0xa2, 0x0f, 0x72, 0x56, + 0xd7, 0xd4, 0xec, 0x59, 0x9d, 0xd9, 0x60, 0x7a, 0xf9, 0x26, 0x94, 0xda, + 0xfd, 0x7c, 0x5c, 0xe8, 0x15, 0x7e, 0x9a, 0xe9, 0x3d, 0x71, 0x02, 0x03, + 0x01, 0x00, 0x01, 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, + 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x8b, 0x37, 0x99, 0x6d, 0x76, 0x3f, + 0xc5, 0x2b, 0x48, 0xf8, 0x0d, 0x61, 0xf2, 0x62, 0x8e, 0xc6, 0xe7, 0xd5, + 0xb6, 0x4e, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, + 0x16, 0x80, 0x14, 0x8b, 0x37, 0x99, 0x6d, 0x76, 0x3f, 0xc5, 0x2b, 0x48, + 0xf8, 0x0d, 0x61, 0xf2, 0x62, 0x8e, 0xc6, 0xe7, 0xd5, 0xb6, 0x4e, 0x30, + 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, + 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, + 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0xb2, 0x28, 0xe3, + 0x94, 0x02, 0x6f, 0xe5, 0x2a, 0xdc, 0x29, 0x7d, 0xcf, 0x2b, 0x88, 0x09, + 0x4f, 0x73, 0x8a, 0xc3, 0x54, 0xfc, 0xa3, 0x40, 0x84, 0x82, 0xce, 0x32, + 0x8d, 0x75, 0x51, 0xa2, 0xc3, 0x3f, 0x01, 0x0f, 0xde, 0x1b, 0x1f, 0x48, + 0xdb, 0x8f, 0xf9, 0xe0, 0xf3, 0x23, 0x78, 0x17, 0x4a, 0x84, 0xbc, 0xf4, + 0x84, 0xb5, 0xe5, 0x8c, 0x17, 0x36, 0x7f, 0x4f, 0x6f, 0x54, 0x47, 0xbd, + 0xe6, 0x40, 0xb0, 0x8a, 0x73, 0x74, 0x65, 0x57, 0x98, 0xf6, 0x77, 0x58, + 0x0e, 0x5f, 0x82, 0x77, 0xb3, 0xd9, 0x87, 0xf8, 0xe9, 0x21, 0x11, 0x37, + 0x4c, 0x6e, 0x5f, 0xda, 0x1e, 0x81, 0xa6, 0xa3, 0x45, 0x09, 0x81, 0x26, + 0xd0, 0xb6, 0xe1, 0x27, 0xa5, 0xc3, 0x6e, 0xed, 0x86, 0xb7, 0x4f, 0xf3, + 0x7e, 0x34, 0xa5, 0x0b, 0x8a, 0xd1, 0x56, 0x65, 0x04, 0xe2, 0x16, 0x71, + 0x11, 0xdc, 0xa8, 0xa6, 0xe0, 0x57, 0x91, 0x63, 0xe2, 0x9d, 0xe7, 0x86, + 0x00, 0xa6, 0xb4, 0x75, 0xf3, 0x37, 0x63, 0x48, 0x41, 0xcd, 0x97, 0x12, + 0x2e, 0x5c, 0xc0, 0xf0, 0x13, 0x62, 0x71, 0xc1, 0x8e, 0x65, 0x28, 0x52, + 0x09, 0x71, 0x87, 0x33, 0x27, 0x77, 0x84, 0x2f, 0xb4, 0x9a, 0x0a, 0x62, + 0xe6, 0x69, 0x05, 0xd7, 0x94, 0x70, 0x8a, 0xb9, 0x61, 0x68, 0xdb, 0xbd, + 0x4b, 0x58, 0xd3, 0x74, 0x0e, 0x3e, 0x00, 0x6c, 0x64, 0x02, 0x22, 0x4f, + 0x62, 0xbe, 0xe1, 0x53, 0x96, 0xa5, 0x6a, 0x7d, 0xf7, 0x8c, 0x77, 0x42, + 0x49, 0xb3, 0xb0, 0x44, 0xf1, 0xa9, 0xd5, 0x64, 0xdf, 0xcc, 0x8b, 0x90, + 0x03, 0x05, 0xb8, 0x07, 0x5f, 0x6e, 0x88, 0x11, 0x7e, 0x93, 0x85, 0xe6, + 0x3c, 0x87, 0x92, 0x74, 0xbb, 0xfe, 0x01, 0x32, 0xe8, 0x0b, 0xa9, 0xab, + 0x15, 0xd4, 0x8a, 0x4f, 0xd7, 0x40, 0x12, 0xe1, 0xde, 0x8a, 0xa8, 0x7c, + 0xf5, 0x31, 0x82, 0x01, 0xb6, 0x30, 0x82, 0x01, 0xb2, 0x02, 0x01, 0x01, + 0x30, 0x20, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, + 0x03, 0x0c, 0x08, 0x74, 0x65, 0x73, 0x74, 0x2d, 0x6b, 0x65, 0x79, 0x02, + 0x09, 0x00, 0xbb, 0x94, 0x92, 0x5f, 0x3b, 0x5e, 0xd3, 0x2d, 0x30, 0x0d, + 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, + 0x00, 0xa0, 0x69, 0x30, 0x18, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, + 0x0d, 0x01, 0x09, 0x03, 0x31, 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, + 0xf7, 0x0d, 0x01, 0x07, 0x01, 0x30, 0x1c, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x05, 0x31, 0x0f, 0x17, 0x0d, 0x31, 0x34, + 0x31, 0x30, 0x30, 0x38, 0x30, 0x36, 0x31, 0x30, 0x32, 0x36, 0x5a, 0x30, + 0x2f, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x04, + 0x31, 0x22, 0x04, 0x20, 0xa7, 0x2d, 0xb1, 0x8a, 0xc3, 0x9b, 0x15, 0xb9, + 0xd8, 0x72, 0x1b, 0x33, 0x4e, 0xf7, 0x46, 0xaf, 0x62, 0x26, 0xa7, 0x6d, + 0x18, 0xfa, 0x16, 0x92, 0x9f, 0x90, 0x25, 0x47, 0x5d, 0x2c, 0x12, 0x39, + 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, + 0x01, 0x05, 0x00, 0x04, 0x82, 0x01, 0x00, 0xdc, 0xe7, 0xf2, 0xa2, 0xea, + 0x24, 0x38, 0x52, 0xbf, 0xd1, 0x66, 0xfc, 0xb5, 0x74, 0xf8, 0x5b, 0x6d, + 0x82, 0x20, 0xbc, 0xb5, 0x6f, 0x60, 0x9e, 0xab, 0xe9, 0x8e, 0xcd, 0x22, + 0x99, 0x85, 0xdd, 0xb5, 0xc8, 0x5e, 0x3c, 0x9b, 0x1a, 0xe8, 0x06, 0xfb, + 0x7f, 0x07, 0x91, 0xe6, 0x14, 0xbb, 0x7c, 0xce, 0x86, 0xc7, 0xbe, 0x03, + 0x0f, 0x14, 0x60, 0x59, 0x24, 0x96, 0xc7, 0xb0, 0x9a, 0x77, 0x66, 0x7a, + 0xed, 0x0f, 0x0c, 0xaa, 0x1b, 0xc2, 0x40, 0xa1, 0x8e, 0x2e, 0x8a, 0x27, + 0x57, 0x08, 0xce, 0x3c, 0x4e, 0xd6, 0x4c, 0xcf, 0x1c, 0xc2, 0x8b, 0xef, + 0xf1, 0x96, 0x2f, 0x29, 0xbc, 0x48, 0x03, 0x7f, 0x58, 0x53, 0x58, 0x49, + 0x0a, 0x3e, 0x49, 0x3c, 0x14, 0xed, 0x1f, 0x04, 0x56, 0x99, 0x3e, 0x01, + 0xfb, 0x5d, 0x47, 0xd2, 0xdf, 0xdd, 0x00, 0x6a, 0x65, 0x43, 0x42, 0x2a, + 0xb5, 0xd1, 0xb8, 0x09, 0xf1, 0x82, 0xfd, 0x9e, 0x0e, 0x56, 0x66, 0xf3, + 0x03, 0x52, 0x1a, 0x75, 0x8f, 0x13, 0x2c, 0x92, 0x3c, 0x08, 0xb7, 0x95, + 0xdf, 0x45, 0x31, 0xde, 0xc0, 0x62, 0x45, 0x54, 0xbf, 0x1e, 0xfc, 0xd0, + 0x7e, 0xc1, 0x51, 0xc7, 0x2a, 0x8a, 0xef, 0x31, 0x92, 0xf8, 0x48, 0x1d, + 0x61, 0x87, 0x4b, 0x9a, 0x70, 0xdc, 0x93, 0x12, 0x97, 0x72, 0x6e, 0x6d, + 0xbc, 0xeb, 0x7f, 0x83, 0x3d, 0x54, 0x83, 0xae, 0x6a, 0x7a, 0x47, 0x04, + 0xd3, 0xc0, 0xee, 0xc7, 0x85, 0x0f, 0xd6, 0x89, 0x48, 0xc0, 0x68, 0xe3, + 0x6c, 0x86, 0xcd, 0x17, 0xc0, 0x8d, 0xaa, 0xfd, 0xc6, 0x0d, 0xa6, 0xc4, + 0xc3, 0xef, 0xc5, 0xcc, 0x47, 0xf9, 0x0c, 0x21, 0xe8, 0x86, 0xcb, 0x93, + 0xe0, 0x37, 0x21, 0x2b, 0xa9, 0xe3, 0x7e, 0x6a, 0x6c, 0xde, 0x3e, 0x68, + 0x65, 0xb6, 0xff, 0xbf, 0xbd, 0x08, 0xe1, 0xed, 0x0c, 0x19, 0xb2 +}; + #endif diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c index 42ba395..aba85a8 100644 --- a/src/uefi/uefirtauthvar/uefirtauthvar.c +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c @@ -87,6 +87,19 @@ static long getvar( return ioret; } +static void uefirtvariable_env_cleanup(void) +{ + uint64_t status; + uint8_t data[getvar_buf_size]; + uint64_t getdatasize = sizeof(data); + uint32_t attributestest; + + long ioret = getvar(>estguid, &attributestest, &getdatasize, data, &status); + if (ioret != -1 && status == EFI_SUCCESS) + setvar(>estguid, attributes, sizeof(AuthVarDel), AuthVarDel, &status); + return; +} + static int uefirtauthvar_init(fwts_framework *fw) { if (fwts_firmware_detect() != FWTS_FIRMWARE_UEFI) { @@ -105,6 +118,8 @@ static int uefirtauthvar_init(fwts_framework *fw) return FWTS_ABORTED; } + uefirtvariable_env_cleanup(); + return FWTS_OK; }