From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DB175013C9; Wed, 30 Sep 2026 16:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790784297; cv=none; b=GFL/7Z1e1ODZVWGWKhMV33gjFy0XrrlUBGqvd77QAbHIo1AuDD6JGTt4q04J+usvfDPZjFOlXu06tPkMugUV5fdUdTPl73UCH6URVEmt7ErlJt2V9pkswKXQFk33VmQwZ6C9O2rD6r546CWcID0yEvm8VnrwX6OvoB8BymW16wo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790784297; c=relaxed/simple; bh=qhfDWYtyFTNn35yf1m0xu3GfrOtvrgXtE/1EhV+4nbY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FY1QQVJMu+7c2LfT+jzVUGXdbQTyWpNr7ZVBNgsOhGRRkBDxv3GhWLkAllNrFWVEYea7U2SgzzpbDGWj3e064YbwqB6PEf5HyKsnuuuNMXrYTv97YEmfQF061234CLNZQiBo3Ne51XME9JuxYj18ZjXWU7HE5CRgz1eL+eH4ujM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=F/unyM+f; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="F/unyM+f" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 102D71F00898; Wed, 30 Sep 2026 16:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790784292; bh=yR/iOlv1ygoWcd2Z8dcOqTM7WjGtcxQIqE80+Fda2xM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=F/unyM+f/vO3zxCpPsEjEeqOy06qqAT9Vc3wzktaycertXtEJOB7Xo4AU9o4LGhRg DWg9FJSSVKED3Y9kbqkLDGahmHavyw+2WvkTjdavbD4i5uDxGw3nRIdu1KdSwvhWpg oLADKn0ALCTF7xV2duTsES6tfLPaSMfujUnrKdQM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, ikaros , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 6.1 103/982] ACPICA: validate byte_count in acpi_ps_get_next_package_length() Date: Wed, 30 Sep 2026 17:13:59 +0200 Message-ID: <20260930152419.024589983@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152416.775402466@linuxfoundation.org> References: <20260930152416.775402466@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: ikaros [ Upstream commit d49c6ee08365a8596f639da46eb7e71752b0cd42 ] Validate package length reading in acpi_ps_get_next_package_length(). Link: https://github.com/acpica/acpica/commit/40e03f9941e2 Signed-off-by: ikaros Signed-off-by: Rafael J. Wysocki Link: https://patch.msgid.link/3616255.QJadu78ljV@rafael.j.wysocki Signed-off-by: Sasha Levin --- drivers/acpi/acpica/psargs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c index 55af9b3fe8d40..cc27f7888bdca 100644 --- a/drivers/acpi/acpica/psargs.c +++ b/drivers/acpi/acpica/psargs.c @@ -48,6 +48,7 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) u32 package_length = 0; u32 byte_count; u8 byte_zero_mask = 0x3F; /* Default [0:5] */ + u32 remaining; ACPI_FUNCTION_TRACE(ps_get_next_package_length); @@ -55,7 +56,23 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) * Byte 0 bits [6:7] contain the number of additional bytes * used to encode the package length, either 0,1,2, or 3 */ + + /* Check if we have at least one byte to read */ + remaining = (u32)ACPI_PTR_DIFF(parser_state->aml_end, aml); + if (remaining == 0) { + return_UINT32(0); + } + byte_count = (aml[0] >> 6); + + /* Validate byte_count and ensure we have enough bytes to read */ + if (byte_count >= remaining) { + + /* Clamp to available bytes and advance to end */ + parser_state->aml = parser_state->aml_end; + return_UINT32(0); + } + parser_state->aml += ((acpi_size)byte_count + 1); /* Get bytes 3, 2, 1 as needed */ -- 2.53.0