Skip to content

Commit b99c2d9

Browse files
author
Miklos Szeredi
committed
ovl: handle ATTR_KILL*
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 <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]> Fixes: 4bacc9c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay") Cc: <[email protected]>
1 parent a99cde4 commit b99c2d9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/overlayfs/inode.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
8080
goto out_drop_write;
8181
}
8282

83+
if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
84+
attr->ia_valid &= ~ATTR_MODE;
85+
8386
inode_lock(upperdentry->d_inode);
8487
err = notify_change(upperdentry, attr, NULL);
8588
if (!err)

0 commit comments

Comments
 (0)