ovl: copy new uid/gid into overlayfs runtime inode
authorKonstantin Khlebnikov <koct9i@gmail.com>
Sun, 31 Jan 2016 13:21:29 +0000 (16:21 +0300)
committerSasha Levin <sasha.levin@oracle.com>
Tue, 22 Mar 2016 15:11:10 +0000 (11:11 -0400)
[ Upstream commit b81de061fa59f17d2730aabb1b84419ef3913810 ]

Overlayfs must update uid/gid after chown, otherwise functions
like inode_owner_or_capable() will check user against stale uid.
Catched by xfstests generic/087, it chowns file and calls utimes.

Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
fs/overlayfs/inode.c

index e3903b74a1f2f7b335971687d15d7a398dc3b119..8774ebb5d80ac64ca24794c97d78ede6bfca101e 100644 (file)
@@ -53,6 +53,8 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
        if (upperdentry) {
                mutex_lock(&upperdentry->d_inode->i_mutex);
                err = notify_change(upperdentry, attr, NULL);
+               if (!err)
+                       ovl_copyattr(upperdentry->d_inode, dentry->d_inode);
                mutex_unlock(&upperdentry->d_inode->i_mutex);
        } else {
                err = ovl_copy_up_last(dentry, attr, false);