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 E36BB5349AC; Wed, 30 Sep 2026 17:51: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=1790790692; cv=none; b=FHyVptovMS9E4v3G9f4tmuAiHPvhl1gu6+hBjECCJUtJzYiezcVhuHe4wNm7LhoRvOelJV5zkYBkhwtOXeZpGrX7R8Mmhyau01jju24IbN+7TWCmPDIZ1ZY21H4vOv2hwU+dnJH+Y0DD+4znRSX8yRPY6Vq5JoR/BT3DWfIgSxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790790692; c=relaxed/simple; bh=lg5vLjXdjnc9JSg/qHBWJiONE1flNpU+aOL9hgqTXJQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ep1tKxWwfY/QbMzSADad60KoYiXjuLOuhau6V12hBirE894yV8JUDFYycvPBc3HkOg16mZiD0MKni9YqHkQVN7DuVSu1v5aOghAQ+NzdWh6MplNmhDOZ41wer1YkpFlUVv52q/BIb25yx6IeY5hhymslk/WT42+FJvtPbIcGnL4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=p1PKypkR; 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="p1PKypkR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B2B11F000FF; Wed, 30 Sep 2026 17:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790790690; bh=PFU7zJgfvUrVruS3jwiu2eGFZMFzY6pwdRaVREHZ08w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=p1PKypkRuH6NyUV58pdwpCHLYGA3dWqYaJZyFKO2+aFJySacldt7hsZ8TjjzLiheo vSwNPLK0rCND7g3H8Vm/cfFR6ahrSrqXt7h5UESDWUCj8R09yWxBf8pRYZIqdD2i69 2h/c6QlaVS/C24Ss2Qe+mGPiw/MuiDUkWpnUV+aE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sudeep Holla , Sasha Levin Subject: [PATCH 5.15 041/752] firmware: arm_scmi: Validate BASE_ERROR_EVENT payload size Date: Wed, 30 Sep 2026 17:18:31 +0200 Message-ID: <20260930152359.041377994@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152358.131179731@linuxfoundation.org> References: <20260930152358.131179731@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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sudeep Holla [ Upstream commit 56e7e64cdd0e7209a58c8ec66028d63387402919 ] BASE_ERROR_EVENT carries a variable number of message reports, with the count encoded in error_status. The notification parser used that count without checking whether the received payload contained all reported entries. Reject truncated payloads before copying the report array. Link: https://patch.msgid.link/20260517-scmi_fixes-v1-2-d86daec4defd@kernel.org Signed-off-by: Sudeep Holla Signed-off-by: Sasha Levin --- drivers/firmware/arm_scmi/base.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_scmi/base.c b/drivers/firmware/arm_scmi/base.c index 3fe172c03c247..40bc608ded142 100644 --- a/drivers/firmware/arm_scmi/base.c +++ b/drivers/firmware/arm_scmi/base.c @@ -292,6 +292,8 @@ static void *scmi_base_fill_custom_report(const struct scmi_protocol_handle *ph, void *report, u32 *src_id) { int i; + u32 error_status; + size_t expected_sz; const struct scmi_base_error_notify_payld *p = payld; struct scmi_base_error_report *r = report; @@ -305,10 +307,19 @@ static void *scmi_base_fill_custom_report(const struct scmi_protocol_handle *ph, if (evt_id != SCMI_EVENT_BASE_ERROR_EVENT || sizeof(*p) < payld_sz) return NULL; + expected_sz = offsetof(typeof(*p), msg_reports); + if (payld_sz < expected_sz) + return NULL; + r->timestamp = timestamp; r->agent_id = le32_to_cpu(p->agent_id); - r->fatal = IS_FATAL_ERROR(le32_to_cpu(p->error_status)); - r->cmd_count = ERROR_CMD_COUNT(le32_to_cpu(p->error_status)); + error_status = le32_to_cpu(p->error_status); + r->fatal = IS_FATAL_ERROR(error_status); + r->cmd_count = ERROR_CMD_COUNT(error_status); + expected_sz += r->cmd_count * sizeof(p->msg_reports[0]); + if (payld_sz < expected_sz) + return NULL; + for (i = 0; i < r->cmd_count; i++) r->reports[i] = le64_to_cpu(p->msg_reports[i]); *src_id = 0; -- 2.53.0