Skip to content

fix: MessageQueueShm head index boundary check #405

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

yinggeh
Copy link
Contributor

@yinggeh yinggeh commented Jul 1, 2025

What does the PR do?

When attacker registers the same shm created by python backend, they can overwrite MessageQueueShm::head data with a very large index and inject malicious code to the memory space.

Checklist

  • PR title reflects the change and is of format <commit_type>: <Title>
  • Changes are described in the pull request.
  • Related issues are referenced.
  • Populated github labels field
  • Added test plan and verified test passes.
  • Verified that the PR passes existing CI.
  • Verified copyright is correct on all changed files.
  • Added succinct git squash message before merging ref.
  • All template sections are filled out.
  • Optional: Additional screenshots for behavior/output changes with before/after.

Commit Type:

  • fix

Related PRs:

Where should the reviewer start?

The index boundary check is in src/message_queue.h

Test plan:

  • CI Pipeline ID:
    30975011

Caveats:

Background

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • closes GitHub issue: #xxx

@yinggeh yinggeh self-assigned this Jul 1, 2025
@yinggeh yinggeh added the bug Something isn't working label Jul 1, 2025
@yinggeh yinggeh changed the title fix: Additional check on message queue indices fix: Additional check on message queue shm indices Jul 1, 2025
@yinggeh yinggeh changed the title fix: Additional check on message queue shm indices fix: MessageQueueShm head index boundary check Jul 1, 2025
@yinggeh
Copy link
Contributor Author

yinggeh commented Jul 1, 2025

No unit test because triton-inference-server/server#8273 makes the exploitation impossible.

@@ -54,105 +51,6 @@ using cudaStream_t = void*;

namespace triton { namespace backend { namespace python {

#define LOG_IF_EXCEPTION(X) \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved log related code to new files to break circular dependency.

@@ -1569,138 +1570,6 @@ Stub::ProcessBLSResponseDecoupled(std::unique_ptr<IPCMessage>& ipc_message)
}
}

std::unique_ptr<Logger> Logger::log_instance_;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved log related code to new files to break circular dependency.

@@ -0,0 +1,170 @@
// Copyright 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved log related code to new files to break circular dependency.

@@ -0,0 +1,134 @@
// Copyright 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved log related code to new files to break circular dependency.

@yinggeh yinggeh requested review from kthui and krishung5 July 2, 2025 00:57
@yinggeh yinggeh marked this pull request as draft July 2, 2025 18:00
@yinggeh yinggeh marked this pull request as ready for review July 2, 2025 23:42
@yinggeh yinggeh requested a review from Tabrizian July 2, 2025 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

1 participant