Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=80.241.56.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796293224; b=e5p/Y0hhlE0jTF2DZYPsp/Mkfnk4w9dW4FeHklj3XYLP6casZwo4ASTP4VcbLsR/t43V rI0JBSqSb46iaQYcnHkwO6lkYe0BvapIWxlqqaZiNqI4TMgDhuYToX7p7JYaXT9WXr8U+ r0xqSmQrXbkZM9iP/WqNrXSgp1mFacXEITld+zjE9/vCMXoeftJ3uiGWq/c1YlOPaigva F9iLz6iczj9Y2bRBee35fJb64rC5YbV6u7RUEsXNry7a3RA2+uudC2BWQk/XFkSxJJ7Iy fGLB1HD/xSeVeyjQm77376KCpyhc6ysEL5WcmwdBc6bWCQ9RSiJtdKq3IwyFpnz/dsQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796293224; h=DMARC-Filter:Received:DKIM-Signature:Message-ID:Subject:From: Reply-To:To:Cc:Date:In-Reply-To:References:Content-Type: Content-Transfer-Encoding:User-Agent:MIME-Version:X-MBO-RS-META: X-MBO-RS-ID; bh=2S0QaHbEswtf8m0rAMImZZpol6SjJ/Jqp/gRw8C6pMw=; b=JQQ10N0G3DZAzuo5g8OPVD72d6Qp1wQnihCq7l2AJ8HVpk9skwxQ4qGP87ZE7ssavOCA K9a4lMjZlpbl5K3CYeIBTTUz0XxDjLoLUiTp1SCm6SmcqXCs5zK3rVc9Mad9F/66V2TRg XahRDZE0hmZD8vx/daf360gfYujvvgxWUdzJo5txL8RNYc+gdtVxdMNFvVGd0kVtZLse8 NS5KBgSR6bAnPrRHTmNOUoctOioAMyWDYmhstsUDNgu6Z7MirvYqKyon+qWlQ35VOFdEh OhPD4mUOcdlbt0IDSDpG8Dx9lQISVr9syFMs2d+h9fapUsvb3tAC6PAvfGQClwWa9Ww== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=mailbox.org; spf=pass smtp.mailfrom=mailbox.org; dkim=pass header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=PQ0bRnxY; arc=none smtp.remote-ip=80.241.56.172 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) (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 3982B606A32C; Thu, 3 Dec 2026 10:20:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3982B606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mailbox.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=PQ0bRnxY Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4jg9cF4C2wzMlyZ; Thu, 03 Dec 2026 11:20:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1796293213; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2S0QaHbEswtf8m0rAMImZZpol6SjJ/Jqp/gRw8C6pMw=; b=PQ0bRnxYVTu/P9VlFSgGLHwNBQ4AptbGpp4qiKvMMSkirIlhiWBc/nIm8WSJ+bQ6TYmjQ+ 44YM20nI4bKxyAhJAJyXhiCv7IxKdz5nCNkrp0HJAZvUyDonXGhr44JZQGnPRXpBdd1QG3 t/NSkb+OH/ezwthcZBooo3R2UksD2mTeI8YwONnKHSADfBWe/RCzHjnrBIeUqj6XD3gyw4 FkOAChluBVWi9vM2xJCQWHtKjCbX6evAitl2phgS7pNILe6v/LUrd9IsxUelBt9WTaIX2k Com/+bGAK5Id0CnAEqzAPnsFF3eLfbJy7eRqyenrkRfzT8ZK9KPktHXt2vuULA== Message-ID: Subject: Re: [PATCH v3 5/9] rust: DmaFence: Replace call_rcu() with RcuState From: Philipp Stanner Reply-To: phasta@kernel.org To: Gary Guo , Philipp Stanner , Miguel Ojeda , Boqun Feng , =?ISO-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , Onur =?ISO-8859-1?Q?=D6zkan?= , Sumit Semwal , Christian =?ISO-8859-1?Q?K=F6nig?= , Matthew Brost , David Airlie , Simona Vetter , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Lyude Paul , "Joel Fernandes (NVIDIA)" , Boris Brezillon , Yuvan Shen Cc: rust-for-linux@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, rcu@vger.kernel.org Date: Thu, 03 Dec 2026 11:20:07 +0100 In-Reply-To: References: <20261202113914.1660411-2-phasta@kernel.org> <20261202113914.1660411-7-phasta@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-3.fc44) X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MBO-RS-META: ksq6ax4ic8icxiixw9p47opcr496opah X-MBO-RS-ID: 80301663da3a6b5a416 On Wed, 2026-12-02 at 17:12 +0000, Gary Guo wrote: [=E2=80=A6] > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // If a DriverFence signals= without doing a synchronize_rcu(), and a > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // fctx drops immediately a= fterwards, then backend_ops still accessing > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // the fctx might run into = UAF if we don't wait for them here. > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 synchronize_rcu(); >=20 > This condition is only true for !needs_drop? >=20 > I think this should be >=20 > =C2=A0=C2=A0=C2=A0 if !needs_drop::<...>() { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 synchronize_rcu(); > =C2=A0=C2=A0=C2=A0 } No, because fence callbacks also access the driver_name and timeline_name strings in the fctx and only are guaranteed to have stopped that after the last fence was signaled :) Besides fctx drop is not a hot path, they drop relatively rarely. > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // SAFETY: Valid because `s= elf` is valid. RCU above ensures that all > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // accessors are gone. > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsafe { drop_in_place(&raw= mut self.data) }; >=20 > Sashiko's finding is valid here. So if I do drop_in_place(NonNull) it does not invoke NonNull's drop in place? https://rust.docs.kernel.org/next/core/ptr/struct.NonNull.html#method.drop_= in_place So I gotta do `NonNull::drop_in_place(self.data)`. That's not super intuitive. If I do `drop(foo)`, then it will call foo's drop implementation. I understand why a drop(non_null) must not behave like that, but from a drop_in_place(non_null) I would expect it to call the deconstructor. P.