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 87255EEB560 for ; Fri, 8 Sep 2023 18:04:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243016AbjIHSEP (ORCPT ); Fri, 8 Sep 2023 14:04:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343593AbjIHSEM (ORCPT ); Fri, 8 Sep 2023 14:04:12 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A539B1FF6; Fri, 8 Sep 2023 11:03:40 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E076C43397; Fri, 8 Sep 2023 18:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694196157; bh=cWfzasjKc6OYRtp8td5HXClSIfRavFdl20grMYcqxao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WBmTPYs0LxK/0Xv0RdPPXbzHEqNOyTOo7LQa1fVCRZ93ap32h5k/z15P9aErNBuwl U2YGb+aW6wTK1hfUKjOnYfXNF0kqlHVhE7giMM5Yrg4LL9nimxdG6vQe3XmAggYXrn al+jz/4XlYpc5yRMpCbp5e1LbHJ4TuEwgXuyEWNK+z49GM9aGn6RgnQ1R0X0z4eRjk YS0rfkGov88Siuis5MbaNOPfBgZZfEBCFj+XGE5h607agxPrZrNwuuDCisBCTpVor9 CONxbb+pID8CHo1YnFy/nPQmp8MC+G+49x0AMEpx5aBMa10dhqZcfOpLyAnYsmKHL5 lZFoNHaG55hRg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mario Limonciello , Bjorn Helgaas , "Rafael J . Wysocki" , Sasha Levin , rafael@kernel.org, philipp.zabel@gmail.com, andriy.shevchenko@linux.intel.com, linux-acpi@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 09/10] ACPI: x86: s2idle: Catch multiple ACPI_TYPE_PACKAGE objects Date: Fri, 8 Sep 2023 14:02:01 -0400 Message-Id: <20230908180203.3458330-9-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230908180203.3458330-1-sashal@kernel.org> References: <20230908180203.3458330-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.52 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Mario Limonciello [ Upstream commit 883cf0d4cf288313b71146ddebdf5d647b76c78b ] If a badly constructed firmware includes multiple `ACPI_TYPE_PACKAGE` objects while evaluating the AMD LPS0 _DSM, there will be a memory leak. Explicitly guard against this. Suggested-by: Bjorn Helgaas Signed-off-by: Mario Limonciello Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/x86/s2idle.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c index e499c60c45791..2e0778ddd0ad8 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -112,6 +112,12 @@ static void lpi_device_get_constraints_amd(void) union acpi_object *package = &out_obj->package.elements[i]; if (package->type == ACPI_TYPE_PACKAGE) { + if (lpi_constraints_table) { + acpi_handle_err(lps0_device_handle, + "Duplicate constraints list\n"); + goto free_acpi_buffer; + } + lpi_constraints_table = kcalloc(package->package.count, sizeof(*lpi_constraints_table), GFP_KERNEL); -- 2.40.1