Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1793085pxb; Mon, 23 Aug 2021 04:58:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJA8H61lm6/hhMPDIVIyVQY0P8KOO8lAg35zc+BIV64H7PV5D9Blwxf1oRalJZLLKhEKjx X-Received: by 2002:a05:6e02:78d:: with SMTP id q13mr22838980ils.262.1629719883368; Mon, 23 Aug 2021 04:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629719883; cv=none; d=google.com; s=arc-20160816; b=Ck7XyGBTmKgSafgdX63kcSc8mzPA+/EzTKFFlNXkaOymxQAvcWcx+jNAMMKEg35Y28 XDmQl18RTakp/gZG+hDi1ViHz8usANwHIxxAXXBaVgcvXnSnE6cue7zPLdwrVIQLojPx pliqIBT4xWFubdrHrz/5nXQLDR0zHmG63QXCFAMfgu1TAXF5ZZsjyWgBDEwvixyQrnjb vVdVQYWQ3GttJnw4wQ1Rg6NhxHafTJ7QLIz60Fx8TbJQNUa1AoiCybb/tiL2q/smkRfM xG58wjHra8KbJvv0YzY2jZexs9B3b8Ab5Ng5sn1lLH2XXVA8+OmRkjmwkiO4VV87PORY yTfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=kzhe3tz4ti2cvsDMx60UQk7xJRrm36DynbXcCRuqs8U=; b=qQ7UmVdxbmnsS+2NA0y5IqHcU6YfNOBBB+w7hXUeqbvOlYSwvLgkIbQcRLG5BGGnch d1VUg6HRccCoctQmcTeRx+LHKgahO+R4UAHg7wo+kozRgsbug/u1JtgLiGtbqE1uuTzh 5y1f2WwQltA/CltFDcQ13HdwlZP413oeG/nQu6UToKsDbCaTSAvGAm73NZ8Nm4my+m7i bh/aC2D8/xIkr8Nkq5d7Ea7e2Lcplzn2ucjzKec3p3m5zvPfe8q/FmjbuyCLw6WXzbEd rkwhFJ3CEuryQuicU7Mzjrf8m7eLiox2HG/p+im8D0p6vXuNd8OecqYyE6p5CeYnjUtK rCUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q14si13068332ilv.151.2021.08.23.04.57.50; Mon, 23 Aug 2021 04:58:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233684AbhHWL5m (ORCPT + 99 others); Mon, 23 Aug 2021 07:57:42 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:56053 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230289AbhHWL5l (ORCPT ); Mon, 23 Aug 2021 07:57:41 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R771e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=xueshuai@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0UlKNrJN_1629719817; Received: from localhost.localdomain(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0UlKNrJN_1629719817) by smtp.aliyun-inc.com(127.0.0.1); Mon, 23 Aug 2021 19:56:57 +0800 From: Shuai Xue To: ardb@kernel.org Cc: xueshuai@linux.alibaba.com, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, zhangliguang@linux.alibaba.com Subject: [PATCH] efi: cper: check section header more appropriately Date: Mon, 23 Aug 2021 19:56:54 +0800 Message-Id: <20210823115654.45405-1-xueshuai@linux.alibaba.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When checking a generic status block, we iterate over all the generic data blocks. The loop condition checks that the generic data block is valid. Because the size of data blocks (excluding error data) may vary depending on the revision and the revision is contained within the data block, we should ensure that enough of the current data block is valid appropiriately for different revision. Signed-off-by: Shuai Xue --- drivers/firmware/efi/cper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c index e15d484b6a5a..e80706d9e78a 100644 --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c @@ -635,7 +635,7 @@ int cper_estatus_check(const struct acpi_hest_generic_status *estatus) data_len = estatus->data_length; apei_estatus_for_each_section(estatus, gdata) { - if (sizeof(struct acpi_hest_generic_data) > data_len) + if (acpi_hest_get_size(gdata) > data_len) return -EINVAL; record_size = acpi_hest_get_record_size(gdata); -- 2.20.1.12.g72788fdb