From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C708606A322 for ; Thu, 3 Dec 2026 05:59:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mZlp/b0+ Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A53CB10E0A4; Thu, 3 Dec 2026 05:59:17 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id E998610E0A4 for ; Thu, 3 Dec 2026 05:59:10 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 30D2740725; Thu, 3 Dec 2026 05:59:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0167E1F000C1; Thu, 3 Dec 2026 05:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796277550; bh=421UMBzmb0Xqgk2KFLmb+FROeiVSuzVdXi2sbwFzN6Q=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=mZlp/b0+uj+OVl32jUjw/ALxe6JMU1PGBpmF80IeuxTGNVMjZ6L6B6kte348A5fKU OnmDa+FZ6YxT1jBhiWPNm1QrEEt8ddUKkqUAQZwu9orAHKRFlMqolrF9P0Ta8kNtZS 07N2TwbO5Ajo1A0egaHgapiKlfm86y7RSOM6mcQv0uoyrmuPICOePKHnvDpSdkDSjj DQL6MUzU1b9UrfOgH++g8D7L9fPYqAvvXrIKdENy4fiK6kNoV1Z9f8zPXaaZteHOft 1nrzjWNir1lcyN+fJ9IyYDk1RTpFA0dHO7t+2NRCImJZ+gRChhUPK/g7gU/U9+BuYZ 7yCOs0lnzk7gA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/2] misc: fastrpc: use fastrpc_cb_devices_destroy() in probe error path To: "Ekansh Gupta" Cc: dri-devel@lists.freedesktop.org In-Reply-To: <20261203-fastrpc-probe-ordering-fix-v1-2-b5e56e5c895f@oss.qualcomm.com> References: <20261203-fastrpc-probe-ordering-fix-v1-0-b5e56e5c895f@oss.qualcomm.com> <20261203-fastrpc-probe-ordering-fix-v1-2-b5e56e5c895f@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 05:59:09 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] misc: fastrpc: UAF of CB devices freed by fastrpc_cb_devices_destroy() - [Low] misc: fastrpc: commit log misses that of_platform_depopulate() was a no-op - [Low] misc: fastrpc: inaccurate commit message and Fixes attribution -- commit 64e6c11d9bcb9cc1584f86ad076bfec7bd18df7d Author: Ekansh Gupta > misc: fastrpc: use fastrpc_cb_devices_destroy() in probe error path > > Since commit 81b3908cf7b9 ("misc: fastrpc: iterate CB nodes manually > instead of of_platform_populate"), the CB devices are created by > fastrpc_cb_devices_create(), but the probe error path still tears them > down with of_platform_depopulate(). > > Use fastrpc_cb_devices_destroy(), as fastrpc_rpmsg_remove() already > does, so that the sessions are invalidated under the channel lock > before the CB devices are removed. [Severity: Low] Does the commit message understate what this change fixes? fastrpc_cb_devices_create() creates child devices individually via of_platform_device_create() and never sets OF_POPULATED_BUS on rdev->of_node. Because of_platform_depopulate() returns immediately when OF_POPULATED_BUS is unset, it was a complete no-op that leaked the CB platform devices and left OF_POPULATED set on their DT nodes, causing later re-probes to fail with -ENODEV. In addition, cctx->session[i].valid is only checked in fastrpc_session_alloc() during fastrpc_device_open(), which misc_deregister() has already prevented before err_depopulate runs. > Fixes: 81b3908cf7b9 ("misc: fastrpc: iterate CB nodes manually instead of= of_platform_populate") > Co-developed-by: Vinayak Katoch > Signed-off-by: Vinayak Katoch > Signed-off-by: Ekansh Gupta [Severity: Low] Is this Fixes: tag pointing to the right commit? Commit 81b3908cf7b9 ("misc: fastrpc: iterate CB nodes manually instead of of_platform_populate") had no err_depopulate label or of_platform_depopulate() call. Commit 367972113065 ("misc: fastrpc: fix init ordering race in rpmsg probe") added err_depopulate on a branch that still used of_platform_populate(), and the mismatch was introduced by the merge commit 3680d0d62e9c ("Merge branch 'fastrpc-for-v7.5' into fastrpc-for-next"). If that merge commit is permanent in history, the commit message and Fixes: tag should reference it instead. > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > index cb0972722e083..ff8a94cc522d2 100644 > --- a/drivers/misc/fastrpc.c > +++ b/drivers/misc/fastrpc.c > @@ -2854,7 +2854,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device = *rpdev) > fastrpc_notify_users(user); > spin_unlock_irqrestore(&data->lock, flags); > =20 > - of_platform_depopulate(rdev); > + fastrpc_cb_devices_destroy(rpdev); > fastrpc_channel_ctx_put(data); > return err; [Severity: High] Can calling fastrpc_cb_devices_destroy() here trigger a use-after-free on the freed CB struct device? On CDSP and GDSP, fastrpc_rpmsg_probe() registers secure_fdevice before fdevice, so userspace can open the first node before the second fastrpc_device_register() fails and jumps to err_depopulate. Neither fastrpc_cb_init() nor __fastrpc_buf_alloc() takes a get_device() reference on the CB device, and clearing session[i].valid only blocks new opens. CPU0 (probe error path) CPU1 / kworker fastrpc_rpmsg_probe() fastrpc_device_register(secure) fastrpc_device_open() fl->sctx =3D &cctx->session[i] /* allocate buf / submit invoke */ fastrpc_device_register(non-sec) -> fails misc_deregister(...) fastrpc_notify_users() fastrpc_context_schedule_put_work() fastrpc_cb_devices_destroy() of_platform_device_destroy() platform_device_unregister() /* frees CB struct device */ fastrpc_context_put_wq() fastrpc_buf_free(ctx->buf) dma_free_coherent(buf->dev, ...) <-- use-after-free Because of_platform_depopulate() was previously a no-op, this change newly exposes the probe error path to freeing the CB platform devices while scheduled put_work, open fds (e.g. fastrpc_dmabuf_alloc()), and exported dma-bufs still dereference fl->sctx->dev and buf->dev, causing kernel memory corruption or a panic. (The same underlying fastrpc_cb_devices_destroy() issue also affects fastrpc_rpmsg_remove().) Should sessions and buffers hold a get_device() reference, or should CB device teardown wait until the last channel context reference is dropped in fastrpc_channel_ctx_free()? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-fastrpc-pr= obe-ordering-fix-v1-0-b5e56e5c895f@oss.qualcomm.com?part=3D2