mirror of
https://github.com/torvalds/linux.git
synced 2026-09-13 14:44:42 +02:00
smb/client: fix integer truncation in collapse range
smb3_collapse_range() stores the ssize_t return value of
smb2_copychunk_range() in an int. A successful copy larger than
INT_MAX is truncated to a negative value and treated as an error.
Reproducer:
MNT=/mnt/scratch
truncate -s 2056M "$MNT/file"
fallocate --collapse-range -o 1M -l 1M "$MNT/file"
Fix this by using __smb2_copychunk_range(), which reports success as
zero instead of returning the copied byte count.
Before this change, the reproducer fails with:
fallocate: fallocate failed: Success
and the file size remains unchanged at 2056 MiB. After this change, the
reproducer succeeds and the file size becomes the expected 2055 MiB.
Fixes: 5476b5dd82 ("cifs: add support for FALLOC_FL_COLLAPSE_RANGE")
Signed-off-by: Huiwen He <hehuiwen@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
This commit is contained in:
parent
0923ae9f23
commit
7811701d6a
|
|
@ -4036,8 +4036,8 @@ static long smb3_collapse_range(struct file *file, struct cifs_tcon *tcon,
|
|||
spin_unlock(&inode->i_lock);
|
||||
netfs_wait_for_outstanding_io(inode);
|
||||
|
||||
rc = smb2_copychunk_range(xid, cfile, cfile, off + len,
|
||||
old_eof - off - len, off);
|
||||
rc = __smb2_copychunk_range(xid, cfile, cfile, off + len,
|
||||
old_eof - off - len, off);
|
||||
if (rc < 0)
|
||||
goto out_2;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user