Skip to content

Commit acff81e

Browse files
szmiAl Viro
authored and
Al Viro
committed
ovl: fix permission checking for setattr
[Al Viro] The bug is in being too enthusiastic about optimizing ->setattr() away - instead of "copy verbatim with metadata" + "chmod/chown/utimes" (with the former being always safe and the latter failing in case of insufficient permissions) it tries to combine these two. Note that copyup itself will have to do ->setattr() anyway; _that_ is where the elevated capabilities are right. Having these two ->setattr() (one to set verbatim copy of metadata, another to do what overlayfs ->setattr() had been asked to do in the first place) combined is where it breaks. Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Cc: <stable@vger.kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 31ade3b commit acff81e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/overlayfs/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
4949
if (err)
5050
goto out;
5151

52-
upperdentry = ovl_dentry_upper(dentry);
53-
if (upperdentry) {
52+
err = ovl_copy_up(dentry);
53+
if (!err) {
54+
upperdentry = ovl_dentry_upper(dentry);
55+
5456
mutex_lock(&upperdentry->d_inode->i_mutex);
5557
err = notify_change(upperdentry, attr, NULL);
5658
mutex_unlock(&upperdentry->d_inode->i_mutex);
57-
} else {
58-
err = ovl_copy_up_last(dentry, attr, false);
5959
}
6060
ovl_drop_write(dentry);
6161
out:

0 commit comments

Comments
 (0)