Commit 84f39aa
Arm backend: Fix integer overflow in VGFBackend IO size computation (pytorch#19256)
Replace std::accumulate with std::multiplies<>() with an explicit loop
using c10::mul_overflows() to detect overflow before each
multiplication. The previous code would silently wrap on overflow,
producing an undersized memcpy size that could lead to out-of-bounds
reads/writes when copying tensor data to/from Vulkan device memory.
Also reject negative dimensions before casting to size_t.
This PR was authored with the assistance of Claude.
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils
@Sebastian-Larsson @robell
Co-authored-by: Github Executorch <github_executorch@arm.com>1 parent beca948 commit 84f39aa
1 file changed
Lines changed: 26 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
| 8 | + | |
10 | 9 | | |
11 | 10 | | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
195 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
196 | 206 | | |
197 | 207 | | |
198 | 208 | | |
| |||
226 | 236 | | |
227 | 237 | | |
228 | 238 | | |
229 | | - | |
230 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
231 | 251 | | |
232 | 252 | | |
233 | 253 | | |
| |||
0 commit comments