Add device-side bounds checks to permute_multi_embs_kernel#5806
Open
efiks wants to merge 1 commit into
Open
Conversation
Summary: X-link: facebookresearch/FBGEMM#2732 Add device-side safety checks to `permute_multi_embs_kernel` to prevent CUDA illegal memory access crashes when permute arguments are stale or corrupt: 1. **Forward-path bounds check**: After parsing the permutes table, validate that `in_tensor` and `out_tensor` indices are within the bounds of `in_lengths` and `out_lengths` before dereferencing device pointers. Threads with invalid indices return early instead of crashing. 2. **Reverse-permute loop guard**: Add an iteration counter capped at `permute_size` to prevent infinite loops when the permutes linked-list `next` chain is corrupt. Also add an `in_tensor` bounds check inside the loop body to bail on corrupt data rather than performing OOB device memory access. Differential Revision: D107013820
Contributor
|
@efiks has exported this pull request. If you are a Meta employee, you can view the originating Diff in D107013820. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
X-link: https://github.com/facebookresearch/FBGEMM/pull/2732
Add device-side safety checks to
permute_multi_embs_kernelto prevent CUDA illegal memory access crashes when permute arguments are stale or corrupt:Forward-path bounds check: After parsing the permutes table, validate that
in_tensorandout_tensorindices are within the bounds ofin_lengthsandout_lengthsbefore dereferencing device pointers. Threads with invalid indices return early instead of crashing.Reverse-permute loop guard: Add an iteration counter capped at
permute_sizeto prevent infinite loops when the permutes linked-listnextchain is corrupt. Also add anin_tensorbounds check inside the loop body to bail on corrupt data rather than performing OOB device memory access.Differential Revision: D107013820