TL;DR
gVisor's MemoryManager.Pin() is documented to return pinned pages and an error when a range is only partly mapped. Three of the four device proxies that call it set up the unpin before checking the error. rdmaproxy checked the error first, so a workload inside the sandbox could make memory stay allocated after freeing it, for as long as the sandbox ran. The fix moved two lines, and Google merged the exact patch I proposed.
Summary
rdmaproxy is gVisor’s experimental RDMA device proxy. Before it hands an application’s buffer to the host’s RDMA driver, its MirrorAppPages() function pins the buffer’s pages through the Sentry’s memory manager. If the buffer was only partly mapped, Pin() pinned the mapped part and returned an error, and MirrorAppPages() returned that error without releasing what had been pinned. Each failed registration left its pages permanently referenced, so they could no longer be freed by the application or by its exit, only by shutting down the sandbox.
| Component | pkg/sentry/devices/rdmaproxy, MirrorAppPages() |
|---|---|
| Class | Missing release of a resource after use (CWE-401) |
| Affected | gVisor with --rdmaproxy (experimental, off by default), from the proxy's first commit 54b1c837e3 (July 2026) |
| Fix | fa71dc1ed5, merged 24 November 2026 |
| CVE | None: the gVisor team doesn't assign CVEs for experimental features |
Background: gVisor and Device Proxies
gVisor runs containers on top of the Sentry, an application kernel written in Go that runs in user space and implements Linux system calls itself. The containerized application never talks to the host kernel directly; the Sentry does that on its behalf, through a narrow set of host system calls.
Accelerators break that model, because their drivers can’t be emulated in software. For them, gVisor has device proxies: nvproxy for NVIDIA GPUs, tpuproxy for TPUs and rdmaproxy for RDMA network adapters. A proxy checks and translates the application’s ioctl calls, then forwards them to the real host driver.
RDMA and GPU hardware read and write application buffers directly through DMA, so those buffers have to stay at fixed physical addresses while the device uses them. Before forwarding a memory registration, rdmaproxy therefore takes a reference on every page of the application’s buffer and maps those pages into the Sentry’s own address space. The host driver then pins the Sentry’s copy of the mapping as usual.
There are two layers of “pinning” here, and the bug lives entirely in the first one. gVisor’s Pin() only takes references inside the Sentry’s page allocator; the host kernel’s own pinning happens later, when the forwarded ioctl reaches the host driver.
How I Found It
I was auditing gVisor’s device proxies, the code that deliberately reaches past the sandbox to host drivers. All of them need the same delicate step, taking references on application pages, so I compared how each one calls Pin(). Four call sites do the same job, and three of them release a partial pin correctly. rdmaproxy, added in 2026 while the other two proxies date from 2023, was the odd one out.
The Pin Contract
MemoryManager.Pin() in pkg/sentry/mm/pma.go documents an unusual behavior:
// Pin returns the memmap.File ranges currently mapped by addresses in ar in
// mm, acquiring a reference on the returned ranges which the caller must
// release by calling Unpin. If not all addresses are mapped, Pin returns a
// non-nil error. Note that Pin may return both a non-empty slice of
// PinnedRanges and a non-nil error.
func (mm *MemoryManager) Pin(ctx context.Context, ar hostarch.AddrRange,
at hostarch.AccessType, ignorePermissions bool) ([]PinnedRange, error)
Most functions that return an error leave nothing behind. Pin() doesn’t work that way: if the range has an unmapped hole, it truncates the range at the hole, takes a reference on every page before it, and returns those pages together with the error. The caller owns those references either way, so it must call mm.Unpin(prs) whether or not err is nil.
rdmaproxy and Its Siblings
Every Pin() caller in gVisor’s device proxies before the fix:
| Call site | When the unpin is set up | Partial pin released? |
|---|---|---|
nvproxy/frontend.go:694 |
cleanup.Make + defer, before the error check |
Yes |
tpuproxy/accel/gasket_ioctl.go:83 |
cu.Add(...) on an existing cleanup, before the error check |
Yes |
tpuproxy/vfio/vfio_fd.go:207 |
cu.Add(...) on an existing cleanup, before the error check |
Yes |
rdmaproxy/ioctl_unsafe.go:140 |
cleanup.Make + defer, after the error check |
No |
The TPU proxy shows the correct pattern:
// tpuproxy/accel/gasket_ioctl.go
prs, err := t.MemoryManager().Pin(ctx, ar, hostarch.ReadWrite, false /* ignorePermissions */)
cu.Add(func() {
mm.Unpin(prs)
})
if err != nil {
return 0, err // the deferred cleanup still unpins any partial result
}
And rdmaproxy before the fix:
// rdmaproxy/ioctl_unsafe.go, MirrorAppPages()
prs, pinErr := t.MemoryManager().Pin(t, appAR, at, false /* ignorePermissions */)
if pinErr != nil {
return nil, 0, pinErr // prs may be non-empty here, and is never unpinned
}
cu := cleanup.Make(func() { mm.Unpin(prs) })
defer cu.Clean()
MirrorAppPages() is reached from three places: memory registration through the ioctl interface (ioctl.go:515), memory registration through the legacy write-command interface (ioctl.go:496), and the mlx5 driver’s queue buffers (cxproxy.go:68,78). The two registration paths are the easy trigger, because the application chooses both the address and the length.
The mirroring also happens before the request is forwarded to the host (ioctl.go:282). The host driver never sees a registration that fails here, so it doesn’t matter whether the hardware would have accepted it.
Impact and Preconditions
An attacker needs:
- a gVisor sandbox started with
--rdmaproxy, which is labelled work-in-progress and off by default; - a host RDMA device (
/dev/infiniband/uverbs*) passed into the container; - the ability to run code inside the sandbox.
The trigger is a memory registration whose range ends in an unmapped page: mmap a buffer, munmap its last page, and register the whole range. Pin() doesn’t even need the pages to have been touched, because it allocates any page that isn’t backed yet. It pins every page up to the hole and returns EFAULT, and those references are never dropped. One registration can cover up to maxMirrorLen, 64 GiB, and the attacker can repeat it.
The leaked pages live in the Sentry’s memory file and stay allocated until the sandbox exits. They survive munmap() and the exit of the process that registered them. What that means in practice depends on how the sandbox is limited:
- With a memory limit, such as a Kubernetes pod limit, the leaked pages count against the sandbox’s own cgroup. The sandbox runs out of memory, and so does any other container sharing it, such as another container in the same pod. The host and other sandboxes are not affected.
- Without a limit, which is the default for a bare
runsc, the leak puts pressure on the whole host. A workload without a limit could already allocate host memory freely, though. What the bug adds is that memory can’t be given back once it’s freed, so nothing short of restarting the sandbox recovers it.
It’s a denial-of-service bug in an experimental feature, with no information disclosure and no escape. Because rdmaproxy is experimental, the gVisor team decided it doesn’t qualify for a CVE.
Verification
I didn’t have RDMA hardware to run an end-to-end exploit, so I verified the bug in two ways: by reading the code paths above, and with two unit tests I sent along with the report.
The first runs against the real memory manager and checks the contract itself: pinning a two-page range where only the first page is mapped returns an error and a non-empty slice.
func TestPinPartialMappingErrorBehavior(t *testing.T) {
ctx := contexttest.Context(t)
mm := testMemoryManager(ctx, t)
defer mm.DecUsers(ctx)
// Map one page, then pin two: the second page is unmapped.
addr, err := mm.MMap(ctx, memmap.MMapOpts{
Length: hostarch.PageSize,
Private: true,
Perms: hostarch.ReadWrite,
MaxPerms: hostarch.AnyAccess,
})
if err != nil {
t.Fatalf("MMap got err %v want nil", err)
}
partialAR := hostarch.AddrRange{Start: addr, End: addr + 2*hostarch.PageSize}
prs, pinErr := mm.Pin(ctx, partialAR, hostarch.ReadWrite, false /* ignorePermissions */)
if pinErr == nil {
t.Fatalf("Pin on partially mapped range unexpectedly succeeded")
}
if len(prs) == 0 {
t.Fatalf("Pin returned empty prs; expected the pinned prefix")
}
Unpin(prs) // the call rdmaproxy skipped
}
The second is a model rather than a test of MirrorAppPages() itself. It runs both orderings, error check first and cleanup first, against a fake memory manager that counts pins and unpins. With the error check first, four pages are pinned and none are unpinned. With the cleanup first, all four are released.
The Fix
The fix moves the cleanup above the error check, so it runs on both paths. The merged commit is the exact diff I proposed in the report:
--- a/pkg/sentry/devices/rdmaproxy/ioctl_unsafe.go
+++ b/pkg/sentry/devices/rdmaproxy/ioctl_unsafe.go
@@ -138,13 +138,12 @@ func MirrorAppPages(t *kernel.Task, addr, length uint64) (*MirroredPages, uintpt
at := hostarch.ReadWrite
prs, pinErr := t.MemoryManager().Pin(t, appAR, at, false /* ignorePermissions */)
+ cu := cleanup.Make(func() { mm.Unpin(prs) })
+ defer cu.Clean()
if pinErr != nil {
return nil, 0, pinErr
}
- cu := cleanup.Make(func() { mm.Unpin(prs) })
- defer cu.Clean()
-
// Prefer a single contiguous internal mapping if the pinned range is one
// physically contiguous run.
var m uintptr
When Pin() fails, the deferred cleanup now releases the partial result on return. When it succeeds, nothing changes: MirrorAppPages() already hands ownership of the pages to the returned mirror by releasing the cleanup on its success path.
Disclosure and Timeline
| 2026 | Event |
|---|---|
| 16 Jul | rdmaproxy added in 54b1c837e3, with the bug present from its first commit |
| 26 Sep | Reported privately to the gVisor security team, with two tests and a patch |
| 7 Oct | Ryan El Kochta of the gVisor team confirmed they would look at a fix and offered credit; as an experimental feature, rdmaproxy doesn’t qualify for a CVE |
| 24 Nov | Fix merged as fa71dc1ed5, with Reported-By credit, about four months after the bug was introduced |
Takeaways
- An error doesn’t always mean nothing happened. Any function that acquires resources step by step can fail halfway. When an API documents that it can return a partial result and an error, set up the cleanup before checking the error, every time.
- Compare a component with its siblings. gVisor already had the correct pattern in three places. The newest copy of an established pattern is a good place to look for a mistake, and putting the call sites side by side is what made this one stand out.