From: Miklos Szeredi Date: Mon, 4 Jul 2016 14:49:48 +0000 (+0200) Subject: ovl: handle ATTR_KILL* X-Git-Tag: v4.1.12-92~15^2~37 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d8aeb46003e16c2fb89123b4222c1529cf824a5b;p=users%2Fjedix%2Flinux-maple.git ovl: handle ATTR_KILL* Orabug: 25308102 [ 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 Signed-off-by: Miklos Szeredi Fixes: 4bacc9c9234c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay") Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin (cherry picked from commit cb75f65fe798bcac694f6bde299c52d31bdc8e96) Signed-off-by: Dhaval Giani --- diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index edd2a4a5fd3c1..34c184bec0fd1 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -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);