All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@kernel.org>
To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: Jens Wiklander <jens.wiklander@linaro.org>,
	 Sudeep Holla <sudeep.holla@kernel.org>
Subject: [PATCH 5/8] firmware: arm_ffa: Validate framework notification payload bounds
Date: Thu, 23 Apr 2026 18:22:55 +0100	[thread overview]
Message-ID: <20260423-ffa_fixes-v1-5-61189661affe@kernel.org> (raw)
In-Reply-To: <20260423-ffa_fixes-v1-0-61189661affe@kernel.org>

Framework notification callbacks copy an indirect message payload out of
the shared Rx buffer. Validate the reported offset and size before
kmemdup() so malformed firmware data cannot drive an out-of-bounds read
or an oversized allocation.

Fixes: 285a5ea0f542 ("firmware: arm_ffa: Add support for handling framework notifications")
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
---
 drivers/firmware/arm_ffa/driver.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 764cb1226182..0e030f377985 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -1469,6 +1469,7 @@ static void handle_fwk_notif_callbacks(u32 bitmap)
 	int notify_id = 0, target;
 	struct ffa_indirect_msg_hdr *msg;
 	struct notifier_cb_info *cb_info = NULL;
+	size_t min_offset = offsetof(struct ffa_indirect_msg_hdr, uuid);
 
 	/* Only one framework notification defined and supported for now */
 	if (!(bitmap & FRAMEWORK_NOTIFY_RX_BUFFER_FULL))
@@ -1476,6 +1477,13 @@ static void handle_fwk_notif_callbacks(u32 bitmap)
 
 	scoped_guard(mutex, &drv_info->rx_lock) {
 		msg = drv_info->rx_buffer;
+		if ((msg->offset != min_offset && msg->offset < sizeof(*msg)) ||
+		    msg->offset > drv_info->rxtx_bufsz ||
+		    msg->size > drv_info->rxtx_bufsz - msg->offset) {
+			pr_err("invalid framework notification message\n");
+			goto release_rx;
+		}
+
 		buf = kmemdup((void *)msg + msg->offset, msg->size, GFP_KERNEL);
 		if (!buf)
 			goto release_rx;

-- 
2.43.0



  parent reply	other threads:[~2026-04-23 17:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23 17:22 [PATCH 0/8] firmware: arm_ffa: Fix cleanup, notification, and discovery paths Sudeep Holla
2026-04-23 17:22 ` [PATCH 1/8] firmware: arm_ffa: Check for NULL FF-A ID table while driver registration Sudeep Holla
2026-04-23 17:22 ` [PATCH 2/8] firmware: arm_ffa: Skip free_pages on RX buffer alloc failure Sudeep Holla
2026-04-23 17:22 ` [PATCH 3/8] firmware: arm_ffa: Align RxTx buffer size before mapping Sudeep Holla
2026-04-27  9:30   ` Sebastian Ene
2026-04-27 12:42     ` Sudeep Holla
2026-04-23 17:22 ` [PATCH 4/8] firmware: arm_ffa: Fix Rx buffer release in fwk notification handler Sudeep Holla
2026-04-23 17:22 ` Sudeep Holla [this message]
2026-04-23 17:22 ` [PATCH 6/8] firmware: arm_ffa: Unregister v1.0 bus notifier on teardown Sudeep Holla
2026-04-23 17:22 ` [PATCH 7/8] firmware: arm_ffa: Fix sched-recv callback partition lookup Sudeep Holla
2026-04-23 17:22 ` [PATCH 8/8] firmware: arm_ffa: Bound PARTITION_INFO_GET_REGS copies Sudeep Holla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260423-ffa_fixes-v1-5-61189661affe@kernel.org \
    --to=sudeep.holla@kernel.org \
    --cc=jens.wiklander@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.