Repository navigation
rpc : validate 2d tensor stride and catch allocation errors - #31322
Open
sohaibharraoui wants to merge 1 commit into
Open
sohaibharraoui wants to merge 1 commit into
sohaibharraoui wants to merge 1 commit into
Conversation
sohaibharraoui
marked this pull request as ready for review
October 28, 2026 16:17
Contributor
Author
|
Hi @am17an, this is a small follow-up in the same file that adds stride validation to |
This branch has not been deployed
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.
Overview
This fixes a remotely triggerable crash of the RPC server through the
GET_TENSOR_2DandSET_TENSOR_2Dcommands.stride >= sizewhenn_copies > 1inget_tensor_2dandset_tensor_2d. Whenstride < size(e.g.stride == 0),(n_copies - 1) * stride + sizeunder-calculates the memory footprint, bypassing buffer/tensor bounds checks. In hardware backends like CUDA, it also breakscudaMemcpy2DAsync(pitch >= widthinvariant), causing aCUDA_CHECKabort.std::exceptionaroundresponse.resize(...)inget_tensor_2d. If an allocation fails (std::bad_allocorstd::length_error), the server previously crashed the whole process viastd::terminate(). It now logs the error and returnsfalse, dropping only that client connection.Additional information
stride = 0withn_copies = 0x8000000000000000. Unpatched server aborted (SIGABRT); patched server rejected the request cleanly and kept running.ggml_backend_tensor_set_2d/get_2d(ggml-backend-meta.cpp) always passstride >= size, so the new check does not reject legitimate requests from the RPC client.-DGGML_RPC=ON.Requirements