Received: from fhigh-b3-smtp.messagingengine.com (fhigh-b3-smtp.messagingengine.com [202.12.124.154]) (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 E1829846A for ; Mon, 18 May 2026 13:40:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.154 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779111637; cv=none; b=AmduXJQuQTT8qYrdFTNeeOCm17cTH4p0UmtWyK33VLOA1BgCMf27lvZFDjg6P72dmfe/mG/T9tX8ZasoFaOQdqGSoL4sHDOVw4vZ5n2qDNJfg2xnc1mUSha4Z48LFOfMI1ucbMbyPkvVqs4sG6ADYYi6kg8oPBmlDIoITPRQuvo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779111637; c=relaxed/simple; bh=y5YCMW5pJxVRzfiREh/cwGNAxSOXwhuCaPub7DT4Ge8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Dd/fFi3Th90WZ5SqHE2yPn1xDxnZx7cI6Y5hQ85KRHaunp+pCPovqEMPK7dZSYxJ6UbsshIH76y6aX6G4f85c0vB/CG7veGSJmr1mMl+/FD4FqGkmDZyGjD+rJXFXryepDfGWjBQy7pEgEzafb42HWPyPYlc4r7HwKVdsV4HSjc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bsbernd.com; spf=pass smtp.mailfrom=bsbernd.com; dkim=pass (2048-bit key) header.d=bsbernd.com header.i=@bsbernd.com header.b=nKlGXvTe; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=OGccABEX; arc=none smtp.client-ip=202.12.124.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bsbernd.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bsbernd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bsbernd.com header.i=@bsbernd.com header.b="nKlGXvTe"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OGccABEX" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id BB4CF7A011C; Mon, 18 May 2026 09:40:34 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Mon, 18 May 2026 09:40:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsbernd.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1779111634; x=1779198034; bh=x3ZnqmK6dBpt+lvdbHCPoG4z49tou97P+HHjRNGSdzo=; b= nKlGXvTe93YUQ0hNiKL2M7BCTu6j6idwDwg9e5zFMUAA0rabTsfgpgyJ+gQ1iEXH MLRkqf6XeOfIMYO/fF6TjAV1DwNkVcjv71FsgVXK3WO4jHAh9OMlM6mCtxsK7ODA 16FeI1XH7CfAyTpts9VwO9LRa+7aRNJ1SfNENdt4DMAF2d1BzhgKxd7XYDretDBW Zj9tA+qZUZJxicWaWOEb8+0pr8OYSS1dz8ykqGclRzumpTzlVXM5eANB1Z+CoYdn Q0FtbxLl9IIBTocykXAHM0hKYVbwC/5xBw/6C/zTs05pV6vPanRf1jrNVjXnjnt+ Wh81AAK9Ryi7hMoj1i3MSg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1779111634; x= 1779198034; bh=x3ZnqmK6dBpt+lvdbHCPoG4z49tou97P+HHjRNGSdzo=; b=O GccABEXAVJuNfUBx0I1OaxBgZkQ1v9+QZwa4HrSeZWDkJKeZVCQjf7OvSh9f4Gcv aOHXlVZxCvdr8Z8azgTE8/8idXKDIOZRcQxze9f1aLgJi9NSZzgBNIAs9FBXCbkf IXraQxUzgm9lnHwhEMbvjMpVXezT9IX88W8Uc6b8LqmCTWyKDm1O4qnWeA1ngP03 M0aNwR7QWTUyAMrfwsWv6xaSXJTWQwllx2gr/NpU589HsJn5IsVHEg/ur2JZNUbr PoXH8f64s+SlbOPQNOSqUYhMBgMEIMnLarkrUcsdHD7T6C1CVOcwbJd7khqI4/wj ms5Dkj7CXF5XxGL2gwBPA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddufeeltdduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeeuvghrnhgu ucfutghhuhgsvghrthcuoegsvghrnhgusegsshgsvghrnhgurdgtohhmqeenucggtffrrg htthgvrhhnpeehhfejueejleehtdehteefvdfgtdelffeuudejhfehgedufedvhfehueev udeugeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gsvghrnhgusegsshgsvghrnhgurdgtohhmpdhnsggprhgtphhtthhopeejpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopehjohgrnhhnvghlkhhoohhnghesghhmrghilhdrtg homhdprhgtphhtthhopehmihhklhhoshesshiivghrvgguihdrhhhupdhrtghpthhtohep fhhushgvqdguvghvvghlsehlihhsthhsrdhlihhnuhigrdguvghvpdhrtghpthhtoheprg hlihesuggunhdrtghomhdprhgtphhtthhopehhohhrshhtsegsihhrthhhvghlmhgvrhdr uggvpdhrtghpthhtohepghhgrghnjhhiuddusehnrghvvghrrdgtohhmpdhrtghpthhtoh epshhtrggslhgvsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i5c2e48a5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 18 May 2026 09:40:33 -0400 (EDT) Message-ID: Date: Mon, 18 May 2026 15:40:31 +0200 Precedence: bulk X-Mailing-List: fuse-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 3/3] fuse: fix moving cancelled entry to ent_in_userspace list To: Joanne Koong , miklos@szeredi.hu Cc: fuse-devel@lists.linux.dev, ali@ddn.com, horst@birthelmer.de, Heechan Kang , stable@vger.kernel.org References: <20260515045541.1171335-1-joannelkoong@gmail.com> <20260515045541.1171335-4-joannelkoong@gmail.com> From: Bernd Schubert Content-Language: fr, en-US, de-DE, ru-RU In-Reply-To: <20260515045541.1171335-4-joannelkoong@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/15/26 06:55, Joanne Koong wrote: > fuse_uring_cancel() moves entries that are available (these have no reqs > attached) to the ent_in_userspace list. ent_list_request_expired() > checks the first entry on ent_in_userspace and dereferences > ent->fuse_req unconditionally, which will crash on a cancelled entry > that was moved to this list. > > Fix this by freeing the entry and dropping queue_refs directly in > fuse_uring_cancel(). This is safe because cancel is the cancel handler > itself - after io_uring_cmd_done(), no more cancels will be dispatched > for this command, and teardown serializes with cancel via queue->lock. > > Since cancel now decrements queue_refs, fuse_uring_abort() must no > longer gate fuse_uring_abort_end_requests() on queue_refs > 0, as > cancelled entries may have already dropped queue_refs while requests are > still queued. Remove the gate so abort always flushes requests and stops > queues. > > Reported-by: Heechan Kang > Fixes: 4fea593e625c ("fuse: optimize over-io-uring request expiration check") > Cc: stable@vger.kernel.org > Co-developed-by: Jian Huang Li > Co-developed-by: Horst Birthelmer > Signed-off-by: Joanne Koong > --- > fs/fuse/dev_uring.c | 6 ++++-- > fs/fuse/dev_uring_i.h | 6 +++--- > 2 files changed, 7 insertions(+), 5 deletions(-) > > diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c > index d9108b5b5db8..f4ba64a1796a 100644 > --- a/fs/fuse/dev_uring.c > +++ b/fs/fuse/dev_uring.c > @@ -511,8 +511,7 @@ static void fuse_uring_cancel(struct io_uring_cmd *cmd, > queue = ent->queue; > spin_lock(&queue->lock); > if (ent->state == FRRS_AVAILABLE) { > - ent->state = FRRS_USERSPACE; > - list_move_tail(&ent->list, &queue->ent_in_userspace); > + list_del_init(&ent->list); > need_cmd_done = true; > ent->cmd = NULL; > } > @@ -521,6 +520,9 @@ static void fuse_uring_cancel(struct io_uring_cmd *cmd, > if (need_cmd_done) { > /* no queue lock to avoid lock order issues */ > io_uring_cmd_done(cmd, -ENOTCONN, issue_flags); > + kfree(ent); > + if (atomic_dec_and_test(&queue->ring->queue_refs)) > + wake_up_all(&queue->ring->stop_waitq); > } > } > > diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h > index 368f4d0790eb..22ec67e39ee0 100644 > --- a/fs/fuse/dev_uring_i.h > +++ b/fs/fuse/dev_uring_i.h > @@ -150,10 +150,10 @@ static inline void fuse_uring_abort(struct fuse_chan *fch) > if (ring == NULL) > return; > > - if (atomic_read(&ring->queue_refs) > 0) { > - fuse_uring_abort_end_requests(ring); > + fuse_uring_abort_end_requests(ring); > + > + if (atomic_read(&ring->queue_refs) > 0) > fuse_uring_stop_queues(ring); > - } > } > > static inline void fuse_uring_wait_stopped_queues(struct fuse_chan *fch) Reviewed-by: Bernd Schubert