From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E391E43E075 for ; Tue, 4 Aug 2026 09:18:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785835104; cv=none; b=EaDVUuPbaEl+bJRt378YSSklDks1OhwvT2yc4OaxxSlv5SeeDvwL1/TU4lxpYvk5fvR7AYwAX/03oJ4k4PF2Wuaa61ieiXkBynN3aSM22gaby97TFjPBXyo35IQWE95GwAksqcUHRRm1Fmj585nEJcjo1V/Ca7Z6m8q99tvUVTM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785835104; c=relaxed/simple; bh=RAB/MyUME2ucjjrxIXJWFmq6CahFTDgCw45WyA2sOc0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DX+bnClPaRHaDDM4eTATfN2oZZfy/A5KaoB41ADWZWLIq2+hs+6cT+mR+6OQq4P3PiD6dBTEAbJltNlwszR3ubzJpHHF+YyCdqPIORal/8TmAjLyK6pAX09xnFhMloNAX7EJ3OpUKbLxWy2B5ZaptHYsDw8IKE7/jby174QDd6o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dUMj4pFr; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dUMj4pFr" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2cc891373e0so48100915ad.2 for ; Tue, 04 Aug 2026 02:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785835102; x=1786439902; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GoaS38uzGP/FgfFST1kKMJA7M2vxyy+l5McECO9UQbc=; b=dUMj4pFrHS1DN9pKu2ZfHicLI84a/japONh3kBIv6iEW0QQ5DpNMlayAJEtpKpVELv 30POkGkab1N1IWSWP3H5iP9chGDEInfgrjkz6l8qTCJwZDdhBJ1ZMZIDs1p0ilkU/zzk 2I9J337Z18geoNVn0pi5kqiFqR1fe7jFuiHnV/mO7iNqZiZPyLPEqgo9Ua9rgzbuVy1n osxTeO1iJv8Q/dxVfR2sgp1gh34hJ8sIWAQuMjOH9ejNKCI+EPk55X1aXZCPj1gZp9i5 X8AKOwyVO8MVaVwqmsLk149cGZC/3mLu+dVY3pkQsjqG1L6iVn/nTcu5MXcbE7O4Uw25 0h3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785835102; x=1786439902; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=GoaS38uzGP/FgfFST1kKMJA7M2vxyy+l5McECO9UQbc=; b=N622/ZLWn7NMzTBjlfhqVNFnILrzxyrlf+7YEd4IGcVo68HiPckOg21sDpuiQzL69b bMilwi+H+2cgQmZL4f46e2I6iTKtjBUPaHdvl8/+oiAMQSUb/TA2ofeTVRN78298Yl6v qmUrs3j9MGCzfPyFBEWOmdfl/p5WD8lLnPct4YZwT4nzlEdgH5OQge24PuwsqLadgdAF in/31iY1STZoU8m7psvKpCldoeP7LC7OGG/qv6hcnkz9nT3FVbEwiKPa2g6o19brrHVX N9nXBe+7Et/5dXWHZpWMrLJssabJoQaGGvWGZfxA8xJFVc/9MA5gB34xn8xl1hGpIbJf NlBQ== X-Forwarded-Encrypted: i=1; AHgh+Rr2wmOYEUm1ik0EUwTvq4t9tsN5ivaa3Pk61zgXcRII2Wdnxeqe8s9X2tXmbfOiZfyMkwXrwcnBY4D9eg0=@vger.kernel.org X-Gm-Message-State: AOJu0YxMMg7JCVzMrDHVb8Pcj0alktIrlc+DIPaNRj2b723MSLcyU/Cq cj9lGOop4AYsCSpk7E/+i7/EfV1RToL2YsI/RKqelrkrCyyGJuxo/jg5 X-Gm-Gg: AR+sD13NWhUCRCm+fmTfFVzn5EkKpCUi95BANADRaey6eZdSj6TssiFE6ue+4vFfsGJ YVYk8QGnNgqRBnro2kyrpdsvdggPaWvqnG7CGN9omgO37AxN/J0U0c9JDumbEh+oQKV1SSmJIMv 2Emfc1uDiDZc86A8TSLWohwUPxJW8rmSaplwLR8ompYC1S6Oa4TMHaPYOedgtcIZSOfaL1ba5ae L2tMyC5jHJSdKMYmkcNtL5aTVjUE0CNfGPfLudpUFPeMmMKHOd0fexrpZ1vFvRfxTKDELLadEQ1 ZZ+XJXrEp6O699KBQNeu+M7z7CA1uP3EwkqOt+VfwDB0VqNYbF0Fzr75OsmRoy6SEDCyWOhvElv GDQQ//D9H/ztXzL0Lo54QyFyZBS2Xz8YgPc/d7yh6VsHSAeDseTS3kghxxgA6GcwIhj9AWsC2jF VslN9Bj8UowL5FiNLiVHRKhznHDBt3EHoY9N+oVU95DdYwW8nH+mo/cvCKiqyHHs4= X-Received: by 2002:a17:903:1a67:b0:2cf:7e56:22c4 with SMTP id d9443c01a7336-2d0523e1c85mr138995385ad.30.1785835102279; Tue, 04 Aug 2026 02:18:22 -0700 (PDT) Received: from TENCENT64.site ([103.7.29.106]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d0a9f8fee7sm3681065ad.16.2026.08.04.02.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 02:18:21 -0700 (PDT) From: Jun Yang X-Google-Original-From: Jun Yang To: Miklos Szeredi , fuse-devel@lists.linux.dev Cc: Zhao Chen , linux-kernel@vger.kernel.org, Jun Yang , stable@kernel.org, TencentOS Corvus AI Subject: [PATCH 2/2] fuse: don't queue an interrupt for a request that is back on fiq->pending Date: Tue, 4 Aug 2026 17:17:09 +0800 Message-ID: <20260804091757.503476-3-junvyyang@tencent.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20260804091757.503476-1-junvyyang@tencent.com> References: <20260804091757.503476-1-junvyyang@tencent.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit fuse_dev_queue_interrupt() links a request onto fiq->interrupts based on an FR_SENT observation its callers make without fiq->lock: in request_wait_answer(), in fuse_dev_do_read() after setting FR_SENT, and in fuse_dev_do_write() on an interrupt reply with -EAGAIN. fuse_chan_resend() invalidates that observation: under fiq->lock it clears FR_SENT, sets FR_PENDING and splices the request back onto fiq->pending. A caller that sampled FR_SENT just before that happens links the request onto fiq->interrupts just after, so the request ends up queued on fiq->pending *and* on fiq->interrupts. That combination is a problem, because a request on fiq->pending can be released without ever going through fuse_request_end(). A waiter whose wait is interrupted calls fuse_remove_pending_req(), which sees FR_PENDING, unlinks the request from fiq->pending and drops the queue's reference; fuse_chan_send() then drops the last one. Unlike fuse_request_end(), that path has no FR_INTERRUPTED cleanup, so the request can be released while still linked on fiq->interrupts, and the next fuse_dev_do_read() walks it in fuse_read_interrupt(). Re-check FR_SENT in fuse_dev_queue_interrupt() under fiq->lock, which is the lock fuse_chan_resend() holds when it clears it. This restores the invariant "FR_PENDING set => intr_entry not linked", both sides of it now being taken under fiq->lock. No interrupt is lost: the request is going back to the daemon, and fuse_dev_do_read() re-queues the interrupt once it has set FR_SENT again. Confirmed on v7.2-rc6 (075b74841bd0). Fixes: 760eac73f9f6 ("fuse: Introduce a new notification type for resend pending requests") Cc: stable@kernel.org Reported-by: TencentOS Corvus AI Assisted-by: tencentos-corvus-ai:kimi-k3 Signed-off-by: Jun Yang --- A KASAN reproducer for this issue is available if requested. fs/fuse/dev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index e62c7ed8bcf4..c4df1d4abd33 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -240,6 +240,11 @@ void fuse_dev_queue_forget(struct fuse_iqueue *fiq, void fuse_dev_queue_interrupt(struct fuse_iqueue *fiq, struct fuse_req *req) { spin_lock(&fiq->lock); + /* fuse_chan_resend() may have put the request back on fiq->pending */ + if (!test_bit(FR_SENT, &req->flags)) { + spin_unlock(&fiq->lock); + return; + } if (list_empty(&req->intr_entry)) { list_add_tail(&req->intr_entry, &fiq->interrupts); /* -- 2.43.7