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 #7217

Draft
wants to merge 7 commits 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
11 changes: 8 additions & 3 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2020-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2020-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -948,8 +948,8 @@ def create_dockerfile_buildbase(ddir, dockerfile_name, argmap):
# Current libboost-dev apt packages are < 1.78, so install from tar.gz
RUN wget -O /tmp/boost.tar.gz \
https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz && \
(cd /tmp && tar xzf boost.tar.gz) && \
mv /tmp/boost_1_80_0/boost /usr/include/boost
(cd /tmp && tar xzf boost.tar.gz) && cd /tmp/boost_1_80_0 && mv /tmp/boost_1_80_0/boost /usr/include/boost && \
./bootstrap.sh --prefix=/usr && ./b2 --with-filesystem install
rmccorm4 marked this conversation as resolved.
Show resolved Hide resolved

# Server build requires recent version of CMake (FetchContent required)
RUN apt update && apt install -y gpg wget && \
Expand Down Expand Up @@ -1555,6 +1555,11 @@ def core_build(cmake_script, repo_dir, cmake_dir, build_dir, install_dir,
cmake_script.cp(
os.path.join(repo_install_dir, 'lib', 'libtritonserver.so'),
os.path.join(install_dir, 'lib'))
# Copy boost filesystem library used to compile tritonserver
cmake_script.mkdir(os.path.join(install_dir, 'boost_filesystem'))
cmake_script.cp(
os.path.join('/usr', 'lib', 'libboost_filesystem.so.1.80.0'),
os.path.join(install_dir, 'boost_filesystem'))
mc-nv marked this conversation as resolved.
Show resolved Hide resolved
rmccorm4 marked this conversation as resolved.
Show resolved Hide resolved

cmake_script.mkdir(os.path.join(install_dir, 'include', 'triton'))
cmake_script.cpdir(
Expand Down
81 changes: 80 additions & 1 deletion qa/L0_lifecycle/lifecycle_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2018-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -28,8 +28,10 @@

sys.path.append("../common")

import base64
from builtins import range
from functools import partial
import json
import os
import shutil
import signal
Expand Down Expand Up @@ -2385,6 +2387,83 @@ def test_file_override(self):
base[0],
], (3,), model_shape)

# Test that model load API file override can't be used to create files
# outside of any model directory.
def test_file_override_security(self):
# When using model load API, temporary model directories are created in
# a randomly generated /tmp/folderXXXXXX directory for the life of the
# model, and cleaned up on model unload.
model_basepath = "/tmp/folderXXXXXX"
if os.path.exists(model_basepath) and os.path.isdir(model_basepath):
shutil.rmtree(model_basepath)
os.makedirs(model_basepath)

# Set file override paths that try to escape out of model directory,
# and test both pre-existing and non-existent files.
root_home_dir = "/root"

# Relative paths
escape_dir_rel = os.path.join("..", "..", "root")
escape_dir_full = os.path.join(model_basepath, escape_dir_rel)
self.assertEqual(os.path.abspath(escape_dir_full), root_home_dir)

new_file_rel = os.path.join(escape_dir_rel, "new_dir", "test.txt")
self.assertFalse(os.path.exists(os.path.join(model_basepath, new_file_rel)))
existing_file_rel = os.path.join(escape_dir_rel, ".bashrc")
self.assertTrue(os.path.exists(os.path.join(model_basepath, existing_file_rel)))

# Symlinks
## No easy way to inject symlink into generated temp model dir, so for
## testing sake, make a fixed symlink path in /tmp.
escape_dir_symlink_rel = os.path.join("..", "escape_symlink")
escape_dir_symlink_full = "/tmp/escape_symlink"
self.assertEqual(
os.path.abspath(os.path.join(model_basepath, escape_dir_symlink_rel)),
escape_dir_symlink_full,
)
if os.path.exists(escape_dir_symlink_full):
os.unlink(escape_dir_symlink_full)
os.symlink(root_home_dir, escape_dir_symlink_full)
self.assertTrue(os.path.abspath(escape_dir_symlink_full), root_home_dir)

symlink_new_file_rel = os.path.join(
escape_dir_symlink_rel, "new_dir", "test.txt"
)
self.assertFalse(
os.path.exists(os.path.join(model_basepath, symlink_new_file_rel))
)
symlink_existing_file_rel = os.path.join(escape_dir_symlink_rel, ".bashrc")
self.assertTrue(
os.path.exists(os.path.join(model_basepath, symlink_existing_file_rel))
)

# Contents to try writing to file, though it should fail to be written
new_contents = "This shouldn't exist"
new_contents_b64 = base64.b64encode(new_contents.encode())

new_files = [new_file_rel, symlink_new_file_rel]
existing_files = [existing_file_rel, symlink_existing_file_rel]
all_files = new_files + existing_files
for filepath in all_files:
# minimal config to create a new model
config = json.dumps({"backend": "identity"})
files = {f"file:{filepath}": new_contents_b64}
with httpclient.InferenceServerClient("localhost:8000") as client:
with self.assertRaisesRegex(InferenceServerException, "failed to load"):
client.load_model("new_model", config=config, files=files)

for rel_path in new_files:
# Assert new file wasn't created
self.assertFalse(os.path.exists(os.path.join(model_basepath, rel_path)))

for rel_path in existing_files:
# Read the existing file and make sure it's contents weren't overwritten
existing_file = os.path.join(model_basepath, rel_path)
self.assertTrue(os.path.exists(existing_file))
with open(existing_file) as f:
contents = f.read()
self.assertNotEqual(contents, new_contents)

def test_shutdown_dynamic(self):
model_shape = (1, 1)
input_data = np.ones(shape=(1, 1), dtype=np.float32)
Expand Down
Loading