From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA387C433F5 for ; Mon, 18 Apr 2022 13:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240221AbiDRN4m (ORCPT ); Mon, 18 Apr 2022 09:56:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244885AbiDRNbA (ORCPT ); Mon, 18 Apr 2022 09:31:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C3BBB40; Mon, 18 Apr 2022 05:57:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E7295B80D9C; Mon, 18 Apr 2022 12:57:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5178BC385A1; Mon, 18 Apr 2022 12:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286626; bh=CtgnVmjO7n35BM1i49bLL7QIy1XlXumsaStrof2QA5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EcV0zCs5H3Bykpzs6qYLHgW+oT3/Oe34aBiUqY+4lCOhNfXASZ7qHytmdQh78g+zC 6GpUjSYdLPXm1ECy4vPLbat/u+EqF0VPuK1NOfe84wVu0Xv+I/Yt5VRLWWMWtYFX87 TPKxo2UAz6u9ESXtRGUeLEsGoO2gwReJo06uelWY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , "Rafael J. Wysocki" , Huang Rui Subject: [PATCH 4.14 194/284] ACPI: CPPC: Avoid out of bounds access when parsing _CPC data Date: Mon, 18 Apr 2022 14:12:55 +0200 Message-Id: <20220418121217.247611588@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki commit 40d8abf364bcab23bc715a9221a3c8623956257b upstream. If the NumEntries field in the _CPC return package is less than 2, do not attempt to access the "Revision" element of that package, because it may not be present then. Fixes: 337aadff8e45 ("ACPI: Introduce CPU performance controls using CPPC") BugLink: https://lore.kernel.org/lkml/20220322143534.GC32582@xsang-OptiPlex-9020/ Reported-by: kernel test robot Signed-off-by: Rafael J. Wysocki Reviewed-by: Huang Rui Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/cppc_acpi.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -678,6 +678,11 @@ int acpi_cppc_processor_probe(struct acp cpc_obj = &out_obj->package.elements[0]; if (cpc_obj->type == ACPI_TYPE_INTEGER) { num_ent = cpc_obj->integer.value; + if (num_ent <= 1) { + pr_debug("Unexpected _CPC NumEntries value (%d) for CPU:%d\n", + num_ent, pr->id); + goto out_free; + } } else { pr_debug("Unexpected entry type(%d) for NumEntries\n", cpc_obj->type);