Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the inter-process communication (IPC) layer within the LightLLM framework. The previous custom shared memory (SHM) based RPC system has been replaced with Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the inter-process communication mechanism from a custom shared-memory implementation to using the rpyc library, which is a positive architectural change. However, a critical security vulnerability has been introduced by using rpyc with allow_pickle=True over a Unix domain socket located in the world-writable directory (/tmp). This configuration allows any local user on the system to achieve arbitrary code execution by sending malicious pickle payloads. Additionally, a change to a command-line argument default alters a key feature's behavior, which should be clarified for users.
| success_event.set() | ||
| model_rpc_server = ModelRpcServer(args, rank, rank_in_node, node_world_size, info_queue) | ||
| # Start rpyc server with Unix socket | ||
| t = ThreadedServer(model_rpc_server, socket_path=socket_path, protocol_config={"allow_pickle": True}) |
There was a problem hiding this comment.
The application uses the rpyc library for inter-process communication between the router and model inference processes. Both the server (ThreadedServer) and the client (unix_connect) are configured with allow_pickle=True. The communication occurs over a Unix domain socket located in the /tmp directory. Because /tmp is a world-writable directory on most Unix-like systems, any local user can identify the socket and connect to it. Since allow_pickle is enabled, an attacker can send a maliciously crafted pickled object to the server or client, which, upon deserialization, will execute arbitrary code in the context of the lightllm process.
| return None | ||
| from lightllm.utils.retry_utils import retry | ||
|
|
||
| conn = retry(max_attempts=20, wait_time=2)(unix_connect)(socket_path, config={"allow_pickle": True}) |
There was a problem hiding this comment.
| def _generate_unix_socket_path() -> str: | ||
| """Generate a random Unix socket path""" | ||
| unique_id = uuid.uuid4().hex[:8] | ||
| return f"/tmp/lightllm_model_infer_{unique_id}.sock" |
There was a problem hiding this comment.
Using /tmp for Unix domain sockets can be a security risk on multi-user systems. The /tmp directory is typically world-writable, and while the socket name is randomized, it's not impossible for another local user to discover and connect to it. Since protocol_config has allow_pickle=True, a malicious local user could potentially execute arbitrary code by sending crafted pickle data to the socket. It's strongly recommended to use a more secure location. For example, you could create a temporary directory with restricted permissions using tempfile.mkdtemp() and place the socket file there.
| parser.add_argument("--disable_dynamic_prompt_cache", action="store_true", help="disable dynamic prompt cache") | ||
|
|
||
| parser.add_argument("--chunked_prefill_size", type=int, default=8192, help="chunked prefill size") | ||
| parser.add_argument("--chunked_prefill_size", type=int, default=None, help="chunked prefill size") |
There was a problem hiding this comment.
Changing the default value of chunked_prefill_size from 8192 to None effectively disables the chunked prefill feature by default. This is a significant change in default behavior that might surprise users. It would be good to either reconsider this change or update the help string to clarify that chunked prefill is disabled by default and must be explicitly enabled by setting a size.
No description provided.