Skip to content

Commit ea23007

Browse files
committed
cuda.core: drop unpickle UserWarning; document trust boundary only
NVBUG V13.1 mitigation is documentation, not a per-unpickle warning. Legitimate multiprocessing IPC buffer sharing would spam UserWarning on every round-trip.
1 parent 6aa17f5 commit ea23007

4 files changed

Lines changed: 3 additions & 80 deletions

File tree

cuda_core/cuda/core/_memory/_buffer.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ from cuda.core.typing import DevicePointerType
2626

2727
from cuda.core._stream cimport Stream, Stream_accept, default_stream
2828
from cuda.core._utils.cuda_utils cimport HANDLE_RETURN, _parse_fill_value
29-
from cuda.core._utils.cuda_utils import warn_ipc_buffer_unpickle
3029

3130
import sys
3231
from typing import TYPE_CHECKING
@@ -143,10 +142,12 @@ cdef class Buffer:
143142
# pickle path cannot thread an explicit stream through. Seed the
144143
# imported buffer's deallocation with the current context's default
145144
# stream; the receiver can override via buffer.close(stream).
146-
warn_ipc_buffer_unpickle()
147145
return Buffer.from_ipc_descriptor(mr, ipc_descriptor, stream=default_stream())
148146

149147
def __reduce__(self) -> tuple[object, ...]:
148+
# Security note (CWE-502): unpickling a Buffer performs a live CUDA IPC
149+
# import using descriptor bytes from the pickle stream. Only deserialize
150+
# Buffers from a principal at least as trusted as this process.
150151
# Must not serialize the parent's stream!
151152
return Buffer._reduce_helper, (self.memory_resource, self.ipc_descriptor)
152153

cuda_core/cuda/core/_utils/cuda_utils.pyi

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ _keep_nvrtc_in_stub: 'nvrtc.nvrtcResult'
6060
_keep_runtime_in_stub: 'runtime.cudaError_t'
6161
ComputeCapability = namedtuple('ComputeCapability', ('major', 'minor'))
6262
_fork_warning_checked = False
63-
_ipc_pickle_warning_checked = False
6463

6564
def _check_driver_error(error: cydriver.CUresult) -> int:
6665
...
@@ -141,11 +140,5 @@ def reset_fork_warning() -> None:
141140
to check the warning behavior.
142141
"""
143142

144-
def reset_ipc_pickle_warning() -> None:
145-
"""Reset the IPC buffer unpickle warning flag for testing purposes."""
146-
147-
def warn_ipc_buffer_unpickle() -> None:
148-
"""Warn that unpickling a Buffer performs an IPC import from embedded data."""
149-
150143
def check_multiprocessing_start_method() -> None:
151144
"""Check if multiprocessing start method is 'fork' and warn if so."""

cuda_core/cuda/core/_utils/cuda_utils.pyx

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,6 @@ class Transaction:
348348
# Track whether we've already warned about fork method
349349
_fork_warning_checked = False
350350
351-
# Track whether we've already warned about unpickling IPC buffers
352-
_ipc_pickle_warning_checked = False
353-
354351
355352
def reset_fork_warning() -> None:
356353
"""Reset the fork warning check flag for testing purposes.
@@ -362,28 +359,6 @@ def reset_fork_warning() -> None:
362359
_fork_warning_checked = False
363360
364361
365-
def reset_ipc_pickle_warning() -> None:
366-
"""Reset the IPC buffer unpickle warning flag for testing purposes."""
367-
global _ipc_pickle_warning_checked
368-
_ipc_pickle_warning_checked = False
369-
370-
371-
def warn_ipc_buffer_unpickle() -> None:
372-
"""Warn that unpickling a Buffer performs an IPC import from embedded data."""
373-
global _ipc_pickle_warning_checked
374-
if _ipc_pickle_warning_checked:
375-
return
376-
_ipc_pickle_warning_checked = True
377-
message = (
378-
"Unpickling a cuda.core.Buffer imports GPU memory via the embedded "
379-
"IPCBufferDescriptor. Only unpickle Buffer objects received from a "
380-
"trusted same-host peer process; malicious pickle payloads can supply "
381-
"crafted descriptors. Prefer explicit Buffer.from_ipc_descriptor only "
382-
"with descriptors from cooperating peers."
383-
)
384-
warnings.warn(message, UserWarning, stacklevel=4)
385-
386-
387362
cdef inline tuple _read_fill_ptr(const char* ptr, Py_ssize_t width):
388363
"""Extract (value, element_size) from a raw pointer of known width."""
389364
cdef unsigned int val

cuda_core/tests/test_ipc_pickle_warning.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)