FAILED: patch "[PATCH] fuse: fix invalidate lock leak on setattr writeback failure" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 9afeca0d569c9fc89d758fe7a9339d1e8afb1546
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026083119-surname-nimble-f2a7@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 9afeca0d569c9fc89d758fe7a9339d1e8afb1546 Mon Sep 17 00:00:00 2001
From: Baokun Li <[email protected]>
Date: Mon, 17 Aug 2026 23:18:00 +0800
Subject: [PATCH] fuse: fix invalidate lock leak on setattr writeback failure
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
fuse_do_setattr() takes filemap_invalidate_lock() for a DAX truncate (fault_blocked = true) and releases it at the out:/error: labels. But when a writeback flush is also needed, a write_inode_now() failure returns directly and leaks the lock, so any later fault or truncate on the file stalls on the stale rwsem.
For example, truncate(2) on a setuid file reaches fuse_do_setattr() with both ATTR_SIZE and ATTR_MODE set:
truncate(2)
└─ do_truncate()
├─ dentry_needs_remove_privs() # S_ISUID
└─ notify_change() # KILL_SUID -> ATTR_MODE
└─ fuse_setattr() # no killpriv:
│ # ia_valid |= ATTR_MODE
└─ fuse_do_setattr()
├─ filemap_invalidate_lock() # IS_DAX && is_truncate
└─ write_inode_now() # is_wb && ATTR_MODE
└─ if (err) # e.g. daemon -> -EIO
return err # <- lock leakedFix this by adding an unlock label that releases the lock before returning the error, and use it for the fuse_dax_break_layouts() failure path as well.
fs/fuse/dir.c +4 -5
@@ -2170,10 +2170,8 @@ int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry,filemap_invalidate_lock (mapping); fault_blocked = true; err =fuse_dax_break_layouts (inode,0 ,-1 ); -if (err) { -filemap_invalidate_unlock (mapping); -return err; - } +if (err) + goto unlock; }if (attr->ia_valid &ATTR_OPEN ) {
@@ -2200,7 +2198,7 @@ int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry, ATTR_TIMES_SET)) { err =write_inode_now (inode, true);if (err) -return err; + goto unlock;fuse_set_nowrite (inode);fuse_release_nowrite (inode);
@@ -2308,6 +2306,7 @@ int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry,clear_bit (FUSE_I_SIZE_UNSTABLE , &fi->state); +unlock:if (fault_blocked)filemap_invalidate_unlock (mapping);return err;
Sasha Levin
maintainerPATCH 1/1 fuse: fix invalidate lock leak on setattr writeback failure
From: Baokun Li <[email protected]>
[ Upstream commit 9afeca0d569c9fc89d758fe7a9339d1e8afb1546 ]
fuse_do_setattr() takes filemap_invalidate_lock() for a DAX truncate (fault_blocked = true) and releases it at the out:/error: labels. But when a writeback flush is also needed, a write_inode_now() failure returns directly and leaks the lock, so any later fault or truncate on the file stalls on the stale rwsem.
For example, truncate(2) on a setuid file reaches fuse_do_setattr() with both ATTR_SIZE and ATTR_MODE set:
truncate(2)
└─ do_truncate()
├─ dentry_needs_remove_privs() # S_ISUID
└─ notify_change() # KILL_SUID -> ATTR_MODE
└─ fuse_setattr() # no killpriv:
│ # ia_valid |= ATTR_MODE
└─ fuse_do_setattr()
├─ filemap_invalidate_lock() # IS_DAX && is_truncate
└─ write_inode_now() # is_wb && ATTR_MODE
└─ if (err) # e.g. daemon -> -EIO
return err # <- lock leakedFix this by adding an unlock label that releases the lock before returning the error, and use it for the fuse_dax_break_layouts() failure path as well.
--- fs/fuse/dir.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/fuse/dir.c +4 -5
@@ -1651,10 +1651,8 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,down_write (&fi->i_mmap_sem); fault_blocked = true; err =fuse_dax_break_layouts (inode,0 ,0 ); -if (err) { -up_write (&fi->i_mmap_sem); -return err; - } +if (err) + goto unlock; }if (attr->ia_valid &ATTR_OPEN ) {
@@ -1681,7 +1679,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr, ATTR_TIMES_SET)) { err =write_inode_now (inode, true);if (err) -return err; + goto unlock;fuse_set_nowrite (inode);fuse_release_nowrite (inode);
@@ -1768,6 +1766,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,clear_bit (FUSE_I_SIZE_UNSTABLE , &fi->state); +unlock:if (fault_blocked)up_write (&fi->i_mmap_sem);return err;
Signature · 1 line
2.53.0