From patchwork Tue Nov 21 03:21:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 839889 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3ygrVP4pNtz9rxm; Tue, 21 Nov 2017 14:22:05 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1eGz8N-0000VD-DI; Tue, 21 Nov 2017 03:22:03 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1eGz8M-0000Ue-C4 for fwts-devel@lists.ubuntu.com; Tue, 21 Nov 2017 03:22:02 +0000 Received: from 1.general.alexhung.us.vpn ([10.172.65.254] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1eGz8L-0006Zu-Ic; Tue, 21 Nov 2017 03:22:02 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH] acpi: LPIT: check for monotonically increasing UID Date: Tue, 21 Nov 2017 11:21:57 +0800 Message-Id: <1511234517-12005-1-git-send-email-alex.hung@canonical.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 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" Signed-off-by: Alex Hung Acked-by: Colin Ian King --- src/acpi/lpit/lpit.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/acpi/lpit/lpit.c b/src/acpi/lpit/lpit.c index eb4e3af..de7073c 100644 --- a/src/acpi/lpit/lpit.c +++ b/src/acpi/lpit/lpit.c @@ -162,8 +162,10 @@ static int lpit_test1(fwts_framework *fw) /* Got enough data to be able to inspect the initial 2 x 32 bit words.. */ while (length > 8) { + fwts_acpi_table_lpit_c_state *lpi = (fwts_acpi_table_lpit_c_state *)data; uint32_t *ptr = (uint32_t *)data; uint32_t lpi_length = *(ptr + 1); + uint16_t uid = 0; /* Stated LPI length must not be longer than what's left in the table */ if (length < lpi_length) { @@ -181,6 +183,16 @@ static int lpit_test1(fwts_framework *fw) switch (*ptr) { case 0x0: lpit_check_type_0(fw, &length, &data, &passed); + + if (uid > lpi->id && (lpi->id - uid) > 1) { + passed = false; + fwts_failed(fw, LOG_LEVEL_CRITICAL, + "LPITNativeCStateBadUID", + "Unique ID of Native C-state based LPI " + "structure must be a zero-based monotonically " + "increasing value"); + } + uid = lpi->id; break; default: passed = false;