From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795029912; b=ZN/qY6IbSvIgceh4gJ9htcZwwbJtaf6kLXN3GxC2rGJF3QBEWqo+SQKYpz3kWdAUQROM Xi5XEF0WiK+0oT4s2L7yX0s9z/riVdHJhrDZN1kuUjP1F5d7XUMbHKIwgBaan2J0h8dy2 HFwpuNxcQqbvqLxN6O2gHY4G1qJohaT4NCD03KJCIVBrfmU0o5TYzu/7/Ub5rUVrU8Zd1 rnnp7pzkxZg6+FiNs5MFTU5c7i6xu4QYSXwW+nB0zrd77UE5qdieNN8VUBGIAqKan+ajy G/7N++6v64UhU7osKGj8sU0nDlrZTrKJZqY3/n0XZGpG4haNT4dEqYS2kqazgRgAHrA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795029912; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=0B86w9upqn5yusWY1pur+KfeHiPVckP6YV6pawOXAtA=; b=GRkQJA1OOVWkWsIPxTb98dVB4ZZjliFe5u7wmfFnK7LQczVrnF0aCqtuNWfjaenDyRSa eAbL+RvJaGJuGI1PpHtvPYY3qzL20peyXiubyovZJY9bn/bvTDuQjJtJ6lJpp36U53S6K UNQf1qkajdPwiCgbDxVXW2o00gjvK5hVioBxEyVMXuy3sOtLKy32KdYTV9W5D2cFMEhZd s06abLmvBpJvOKq+anCeMNEZg4U79wVwRjaLBfh4Kedn8lROgdPYyv/aULPLkp+E142Ec ZQVwcfjwfj7buT9p470w8ARG8x1ZYV8kPQlfFbhbOwf2lLP+pNGpEXAuSB/6TwkcBrA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=d1eEwaNL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4733060A2628; Wed, 18 Nov 2026 19:25:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=d1eEwaNL Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9852C1F0089E; Wed, 18 Nov 2026 19:25:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795029912; bh=0B86w9upqn5yusWY1pur+KfeHiPVckP6YV6pawOXAtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=d1eEwaNLkcJ5dMqM2nrOPA67dqfUzevoqxe0biK1zra83Lvidf4/qJTCG0nZpTMAe cyfyjh9d73iDOUzyrC/Fx1eZkJxoNNhDN+QhNtPq3LyWHLm1L6eKD4TxG2yh4SQiSS oiTXAwwe0go7WdObl+7HUQYwGNKjzJTvwsYjgEjs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , Christian Loehle , Sumit Gupta , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 6.12 0466/1756] ACPI: CPPC: Validate the _CPC package header Date: Wed, 18 Nov 2026 15:43:13 +0100 Message-ID: <20261118150027.392321651@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150007.957976754@linuxfoundation.org> References: <20261118150007.957976754@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christian Loehle [ Upstream commit fb345025f161d17fe7c8a6048c7e80e467fa8ddf ] The _CPC NumEntries field includes every package element, including NumEntries and Revision. acpi_cppc_processor_probe() nevertheless reads those first two elements before checking that they exist and trusts NumEntries when walking the remaining elements. Reject packages with fewer than two elements and NumEntries values which exceed the package count before accessing Revision or iterating over register descriptors. Although the specification defines NumEntries as the number of package elements, tolerate additional trailing elements because ignoring them is safe and avoids rejecting padded firmware. Revision is specified as a BYTE, but the parser assigns its 64-bit AML Integer to an unsigned int before validating it. Reject values above U8_MAX before conversion so, for example, 0x100000004 cannot truncate to revision 4. Fixes: 337aadff8e45 ("ACPI: Introduce CPU performance controls using CPPC") Reported-by: Sashiko Link: https://sashiko.dev/#/patchset/20260724134251.1632824-1-christian.loehle%40arm.com Link: https://sashiko.dev/#/patchset/20260808082644.1251332-1-christian.loehle%40arm.com Signed-off-by: Christian Loehle Tested-by: Sumit Gupta Link: https://patch.msgid.link/20260916162805.1039247-2-christian.loehle@arm.com Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/cppc_acpi.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 95ab801679e83..bc8481a8c534b 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -737,6 +737,11 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) } out_obj = (union acpi_object *) output.pointer; + if (out_obj->package.count < 2) { + pr_debug("Unexpected _CPC package count (%u) for CPU:%d\n", + out_obj->package.count, pr->id); + goto out_buf_free; + } cpc_ptr = kzalloc(sizeof(struct cpc_desc), GFP_KERNEL); if (!cpc_ptr) { @@ -747,12 +752,15 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) /* First entry is NumEntries. */ 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); + if (cpc_obj->integer.value < 2 || + cpc_obj->integer.value > out_obj->package.count) { + pr_debug("Invalid _CPC NumEntries (%llu) for package count (%u) on CPU:%d\n", + cpc_obj->integer.value, out_obj->package.count, + pr->id); goto out_free; } + + num_ent = cpc_obj->integer.value; } else { pr_debug("Unexpected _CPC NumEntries entry type (%d) for CPU:%d\n", cpc_obj->type, pr->id); @@ -762,6 +770,12 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) /* Second entry should be revision. */ cpc_obj = &out_obj->package.elements[1]; if (cpc_obj->type == ACPI_TYPE_INTEGER) { + if (cpc_obj->integer.value > U8_MAX) { + pr_debug("Invalid _CPC Revision (%llu) for CPU:%d\n", + cpc_obj->integer.value, pr->id); + ret = -EINVAL; + goto out_free; + } cpc_rev = cpc_obj->integer.value; } else { pr_debug("Unexpected _CPC Revision entry type (%d) for CPU:%d\n", -- 2.53.0