Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4e1ac55 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Sasha Levin
Browse files

ovl: handle ATTR_KILL*



[ Upstream commit b99c2d913810e56682a538c9f2394d76fca808f8 ]

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: default avatarEryu Guan <eguan@redhat.com>
Signed-off-by: default avatarMiklos 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>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
parent 69fb704c
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -54,6 +54,10 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
		upperdentry = ovl_dentry_upper(dentry);
		upperdentry = ovl_dentry_upper(dentry);


		mutex_lock(&upperdentry->d_inode->i_mutex);
		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);
		err = notify_change(upperdentry, attr, NULL);
		if (!err)
		if (!err)
			ovl_copyattr(upperdentry->d_inode, dentry->d_inode);
			ovl_copyattr(upperdentry->d_inode, dentry->d_inode);