smb: client: fix UBSAN array-index-out-of-bounds in smb2_copychunk_range
Changes
1 files changed · +6 −0
| File | Status | Add | Del | Content |
|---|---|---|---|---|
| fs/smb/client/smb2ops.c | modified | +6 | −0 | View file |
fs/smb/client/smb2ops.c
View filediff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index a16ded4..c1aaf77 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -1905,6 +1905,12 @@ retry:
src_off_prev = src_off;
dst_off_prev = dst_off;
+ /*
+ * __counted_by_le(ChunkCount): set to allocated chunks before
+ * populating Chunks[]
+ */
+ cc_req->ChunkCount = cpu_to_le32(chunk_count);
+
chunks = 0;
copy_bytes = 0;
copy_bytes_left = umin(total_bytes_left, tcon->max_bytes_copy);