summaryrefslogtreecommitdiffstats
path: root/fs/overlayfs/inode.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2015-12-04 13:18:48 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-12-06 12:28:23 -0500
commitacff81ec2c79492b180fade3c2894425cd35a545 (patch)
treeda3c7514877f6881b8be76e203614917227be52a /fs/overlayfs/inode.c
parent31ade3b83e1821da5fbb2f11b5b3d4ab2ec39db8 (diff)
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>
Diffstat (limited to 'fs/overlayfs/inode.c')
-rw-r--r--fs/overlayfs/inode.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index ec0c2a050043..961284936917 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -49,13 +49,13 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
49 if (err) 49 if (err)
50 goto out; 50 goto out;
51 51
52 upperdentry = ovl_dentry_upper(dentry); 52 err = ovl_copy_up(dentry);
53 if (upperdentry) { 53 if (!err) {
54 upperdentry = ovl_dentry_upper(dentry);
55
54 mutex_lock(&upperdentry->d_inode->i_mutex); 56 mutex_lock(&upperdentry->d_inode->i_mutex);
55 err = notify_change(upperdentry, attr, NULL); 57 err = notify_change(upperdentry, attr, NULL);
56 mutex_unlock(&upperdentry->d_inode->i_mutex); 58 mutex_unlock(&upperdentry->d_inode->i_mutex);
57 } else {
58 err = ovl_copy_up_last(dentry, attr, false);
59 } 59 }
60 ovl_drop_write(dentry); 60 ovl_drop_write(dentry);
61out: 61out: