From patchwork Thu Aug 3 21:32:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Baicar X-Patchwork-Id: 9879879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E3616037D for ; Thu, 3 Aug 2017 21:32:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12C8C2891C for ; Thu, 3 Aug 2017 21:32:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0710B28929; Thu, 3 Aug 2017 21:32:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C8452891C for ; Thu, 3 Aug 2017 21:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751845AbdHCVcb (ORCPT ); Thu, 3 Aug 2017 17:32:31 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:39344 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751599AbdHCVca (ORCPT ); Thu, 3 Aug 2017 17:32:30 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 24CE46081B; Thu, 3 Aug 2017 21:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1501795950; bh=vmLlU23yBdFPiB0SN2Zr8G0jrGsF5myW43qN99mmJhQ=; h=From:To:Cc:Subject:Date:From; b=neB9EOCdmnjbjZgn6Otv4OJbgtiMBZlvQLE6FxfEJ5bkk1RafJ20I4vCDUo1LGr9B xeKgpD8qx+OIWwvPhJeSwJYLRpslwdkrWNIhc4LzwYjeF36+A6X36jkPvwogpBYDg3 qBL+0XuBruC6IebkuZFiq2aUxTtao+ryqCW6mRDs= Received: from tbaicar-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tbaicar@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 1A969605A8; Thu, 3 Aug 2017 21:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1501795949; bh=vmLlU23yBdFPiB0SN2Zr8G0jrGsF5myW43qN99mmJhQ=; h=From:To:Cc:Subject:Date:From; b=mCwN62P/vZyAQS2UN86JcTZDgCsroIIQJjP8vBA3v4gAgS1mGZD/ZzME0AkBPmDyF nYdf0h5EHbgPRz0OphwW46hXFv5slERsv6qPvwWkxrIF4EpIISyYAJCDJpEqlIdPbJ 5HBXczgHQoLvd5FxPm5K7vNJ+7b9uq7npiANX1EY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1A969605A8 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=tbaicar@codeaurora.org From: Tyler Baicar To: rjw@rjwysocki.net, lenb@kernel.org, will.deacon@arm.com, james.morse@arm.com, bp@suse.de, shiju.jose@huawei.com, geliangtang@gmail.com, andriy.shevchenko@linux.intel.com, tony.luck@intel.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, austinwc@codeaurora.org Cc: Tyler Baicar Subject: [PATCH] acpi: apei: fix GHES estatus iteration Date: Thu, 3 Aug 2017 15:32:25 -0600 Message-Id: <1501795945-5331-1-git-send-email-tbaicar@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently iterating through the GHES estatus blocks does not take into account the new generic data v3 structure size. This can result in garbage non-standard trace events to be triggered since the loop will not properly iterate through the estatus blocks and not properly terminate. Update the GHES estatus iteration to properly increment through the estatus blocks similar to how the CPER estatus printing iterates through them. Fixes: bbcc2e7b642e ("ras: acpi/apei: cper: add support for generic data v3 structure") Signed-off-by: Tyler Baicar Tested-by: Austin Christ --- drivers/acpi/apei/apei-internal.h | 5 ----- drivers/acpi/apei/ghes.c | 8 +++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h index 6e9f14c..cb41260 100644 --- a/drivers/acpi/apei/apei-internal.h +++ b/drivers/acpi/apei/apei-internal.h @@ -120,11 +120,6 @@ int apei_exec_collect_resources(struct apei_exec_context *ctx, struct dentry; struct dentry *apei_get_debugfs_dir(void); -#define apei_estatus_for_each_section(estatus, section) \ - for (section = (struct acpi_hest_generic_data *)(estatus + 1); \ - (void *)section - (void *)estatus < estatus->data_length; \ - section = (void *)(section+1) + section->error_data_length) - static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus) { if (estatus->raw_data_length) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 6a6895a..dba1771 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -466,9 +466,13 @@ static void ghes_do_proc(struct ghes *ghes, guid_t *sec_type; guid_t *fru_id = &NULL_UUID_LE; char *fru_text = ""; + unsigned int data_len; sev = ghes_severity(estatus->error_severity); - apei_estatus_for_each_section(estatus, gdata) { + data_len = estatus->data_length; + gdata = (struct acpi_hest_generic_data *)(estatus + 1); + + while (data_len >= acpi_hest_get_size(gdata)) { sec_type = (guid_t *)gdata->section_type; sec_sev = ghes_severity(gdata->error_severity); if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID) @@ -528,6 +532,8 @@ static void ghes_do_proc(struct ghes *ghes, sec_sev, err, gdata->error_data_length); } + data_len -= acpi_hest_get_record_size(gdata); + gdata = acpi_hest_get_next(gdata); } }