Skip to content

Commit b82c789

Browse files
Miklos Szeredigregkh
authored andcommitted
ovl: handle ATTR_KILL*
commit b99c2d913810e56682a538c9f2394d76fca808f8 upstream. Before 4bacc9c ("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: 4bacc9c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay") Cc: Eric Schultz <eric@startuperic.com> Cc: Eric Hameleers <alien@slackware.com> [backported by Eric Hameleers as seen in https://bugzilla.kernel.org/show_bug.cgi?id=150711] Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 34bf123 commit b82c789

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

fs/overlayfs/inode.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
6363
if (!err) {
6464
upperdentry = ovl_dentry_upper(dentry);
6565

66+
if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
67+
attr->ia_valid &= ~ATTR_MODE;
68+
6669
mutex_lock(&upperdentry->d_inode->i_mutex);
6770
err = notify_change(upperdentry, attr, NULL);
6871
if (!err)

0 commit comments

Comments
 (0)