Skip to content

Commit fa2fd0b

Browse files
hac-vsmfrench
authored andcommitted
smb: client: fix UBSAN array-index-out-of-bounds in smb2_copychunk_range
struct copychunk_ioctl_req::ChunkCount is annotated with __counted_by_le() as the number of elements in Chunks[]. smb2_copychunk_range reuses ChunkCount to store the number of chunks sent in the current iteration. If a later iteration populates more chunks than a previous one, the stale smaller value trips UBSAN. Set ChunkCount to chunk_count (allocated capacity) before populating Chunks[]. Fixes: cc26f59 ("smb: move copychunk definitions to common/smb2pdu.h") Link: https://lore.kernel.org/linux-cifs/CAH2r5ms9AWLy8WZ04Cpq5XOeVK64tcrUQ6__iMW+yk1VPzo1BA@mail.gmail.com Tested-by: Youling Tang <tangyouling@kylinos.cn> Acked-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent bc31161 commit fa2fd0b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

fs/smb/client/smb2ops.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,6 +1905,12 @@ smb2_copychunk_range(const unsigned int xid,
19051905
src_off_prev = src_off;
19061906
dst_off_prev = dst_off;
19071907

1908+
/*
1909+
* __counted_by_le(ChunkCount): set to allocated chunks before
1910+
* populating Chunks[]
1911+
*/
1912+
cc_req->ChunkCount = cpu_to_le32(chunk_count);
1913+
19081914
chunks = 0;
19091915
copy_bytes = 0;
19101916
copy_bytes_left = umin(total_bytes_left, tcon->max_bytes_copy);

0 commit comments

Comments
 (0)