Commit a8ff3d7
Github Executorch
Fix integer overflow in compute_numel() (TOB-EXECUTORCH-19)
compute_numel() multiplies tensor dimensions without overflow protection.
The result is used for size calculations in make_tensor_ptr() and
clone_tensor_ptr(), so an overflow could lead to undersized allocations
and subsequent buffer overflows.
Add an ET_CHECK_MSG before each multiplication to verify that
numel * sizes[i] will not exceed SSIZE_MAX.
This PR was authored with the assistance of Claude.1 parent 15e8bf7 commit a8ff3d7
1 file changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
41 | 48 | | |
42 | 49 | | |
43 | 50 | | |
| |||
0 commit comments