onnxruntime
fccf03ba - Guard MlasConvPrepare working-buffer products with SafeInt (#29444)

Commit
11 days ago
Guard MlasConvPrepare working-buffer products with SafeInt (#29444) This pull request strengthens the safety of arithmetic operations in the convolution implementation by using `SafeInt` to prevent integer overflows, especially in cases where tensor shapes may be attacker-controlled. It also removes some compiler-specific warning pragmas that are no longer needed due to these changes. **Enhanced integer safety in convolution calculations:** * Replaced raw `size_t` multiplications with `SafeInt<size_t>` for calculating input/output sizes and kernel dimensions, ensuring that any arithmetic overflow is caught and handled appropriately. This is particularly important for preventing security vulnerabilities from attacker-controlled tensor shapes. [[1]](diffhunk://#diff-3f8429fb413f2d0edd2e6b08b2a516744293e5ba092ab9c9da7b34ed0b28948dL1563-R1566) [[2]](diffhunk://#diff-3f8429fb413f2d0edd2e6b08b2a516744293e5ba092ab9c9da7b34ed0b28948dL1581-R1594) * Used `SafeInt<size_t>` for all working buffer size calculations, including those involving thread counts and batch/group products, to prevent buffer overflows and ensure correct memory allocation. [[1]](diffhunk://#diff-3f8429fb413f2d0edd2e6b08b2a516744293e5ba092ab9c9da7b34ed0b28948dL1678-R1686) [[2]](diffhunk://#diff-3f8429fb413f2d0edd2e6b08b2a516744293e5ba092ab9c9da7b34ed0b28948dL1777-L1791) **Code cleanup and maintenance:** * Removed MSVC-specific warning suppression pragmas since `SafeInt` now guards against arithmetic overflow, making these warnings obsolete. [[1]](diffhunk://#diff-3f8429fb413f2d0edd2e6b08b2a516744293e5ba092ab9c9da7b34ed0b28948dL1331-L1335) [[2]](diffhunk://#diff-3f8429fb413f2d0edd2e6b08b2a516744293e5ba092ab9c9da7b34ed0b28948dL1777-L1791) * Added the `core/common/safeint.h` include to provide access to the `SafeInt` functionality.
Author
Parents
Loading