Skip to content

Commit 2af18f8

Browse files
author
Sudeep Holla
committed
firmware: arm_ffa: Keep framework RX release under lock
The framework notification handler drops rx_lock before issuing FFA_RX_RELEASE, leaving a window where another RX-buffer user can start a new FF-A transaction before ownership has actually been returned to firmware. Move the FFA_RX_RELEASE calls so they execute while rx_lock is still held on both the kmemdup() failure path and the normal success path. While doing that, switch the handler to scoped_guard() to keep the critical section explicit. Fixes: 285a5ea ("firmware: arm_ffa: Add support for handling framework notifications") Link: https://patch.msgid.link/20260428-ffa_fixes-v2-7-8595ae450034@kernel.org Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
1 parent 3974ea1 commit 2af18f8

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

drivers/firmware/arm_ffa/driver.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,25 +1492,22 @@ static void handle_fwk_notif_callbacks(u32 bitmap)
14921492
if (!(bitmap & FRAMEWORK_NOTIFY_RX_BUFFER_FULL))
14931493
return;
14941494

1495-
mutex_lock(&drv_info->rx_lock);
1495+
scoped_guard(mutex, &drv_info->rx_lock) {
1496+
msg = drv_info->rx_buffer;
1497+
buf = kmemdup((void *)msg + msg->offset, msg->size, GFP_KERNEL);
1498+
if (!buf) {
1499+
ffa_rx_release();
1500+
return;
1501+
}
14961502

1497-
msg = drv_info->rx_buffer;
1498-
buf = kmemdup((void *)msg + msg->offset, msg->size, GFP_KERNEL);
1499-
if (!buf) {
1500-
mutex_unlock(&drv_info->rx_lock);
1501-
return;
1503+
target = SENDER_ID(msg->send_recv_id);
1504+
if (msg->offset >= sizeof(*msg))
1505+
uuid_copy(&uuid, &msg->uuid);
1506+
else
1507+
uuid_copy(&uuid, &uuid_null);
1508+
ffa_rx_release();
15021509
}
15031510

1504-
target = SENDER_ID(msg->send_recv_id);
1505-
if (msg->offset >= sizeof(*msg))
1506-
uuid_copy(&uuid, &msg->uuid);
1507-
else
1508-
uuid_copy(&uuid, &uuid_null);
1509-
1510-
mutex_unlock(&drv_info->rx_lock);
1511-
1512-
ffa_rx_release();
1513-
15141511
read_lock(&drv_info->notify_lock);
15151512
cb_info = notifier_hnode_get_by_vmid_uuid(notify_id, target, &uuid);
15161513
read_unlock(&drv_info->notify_lock);

0 commit comments

Comments
 (0)