Skip to content

Commit 4a1cc9e

Browse files
author
Sudeep Holla
committed
firmware: arm_ffa: Validate framework notification message layout
Framework notifications carry an indirect message in the shared RX buffer. Validate the reported offset and size before using them, reject zero-length payloads, and ensure that any non-header payload starts at the UUID field rather than in the middle of the message header. Use the validated offset and size values for both kmemdup() and the UUID parsing path so malformed firmware data cannot drive an out-of-bounds read or an oversized allocation. Fixes: 285a5ea ("firmware: arm_ffa: Add support for handling framework notifications") Link: https://patch.msgid.link/20260428-ffa_fixes-v2-8-8595ae450034@kernel.org Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
1 parent 2af18f8 commit 4a1cc9e

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

drivers/firmware/arm_ffa/driver.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,21 +1487,35 @@ static void handle_fwk_notif_callbacks(u32 bitmap)
14871487
int notify_id = 0, target;
14881488
struct ffa_indirect_msg_hdr *msg;
14891489
struct notifier_cb_info *cb_info = NULL;
1490+
size_t min_offset = offsetof(struct ffa_indirect_msg_hdr, uuid);
14901491

14911492
/* Only one framework notification defined and supported for now */
14921493
if (!(bitmap & FRAMEWORK_NOTIFY_RX_BUFFER_FULL))
14931494
return;
14941495

14951496
scoped_guard(mutex, &drv_info->rx_lock) {
1497+
u32 offset, size;
1498+
14961499
msg = drv_info->rx_buffer;
1497-
buf = kmemdup((void *)msg + msg->offset, msg->size, GFP_KERNEL);
1500+
offset = msg->offset;
1501+
size = msg->size;
1502+
1503+
if (!size || (offset != min_offset && offset < sizeof(*msg)) ||
1504+
offset > drv_info->rxtx_bufsz ||
1505+
size > drv_info->rxtx_bufsz - offset) {
1506+
pr_err("invalid framework notification message\n");
1507+
ffa_rx_release();
1508+
return;
1509+
}
1510+
1511+
buf = kmemdup((void *)msg + offset, size, GFP_KERNEL);
14981512
if (!buf) {
14991513
ffa_rx_release();
15001514
return;
15011515
}
15021516

15031517
target = SENDER_ID(msg->send_recv_id);
1504-
if (msg->offset >= sizeof(*msg))
1518+
if (offset >= sizeof(*msg))
15051519
uuid_copy(&uuid, &msg->uuid);
15061520
else
15071521
uuid_copy(&uuid, &uuid_null);

0 commit comments

Comments
 (0)