Repository navigation
[https://nvbugs/6208457][fix] Pass IPC HMAC key through file descriptor #15654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JunyiXu-nv
merged 6 commits into
NVIDIA:main
from
yibinl-nvidia:dev-yibinl-remove-hmac-key-env-variable
Jul 3, 2026
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ac1adc1
Pass IPC HMAC key through file descriptor
yibinl-nvidia 5d72ee0
Remove raw IPC HMAC key environment variable
yibinl-nvidia da7f5d3
Apply pre-commit formatting
yibinl-nvidia c110358
Harden HMAC IPC validation
yibinl-nvidia a2909be
handle nonblocking HMAC key fd
yibinl-nvidia 279ea54
fix: validate IPC HMAC key FD payload
yibinl-nvidia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import os | ||
| import threading | ||
|
|
||
| import pytest | ||
|
|
||
| from tensorrt_llm.executor import utils as executor_utils | ||
| from tensorrt_llm.executor.utils import LlmLauncherEnvs | ||
|
|
||
|
|
||
| def _reset_ipc_hmac_key_env(monkeypatch): | ||
| monkeypatch.setattr(executor_utils, "_SPAWN_PROXY_PROCESS_IPC_HMAC_KEY", None) | ||
| monkeypatch.delenv( | ||
| LlmLauncherEnvs.TLLM_SPAWN_PROXY_PROCESS_IPC_HMAC_KEY_FD.value, raising=False | ||
| ) | ||
|
|
||
|
|
||
| def _write_key_fd(key_hex: str) -> int: | ||
| read_fd, write_fd = os.pipe() | ||
| os.write(write_fd, key_hex.encode("ascii")) | ||
| os.close(write_fd) | ||
| return read_fd | ||
|
|
||
|
|
||
| def test_get_spawn_proxy_process_ipc_hmac_key_from_fd(monkeypatch): | ||
| _reset_ipc_hmac_key_env(monkeypatch) | ||
| key_hex = "01" * 32 | ||
| read_fd = _write_key_fd(key_hex) | ||
| monkeypatch.setenv(LlmLauncherEnvs.TLLM_SPAWN_PROXY_PROCESS_IPC_HMAC_KEY_FD.value, str(read_fd)) | ||
|
|
||
| key = executor_utils.get_spawn_proxy_process_ipc_hmac_key_env() | ||
|
|
||
| assert key == bytes.fromhex(key_hex) | ||
| assert LlmLauncherEnvs.TLLM_SPAWN_PROXY_PROCESS_IPC_HMAC_KEY_FD not in os.environ | ||
| with pytest.raises(OSError): | ||
| os.fstat(read_fd) | ||
|
|
||
|
|
||
| def test_get_spawn_proxy_process_ipc_hmac_key_caches_fd_key(monkeypatch): | ||
| _reset_ipc_hmac_key_env(monkeypatch) | ||
| key_hex = "02" * 32 | ||
| read_fd = _write_key_fd(key_hex) | ||
| monkeypatch.setenv(LlmLauncherEnvs.TLLM_SPAWN_PROXY_PROCESS_IPC_HMAC_KEY_FD.value, str(read_fd)) | ||
|
|
||
| key = executor_utils.get_spawn_proxy_process_ipc_hmac_key_env() | ||
|
|
||
| assert key == bytes.fromhex(key_hex) | ||
| assert LlmLauncherEnvs.TLLM_SPAWN_PROXY_PROCESS_IPC_HMAC_KEY_FD not in os.environ | ||
| assert executor_utils.get_spawn_proxy_process_ipc_hmac_key_env() == key | ||
|
|
||
|
|
||
| def test_get_spawn_proxy_process_ipc_hmac_key_from_nonblocking_fd(monkeypatch): | ||
| _reset_ipc_hmac_key_env(monkeypatch) | ||
| key_hex = "03" * 32 | ||
| read_fd, write_fd = os.pipe() | ||
| os.set_blocking(read_fd, False) | ||
|
|
||
| def write_key(): | ||
| try: | ||
| os.write(write_fd, key_hex.encode("ascii")) | ||
| finally: | ||
| os.close(write_fd) | ||
|
|
||
| writer = threading.Timer(0.05, write_key) | ||
| writer.start() | ||
| monkeypatch.setenv(LlmLauncherEnvs.TLLM_SPAWN_PROXY_PROCESS_IPC_HMAC_KEY_FD.value, str(read_fd)) | ||
|
|
||
| try: | ||
| key = executor_utils.get_spawn_proxy_process_ipc_hmac_key_env() | ||
| finally: | ||
| writer.join() | ||
|
|
||
| assert key == bytes.fromhex(key_hex) | ||
|
|
||
|
|
||
| def test_get_spawn_proxy_process_ipc_hmac_key_missing(monkeypatch): | ||
| _reset_ipc_hmac_key_env(monkeypatch) | ||
|
|
||
| with pytest.raises(RuntimeError, match="HMAC encryption is required"): | ||
| executor_utils.get_spawn_proxy_process_ipc_hmac_key_env() |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.