Repository navigation
Validate device-name output lengths before native access - #62
Draft
RicheyWorks wants to merge 1 commit into
Draft
RicheyWorks wants to merge 1 commit into
RicheyWorks wants to merge 1 commit into
Conversation
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.
cuDeviceGetNameforwardslento CUDA without checking the Java output array's actual size. An excessive length lets the native call write beyond the array storage; a negative length is also forwarded instead of rejected at the Java boundary.After the existing null checks and before acquiring critical array storage, reject
len < 0orlen > name.lengthwithIllegalArgumentException. Document this exception. Preserve existing null handling, valid partial/exact output lengths and native handling of zero length. Signatures and valid-output copy-back are unchanged. Valid calls retain native result-code behavior; invalid Java output lengths now throw rather than being forwarded.Six isolated child-JVM tests cover negative/oversized lengths, exact/partial valid lengths and null name/device arguments. Children enable JNI checking, capture diagnostics and have a 30-second timeout so a broken JNI build cannot terminate JUnit. Invalid-length cases require the exception and untouched sentinel bytes; valid cases check CUDA success and untouched bytes beyond
len.Verification on Windows x86_64, RTX 4090/driver 617.42, Temurin JDK 22/JUnit 4.13.1:
FATAL ERROR ... failed bounds checkin the isolated child; negative length lacks the validation exception. Four controls pass.jcuda-common9d41fb5: all six pass, zero failures/errors/skips. A separately logged oversized-length run confirms the rebuilt DLL and successful rejection. No JNI warnings on the fixed path.git apply --checkover this guard. Combined runtime behavior was not tested. No other matching length-check contribution found.CUDA contract: device-name query.
The regression itself enables JNI checking in every child and propagates the selected library path.