diff mbox

[wily/xenial] ovl: copy new uid/gid into overlayfs runtime inode

Message ID 1457731394-67110-1-git-send-email-seth.forshee@canonical.com
State New
Headers show

Commit Message

Seth Forshee March 11, 2016, 9:23 p.m. UTC
From: Konstantin Khlebnikov <koct9i@gmail.com>

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>
(backported from commit b81de061fa59f17d2730aabb1b84419ef3913810)
BugLink: http://bugs.launchpad.net/bugs/1555997
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 fs/overlayfs/inode.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Seth Forshee March 11, 2016, 9:26 p.m. UTC | #1
On Fri, Mar 11, 2016 at 03:23:14PM -0600, Seth Forshee wrote:
> From: Konstantin Khlebnikov <koct9i@gmail.com>
> 
> 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>

Note that this should also come to us via upstream stable. If it will
make it into the next release via stable updates that's fine, I just
want to make sure we get it one way or the other in our next kernel
updates.
Tim Gardner March 14, 2016, 1:24 p.m. UTC | #2
Applied to Xenial
Brad Figg March 14, 2016, 3:55 p.m. UTC | #3
Applied to the master-next branch of Wily.
diff mbox

Patch

diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index b29036a..05ac9a9 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -65,6 +65,8 @@  int ovl_setattr(struct dentry *dentry, struct iattr *attr)
 
 		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);
 	}
 	ovl_drop_write(dentry);