From patchwork Fri Oct 24 10:31:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 402793 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 7B4E2140081; Fri, 24 Oct 2014 21:32:01 +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 1XhcA4-0007U4-Db; Fri, 24 Oct 2014 10:32:00 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1Xhc9z-0007Ts-7N for fwts-devel@lists.ubuntu.com; Fri, 24 Oct 2014 10:31:55 +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 1Xhc9y-0008M9-C3; Fri, 24 Oct 2014 10:31:55 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 09/15][RESEND] uefirtauthvar: setting authenticated variable with invalid modified data test Date: Fri, 24 Oct 2014 18:31:49 +0800 Message-Id: <1414146709-9896-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 This test sets the authenticated variable with invalid modified data, firmware should check the data and return EFI_SECURITY_VIOLATION. Signed-off-by: Ivan Hu Acked-by: Colin Ian King Acked-by: Colin Ian King Acked-by: Alex Hung --- src/uefi/uefirtauthvar/authvardefs.h | 118 ++++++++++++++++++++++++++++++++ src/uefi/uefirtauthvar/uefirtauthvar.c | 35 ++++++++++ 2 files changed, 153 insertions(+) diff --git a/src/uefi/uefirtauthvar/authvardefs.h b/src/uefi/uefirtauthvar/authvardefs.h index 1707dd3..dae55ef 100644 --- a/src/uefi/uefirtauthvar/authvardefs.h +++ b/src/uefi/uefirtauthvar/authvardefs.h @@ -638,4 +638,122 @@ static uint8_t AuthVarUpdate[] = { static uint8_t AuthVarUpdateData[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39}; +/* + * The same as AuthVarCreate, + * modified data content: 123456789aabcdef + */ +static uint8_t AuthVarModData[] = { + 0xde, 0x07, 0x09, 0x08, 0x03, 0x29, 0x0f, 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, 0x7a, 0x43, 0xdd, 0x51, 0x9a, 0x31, + 0x4a, 0x4a, 0x4f, 0xf0, 0x65, 0xfe, 0xae, 0x10, 0x30, 0xf8, 0xaa, 0x69, + 0x54, 0xaf, 0xff, 0x4b, 0x3d, 0x48, 0x5d, 0x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f9, 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, 0x33, 0x34, 0x31, 0x31, 0x35, 0x5a, 0x30, + 0x2f, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x04, + 0x31, 0x22, 0x04, 0x20, 0x7d, 0x9f, 0x1b, 0x65, 0x76, 0x70, 0x66, 0xe3, + 0xa0, 0x6a, 0x53, 0x01, 0xd9, 0xde, 0x6f, 0x6a, 0x88, 0xcb, 0x76, 0xb3, + 0xf8, 0xd6, 0xc4, 0x45, 0x3a, 0x8f, 0x7b, 0x9d, 0x06, 0x50, 0xc6, 0x12, + 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, + 0x01, 0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0x7f, 0x6e, 0x4f, 0x70, 0x68, 0x4a, 0x1d, 0xa7, 0x9c, + 0x0e, 0x1d, 0x42, 0xaf, 0x6f, 0x0f, 0x6d, 0x8f, 0x91, 0x69, 0x6a, 0xff, + 0x73, 0x86, 0xc6, 0xc3, 0x24, 0x7d, 0x60, 0x67, 0xb4, 0xae, 0xa8, 0xb4, + 0x19, 0xba, 0x7a, 0x61, 0xc9, 0xad, 0xcc, 0xcf, 0x9f, 0xfe, 0x13, 0x1e, + 0xc3, 0x2c, 0xfd, 0x3a, 0x25, 0xdf, 0xa2, 0xc6, 0xb2, 0x15, 0x18, 0x54, + 0xbd, 0x51, 0xc1, 0x84, 0x62, 0x0f, 0x72, 0x8d, 0x67, 0xce, 0xe6, 0xbd, + 0x6e, 0x21, 0x58, 0x1f, 0x77, 0xf4, 0xfc, 0x36, 0xf9, 0x0c, 0x1d, 0x31, + 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x61, 0x62, 0x63, + 0x64, 0x65, 0x66 +}; + #endif diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c index 854f067..1007af5 100644 --- a/src/uefi/uefirtauthvar/uefirtauthvar.c +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c @@ -515,6 +515,40 @@ static int uefirtauthvar_test7(fwts_framework *fw) return FWTS_ERROR; } +/* + * Set the authenticated variable with invalid modified data, + * expect EFI_SECURITY_VIOLATION returned. + */ +static int uefirtauthvar_test8(fwts_framework *fw) +{ + long ioret; + uint64_t status; + int supcheck; + + ioret = setvar(>estguid, attributes, sizeof(AuthVarModData), AuthVarModData, &status); + + if (ioret == -1) { + supcheck = check_fw_support(fw, status); + if (supcheck != FWTS_OK) + return supcheck; + + if (status == EFI_SECURITY_VIOLATION) { + fwts_passed(fw, "Set authenticated variable test with invalid modified data passed."); + return FWTS_OK; + } + + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "UEFISetAuthVarInvalidData", + "Set authenticated variable fail"); + fwts_uefi_print_status_info(fw, status); + } + + fwts_failed(fw, LOG_LEVEL_HIGH, + "UEFISetAuthVarInvalidData", + "Set authenticated variable expected fail but success"); + + return FWTS_ERROR; +} static fwts_framework_minor_test uefirtauthvar_tests[] = { { uefirtauthvar_test1, "Create authenticated variable test." }, @@ -524,6 +558,7 @@ static fwts_framework_minor_test uefirtauthvar_tests[] = { { uefirtauthvar_test5, "Update authenticated variable test." }, { uefirtauthvar_test6, "Authenticated variable test with old authenticated variable." }, { uefirtauthvar_test7, "Delete authenticated variable test." }, + { uefirtauthvar_test8, "Authenticated variable test with invalid modified data." }, { NULL, NULL } };