From nobody Fri Oct 2 06:58:00 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 BC5953EDE7A for ; Tue, 4 Aug 2026 09:18:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785835102; cv=none; b=MExR3qReLjV1cmS4QWiVaxa+IKDuE4YB3GYK0YX18lTDeAQ7pOQLtpG0tzyiCMhgvLQYiQXpK69v3Z+9NX8jCw8k93GGcGZamrkc79DjgH583QWkvPNBetsj7iIHSd0trR4xehZoM0Er9j/aBvjoizhFJHQINziBXYOhwtFCR5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785835102; c=relaxed/simple; bh=+JfP1gbbEZxAYpS9FbypkcJck3cynRxZRgE5Qr05GrI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=blnMW150njHZNVYe7F3bATSHuRSESrDriGIwmNikknVDHHhzM/0ceU3eZGlNFJymmOu9/YqX+h2MeJvTr4wKYIVssu0dv+Kufg1lSoOAcjkhBTYaBLVO5+NW3FOdVmVAfnm3s15xRyFu+9WDjJPNBq78Bb+Q+5he7NP4bAXPHHY= 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=h+c2Uy1g; arc=none smtp.client-ip=209.85.214.181 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="h+c2Uy1g" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2ceb096e675so51371835ad.0 for ; Tue, 04 Aug 2026 02:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785835100; x=1786439900; 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=M6DADmIX820j0VkQtSmHS96HmvLl3nEhITSRy3Q0IpM=; b=h+c2Uy1g9Jm3lscS8az7oBABC9VsRw7DKH3S/huSgvO5iPUQ32Pa2J53OApJ/RNKni n2rrZFHHRq62HApuagrbK6Ox7g5JPSD1FNGJgY89wWJ14hvNv/0Pe/bYj1SCdNNT33cC zjrS6kLWCxlLYi4NEN6iOI9BUxWdYEvg0VZOXWRqpRC3saQqkbuCdP1HTJ75nLfDbwGJ DErGoIR/PWdnI8rSOovjaSYLON1+lYYyOwxorenBWOdYQesQw8RDO5v9qr/tFUDDSnVo 020w/R7DrgqzoI5ejFpBBgW4zqiyJv8KzSJ7oJSZ/hSDyKrqBAjmtP+OGsOSVFlsas7E j8hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785835100; x=1786439900; 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=M6DADmIX820j0VkQtSmHS96HmvLl3nEhITSRy3Q0IpM=; b=fR8c8kr9g368Ne/8IyFv43cPIbBhEBQARGqwmxNsMJ6D0ytyYm6GmTNBhw9d/O5HjP wJOXQ4Q99RMJLRJtF7NCoiW2YvW+vsBv5R2ROPOtV7j8HNtg5SyFt4ZpIfsF9PqddgI2 QX5Xz5hIZ+XGaYSHkUx69gJCEOvBbV0UhiaiNZkyzjWwhU+wuFtFWZ0tNfl2tTy/A5Gg mj0Ei6XbyeOxx9QLQDfrhw7FrBNLg/BLw+ECaXUrERImwpYkt9LLTEMVVzDHvBiHXoQn YiAlQcT9gA0f3YQorQXM8WXIBNEag7yajXJ32WYZ5Oh2MkuVDR0aBiWP4cDyRYC8JLd9 Sn9w== X-Forwarded-Encrypted: i=1; AHgh+Ro57ARlYhodrRQ4tZt/W2gvwVu/7CgF0Gr+8bzglK9fxOUPnsl7jSCAq7ds1m198IdPzYi7h0TSj6k6wvA=@vger.kernel.org X-Gm-Message-State: AOJu0YwP8DdEeE6sj5tizd7bmj3LoxNAKGAjE/Gp864Od8e9ZjYEMyTu EPzXrroTu2d6FkhGqzC9u7G0CJeaShjsYOsyRXtu+S3aVDwM9eQ/RveC X-Gm-Gg: AR+sD104ZiayppAUkmaPk5X5O8gTSqfGNtUQIWQbQ2wdRNvjwZ1myTgxYXH8L06xgto FOyA5I0Kkb/626mRBLqsu/KEeNn0fwz3UAfe1Xk6qpclMItyQoMqf8flWzJ3MlRyt7SyCasXNKI 6DYpQ5ljzWU5kQ7ZCVczEErGaUeSPY2kQImGfPj5gwExSViwGB/8sFxJ5Ey/+nvXsYlDQ8tG0LO X/qiITZV9RRyLjeng70ftit5Rix/zmW1Rqps1kejZIK9RhXZ9BKrjj0qsBuZiyUeWd5yOElcHDe 67g+Obi2YXHhzHVLNoZdzZQN+8YWVlKicpsT/PUoo3siSKWpazSR0uvcV8c8J+oE3rDK61s0cxH mx8O/PRzSwYVA9ldJe1n0ojS6pDPeo2+Uxls6TMn/MaNRywKGm6CiPsMtDPB569ocuOGV/J872V /XG8jPV69JhPVSB6BlwGJDNcyj8BkOZXZUOHmC81xcHV/vLkRO+l3Km9NpxtFUOxU= X-Received: by 2002:a17:903:2f03:b0:2cc:f7c6:8320 with SMTP id d9443c01a7336-2d052416431mr133850745ad.46.1785835099883; Tue, 04 Aug 2026 02:18:19 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 02:18:19 -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 1/2] fuse: set FR_PENDING under fiq->lock in fuse_chan_resend() Date: Tue, 4 Aug 2026 17:17:08 +0800 Message-ID: <20260804091757.503476-2-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: quoted-printable Content-Type: text/plain; charset="utf-8" FR_PENDING means "queued on fiq->pending, protected by fiq->lock". It is the sole predicate fuse_remove_pending_req() uses to unlink a request and drop the queue's reference. fuse_chan_resend() breaks that invariant. It splices every fpq->processing list onto a stack-local to_queue and drops fch->lock, then sets FR_PENDING on each request while holding no lock at all. From that moment the request advertises "I am on fiq->pending" while it is in fact reachable only through the caller's stack. A waiter whose wait is interrupted takes fiq->lock, sees FR_PENDING, unlinks the request from to_queue and drops its reference, and fuse_chan_send() then drops the last one -- so the request can be released while fuse_chan_resend() is still iterating over it. fiq->lock serialises nothing here, because the request is not on an fiq-protected list. fuse_chan_resend() then walks that same list, and on the !fiq->connected path it drops fiq->lock and walks it with a non-safe list_for_each_entry(). Publish FR_PENDING under fiq->lock, immediately before the splice that actually puts the requests on fiq->pending, and fold the intr_entry cleanup into the same locked walk. A waiter that arrives while the requests are still on the stack now sees FR_PENDING clear, so fuse_remove_pending_req() returns false and it falls through to wait_event(FR_FINISHED) -- the same handling a request already handed to userspace gets. The !fiq->connected path no longer needs to clear the bit, because it was never set. Confirmed on v7.2-rc6 (075b74841bd0). Fixes: 760eac73f9f6 ("fuse: Introduce a new notification type for resend pe= nding 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 | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 5763a7cd3b37..e62c7ed8bcf4 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1781,26 +1781,22 @@ void fuse_chan_resend(struct fuse_chan *fch) } spin_unlock(&fch->lock); =20 - list_for_each_entry_safe(req, next, &to_queue, list) { - set_bit(FR_PENDING, &req->flags); - clear_bit(FR_SENT, &req->flags); - /* mark the request as resend request */ - req->in.h.unique |=3D FUSE_UNIQUE_RESEND; - } - spin_lock(&fiq->lock); if (!fiq->connected) { spin_unlock(&fiq->lock); - list_for_each_entry(req, &to_queue, list) - clear_bit(FR_PENDING, &req->flags); fuse_dev_end_requests(&to_queue); return; } - /* - * Remove interrupt entries for resent requests to prevent stale - * intr_entry on fiq->interrupts after the request is re-queued. - */ - list_for_each_entry(req, &to_queue, list) { + list_for_each_entry_safe(req, next, &to_queue, list) { + /* must be set under fiq->lock, see fuse_remove_pending_req() */ + set_bit(FR_PENDING, &req->flags); + clear_bit(FR_SENT, &req->flags); + /* mark the request as resend request */ + req->in.h.unique |=3D FUSE_UNIQUE_RESEND; + /* + * Remove interrupt entries for resent requests to prevent stale + * intr_entry on fiq->interrupts after the request is re-queued. + */ if (test_bit(FR_INTERRUPTED, &req->flags)) list_del_init(&req->intr_entry); } --=20 2.43.7 From nobody Fri Oct 2 06:58:00 2026 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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D> 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 pe= nding 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 *re= q) { 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); /* --=20 2.43.7