]> git.itanic.dy.fi Git - linux-stable/commitdiff
ovl: handle ATTR_KILL*
authorMiklos Szeredi <mszeredi@redhat.com>
Mon, 4 Jul 2016 14:49:48 +0000 (16:49 +0200)
committerSasha Levin <alexander.levin@verizon.com>
Wed, 3 Aug 2016 18:06:00 +0000 (14:06 -0400)
[ Upstream commit 51234eac5dd8b5feda9a3a8fa766f5398ecf91e3 ]

commit b99c2d913810e56682a538c9f2394d76fca808f8 upstream.

Before 4bacc9c9234c ("overlayfs: Make f_path...") file->f_path pointed to
the underlying file, hence suid/sgid removal on write worked fine.

After that patch file->f_path pointed to the overlay file, and the file
mode bits weren't copied to overlay_inode->i_mode.  So the suid/sgid
removal simply stopped working.

The fix is to copy the mode bits, but then ovl_setattr() needs to clear
ATTR_MODE to avoid the BUG() in notify_change().  So do this first, then in
the next patch copy the mode.

Reported-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: 4bacc9c9234c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
fs/overlayfs/inode.c

index edd2a4a5fd3c1f793e39936db44fd0ad0529ac33..34c184bec0fd1289bd62242b03d940bd95ffabf6 100644 (file)
@@ -67,6 +67,10 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
                upperdentry = ovl_dentry_upper(dentry);
 
                mutex_lock(&upperdentry->d_inode->i_mutex);
+
+               if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
+                       attr->ia_valid &= ~ATTR_MODE;
+
                err = notify_change(upperdentry, attr, NULL);
                if (!err)
                        ovl_copyattr(upperdentry->d_inode, dentry->d_inode);