Skip to content

cuda.core: validate accessed_by kinds before cuMemAdvise (Glasswing V19.1) - #2222

Merged
Andy-Jost merged 1 commit into
NVIDIA:mainfrom
Andy-Jost:ajost/glasswing-v19-1-accessed-by-validation
Jun 15, 2026
Merged

cuda.core: validate accessed_by kinds before cuMemAdvise (Glasswing V19.1)#2222
Andy-Jost merged 1 commit into
NVIDIA:mainfrom
Andy-Jost:ajost/glasswing-v19-1-accessed-by-validation

Conversation

@Andy-Jost

Copy link
Copy Markdown
Contributor

Summary

Addresses Glasswing finding V19.1 (NVBUG 6268913): the ManagedBuffer.accessed_by setter validated element types up front but deferred location-kind checks to _advise_one inside the update loop. A bulk assignment containing an invalid kind (e.g. Host(numa_id=...), which maps to host_numa) could unset valid entries before raising, leaving torn driver state.

Changes

  • cuda_core/cuda/core/_memory/_managed_buffer.py: dry-run _coerce_location and reject unsupported kinds for CU_MEM_ADVISE_SET_ACCESSED_BY before any cuMemAdvise calls
  • cuda_core/tests/memory/test_managed_ops.py: add test_accessed_by_set_assignment_validates_kind_before_mutation

Test Coverage

  • test_accessed_by_set_assignment_validates_kind_before_mutation — invalid bulk assignment raises without removing previously applied accessed_by entries

Related Work

  • NVIDIA/cuda-python-private#380 (Glasswing V19.1, NVBugs 6268913)
  • Part of Glasswing audit umbrella NVIDIA/cuda-python-private#358

Dry-run location-kind checks in the ManagedBuffer.accessed_by setter so
bulk assignment cannot partially mutate driver state when an invalid
Host NUMA variant appears in the target set (Glasswing V19.1).
@Andy-JostAndy-Jost added this to the cuda.core v1.1.0 milestone Jun 15, 2026
@Andy-JostAndy-Jost added bug Something isn't working P2 Low priority - Nice to have cuda.core Everything related to the cuda.core module labels Jun 15, 2026
@Andy-JostAndy-Jost self-assigned this Jun 15, 2026
@Andy-Jost
Andy-Jost requested a review from rparolinJune 15, 2026 17:35
@github-actions

This comment has been minimized.

@mdboommdboom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

target.add(loc)
for loc in target:
spec = _coerce_location(loc)
assert spec is not None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will Glasswing complain that this goes away in -O mode (as it did in another issue)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that Glasswing only flags issues when it can put together a trace that involves crossing a security boundary, so it won't flag every use of assert.

In the other issue (cuda-python-private#382 -- Glasswing V3.2, NVBUG 6268893), it flagged that assert because the data it checked came in through pickle and was therefore untrusted.

@Andy-Jost
Andy-Jost merged commit 4a684f6 into NVIDIA:mainJun 15, 2026
114 checks passed
@Andy-Jost
Andy-Jost deleted the ajost/glasswing-v19-1-accessed-by-validation branch June 15, 2026 20:35
@github-actions

Copy link
Copy Markdown
Doc Preview CI
Preview removed because the pull request was closed or merged.

Andy-Jost added a commit to Andy-Jost/cuda-python that referenced this pull request Jul 8, 2026
Add a Highlights section, backfill PR/issue links on New features entries,
and add Bug fixes entries for the v1.1.0 IPC import hardening (NVIDIA#2219, NVIDIA#2223,
NVIDIA#2224), the ManagedBuffer.accessed_by torn-state fix (NVIDIA#2222), and graph node
attachment lifetimes (NVIDIA#2280).
Highlights (per review): the .pyi type-stub support and the new
cuda.core.texture module; NVLink enumeration is covered in New features /
Bug fixes rather than as a highlight. Also adds a New features entry for the
cuda.core.texture module (NVIDIA#467, NVIDIA#2095, NVIDIA#2307).
Andy-Jost added a commit to Andy-Jost/cuda-python that referenced this pull request Jul 8, 2026
Add a Highlights section, backfill PR/issue links on New features entries,
and add Bug fixes entries for the v1.1.0 IPC import hardening (NVIDIA#2219, NVIDIA#2223,
NVIDIA#2224), the ManagedBuffer.accessed_by torn-state fix (NVIDIA#2222), and graph node
attachment lifetimes (NVIDIA#2280).
Highlights (per review): the .pyi type-stub support and the new
cuda.core.texture module; NVLink enumeration is covered in New features /
Bug fixes rather than as a highlight. Also adds a New features entry for the
cuda.core.texture module (NVIDIA#467, NVIDIA#2095, NVIDIA#2307).
Andy-Jost added a commit that referenced this pull request Jul 8, 2026
* docs(core): finalize 1.1.0 release notes
Add a Highlights section, backfill PR/issue links on New features entries,
and add Bug fixes entries for the v1.1.0 IPC import hardening (#2219, #2223,
#2224), the ManagedBuffer.accessed_by torn-state fix (#2222), and graph node
attachment lifetimes (#2280).
Highlights (per review): the .pyi type-stub support and the new
cuda.core.texture module; NVLink enumeration is covered in New features /
Bug fixes rather than as a highlight. Also adds a New features entry for the
cuda.core.texture module (#467, #2095, #2307).
* Reorder API refs + ensure each section has currentmodule
the compilation toolchain is one of the unique selling points of cuda.core, but we are burying it deeply
---------
Co-authored-by: Leo Fang <leof@nvidia.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugSomething isn't workingcuda.coreEverything related to the cuda.core moduleP2Low priority - Nice to have

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Andy-Jost@mdboom