Skip to content

Conversation

@yuslepukhin
Copy link
Member

@yuslepukhin yuslepukhin commented Dec 25, 2025

Description

Address OOB reads and writes issues.

Motivation and Context

#11828
#13332
See also this: onnx/onnx#4294

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses shortcomings in the Pad kernel implementation across CPU and CUDA providers, with a focus on improving robustness, safety, and edge case handling for padding operations.

Key Changes:

  • Enhanced integer overflow protection using SafeInt throughout CPU and CUDA Pad implementations
  • Added validation for edge cases including zero-extent dimensions and reflect mode constraints
  • Introduced new comprehensive test cases for edge conditions, negative padding, and mixed-sign padding scenarios

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
onnxruntime/test/testdata/test_pad_rce.py Python script to generate ONNX model for RCE (Remote Code Execution) testing with dynamic pad inputs
onnxruntime/test/testdata/test_pad_rce.onnx Generated ONNX model artifact for pad RCE testing
onnxruntime/test/providers/cpu/tensor/pad_test.cc Updated test exclusions for DML provider, added extensive new tests for edge cases, negative padding, and various pad modes
onnxruntime/core/providers/cuda/tensor/pad.h Minor update with copyright header duplication issue
onnxruntime/core/providers/cuda/tensor/pad.cc Enhanced type safety (int32_t→size_t), added SafeInt usage, improved edge case handling for zero extents and reflect mode
onnxruntime/core/providers/cuda/cuda_utils.cu Added Fill template specialization for bool type
onnxruntime/core/providers/cpu/tensor/padbase.h Added helper functions for flattening validation and element coverage checking
onnxruntime/core/providers/cpu/tensor/pad.cc Introduced OutputSink debug wrapper, enhanced SafeInt usage, improved validation for zero extents and reflect mode, conditional flattening logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yuslepukhin yuslepukhin requested a review from tianleiwu January 5, 2026 21:38
@yuslepukhin yuslepukhin changed the title [DRAFT] Address Pad kernel shortcomings [ICM CXX] Address Pad kernel shortcomings Jan 5, 2026
@yuslepukhin yuslepukhin marked this pull request as ready for review January 5, 2026 21:38
Copy link
Contributor

@tianleiwu tianleiwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code and comprehensive tests looks good.

OutputSink only checks boundary in debug build. Is there use case that need bounds check in release build?

Some CI pipeline failed. Please take a look.

tianleiwu
tianleiwu previously approved these changes Jan 6, 2026
@yuslepukhin yuslepukhin merged commit 5d59608 into main Jan 8, 2026
91 checks passed
@yuslepukhin yuslepukhin deleted the yuslepukhin/pad_rce branch January 8, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants