summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaokun Li <libaokun@linux.alibaba.com>2026-08-17 23:18:01 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-09-02 14:28:35 +0200
commita61524da59a2f5ac9c8de23ff98b30da769ab144 (patch)
tree94817dfa178099f417da00fc71e7a75772346620
parent03cfeeb135428fa83f0791d3f8f94d9298cae695 (diff)
downloadlinux-stable-a61524da59a2f5ac9c8de23ff98b30da769ab144.tar.gz
linux-stable-a61524da59a2f5ac9c8de23ff98b30da769ab144.zip
fuse: fix invalidate lock leak on open O_TRUNC DAX failure
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 <libaokun@linux.alibaba.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/fuse/file.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index b7568bebe67d..30da0d0397f2 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -259,7 +259,7 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
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)
@@ -279,9 +279,9 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
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);