From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8311247D94F for ; Tue, 28 Apr 2026 18:33:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777401237; cv=none; b=jfnSn+i6MyaA343WpDRHvEGh0RFnGnI6HUcrOqtVPrEEJBI+12V5pj/kf7CuAbuSjcmntNByOF593M3MN6mW8DfyVgmsIb/wv6B0z/Ctjwjt0KTNbSWKMjnqbO79FRAYYWUuj1nHMttcVdtof7b4hVRT/z1QYjvLgYRlkB2719Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777401237; c=relaxed/simple; bh=eNiNzrXTttjfdrO7y5bhY8rTyrVCsaLHM+IpsjVfBiI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bTQRn/rjh7xbEGh5O2S46MviQhzVVrDpa0KIh8yYvvRd+4ExoaJvydG/j6empnxTZjq6GPCPcC9XCiOV88MFPjNEjnh3JvfjhpRlb3KpOSHPCPyvSuVOTkf2WVHLHJH2FDufs7TX0DmJyQdraQO84QQ7BNHaU/A8aaGIyjoP1Eo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dt1zG7Sg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dt1zG7Sg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE107C2BCB3; Tue, 28 Apr 2026 18:33:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777401237; bh=eNiNzrXTttjfdrO7y5bhY8rTyrVCsaLHM+IpsjVfBiI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dt1zG7Sgb1C2R/yc+aiUzhiemV9UezXjVvGza8bdQAKqo71o1H84zPi67I1SvlRBE K17s7XmcN0a4ITjUfFpgZmGazXRhwcubjkyKd1emVJwyXkEsutKi6ke46IYD5PA7Wd 7K3OSYqXfd/vA1UVpeymM+mm+noT2EhMrx5qU3rjllbtd1ofF6VONPVFEboWRhsLtf 1NFSUOLEK/AecomFx4tS6sOdot4XwyU6dYfdjgKkWaxzdR3ZRzBJy4bKMOzyZQEGFA dVEfkNPCyUfvBHjRIAx27029DX8vx73blxNQBxT6aGTDTpbIV1Uae+ZMQdu6GV4kaR jBlVwYvOsyqZA== From: Sudeep Holla Date: Tue, 28 Apr 2026 19:33:31 +0100 Subject: [PATCH v2 07/11] firmware: arm_ffa: Keep framework RX release under lock Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260428-ffa_fixes-v2-7-8595ae450034@kernel.org> References: <20260428-ffa_fixes-v2-0-8595ae450034@kernel.org> In-Reply-To: <20260428-ffa_fixes-v2-0-8595ae450034@kernel.org> To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Jens Wiklander , Sudeep Holla X-Mailer: b4 0.15.2 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: 285a5ea0f542 ("firmware: arm_ffa: Add support for handling framework notifications") Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index ed502486eb35..18bcbd161805 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1494,25 +1494,22 @@ static void handle_fwk_notif_callbacks(u32 bitmap) if (!(bitmap & FRAMEWORK_NOTIFY_RX_BUFFER_FULL)) return; - mutex_lock(&drv_info->rx_lock); + scoped_guard(mutex, &drv_info->rx_lock) { + msg = drv_info->rx_buffer; + buf = kmemdup((void *)msg + msg->offset, msg->size, GFP_KERNEL); + if (!buf) { + ffa_rx_release(); + return; + } - msg = drv_info->rx_buffer; - buf = kmemdup((void *)msg + msg->offset, msg->size, GFP_KERNEL); - if (!buf) { - mutex_unlock(&drv_info->rx_lock); - return; + target = SENDER_ID(msg->send_recv_id); + if (msg->offset >= sizeof(*msg)) + uuid_copy(&uuid, &msg->uuid); + else + uuid_copy(&uuid, &uuid_null); + ffa_rx_release(); } - target = SENDER_ID(msg->send_recv_id); - if (msg->offset >= sizeof(*msg)) - uuid_copy(&uuid, &msg->uuid); - else - uuid_copy(&uuid, &uuid_null); - - mutex_unlock(&drv_info->rx_lock); - - ffa_rx_release(); - read_lock(&drv_info->notify_lock); cb_info = notifier_hnode_get_by_vmid_uuid(notify_id, target, &uuid); read_unlock(&drv_info->notify_lock); -- 2.43.0