Conversation
af_device_info documents a recommended minimum size of 64 bytes for d_name (docs/details/device.dox, device_func_prop), and the CPU and OpenCL backends write at most 64. The CUDA backend wrote up to 256 and its sanitize loop then read d_name[256], touching 257 bytes of a buffer callers were told to size at 64. Clamp the write to 64 and bound the lookahead loop at 63 so it stays inside the documented buffer. Confirmed with AddressSanitizer against a 64-byte heap allocation: before, "heap-buffer-overflow ... WRITE of size 84"; after, clean. Fixes #3712 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012SRueobKykUocB1SRdHsEE
melonakos
force-pushed
the
fix/3712-cuda-device-info-overflow
branch
from
September 10, 2026 18:47
0257d17 to
854e5ce
Compare
The OpenCL sanitizer looped to 31 with no terminator check, so it read and wrote past the end of any shorter device name. Stop at the terminator and stay within the 64-byte buffer.
melonakos
force-pushed
the
fix/3712-cuda-device-info-overflow
branch
from
September 10, 2026 18:47
854e5ce to
d42cdcb
Compare
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.
The CUDA backend wrote up to 256 bytes into d_name and then scanned 256 bytes sanitizing it, while af_device_info documents 64 and the CPU and OpenCL backends respect that, so conforming callers overflowed. Write and scan within 64 bytes and stop at the terminator. Fixes #3712.