From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 CF218430CD3; Mon, 31 Aug 2026 13:56:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788184602; cv=none; b=Ssk/G919Ajy7NJ/P2PWBhGOVorOJxk/4BbkZRgj4owFfdEoxLVllQXQ52vRQbEJybzn/waSlMlCjUYCK3CvdZvsVxFcVxG2QadcPL6q3QnNpIaw/tLuLC+tykO3lf8l/wz25sDZv+ZoOFTTgG4OHohA8t2i7WHDRNuRgO9LO++w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788184602; c=relaxed/simple; bh=L/1yrCeyHikT87Pl3li/weCoLVOfunM4QKsBfyggztE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BLZPi0ofpWBZHJ5NwblolC1H84/8szaW3BNjr35ivilJa6bcSmPcN46w8Jf9tY0SMjnbI8+ucrXjcMn7PtLPYWPRMUagG2m6C8q/q8yyNF/YkJP88Tj3E2h/60QEmwKd7JBb0kqUt15gStgaHZOnLgLkf6Rq5hzO3+uEiUmabvE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=cRGLQSIx; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="cRGLQSIx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C6221F000E9; Mon, 31 Aug 2026 13:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788184600; bh=GGeO2m0svmTmvhXddpr+QEkxVjPFs8tTrIiAiguRj5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cRGLQSIx3F7XcADKmdSlpvO3YfUKsjAHMJwRRb3kXe6kZXO06UkORwOC1VC4+/ZRO /+lKyUGHFZeP2u2mAsxEjUe+GIUGPQin/g0cj6LcAJgb1XIEYx8B+j0/gxX/BeXT1K vX4e8ZEQQpiKX6ng/nfqFkQklpsfiy0RRPgJipdA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Baokun Li , Miklos Szeredi Subject: [PATCH 6.6 63/91] fuse: fix invalidate lock leak on open O_TRUNC DAX failure Date: Mon, 31 Aug 2026 15:34:51 +0200 Message-ID: <20260831133402.973908841@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831133359.468089036@linuxfoundation.org> References: <20260831133359.468089036@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Baokun Li commit a927f1867e61b78f39f9da0bbba3c98c2ca151fe upstream. fuse_open() takes filemap_invalidate_lock() for a DAX truncate (dax_truncate = true) and releases it before the out_inode_unlock label. But when fuse_dax_break_layouts() fails, the goto out_inode_unlock skips the unlock and leaks the rwsem, so any later fault or truncate on the file stalls on the stale lock. fuse_dax_break_layouts() can fail with -ERESTARTSYS when a signal interrupts the wait for busy DAX pages to drain: open("file", O_RDWR | O_TRUNC) └─ fuse_open() ├─ filemap_invalidate_lock() # dax_truncate └─ fuse_dax_break_layouts() └─ dax_break_layout() └─ wait_page_idle() # TASK_INTERRUPTIBLE └─ fuse_wait_dax_page() # unlock, schedule, re-lock └─ signal → -ERESTARTSYS goto out_inode_unlock # <- lock leaked Fix this by moving filemap_invalidate_unlock() below the label so that all error paths release the lock, and rename the label to out_unlock as it now covers more than just the inode lock. Fixes: 2fdbb8dd0155 ("fuse: fix deadlock between atomic O_TRUNC and page invalidation") Cc: stable@vger.kernel.org # v6.0+ Signed-off-by: Baokun Li Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/fuse/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -260,7 +260,7 @@ int fuse_open_common(struct inode *inode filemap_invalidate_lock(inode->i_mapping); err = fuse_dax_break_layouts(inode, 0, -1); if (err) - goto out_inode_unlock; + goto out_unlock; } if (is_wb_truncate || dax_truncate) @@ -280,9 +280,9 @@ int fuse_open_common(struct inode *inode else if (!(ff->open_flags & FOPEN_KEEP_CACHE)) invalidate_inode_pages2(inode->i_mapping); } +out_unlock: if (dax_truncate) filemap_invalidate_unlock(inode->i_mapping); -out_inode_unlock: if (is_wb_truncate || dax_truncate) inode_unlock(inode);