Two smb3 client fixes, both for stable

-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEE6fsu8pdIjtWE/DpLiiy9cAdyT1EFAmixIG0ACgkQiiy9cAdy
 T1Gk6wv/brd18UMDEiRvQWANkObgx7X5bXfkA6BWThhqZvdyAvo0VxeE/GOcLrNZ
 VKvqjGrmbV6UAjxE3BJzzjPibJqJOvctmVgmS6BlUpYwmv/yrqReyG08I2qZ2aos
 KSoOwLR+W74USBq1RTpCVn00hH315bLlPvJyWhrNeYhp08daJHOapz7wdM1jflv3
 0TJwXsJmszUL+wpS0M9FMQs8pXgiHxOVKSn6o42rDYZxEgeMwdWHVgceBV4yFP6I
 mJ9SWH2HQ9UUsm1F3AdGLDM82BNBQ3W7PcAwRIBiGxx+0NvZMDtnhEfdYrCcleU3
 KZyXnb2yuEx4AUEeKtL7NK4JRAHdm2mG/V3hvlHWj5dQqml62UTJDf3qbqVmjlro
 GSF8EC72Z8+/S+XpJ1NKulyz9MZ9gSYxTUCVag5GH5bAMLHxrQBUuozUwlAJon2d
 tJJTX+H5KrwY5DNn4ixxhDmqCqAt8P5doYNTn7W+F9kDhFWMsyeKmoF5LeXSq6ba
 hVIAnqEa
 =k6YJ
 -----END PGP SIGNATURE-----

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
pull/1334/head
Linus Torvalds 2025-08-29 08:51:34 -07:00
commit 2575e638e2
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 @@ replay_again:
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 @@ finished:
smb2_should_replay(tcon, &retries, &cur_sleep))
goto replay_again;
out:
if (cfile)
cifsFileInfo_put(cfile);