-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The commit message names three drainers\n\nCVE-2026-46316 is Hyunwoo Kim's commit `13031fb6b835`, authored 2026-06-01 23:53 KST and merged into `kvm/master` four days later by Marc Zyngier. The commit message opens with the function's behavior and immediately names the contexts the function runs in:\n\n> \"`vgic_its_invalidate_cache()` walks the per-ITS translation cache with `xa_for_each()` and drops the cache's reference on each entry with `vgic_put_irq()`. It puts the iterated pointer, though, rather than the value returned by `xa_erase()`.\n>\n> The function is called from contexts that do not exclude one another: the ITS command handlers hold `its_lock`, the `GITS_CTLR` write path holds `cmd_lock`, and the path that clears `EnableLPIs` in a redistributor's `GICR_CTLR` holds neither. Two or more of them can drain the same cache concurrently, and if each one observes the same entry, erases it and then puts it, the single reference the cache holds on that entry is dropped more than once. The entry can then be freed while an ITE still maps it.\"\n\nThree contexts. Three different locks, where one of those locks is no lock at all. The third caller, `vgic_mmio_write_v3r_ctlr`, is the path the guest reaches through MMIO. A guest writing the redistributor's `GICR_CTLR` register with `EnableLPIs` cleared enters this chain:\n\n```c\nstatic void vgic_mmio_write_v3r_ctlr(struct kvm_vcpu *vcpu,\n\t\t\t\t gpa_t addr, unsigned int len,\n\t\t\t\t unsigned long val)\n{\n\tstruct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;\n\tu32 ctlr;\n\n\tif (!vgic_has_its(vcpu->kvm))\n\t\treturn;\n\n\tif (!(val & GICR_CTLR_ENABLE_LPIS)) {\n\t\tctlr = atomic_cmpxchg_acquire(&vgic_cpu->ctlr,\n\t\t\t\t\t GICR_CTLR_ENABLE_LPIS,\n\t\t\t\t\t GICR_CTLR_RWP);\n\t\tif (ctlr != GICR_CTLR_ENABLE_LPIS)\n\t\t\treturn;\n\n\t\tvgic_flush_pending_lpis(vcpu);\n\t\tvgic_its_invalidate_all_caches(vcpu->kvm);\n\t\tatomic_set_release(&vgic_cpu->ctlr, 0);\n\t}\n```\n\nThe `cmpxchg` is per-vCPU state. A single vCPU enters `vgic_its_invalidate_all_caches` at most once per enable/disable cycle. Two vCPUs entering at the same moment enter twice. `vgic_its_invalidate_all_caches` walks the VM's ITS device list under `rcu_read_lock` and calls `vgic_its_invalidate_cache(its)` on each ITS's xarray. The ITS is VM-global. The xarray is the same xarray. The two vCPUs are now in the same function on the same data structure, holding only the read-side RCU lock that allows them both to walk.\n\nThe commit message states the locking gap as the existence condition of the bug. Naming a gap is acknowledging it.\n\n## The patch is three lines and does not take a lock\n\nThe CVE-2026-46316 diff:\n\n```diff\n@@ -597,8 +597,10 @@ static void vgic_its_invalidate_cache(struct vgic_its *its)\n \tunsigned long idx;\n\n \txa_for_each(&its->translation_cache, idx, irq) {\n-\t\txa_erase(&its->translation_cache, idx);\n-\t\tvgic_put_irq(kvm, irq);\n+\t\t/* Only the context that erases the entry drops its cache ref. */\n+\t\tirq = xa_erase(&its->translation_cache, idx);\n+\t\tif (irq)\n+\t\t\tvgic_put_irq(kvm, irq);\n \t}\n }\n```\n\nThe pre-patch loop calls `xa_erase(&its->translation_cache, idx)` for its side effect and then puts `irq`, the iteration variable that `xa_for_each` populated on its last advance. The post-patch loop assigns `xa_erase`'s return value back into `irq` and only puts when that return is non-NULL.\n\n`xa_erase` is atomic. The xarray's internal locking guarantees that for any given `(xa, idx)` pair, exactly one concurrent caller wins, gets the previous entry, and observes the slot empty afterward; every other concurrent caller gets `NULL`. The new line reads the atomic outcome instead of the iteration outcome. If a peer drainer already erased index `idx` between this drainer's `xa_for_each` advance and this drainer's `xa_erase`, the local `xa_erase` returns `NULL`, the `if` skips the put, and the cache reference for that entry is dropped by whichever drainer's `xa_erase` actually emptied the slot.\n\nThe patch closes the double-put. It does not close the unsynchronized drain. The three callers still call `vgic_its_invalidate_cache` from contexts that do not exclude one another. Two of them still enter the function on the same xarray at the same time. The loop still races against itself. What changed is that the race no longer drops the same reference twice; `xa_erase`'s atomicity is the only thing that makes the race idempotent.\n\nThe fix Hyunwoo names as `13031fb6b835` is also the fix Hyunwoo wrote. He reported, he patched, and the maintainers reviewed and merged on his timeline. Oliver Upton reviewed; Marc Zyngier signed off. The commit closing the bug is in the same author field as the exploit demonstrating it.\n\n## The race still races\n\nWalk it forward post-patch. Four vCPUs simultaneously write `GICR_CTLR` with the `EnableLPIs` bit cleared. Each vCPU's per-vCPU `cmpxchg` succeeds, each calls `vgic_its_invalidate_all_caches(vcpu->kvm)`, all four enter the RCU walk of the VM's ITS list, all four reach `vgic_its_invalidate_cache(its)` for the same ITS. Four threads, one xarray, no shared lock.\n\nThe four threads each begin `xa_for_each`. Each thread's iteration sees some subset of the xarray's currently-populated indices. They overlap. Two threads advance to index `idx=N` independently. Both observe the same `vgic_irq *` pointer in `irq`. Both call `xa_erase(&its->translation_cache, N)`. One thread's `xa_erase` returns the pointer; the other thread's `xa_erase` returns `NULL`. Only the first calls `vgic_put_irq`. One put per entry.\n\nThe race exists. The race is observable in the trace. The race produces no UAF, because every entry's cache reference is dropped exactly once by whichever thread the xarray's internal lock chose. Any consequence of two threads draining the same xarray concurrently that does not reduce to \"the cache reference is double-dropped on a `vgic_irq`\" is still in scope. The patch's correctness rests on a counterfactual: that no other shared state inside this function will ever care about which of the four concurrent drainers actually erased an entry. The function's body today is one `xa_erase` plus one `vgic_put_irq` call; the counterfactual holds for that body. The body is one commit away from changing.\n\n## The exploit the patch closes is 1005 lines\n\nHyunwoo's CVE-2026-46316 exploit, [ITScape](https://github.com/V4bel/ITScape), is published at `github.com/V4bel/ITScape` under SPDX `GPL-2.0`. The README calls it \"the first guest-to-host escape exploit research targeting KVM/arm64.\" The exploit body, `poc.c`, is 1005 lines of C built on top of the kernel's `tools/testing/selftests/kvm` framework. The PoC targets Linux v7.1-rc6 (the build immediately before `13031fb6b835`) with hardcoded image offsets and runs under QEMU TCG emulating an arm64 host. The host kernel is what gets escaped.\n\nThe chain has six stages and the PoC labels each one in the source.\n\n**Prime the translation cache.** A populated cache is the precondition the bug requires; an empty xarray has nothing to double-put. The PoC's `test_data` declares `nr_devices=128` and `nr_event_ids=1024`, and the guest issues `MAPD` / `MAPTI` / `INT` commands to install 131,072 translation entries. The same intids are reused across two ITSes (`GITS0_BASE_GPA` and `GITS1_BASE_GPA`), so each `(devid,eventid)` slot in ITS#1's ITE table points at the same `vgic_irq` object as the corresponding ITS#0 slot. The PoC labels this comment `[5]`: \"when ITS#1 uses the same intids as ITS#0, the ITEs of the two ITSes point to the same vgic_irq.\" After the free, both ITSes carry dangling ITEs aimed at the same freed slab object.\n\n**Trigger the double-put.** `guest_barrier()` aligns the four vCPUs. Each vCPU writes its own `GICR_CTLR` with `EnableLPIs=0`. All four enter `vgic_its_invalidate_all_caches` and drain the same VM-global ITS xarray under `rcu_read_lock`. Pre-patch, two drainers iterating to the same index both put the iteration variable, the `vgic_irq`'s refcount drops to zero too early, and `kfree_rcu` schedules the slab object for free.\n\n**Force the slab back into circulation.** This is the novel part. `vgic_irq` is `kzalloc(... GFP_KERNEL_ACCOUNT)`, which lands it in `kmalloc-cg-96`. The PoC creates a `guest_memfd` region with `GUEST_MEMFD_FLAG_MMAP | GUEST_MEMFD_FLAG_INIT_SHARED`, the flag pair that lets non-confidential VMs back guest pages with host pages the guest can directly map. The flag pair was added to give regular VMs a guest_memfd fast path; the flag pair is the cross-cache primitive. The guest faults in 32 MB of the region, the per-CPU SLUB cache for `cgroup`-accounted 96-byte allocations bleeds dry, freed slab pages get reused as guest_memfd backing, and the guest now `mmap`s the same page whose 96-byte slots used to hold `vgic_irq`s. The guest writes every 96-byte slot of every backing page with a hand-authored fake `vgic_irq`, byte for byte.\n\n**Read a kernel pointer with no crash.** With `vcpu=0`, `active=1`, `ops=NULL`, and `intid=8192` planted on every slot, the guest sends `MOVI` to migrate the dangling LPI to collection 0. The kernel updates the affinity by writing `vcpu0`'s actual kernel address into the fake irq's `target_vcpu` field at offset 48. The guest scans `gmem+48` and reads `vcpu0`'s kaddr.\n\n**Read an image pointer using the kernel address.** Hyunwoo's writeup calls this the ISO-LEAK. With `target_vcpu` set to `V + 7328 - 6656` (the offset of `pmu.overflow_work.func` inside the vcpu struct minus the offset of `ap_list_head.prev`), the fake irq travels the native path of `vgic_queue_irq_unlock`. `__list_add` performs `new->prev = head->prev`; that store deposits `*(V + 7328) = kvm_pmu_perf_overflow_notify_vcpu`, an image-anchored function pointer, into the fake irq's `ap_list.prev` field, which is a gmem slot the guest reads back. The very next statement in `__list_add` is `head->prev->next = new`, which writes through the same pointer just read. The pointer points at `.text`. The write faults. vCPU0 dies inside `__list_add` after the leak value has landed in gmem and before the kernel reaches any cross-CPU broadcast logic. The death is isolated to ITS#0's `cmd_lock`, which vCPU0 still holds at exit. A surviving vCPU reads `gmem+32`, scans for a value whose top bits match the kernel image's upper half, and computes `kimage_voffset = leaked - linked_addr(kvm_pmu_perf_overflow_notify_vcpu)`.\n\n**Plant the writes through the gadget.** With the slide known, the fake irq's `ops` is no longer NULL. The PoC sets it to a controlled gmem address whose offset 16 holds the runtime address of a four-instruction store sequence at `ed_deschedule+0xd4`. The sequence writes the irq pointer's `+0x28` field to the address at `+0x20`. The guest plants four sweeps: three writes overwriting `poweroff_cmd` (`/sbin/poweroff` by default, in `.data`) with `/bin/touch /ITScape`, and one write replacing `arp_tbl.gc_work.work.func` (`neigh_periodic_work` by default) with `orderly_poweroff`. ITS#1's command queue fires the `INT` that resolves the dangling ITE, the kernel calls `irq->ops->queue_irq_unlock(kvm, irq, flags)`, and the gadget writes. ITS#0's `cmd_lock` is still held by the dead vCPU0; the second ITS is the surviving issue path.\n\n**Wait fifteen seconds.** The gadget runs inside `vgic_queue_irq_unlock` without releasing the lock the entry path acquired, so the executing vCPU leaks a `preempt_count`. Calling `call_usermodehelper` while a preempt leak is outstanding deadlocks the host RCU. The PoC's vCPU1, the one that fired the gadget, exits via `GUEST_DONE` (`do_exit`), which heals the preempt leak. vCPU2 and vCPU3 spin to keep the VM from tearing down on the corrupted vGIC. Within about fifteen seconds the host's neighbor garbage collector wakes up, schedules `arp_tbl.gc_work`, and the workqueue dispatcher calls the function pointer the guest overwrote: `orderly_poweroff` runs, schedules `poweroff_work`, and `__orderly_poweroff` invokes `run_cmd(poweroff_cmd)` via `call_usermodehelper(... UMH_WAIT_EXEC)`. The host kernel forks `/bin/touch /ITScape` as root.\n\n```\n[overwritten] orderly_poweroff(&arp_tbl.gc_work.work)\n schedule_work(&poweroff_work)\n poweroff_work_func(work)\n __orderly_poweroff(poweroff_force=false)\n run_cmd(poweroff_cmd = \"/bin/touch /ITScape\")\n call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC) /* runs as root */\n```\n\nThe PoC's parent process polls for `/ITScape` to appear on the host filesystem. When it does, the escape has succeeded. The PoC's demo screencast shows it.\n\n## The 96-byte UAF is the bug. The escape is the composition.\n\nThe CVE the patch closes is the double-put. The capability the exploit demonstrates is a `kmalloc-cg-96` slab UAF where the guest authors all 96 bytes. Those are not the same thing, and the second does not exist without four design decisions outside `arch/arm64/kvm/vgic/vgic-its.c` that the patch does not touch.\n\nThe first decision is `guest_memfd`'s `MMAP | INIT_SHARED` mode. `guest_memfd` was introduced to back confidential VMs (TDX, SEV-SNP, pKVM) with pages neither the host userspace nor a peer guest can read. The MMAP-and-init-shared flag pair was added to let non-confidential VMs use the same FD type without paying the confidential-VM cost, on the reasoning that a non-confidential VM's memory is already host-readable. The shared mode lets the host VMM `mmap` the FD into its own address space, and the guest itself maps the page on the guest side. Two address spaces, one host page. When the host slab allocator hands out a `kmalloc-cg-96` page and the guest_memfd allocator hands out the same page later, the guest's `mmap` of that page is a direct window onto whatever slab objects last sat there. The flag pair is correct in isolation. Its composition with cgroup-accounted slab merging is the cross-cache primitive.\n\nThe second decision is the `vgic_irq` field layout. A 96-byte object whose fields include a `raw_spinlock_t` at offset 0 (the guest writes zero, the kernel treats it as unlocked), a `target_vcpu` pointer at offset 48 (the guest writes a forged value, the kernel reads it as authoritative routing), a refcount at offset 60 (the guest writes anything `> 0` and the kernel honors it), and an `irq_ops *` at offset 80 (the guest writes a gmem address, the kernel makes an indirect call to `*(ops+16)`). Every field the kernel reads has a permissive interpretation. Replacing any one of those fields with an opaque handle or an enum tag would have closed the entire fake-object construction. None of them are.\n\nThe third decision is `orderly_poweroff`'s indirection through a workqueue. The function exists because the kernel needs to invoke a userspace helper from contexts that cannot themselves call `call_usermodehelper`; the indirection is the contract. The contract lets the exploit fire the gadget in a context that holds an irrelevant lock, exit that context cleanly, and have the workqueue dispatch the userspace command later. Without the indirection the gadget would deadlock; with the indirection the deadlock is decoupled.\n\nThe fourth decision is `arp_tbl.gc_work` running every fifteen seconds regardless of network state. The workqueue's `func` field is a writable kernel symbol whose call site activates on a kernel timer, not on attacker input. The exploit overwrites the symbol and waits. The attacker does not need to fire anything; the host does. The PoC's last log line is `WWW done (poweroff_cmd + orderly_poweroff planted); waiting for neigh-gc UMH`.\n\nHyunwoo borrowed the workqueue trick from Project Zero's [An EPYC Escape](https://googleprojectzero.blogspot.com/2021/06/an-epyc-escape-case-study-of-kvm.html). The 2021 EPYC writeup used the same pattern on x86. The kernel-side decisions the pattern depends on, `orderly_poweroff` exists, `arp_tbl.gc_work` re-arms, `call_usermodehelper` runs in kernel context as root, are architecture-independent. The arm64-specific piece of CVE-2026-46316 is the cross-cache via `guest_memfd MMAP|INIT_SHARED`. The cross-cache is what made the pattern reachable from a vGIC-ITS bug, the way an x86 SEV reflection made it reachable from the EPYC bug.\n\nThis is [Emergent Primitive](/patterns/emergent-primitive). The double-put in `vgic_its_invalidate_cache` is owned by `arch/arm64/kvm/vgic/`. `guest_memfd MMAP|INIT_SHARED` is owned by `virt/kvm/guest_memfd.c`. The `kmalloc-cg-96` slab merging is owned by `mm/slub.c`. The `arp_tbl.gc_work.func` indirection is owned by `net/core/neighbour.c`. The `orderly_poweroff` workqueue dispatch is owned by `kernel/reboot.c`. The escape primitive lives at the intersection. The patch lives in one of the five files.\n\n## What's actually patched, and what isn't\n\nThe patch on `vgic_its_invalidate_cache` closes the specific double-put. Backporting it to `stable@vger.kernel.org`, which `Cc:` makes explicit, will close it on every supported branch. KASAN traces of guest workloads triggering the path will go quiet. CVE-2026-46316's affected-versions field, which the kernel CNA will likely fill with the range from `8201d1028caa` (2024-04-25, the commit that introduced the translation cache) to the patched build, will be accurate at the level of \"no longer triggers the documented chain.\"\n\nThe unsynchronized drain is still there. Three callers still enter `vgic_its_invalidate_cache` from contexts that do not exclude one another. The `GICR_CTLR.EnableLPIs` write path still calls `vgic_its_invalidate_all_caches(kvm)` under `rcu_read_lock` only. A future modification to the loop body, an audit-counter increment, a tracepoint with a side effect, a kfree call somewhere, will sit on top of the same race. The next bug in this drain will not be a refcount.\n\nThe cross-cache via `guest_memfd MMAP|INIT_SHARED` is still there. Any future `kmalloc-cg-*` UAF in code reachable from a guest VM, on any host that has shared-mode `guest_memfd` enabled, has a guest-side cross-cache available. ITScape is the first exploit to use this primitive. The README says \"more variants and follow-up vulnerabilities are expected.\" The 96-byte size is a coincidence of `vgic_irq`'s layout; a different victim object lands the guest in a different `kmalloc-cg-N` slab, and `guest_memfd`'s backing allocator does not care which.\n\nThe KASLR leak via `__list_add` storing `head->prev` into the fake irq's `ap_list.prev` is still there. The `list_add_tail(&irq->ap_list, &vcpu->arch.vgic_cpu.ap_list_head)` call in `vgic_queue_irq_unlock` is the operational path; replacing the list primitive would change the function's semantics. The death-in-the-same-`list_add` mechanic that decouples the leak from any crash logging is independent of the patch.\n\nThe `arp_tbl.gc_work.func` overwrite primitive is still there. Every `struct work_struct` whose `func` field sits at a writable symbol the attacker can locate is a write-what-where target. Hardening would mean some form of CFI on workqueue dispatch; the PoC's \"forward-edge CFI is not applied\" assumption holds for the v7.1-rc6 arm64 build and for production cloud kernels currently in use.\n\n## CVSS PR:N means no privileges on the host\n\nCVE-2026-46316's vector reads `AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H`, score 9.3. PR:N is \"no privileges required.\" The PoC's FAQ section says, in full: \"Do I need root inside the guest VM? Yes. Driving GIC/ITS MMIO requires guest kernel (EL1) privilege. When you are allocated an instance on a public cloud you usually have root on your own VM, so this is satisfied. In a scenario without guest root, it must be chained with an LPE such as [Dirty Frag](https://github.com/V4bel/dirtyfrag).\"\n\nBoth statements describe the same exploit. CVSS's \"privileges\" field models the host's view: an attacker who controls a guest VM has zero privileges on the host. The guest-side prerequisite that the attacker is `uid=0` inside t -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCauOONQAKCRDeZjl4jgkQ JqCMAP9E8wm9BLJxWTT9okT5ZequUwBF7V+cB4gtNTW4GzzP/AEAiIqnvhOeGh35 gSMH70GYhoneaGSoaGOH5hSgXYxtcAU= =jvIr -----END PGP SIGNATURE-----