From patchwork Thu Oct 23 07:21:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 402392 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 5D67A140082; Thu, 23 Oct 2014 18:21:26 +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 1XhCi5-0000w5-8q; Thu, 23 Oct 2014 07:21:25 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1XhChz-0000vt-VS for fwts-devel@lists.ubuntu.com; Thu, 23 Oct 2014 07:21:19 +0000 Received: from 112-104-139-102.adsl.dynamic.seed.net.tw ([112.104.139.102] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1XhChz-0001ML-6K; Thu, 23 Oct 2014 07:21:19 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 13/15][RESEND] uefirtauthvar: test with both authenticated attributes are set Date: Thu, 23 Oct 2014 15:21:15 +0800 Message-Id: <1414048875-25437-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 Set the authitecated variable with both EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS and the EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attributes, firmware should return EFI_INVALID_PARAMETER. Signed-off-by: Ivan Hu --- src/uefi/uefirtauthvar/uefirtauthvar.c | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c index fc59487..6082b75 100644 --- a/src/uefi/uefirtauthvar/uefirtauthvar.c +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c @@ -665,6 +665,55 @@ static int uefirtauthvar_test11(fwts_framework *fw) return FWTS_ERROR; } +/* + * Set the authenticated variable with both EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS + * and the EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attributes, firmware + * should return EFI_INVALID_PARAMETER. + */ +static int uefirtauthvar_test12(fwts_framework *fw) +{ + long ioret; + + uint64_t status; + uint32_t attr_both = attributes | FWTS_UEFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS; + + ioret = setvar(>estguid, attr_both, sizeof(AuthVarCreate), AuthVarCreate, &status); + + if (ioret == -1) { + if (status == EFI_INVALID_PARAMETER) { + fwts_passed(fw, "Test with both authenticated attributes are set passed."); + + return FWTS_OK; + } + if (status == EFI_OUT_OF_RESOURCES) { + fwts_uefi_print_status_info(fw, status); + fwts_skipped(fw, + "Run out of resources for SetVariable " + "UEFI runtime interface: cannot test."); + fwts_advice(fw, + "Firmware may reclaim some resources " + "after rebooting. Reboot and test " + "again may be helpful to continue " + "the test."); + return FWTS_SKIP; + } + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "UEFIRuntimeSetVariable", + "Failed to set variable with UEFI " + "runtime service."); + + fwts_uefi_print_status_info(fw, status); + return FWTS_ERROR; + } + + fwts_failed(fw, LOG_LEVEL_HIGH, + "UEFSetAuthVarWithBothAuthAttr", + "Should not pass setting the autheticated variable " + "with both autheticated attributes are set."); + return FWTS_ERROR; +} + + static fwts_framework_minor_test uefirtauthvar_tests[] = { { uefirtauthvar_test1, "Create authenticated variable test." }, { uefirtauthvar_test2, "Authenticated variable test with the same authenticated variable." }, @@ -677,6 +726,7 @@ static fwts_framework_minor_test uefirtauthvar_tests[] = { { uefirtauthvar_test9, "Authenticated variable test with invalid modified timestamp." }, { uefirtauthvar_test10, "Authenticated variable test with different guid." }, { uefirtauthvar_test11, "Authenticated variable test with invalid attributes." }, + { uefirtauthvar_test12, "Test with both authenticated attributes are set." }, { NULL, NULL } };