Skip to content
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

Jetpack 5.1.2 Patch 2 #354

Draft
wants to merge 1 commit into
base: r23.06
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ endif() # TRITON_ENABLE_GPU
# Minimum of 1.78 required for use of boost::span. This can eventually be
# relaxed and replaced with std::span in C++20.
#
find_package(Boost 1.78 REQUIRED)
find_package(Boost 1.78 REQUIRED COMPONENTS filesystem)
message(STATUS "Using Boost ${Boost_VERSION}")

#
Expand Down Expand Up @@ -455,6 +455,7 @@ target_link_libraries(
triton-common-table-printer # from repo-common
protobuf::libprotobuf
${RE2_LIBRARY}
Boost::filesystem
)

if (NOT WIN32)
Expand Down
27 changes: 22 additions & 5 deletions src/model_repository_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
#include "model_repository_manager.h"

#include <algorithm>
#include <boost/filesystem.hpp>
#include <deque>
#include <future>
#include <stdexcept>
#include <thread>

#include "backend_model.h"
#include "constants.h"
#include "ensemble_utils.h"
Expand Down Expand Up @@ -81,7 +83,8 @@ class LocalizeRepoAgent : public TritonRepoAgent {
RETURN_TRITONSERVER_ERROR_IF_ERROR(
agent_model->AcquireMutableLocation(
TRITONREPOAGENT_ARTIFACT_FILESYSTEM, &temp_dir_cstr));
const std::string temp_dir = temp_dir_cstr;
const std::string temp_dir =
boost::filesystem::canonical(temp_dir_cstr).string();
const auto& files =
*reinterpret_cast<std::vector<const InferenceParameter*>*>(
agent_model->State());
Expand Down Expand Up @@ -109,10 +112,24 @@ class LocalizeRepoAgent : public TritonRepoAgent {
.c_str());
}

// Save model file to the instructed directory
// mkdir
// Resolve any relative paths or symlinks, and enforce that target
// directory stays within model directory for security.
const std::string file_path =
JoinPath({temp_dir, file->Name().substr(file_prefix.size())});
boost::filesystem::weakly_canonical(
JoinPath(
{temp_dir, file->Name().substr(file_prefix.size())}))
.string();
if (file_path.rfind(temp_dir, 0) != 0) {
return TRITONSERVER_ErrorNew(
TRITONSERVER_ERROR_INVALID_ARG,
(std::string("Invalid file parameter '") + file->Name() +
"' with normalized path '" + file_path +
"' must stay within model directory.")
.c_str());
}

// Save model override file to the instructed directory using the
// temporary model directory as the basepath.
const std::string dir = DirName(file_path);
bool dir_exist = false;
RETURN_TRITONSERVER_ERROR_IF_ERROR(FileExists(dir, &dir_exist));
Expand All @@ -131,7 +148,7 @@ class LocalizeRepoAgent : public TritonRepoAgent {
MakeDirectory(dir, true /* recursive */));
}

// write
// Write file contents at specified path
RETURN_TRITONSERVER_ERROR_IF_ERROR(WriteBinaryFile(
file_path,
reinterpret_cast<const char*>(file->ValuePointer()),
Expand Down