Skip to content

Commit 28a3f6a

Browse files
MaxKellermannbrauner
authored andcommitted
fs/open: make chmod_common() and chown_common() killable
Allows killing processes that are waiting for the inode lock. Signed-off-by: Max Kellermann <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent d8c5507 commit 28a3f6a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/open.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,9 @@ int chmod_common(const struct path *path, umode_t mode)
635635
if (error)
636636
return error;
637637
retry_deleg:
638-
inode_lock(inode);
638+
error = inode_lock_killable(inode);
639+
if (error)
640+
goto out_mnt_unlock;
639641
error = security_path_chmod(path, mode);
640642
if (error)
641643
goto out_unlock;
@@ -650,6 +652,7 @@ int chmod_common(const struct path *path, umode_t mode)
650652
if (!error)
651653
goto retry_deleg;
652654
}
655+
out_mnt_unlock:
653656
mnt_drop_write(path->mnt);
654657
return error;
655658
}
@@ -769,7 +772,9 @@ int chown_common(const struct path *path, uid_t user, gid_t group)
769772
return -EINVAL;
770773
if ((group != (gid_t)-1) && !setattr_vfsgid(&newattrs, gid))
771774
return -EINVAL;
772-
inode_lock(inode);
775+
error = inode_lock_killable(inode);
776+
if (error)
777+
return error;
773778
if (!S_ISDIR(inode->i_mode))
774779
newattrs.ia_valid |= ATTR_KILL_SUID | ATTR_KILL_PRIV |
775780
setattr_should_drop_sgid(idmap, inode);

0 commit comments

Comments
 (0)