diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2016-07-04 16:49:48 +0200 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2016-07-04 16:49:48 +0200 |
commit | b99c2d913810e56682a538c9f2394d76fca808f8 (patch) | |
tree | 01c7236cc00eafd5a9f72481ef31c5e17d34783a | |
parent | Linux 4.7-rc6 (diff) | |
download | linux-b99c2d913810e56682a538c9f2394d76fca808f8.tar.xz linux-b99c2d913810e56682a538c9f2394d76fca808f8.zip |
ovl: handle ATTR_KILL*
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")
Cc: <stable@vger.kernel.org>
-rw-r--r-- | fs/overlayfs/inode.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index c831c2e5f803..1233992a7c47 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -80,6 +80,9 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr) goto out_drop_write; } + if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) + attr->ia_valid &= ~ATTR_MODE; + inode_lock(upperdentry->d_inode); err = notify_change(upperdentry, attr, NULL); if (!err) |