|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 |
|
3 | | -# Copyright 2019-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 3 | +# Copyright 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
4 | 4 | # |
5 | 5 | # Redistribution and use in source and binary forms, with or without |
6 | 6 | # modification, are permitted provided that the following conditions |
@@ -385,6 +385,59 @@ def test_infer_byte_size_out_of_bound(self): |
385 | 385 | ) |
386 | 386 | self._cleanup_shm_handles() |
387 | 387 |
|
| 388 | + def test_infer_integer_overflow(self): |
| 389 | + # Test for integer overflow vulnerability in offset + byte_size calculation |
| 390 | + error_msg = [] |
| 391 | + self._configure_server() |
| 392 | + |
| 393 | + offset = 32 |
| 394 | + byte_size = 2**64 - 32 |
| 395 | + |
| 396 | + if self.protocol == "http": |
| 397 | + iu.shm_basic_infer( |
| 398 | + self, |
| 399 | + self.triton_client, |
| 400 | + self._shm_handles[0], |
| 401 | + self._shm_handles[1], |
| 402 | + self._shm_handles[2], |
| 403 | + self._shm_handles[3], |
| 404 | + error_msg, |
| 405 | + shm_output_offset=offset, |
| 406 | + shm_output_byte_size=byte_size, |
| 407 | + protocol=self.protocol, |
| 408 | + use_system_shared_memory=True, |
| 409 | + ) |
| 410 | + |
| 411 | + self.assertEqual(len(error_msg), 1) |
| 412 | + self.assertTrue( |
| 413 | + "Integer overflow detected: byte_size " in error_msg[0], |
| 414 | + f"Unexpected error message: {error_msg[0]}", |
| 415 | + ) |
| 416 | + self._cleanup_shm_handles() |
| 417 | + else: |
| 418 | + # The gRPC client utilizes the int64_param and will throw a separate error for values larger than 2**63-1 |
| 419 | + try: |
| 420 | + iu.shm_basic_infer( |
| 421 | + self, |
| 422 | + self.triton_client, |
| 423 | + self._shm_handles[0], |
| 424 | + self._shm_handles[1], |
| 425 | + self._shm_handles[2], |
| 426 | + self._shm_handles[3], |
| 427 | + error_msg, |
| 428 | + shm_output_offset=offset, |
| 429 | + shm_output_byte_size=byte_size, |
| 430 | + protocol=self.protocol, |
| 431 | + use_system_shared_memory=True, |
| 432 | + ) |
| 433 | + self.assertTrue( |
| 434 | + False, |
| 435 | + "Expected gRPC client to fail on value larger than int64_param maximum", |
| 436 | + ) |
| 437 | + except ValueError as ex: |
| 438 | + self.assertIn("Value out of range:", str(ex)) |
| 439 | + self._cleanup_shm_handles() |
| 440 | + |
388 | 441 | def test_register_out_of_bound(self): |
389 | 442 | create_byte_size = self.DEFAULT_SHM_BYTE_SIZE |
390 | 443 |
|
|
0 commit comments