From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379924; b=rLkapijKbevc+65z26FByUUqnBupyjb4C40kx6mYVCqHNMbIMFU4G3SrRZfz75JN6BUl 2UzFCDKjlN12VYy7miv9ydjOJIn1h3Y0mlKuNhc4vwiSGN5IVk8IY4jb5dmLjpNdpsR0z +oy0B95enxyOCvT4Q7DhAFvAMYH+sOcsV9TN3eTrG5yLQchJc9xvCxKmWZbExx9CuuRQQ QEzmZsVR+cz57PA8Jjgmv93d7XSzoIykduY+1MEbFiymg0aaLZ206j++tN70k4wsDRbL6 o4je4wiCRRg176yAfRFUAREX6N6SwWGgajjcHIZ9SjoXiwaQnMg8HCgj54bzzZI7ynA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379924; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=5TojDtlVKvClybfmH3WQA6sbnzkinGLp3MeniqHIYm8=; b=sWrbmnLMUAbOymc8/e7tlRRgSMhA3g+O0Awf0NduTVBwojFcItRonx6MpkyzM/fTU07D SxgmgufH5WB21Xr3xeE7SE7fS5Im3RG97P9lyMqAuL5r9gXHYTCf++g1BypyYoBVkibLo BX5GPhPJo5Xzyk0gDFtBKvn7Y+sbRsZy7pw8UqP+FA7uuEMDb+Axgaq/YXzdhQm7vNfoC QdPxjsi2lP21pX+b9EHjaEsemf4XrkDnhB4fFrWu+xhvOE6M1VQeUpC0Okxauu7hu9rB5 asNGIimlrJA6F7yR4UxP5QBwo0HrwSGxc7wBx8mJS43go8FDQVFjw6naPSElApyKEyg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FFsVLVXm; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79419606A334; Fri, 4 Dec 2026 10:25:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FFsVLVXm Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC3761F000C2; Fri, 4 Dec 2026 10:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379924; bh=5TojDtlVKvClybfmH3WQA6sbnzkinGLp3MeniqHIYm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FFsVLVXm8F5rpnhCD9BEoBQ8ygTuoTD5/rZBLVjSdO0gNKAaC8PzkE+EFi74rybMM NON0usM0y2fxBq7vahjZSTgL+jV9d5kQtFVVvrGrH7VDZMYl6HT77i6eUUDOIKy0XS V61MFE2clLJwYTuWX7rd9gKvyY7hS2q637pVAUlQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Cemin , Sudeep Holla , Sasha Levin Subject: [PATCH 7.3 052/742] firmware: arm_ffa: Compare notify_id when looking up notifier callbacks Date: Fri, 4 Dec 2026 18:58:36 +0900 Message-ID: <20261204100636.457201202@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Cemin [ Upstream commit 8ab2e426762d199ce8b799d029edafbfb981f5c6 ] The notifier callbacks are kept in a hash table keyed by notification ID, but struct notifier_cb_info does not store the ID and none of the lookup helpers compare it. hash_for_each_possible() walks the whole bucket, so any two IDs that hash to the same bucket are treated as the same registration. With the 64-bucket table, hash_32() maps IDs 2 and 36 to the same bucket. A driver that requests notifications sequentially therefore fails at the 37th request: ARM FF-A: Failed to register callback for 36 - -22 because update_notifier_cb() finds the node registered for ID 2 and rejects the new registration as a duplicate. The same lookup is used on the delivery path, so a notification for a colliding ID can also be dispatched to the callback registered for the other ID. Store the notification ID in the node and compare it in all three lookup helpers. This was found on an arm64 laptop whose embedded controller partition declares 38 notifications: the EC driver failed to probe and every EC event (AC, battery, lid, hotkeys) was lost. Fixes: e0573444edbf ("firmware: arm_ffa: Add interfaces to request notification callbacks") Fixes: c10debfe7f02 ("firmware: arm_ffa: Add support for {un,}registration of framework notifications") Signed-off-by: David Cemin Link: https://patch.msgid.link/20261020220902.611138-1-dcemin@nvidia.com Signed-off-by: Sudeep Holla Signed-off-by: Sasha Levin --- drivers/firmware/arm_ffa/driver.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 28abc808fd32d..ae8cc3a2ba2e7 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1223,6 +1223,7 @@ struct notifier_cb_info { ffa_fwk_notifier_cb fwk_cb; ffa_notifier_cb cb; void *cb_data; + u16 notify_id; }; static int @@ -1302,7 +1303,8 @@ notifier_hnode_get_by_vmid(u16 notify_id, int vmid) struct notifier_cb_info *node; hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) - if (node->fwk_cb && vmid == node->dev->vm_id) + if (node->notify_id == notify_id && node->fwk_cb && + vmid == node->dev->vm_id) return node; return NULL; @@ -1317,7 +1319,8 @@ notifier_hnode_get_by_vmid_uuid(u16 notify_id, int vmid, const uuid_t *uuid) return notifier_hnode_get_by_vmid(notify_id, vmid); hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) - if (node->fwk_cb && vmid == node->dev->vm_id && + if (node->notify_id == notify_id && node->fwk_cb && + vmid == node->dev->vm_id && uuid_equal(&node->dev->uuid, uuid)) return node; @@ -1330,7 +1333,8 @@ notifier_hnode_get_by_type(u16 notify_id, enum notify_type type) struct notifier_cb_info *node; hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) - if (node->cb && type == ffa_notify_type_get(node->dev->vm_id)) + if (node->notify_id == notify_id && node->cb && + type == ffa_notify_type_get(node->dev->vm_id)) return node; return NULL; @@ -1422,6 +1426,7 @@ static int __ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, cb_info->dev = dev; cb_info->cb_data = cb_data; + cb_info->notify_id = notify_id; if (is_framework) cb_info->fwk_cb = cb; else -- 2.53.0