Merge tag 'v6.17-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull smb client fixes from Steve French:

 - Fix possible refcount leak in compound operations

 - Fix remap_file_range() return code mapping, found by generic/157

* tag 'v6.17-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
  fs/smb: Fix inconsistent refcnt update
  smb3 client: fix return code mapping of remap_file_range
This commit is contained in:
Linus Torvalds
2025-08-29 08:51:34 -07:00
2 changed files with 19 additions and 2 deletions

View File

@@ -1358,6 +1358,20 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
truncate_setsize(target_inode, new_size);
fscache_resize_cookie(cifs_inode_cookie(target_inode),
new_size);
} else if (rc == -EOPNOTSUPP) {
/*
* copy_file_range syscall man page indicates EINVAL
* is returned e.g when "fd_in and fd_out refer to the
* same file and the source and target ranges overlap."
* Test generic/157 was what showed these cases where
* we need to remap EOPNOTSUPP to EINVAL
*/
if (off >= src_inode->i_size) {
rc = -EINVAL;
} else if (src_inode == target_inode) {
if (off + len > destoff)
rc = -EINVAL;
}
}
if (rc == 0 && new_size > target_cifsi->netfs.zero_point)
target_cifsi->netfs.zero_point = new_size;

View File

@@ -207,8 +207,10 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
server = cifs_pick_channel(ses);
vars = kzalloc(sizeof(*vars), GFP_ATOMIC);
if (vars == NULL)
return -ENOMEM;
if (vars == NULL) {
rc = -ENOMEM;
goto out;
}
rqst = &vars->rqst[0];
rsp_iov = &vars->rsp_iov[0];
@@ -864,6 +866,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
smb2_should_replay(tcon, &retries, &cur_sleep))
goto replay_again;
out:
if (cfile)
cifsFileInfo_put(cfile);