Skip to content

Commit 8e2b7f6

Browse files
committed
Merge tag 'ovl-fixes-5.7-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs
Pull overlayfs fixes from Miklos Szeredi: "Fix two bugs introduced in this cycle and one introduced in v5.5" * tag 'ovl-fixes-5.7-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs: ovl: potential crash in ovl_fid_to_fh() ovl: clear ATTR_OPEN from attr->ia_valid ovl: clear ATTR_FILE from attr->ia_valid
2 parents 566d136 + 9aafc1b commit 8e2b7f6

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

fs/overlayfs/export.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,9 @@ static struct ovl_fh *ovl_fid_to_fh(struct fid *fid, int buflen, int fh_type)
783783
if (fh_type != OVL_FILEID_V0)
784784
return ERR_PTR(-EINVAL);
785785

786+
if (buflen <= OVL_FH_WIRE_OFFSET)
787+
return ERR_PTR(-EINVAL);
788+
786789
fh = kzalloc(buflen, GFP_KERNEL);
787790
if (!fh)
788791
return ERR_PTR(-ENOMEM);

fs/overlayfs/inode.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,24 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
5858
if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
5959
attr->ia_valid &= ~ATTR_MODE;
6060

61+
/*
62+
* We might have to translate ovl file into real file object
63+
* once use cases emerge. For now, simply don't let underlying
64+
* filesystem rely on attr->ia_file
65+
*/
66+
attr->ia_valid &= ~ATTR_FILE;
67+
68+
/*
69+
* If open(O_TRUNC) is done, VFS calls ->setattr with ATTR_OPEN
70+
* set. Overlayfs does not pass O_TRUNC flag to underlying
71+
* filesystem during open -> do not pass ATTR_OPEN. This
72+
* disables optimization in fuse which assumes open(O_TRUNC)
73+
* already set file size to 0. But we never passed O_TRUNC to
74+
* fuse. So by clearing ATTR_OPEN, fuse will be forced to send
75+
* setattr request to server.
76+
*/
77+
attr->ia_valid &= ~ATTR_OPEN;
78+
6179
inode_lock(upperdentry->d_inode);
6280
old_cred = ovl_override_creds(dentry->d_sb);
6381
err = notify_change(upperdentry, attr, NULL);

0 commit comments

Comments
 (0)