fix: graceful UNAVAILABLE instead of NULL-deref crash on shared-memory requests (TRI-1698) - #8936
Conversation
Greptile SummaryThe PR prevents null
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
C[Client shared-memory request] --> F{HTTP or gRPC frontend}
F --> M{SharedMemoryManager available?}
M -- No --> U[Return UNAVAILABLE]
U --> H[Frontend remains healthy]
M -- Yes --> R[Resolve or manage shared-memory region]
R --> I[Continue inference or control operation]
Reviews (4): Last reviewed commit: "fix: return UNAVAILABLE instead of crash..." | Re-trigger Greptile |
df32ef8 to
4711f19
Compare
| RET=1 | ||
| fi | ||
|
|
||
| # TRI-1698: shared-memory requests must not crash a tritonfrontend-launched |
There was a problem hiding this comment.
Please remove TRI numbers.
There was a problem hiding this comment.
Good catch, thank you. I removed the TRI numbers.
There was a problem hiding this comment.
It's okay if it is a TODO reminder of future works. Here is not the case.
There was a problem hiding this comment.
Thanks Yingge, agreed — trimmed the comments down to one line each and removed the TRI numbers. Much cleaner now.
4711f19 to
becd5af
Compare
… with a null shm manager (TRI-1698) - Null SharedMemoryManager in the Python-bindings (tritonfrontend) frontend let an unauthenticated shared-memory request crash the whole server (CWE-476 / remote DoS) - Guard every shm_manager_ dereference in the HTTP and gRPC infer + shm-control paths, returning TRITONSERVER_ERROR_UNAVAILABLE (HTTP 503) - No behavior change on the standard tritonserver binary path (manager is non-null there) - Add a subprocess-isolated L0_python_api regression test that detects the crash
becd5af to
17039d7
Compare
| ::grpc::Status* status) { | ||
| // A null shared memory manager (e.g. when the frontend is started | ||
| // through the in-process Python bindings) must not be dereferenced. | ||
| // Fail gracefully instead of crashing the process (TRI-1698). |
There was a problem hiding this comment.
same. remove TRI, and keep the comments clean.
| ::grpc::Status* status) { | ||
| // A null shared memory manager (e.g. when the frontend is started | ||
| // through the in-process Python bindings) must not be dereferenced. | ||
| // Fail gracefully instead of crashing the process (TRI-1698). |
| ::grpc::Status* status) { | ||
| // A null shared memory manager (e.g. when the frontend is started | ||
| // through the in-process Python bindings) must not be dereferenced. | ||
| // Fail gracefully instead of crashing the process (TRI-1698). |
What does the PR do?
When a frontend is started through the in-process Python bindings (
tritonfrontend),HTTPAPIServer/gRPC are constructed with a nullSharedMemoryManager(TODO DLIS-7194).An unauthenticated client could crash the whole server process with a single inference
(or shared-memory control) request referencing shared memory, because the request handlers
dereferenced
shm_manager_with no null check (CWE-476 / remote DoS).This guards every untrusted-input-reachable
shm_manager_dereference and returnsTRITONSERVER_ERROR_UNAVAILABLE(HTTP 503 / gRPC UNAVAILABLE) instead of dereferencing.No behavior change on the standard
tritonserverbinary path (manager is non-null there).Checklist
<commit_type>: <Title>Commit Type:
Related PRs:
None.
Where should the reviewer start?
src/http_server.cc—ParseJsonTritonIO(infer input + output guards) andHandleSystemSharedMemory/HandleCudaSharedMemorysrc/grpc/infer_handler.{cc,h}—InferGRPCToInputandInferAllocatorPayloadsrc/grpc/grpc_server.cc— the sixCommonHandlershm control lambdassrc/common.h— sharedkSharedMemoryManagerUnavailableErrorStrqa/L0_python_api/test_shared_memory_frontend.py— regression testTest plan:
Reproduced on
nvcr.io/nvidia/tritonserver:26.03-py3(v2.67.0): server healthy → one inference withshared_memory_region→Fatal Python error: Segmentation fault, process exit 139.New subprocess-isolated e2e test
qa/L0_python_api/test_shared_memory_frontend.py(wired intotest.sh): fails on the unpatched build (detects the crash), asserts a graceful 503 + live server on the patched build.e2e tests added: yes.
CI Pipeline ID: [63707556]
Caveats:
Enabling shared memory through the Python bindings remains out of scope (tracked by DLIS-7194); this PR only makes the unsupported path fail gracefully instead of crashing.
Background
PSIRT TRI-1698. Triage requested a graceful unsupported/unavailable error rather than process termination.
Related Issues:
Relates to TRI-1698