From patchwork Mon Apr 28 08:06:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 343281 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 B2C8F1400D3; Mon, 28 Apr 2014 18:07:04 +1000 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1Wegab-0002Qp-C4; Mon, 28 Apr 2014 08:07:01 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1WegaS-0002Qj-1w for fwts-devel@lists.ubuntu.com; Mon, 28 Apr 2014 08:06:52 +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 1WegaR-0003Br-FF; Mon, 28 Apr 2014 08:06:52 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] uefi: uefirtvariable: report failure when setting variable with invalid attribute successfully (LP: #1310686) Date: Mon, 28 Apr 2014 16:06:46 +0800 Message-Id: <1398672406-3276-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 Some buggy firmwares allow to set variable with invalid attributes, and cannot be got by the getvariable, that causes the test variable exists in the firmware and cannot be set any more, setting variable by setvariable will return EFI_INVALID_PARAMETER. This patch adds to report fail and clean up the test variable. Signed-off-by: Ivan Hu Acked-by: Colin Ian King Acked-by: Alex Hung --- src/uefi/uefirtvariable/uefirtvariable.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c index 5d31ad8..6e40542 100644 --- a/src/uefi/uefirtvariable/uefirtvariable.c +++ b/src/uefi/uefirtvariable/uefirtvariable.c @@ -1156,6 +1156,7 @@ static int setvariable_test5(fwts_framework *fw) static int setvariable_test6(fwts_framework *fw) { + int ret; uint64_t datasize = 10; uint8_t datadiff = 0; uint32_t attributesarray[] = { @@ -1166,7 +1167,15 @@ static int setvariable_test6(fwts_framework *fw) uint64_t index; for (index = 0; index < (sizeof(attributesarray)/(sizeof attributesarray[0])); index++) { - setvariable_invalidattr(fw, attributesarray[index], datasize, variablenametest, >estguid1, datadiff); + ret = setvariable_invalidattr(fw, attributesarray[index], datasize, variablenametest, >estguid1, datadiff); + + if (ret == FWTS_ERROR) { + /* successfully set variable with invalid attributes, test fail */ + fwts_failed(fw, LOG_LEVEL_MEDIUM, "UEFIRuntimeSetVariable", + "Successfully set variable with invalid attribute, expected fail."); + setvariable_insertvariable(fw, 0, datasize, variablenametest, >estguid1, datadiff); + return FWTS_ERROR; + } if (setvariable_checkvariable_notfound(fw, variablenametest, >estguid1) == FWTS_ERROR) {