Skip to content
Merged
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
10 changes: 7 additions & 3 deletions cuda_core/tests/test_program_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2534,15 +2534,19 @@ def test_program_cache_tmp_dir_created_owner_only(tmp_path):
"""``tmp`` stages in-flight compiled device code before the atomic rename into
``entries``, so it must be created owner-only (0o700) regardless of the inherited
umask. ``root``/``entries`` intentionally inherit the umask to keep deliberately
shared caches working (PR #2399 review), so only ``tmp`` is asserted."""
shared caches working (PR #2399 review), so only ``tmp`` is asserted.

Compare only the access bits (``& 0o777``). A setgid parent makes Linux inherit
``S_ISGID`` onto ``tmp``; that bit does not grant access and must not fail the
owner-only check (issue #3214)."""
import stat

from cuda.core.utils._program_cache._file_stream import FileStreamProgramCache

root = tmp_path / "pc"
FileStreamProgramCache(path=root)

mode = stat.S_IMODE(os.stat(root / "tmp").st_mode)
mode = stat.S_IMODE(os.stat(root / "tmp").st_mode) & 0o777
assert mode == 0o700, f"tmp has mode {oct(mode)}"


Expand All @@ -2563,7 +2567,7 @@ def test_program_cache_preexisting_shared_root_used_as_is(tmp_path):
FileStreamProgramCache(path=root)

assert stat.S_IMODE(os.stat(root).st_mode) == 0o777
assert stat.S_IMODE(os.stat(root / "tmp").st_mode) == 0o700
assert (stat.S_IMODE(os.stat(root / "tmp").st_mode) & 0o777) == 0o700


@pytest.mark.thread_unsafe(reason="monkeypatches the process-global NVVM fingerprint probe")
Expand Down
Loading