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 55122501285; Wed, 30 Sep 2026 15:35:30 +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=1790782541; cv=none; b=LS1nQiFr19FcReXZXq0OIqFu115ZNXHMbbe33awvO7Ra2dSNlwIyZaU24isa3hk12y6cZMSetnNTxM35MWaM8ksWCqiPJROpHGJOg6qNb/zT78/KUGJMkN9HEV1w7aUDjzL9Qxlt0uOWbaLgVaFZEVEu3/RgVzORFH4wZgnteSg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790782541; c=relaxed/simple; bh=FgD4RFbu2jgGe9x+LFX7otTBs49Wlk8xDa3M/q0Wx3M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rjHbSek2TIvaG0JzPvo3SgRy644DvAcs6MsaXvfG0IwjxgAPm0WHDOg2ADOBjewt8ukIf74LMhHRwvBplM5IbWt7HOJ/mVzjgTCOhBo9knUl/Sw0snACPaGL6C2qhN/5uf6MxUtxSXRDGWzVbYspKZHc/iZOHcg1Dmo3VdN+bsg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LkUhG6+I; 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="LkUhG6+I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B74C51F00893; Wed, 30 Sep 2026 15:35:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790782530; bh=wBTJRW0FzfYOnHMwHzV64n2y84iP+O9rjp0xn9AjS1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LkUhG6+I16S2/iXftJY77dJn1JnJC5y8RpdGwTXpJu1qTvgZLxg+0MINhgtRGYgpH o81dv1aR+5ZAuLokyUz5W6NwvRjfE/GDP84fTSFbO4xGr5HuQMR1sOgNaY8sFDWFQH gC6rIMMjRSx/zb++SWhQ4QqMR4MQ/aBuEInTPDFE= 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 5.10 080/595] ACPICA: Enhance buffer validation in acpi_ut_walk_aml_resources() Date: Wed, 30 Sep 2026 17:19:33 +0200 Message-ID: <20260930152349.459895649@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152347.700140858@linuxfoundation.org> References: <20260930152347.700140858@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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: ikaros [ Upstream commit b2e21fe8c3361c3d0d57ee56d359bea9b51fda3d ] Enhance buffer validation in acpi_ut_walk_aml_resources() to prevent buffer overflows. Link: https://github.com/acpica/acpica/commit/975cb20c7992 Signed-off-by: ikaros Signed-off-by: Rafael J. Wysocki Link: https://patch.msgid.link/2481429.NG923GbCHz@rafael.j.wysocki Signed-off-by: Sasha Levin --- drivers/acpi/acpica/utresrc.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c index cba5505171dac..d98f1d1c9eaae 100644 --- a/drivers/acpi/acpica/utresrc.c +++ b/drivers/acpi/acpica/utresrc.c @@ -161,6 +161,28 @@ acpi_ut_walk_aml_resources(struct acpi_walk_state *walk_state, /* Walk the byte list, abort on any invalid descriptor type or length */ while (aml < end_aml) { + /* + * Validate that the remaining buffer space can hold enough + * bytes to safely access fields during validation. + * For large resource descriptors (bit 7 set), we need enough + * bytes to access the Type field in serial_bus resources. + * Small resource descriptors only need sizeof(struct aml_resource_end_tag). + */ + if ((acpi_size)(end_aml - aml) < + sizeof(struct aml_resource_end_tag)) { + return_ACPI_STATUS(AE_AML_BUFFER_LENGTH); + } + + /* + * For large resource descriptors, ensure enough space for + * the header plus serial_bus Type field access. + */ + if ((ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) && + ((acpi_size)(end_aml - aml) < + ACPI_OFFSET(struct aml_resource_common_serialbus, + type) + 1)) { + return_ACPI_STATUS(AE_AML_BUFFER_LENGTH); + } /* Validate the Resource Type and Resource Length */ @@ -178,6 +200,14 @@ acpi_ut_walk_aml_resources(struct acpi_walk_state *walk_state, length = acpi_ut_get_descriptor_length(aml); + /* + * Validate that the descriptor length doesn't exceed the + * remaining buffer size to prevent reading beyond the end. + */ + if (length > (acpi_size)(end_aml - aml)) { + return_ACPI_STATUS(AE_AML_BUFFER_LENGTH); + } + /* Invoke the user function */ if (user_function) { -- 2.53.0