From mboxrd@z Thu Jan 1 00:00:00 1970 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 2A2B4352C4F for ; Tue, 4 Aug 2026 09:18:18 +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=1785835100; cv=none; b=rWRzsRhEy4wUXdWSbs7Xk3okT5nskFATgTo6hYdRqzlEz2S1exLtbOijpQ0dlXiFEtwtmDPrFFzfgvG6WZnPkC/rc9rJIl8WKXjwRscx7QSWdBtXweampaO2xec1oaM3BFHqk/dz6Z4WQjHTIhR8eMIz/u2L+U2qZQTkh2U8vv8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785835100; c=relaxed/simple; bh=WUQQSY6H5nJcSQifraCw4S12jimpulyl4w5ppW94kbw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=jF/81FljCPqdDRkNC0GxUQnUqa10nDW0BTyzalSIsMBw6hWdnlNdg4hF52CtRuNE7i/+NybwBh3bceKkrxRSbWlxKFtUvVhnlv/NFTE7qiKVg2qnsAdgVRy4XSTAMX7rS74oN490gnFgyBcglLNhqwKJ3VSj3EC0x1DMyMqxWO4= 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=YqNWNy5C; 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="YqNWNy5C" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2d0407aedd6so48372855ad.0 for ; Tue, 04 Aug 2026 02:18:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785835097; x=1786439897; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=MGZtXrUugdh2Qw+yVg+F+V/hXWeRO6AD+o+/wkdKhes=; b=YqNWNy5ChanyYoZnSm/EhgPrtTyoPO+RadY5+sVinG3fhp5lJG7yNeq4K8D8HQ19AP +RNuWJhv6ZXAnS2m1365NtSxH0C014GPkZ0eNipzlQZ9v91cqaWkGLLJm4forHjgG+sI WEc9aeR5mfq8OdMomCxQDcuCGr/ItgASW9V98A+EQtbL05+E1x9vmv4i44iddRzg83Ua yVMKHPuv1FlFXiMP5h5DMW0ry5Jk/xXDovbFZDMAR9pIqPhsRZO3MoplDCmVCa9XWGqJ NvrUxt/ODY5mtRMNw/ygyDwG4+f/evqul5zB19qsuEXxxonQf7o1TcXE5o0wLRI+uiLl wtgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785835097; x=1786439897; h=content-transfer-encoding:mime-version: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=MGZtXrUugdh2Qw+yVg+F+V/hXWeRO6AD+o+/wkdKhes=; b=B2cz5ru9YE9DsKsexcxEaKaHQvIrHl8UERvhRi+JtSRNoETiL9joI1/LhlYJcQVX5s 68747h/xx1PFN7kgqFq/9oPzlgwQId43VB0sek5aDViyzQGs92AD1wVNOLNfiP6ZnB1m IG6bjnOCROxqRdP5NkHh8VHoKrUzb/BbkJWZ4gyVM2FVie1iOZ15xfRzQEzyuRH3Lby+ vsU9mQsM6eV8qT+4czFalyytoSpnc4acTLXfg8GTAklVOTj5IOUKIXq82C4MzmOFRnAb 9iHS5ScTQvvXM/B1E7xgT2ygavkEVVjh7MhThqxZ/Sf/SHbvINPI6lpGb1oKKKh8Acto nhOg== X-Forwarded-Encrypted: i=1; AHgh+Robv9Y0JzPLFhvUTepcq7Qn/tsGtIA/nBdXircmuJ6MFUjFAtbZaGJT7lw4urLcBRx/4jR0Fc0fhLXCJEA=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4Cf2l/GGxWjNhYrRxyz/Hu+sa/8N+BDRmezJ/l1CBCfUEkiS+ l3uzqWfkOX1MtUN9W+JQ8WN8ivZL/QqBjDICBNs76eoTUUvGwrApdvTw X-Gm-Gg: AR+sD12cajvBjKksBIr+xvfQEHhSxV2y8TDuCw1UJr5P9UDDHLMhyeIfzWqVOt+WqMW bpvcrLJCAk2kmMwnv1nVnj32GmIKXNJ+e4IS4AqZhqWD9uaqAB445lAdFjie1+j4dznv+uhIbTE bA6x/rebyvLUd+okWJ8897yDGPAWXv1lJ/G3YJn2qPr7KZZ4otKURkh/0dtAQiTQjzISTmcy0yl aD1gndURIdz2sUP8w2xmTJEGzAqHEXrZCx+s6x1vF8gu9kYEeEoRJZ0TOPcR4HINun7gXg6HzBg 2S2O33EN+1AZ+JEY4EyZYXf0ero+8wR02UkyLCWFOf7MPyrAomMOKqcRI11U/N345EBgDcV+fsT t9XqGKvNuIW8nPpwAzv9nUiyxBD8Lv+diI2WKgd9MGxrOOGPv0ly+i7OCQhrGSAm0gwGz4vTUgl jBktpm3DiMxZyGJJClibxhpj1MXBwuy8v8/IYHRmudJCL+hjxAj60t5sMW7HiQag0= X-Received: by 2002:a17:902:d2c9:b0:2c9:cf5d:d9bc with SMTP id d9443c01a7336-2d0524b5269mr129321495ad.35.1785835097533; Tue, 04 Aug 2026 02:18:17 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 02:18:17 -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 , TencentOS Corvus AI Subject: [PATCH 0/2] fuse: fix request lifetime races in the resend path Date: Tue, 4 Aug 2026 17:17:07 +0800 Message-ID: <20260804091757.503476-1-junvyyang@tencent.com> X-Mailer: git-send-email 2.43.7 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Two fixes for races introduced together with FUSE_NOTIFY_RESEND (760eac73f9f6, v6.9), where fuse_chan_resend() moves in-flight requests from fpq->processing back onto fiq->pending. Both concern the same invariant. FR_PENDING means "queued on fiq->pending, protected by fiq->lock", and it is what fuse_remove_pending_req() relies on to unlink a request and drop the queue's reference. A request on fiq->pending can therefore be released without going through fuse_request_end(), so anything that sets FR_PENDING, or that leaves a request linked elsewhere while FR_PENDING is set, has to be done under fiq->lock. Patch 1 sets FR_PENDING under fiq->lock. fuse_chan_resend() currently publishes the bit while the requests are reachable only through a stack-local list, so a concurrent waiter can unlink and release a request that fuse_chan_resend() is still iterating over. Patch 2 re-checks FR_SENT under fiq->lock in fuse_dev_queue_interrupt(). Its callers sample FR_SENT unlocked and fuse_chan_resend() clears it under fiq->lock, so a request can end up queued on fiq->pending and linked on fiq->interrupts at the same time. Dependency between the two patches ================================== They are independent and neither supersedes the other, so please apply them together rather than picking one. Patch 2 does not affect the unlocked FR_PENDING publish that patch 1 fixes. Patch 1 cannot catch an intr_entry that is linked after its locked walk has already run, because that link happens once fuse_chan_resend() has released fiq->lock. Patch 1 on its own also makes the condition patch 2 fixes easier to hit, since requests that would previously have been torn out of the resend list now survive to be re-queued. Both were found by code audit and confirmed on v7.2-rc6 (075b74841bd0), where the series was built and tested; the resend and interrupt paths were verified to still be exercised with the series applied. A KASAN reproducer for this issue is available if requested. Reported-by: TencentOS Corvus AI Signed-off-by: Jun Yang Jun Yang (2): fuse: set FR_PENDING under fiq->lock in fuse_chan_resend() fuse: don't queue an interrupt for a request that is back on fiq->pending fs/fuse/dev.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) -- 2.43.7