Repository navigation
rpc : reject malformed tensor dims and op in deserialize_tensor - #30474
void-mckenzie wants to merge 1 commit into
Conversation
996965a to
78ea7c2
Compare
|
@am17an friendly ping in case this slipped by, it's a small one (and my first PR here). One question: should the overflow and block size checks stay in |
|
I ran into this independently and came to propose a fix — found this PR already covers it, so I verified it locally instead (Apple M1 Max, macOS 15, CPU backend): Issue reproduced on the unpatched parent commit ( Fix verified at
FWIW on your question about keeping the checks in One optional nit: |
Closes #30458
Overview
deserialize_tensorpassed the client-suppliedne[]straight intoggml_new_tensor_4d, so a single RPC request whose element count overflowsint64_thitGGML_ASSERTinggml_new_tensor_impland aborted the wholerpc-serverprocess, dropping every connected client. The path is reachable from every tensor-deserializing command (SET_TENSOR,GET_ALLOC_SIZE,GRAPH_COMPUTE, ...).This PR performs the same element-count product check as
ggml.cup front and returnsnullptr, matching how the other malformed-tensor cases indeserialize_tensorare already handled, so a malformed request only fails the command that carries it. It also rejects:ne[0]values that are not a multiple of the tensor type's block size (previously asserted insideggml_row_size)op >= GGML_OP_COUNT(previously read out of bounds viaggml_op_namein the buffer-bounds error log)A raw-socket regression case is added to
test-rpc-multi-server: it sends the three malformed requests asGET_ALLOC_SIZE, asserts that each is rejected without a response (the server closes the connection instead of replying), and that the server keeps accepting new connections and answeringHELLO. The check runs beforeggml_backend_rpc_init()because the server serves clients one at a time, and the probe sockets use a receive timeout so a regression fails fast instead of hanging.Additional information
ggml.c'sGGML_ASSERT.ADDgraph end-to-end over RPC with correct results.get_alloc_sizestores a failed src deserialization as null without checking, which can still abort CUDA servers on malformed inputs. Happy to follow up separately.Requirements