From patchwork Wed Jan 18 06:35:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuai Xue X-Patchwork-Id: 45048 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2194532wrn; Tue, 17 Jan 2023 23:34:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXufn6DyToHyp78iakYBI5YAv/rb19g46ZxFw2MDggJbiwHbmOpp9mtgeQ/RUWdvH2rOlh9i X-Received: by 2002:a17:906:2b8e:b0:86e:3531:5548 with SMTP id m14-20020a1709062b8e00b0086e35315548mr5478630ejg.73.1674027278942; Tue, 17 Jan 2023 23:34:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674027278; cv=none; d=google.com; s=arc-20160816; b=atZinNiujck5ukn4DX3sHzGSG5rDn2030m1ECLxM6t+scif4RPML71GpEarb9tIc2T iRIBdmVv2X2eU2Plv+ZlYFXeVbfA3iMfsOYT4OUfDREQ6ITa9osYijvOv4bxNgR2TDGr 01ensDJ0jw/POcV+7HmqS1f8kef7voh6/5nQhvQwPXIeKefj35OJ1sAfNNfpbiXjZ4fx JUOcm6KYvyEthv5T1lEXT+dYZpYxoph0AkdJHK91srC25e9RWwE3d04xiOPd7Pq5gkL3 /GqsKkFNKEOS0Jp6xB4WGuYNHi3Iv0LJrM0YmylbhXffARlWNzW/3KuYvSBdKO4nlnF2 9ZbA== 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=1/ssCWb5ZaUCeipe75nLOMnFRoejTrwpyx1qmz008ik=; b=ICQWO4e+cPuK+oEUeqjgdFrMI70dKToPJUOScvjXAtX9O2ekp8awfDZ6TgmZc4m9Jl TRRfg+V6G/PG2qmRAQoy/N3pYtDskTIiUdZbfL/P2yN3+F0ShU3oCs9BaNB2Ho4FBGsq I4qU9l697laCgQt5f4HobG18YK/3KxtlfKr5sTMnlqlcDS7TpwjFK9jxVVU5dJaG0hSQ xm03KY73Hw2gGskUcbd+WwClTOXE+udVLSyo9YWKl/t8i0U16xFg2Rvk4Gqg4L64xHdc QeAB6qv3iuxAV/Og7Vea5nL/U/teqvybXrEcnd8bn0EDQ+ZNXBBko42l3XM1tZnUiz7y 5PnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds8-20020a170907724800b00872baebe5d0si4878951ejc.302.2023.01.17.23.34.08; Tue, 17 Jan 2023 23:34:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229733AbjARHJF (ORCPT + 99 others); Wed, 18 Jan 2023 02:09:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbjARHIU (ORCPT ); Wed, 18 Jan 2023 02:08:20 -0500 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 206706C54B; Tue, 17 Jan 2023 22:35:31 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=xueshuai@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0VZpGQyN_1674023708; Received: from localhost.localdomain(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0VZpGQyN_1674023708) by smtp.aliyun-inc.com; Wed, 18 Jan 2023 14:35:10 +0800 From: Shuai Xue To: rafael@kernel.org, tony.luck@intel.com, bp@alien8.de Cc: lenb@kernel.org, james.morse@arm.com, jaylu102@amd.com, benjamin.cheatham@amd.com, dan.j.williams@intel.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linux.alibaba.com, xueshuai@linux.alibaba.com, zhuo.song@linux.alibaba.com Subject: [PATCH] ACPI: APEI: EINJ: Limit error type to 32-bit width Date: Wed, 18 Jan 2023 14:35:04 +0800 Message-Id: <20230118063504.58026-1-xueshuai@linux.alibaba.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755344827967417929?= X-GMAIL-MSGID: =?utf-8?q?1755344827967417929?= The bit map of error types to inject is 32-bit width[1]. Add parameter check to reflect the fact. [1] ACPI Specification 6.4, Section 18.6.4. Error Types Signed-off-by: Shuai Xue Reviewed-by: Tony Luck --- drivers/acpi/apei/einj.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index ab86b2f4e719..b4373e575660 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c @@ -616,6 +616,10 @@ static int error_type_set(void *data, u64 val) u32 available_error_type = 0; u32 tval, vendor; + /* Only low 32 bits for error type are valid */ + if (val & GENMASK_ULL(63, 32)) + return -EINVAL; + /* * Vendor defined types have 0x80000000 bit set, and * are not enumerated by ACPI_EINJ_GET_ERROR_TYPE