Skip to content

Use safe_numel() in et#19075

Merged
meta-codesync[bot] merged 6 commits intogh/lucylq/155/basefrom
gh/lucylq/155/head
Apr 25, 2026
Merged

Use safe_numel() in et#19075
meta-codesync[bot] merged 6 commits intogh/lucylq/155/basefrom
gh/lucylq/155/head

Conversation

@lucylq
Copy link
Copy Markdown
Contributor

@lucylq lucylq commented Apr 23, 2026

Stack from ghstack (oldest at bottom):

The wasm bindings' assert_valid_numel() helper previously computed numel without overflow detection, letting a malicious tensor shape wrap to a small value that bypassed the data-size check. Replace with safe_numel() (returns Result<ssize_t>) and propagate the error via THROW_IF_ERROR as a JavaScript exception, matching the rest of the wasm error plumbing.

Authored with Claude.

Differential Revision: D102082911

The wasm bindings' assert_valid_numel() helper previously computed numel without overflow detection, letting a malicious tensor shape wrap to a small value that bypassed the data-size check. Replace with safe_numel() (returns Result<ssize_t>) and propagate the error via THROW_IF_ERROR as a JavaScript exception, matching the rest of the wasm error plumbing.

Authored with Claude.

Differential Revision: [D102082911](https://our.internmc.facebook.com/intern/diff/D102082911/)

[ghstack-poisoned]
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 23, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19075

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 Cancelled Job, 1 Pending, 4 Unrelated Failures

As of commit 75530a3 with merge base eef7921 (image):

CANCELLED JOB - The following job was cancelled. Please retry:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 23, 2026
@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@lucylq lucylq requested a review from JacobSzwejbka April 24, 2026 17:53
The wasm bindings' assert_valid_numel() helper previously computed numel without overflow detection, letting a malicious tensor shape wrap to a small value that bypassed the data-size check. Replace with safe_numel() (returns Result<ssize_t>) and propagate the error via THROW_IF_ERROR as a JavaScript exception, matching the rest of the wasm error plumbing.

Authored with Claude.

Differential Revision: [D102082911](https://our.internmc.facebook.com/intern/diff/D102082911/)

[ghstack-poisoned]
@lucylq lucylq requested a review from shoumikhin as a code owner April 24, 2026 17:57
lucylq pushed a commit that referenced this pull request Apr 24, 2026
Pull Request resolved: #19075

Replace compute_numel() with safe_numel()

Authored with Claude.
ghstack-source-id: 371824079
@exported-using-ghexport

Differential Revision: [D102082911](https://our.internmc.facebook.com/intern/diff/D102082911/)
The wasm bindings' assert_valid_numel() helper previously computed numel without overflow detection, letting a malicious tensor shape wrap to a small value that bypassed the data-size check. Replace with safe_numel() (returns Result<ssize_t>) and propagate the error via THROW_IF_ERROR as a JavaScript exception, matching the rest of the wasm error plumbing.

Authored with Claude.

Differential Revision: [D102082911](https://our.internmc.facebook.com/intern/diff/D102082911/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Apr 24, 2026
Pull Request resolved: #19075

Replace compute_numel() with safe_numel()

Authored with Claude.
ghstack-source-id: 372480318
@exported-using-ghexport

Differential Revision: [D102082911](https://our.internmc.facebook.com/intern/diff/D102082911/)
@lucylq lucylq changed the title Use safe_numel() in wasm bindings Use safe_numel() in et Apr 24, 2026
The wasm bindings' assert_valid_numel() helper previously computed numel without overflow detection, letting a malicious tensor shape wrap to a small value that bypassed the data-size check. Replace with safe_numel() (returns Result<ssize_t>) and propagate the error via THROW_IF_ERROR as a JavaScript exception, matching the rest of the wasm error plumbing.

Authored with Claude.

Differential Revision: [D102082911](https://our.internmc.facebook.com/intern/diff/D102082911/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Apr 24, 2026
Pull Request resolved: #19075

Replace compute_numel() with safe_numel()

Authored with Claude.
ghstack-source-id: 372584817
@exported-using-ghexport

Differential Revision: [D102082911](https://our.internmc.facebook.com/intern/diff/D102082911/)
The wasm bindings' assert_valid_numel() helper previously computed numel without overflow detection, letting a malicious tensor shape wrap to a small value that bypassed the data-size check. Replace with safe_numel() (returns Result<ssize_t>) and propagate the error via THROW_IF_ERROR as a JavaScript exception, matching the rest of the wasm error plumbing.

Authored with Claude.

Differential Revision: [D102082911](https://our.internmc.facebook.com/intern/diff/D102082911/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Apr 24, 2026
Pull Request resolved: #19075

Replace compute_numel() with safe_numel()

Authored with Claude.
ghstack-source-id: 372584817
@exported-using-ghexport

Differential Revision: [D102082911](https://our.internmc.facebook.com/intern/diff/D102082911/)
The wasm bindings' assert_valid_numel() helper previously computed numel without overflow detection, letting a malicious tensor shape wrap to a small value that bypassed the data-size check. Replace with safe_numel() (returns Result<ssize_t>) and propagate the error via THROW_IF_ERROR as a JavaScript exception, matching the rest of the wasm error plumbing.

Authored with Claude.

Differential Revision: [D102082911](https://our.internmc.facebook.com/intern/diff/D102082911/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Apr 24, 2026
Pull Request resolved: #19075

Replace compute_numel() with safe_numel()

Authored with Claude.
ghstack-source-id: 372649703
@exported-using-ghexport

Differential Revision: [D102082911](https://our.internmc.facebook.com/intern/diff/D102082911/)
@meta-codesync meta-codesync Bot merged commit b84894f into gh/lucylq/155/base Apr 25, 2026
167 of 173 checks passed
@meta-codesync meta-codesync Bot deleted the gh/lucylq/155/head branch April 25, 2026 00:57
lucylq added a commit that referenced this pull request Apr 25, 2026
Differential Revision: D102082911

Pull Request resolved: #19075
lucylq added a commit that referenced this pull request Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants