Commit 8e2b7f63 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 566d1362 9aafc1b0
...@@ -783,6 +783,9 @@ static struct ovl_fh *ovl_fid_to_fh(struct fid *fid, int buflen, int fh_type) ...@@ -783,6 +783,9 @@ static struct ovl_fh *ovl_fid_to_fh(struct fid *fid, int buflen, int fh_type)
if (fh_type != OVL_FILEID_V0) if (fh_type != OVL_FILEID_V0)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
if (buflen <= OVL_FH_WIRE_OFFSET)
return ERR_PTR(-EINVAL);
fh = kzalloc(buflen, GFP_KERNEL); fh = kzalloc(buflen, GFP_KERNEL);
if (!fh) if (!fh)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
...@@ -58,6 +58,24 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -58,6 +58,24 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
attr->ia_valid &= ~ATTR_MODE; attr->ia_valid &= ~ATTR_MODE;
/*
* We might have to translate ovl file into real file object
* once use cases emerge. For now, simply don't let underlying
* filesystem rely on attr->ia_file
*/
attr->ia_valid &= ~ATTR_FILE;
/*
* If open(O_TRUNC) is done, VFS calls ->setattr with ATTR_OPEN
* set. Overlayfs does not pass O_TRUNC flag to underlying
* filesystem during open -> do not pass ATTR_OPEN. This
* disables optimization in fuse which assumes open(O_TRUNC)
* already set file size to 0. But we never passed O_TRUNC to
* fuse. So by clearing ATTR_OPEN, fuse will be forced to send
* setattr request to server.
*/
attr->ia_valid &= ~ATTR_OPEN;
inode_lock(upperdentry->d_inode); inode_lock(upperdentry->d_inode);
old_cred = ovl_override_creds(dentry->d_sb); old_cred = ovl_override_creds(dentry->d_sb);
err = notify_change(upperdentry, attr, NULL); err = notify_change(upperdentry, attr, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment