CVE-2026–53365 Explained: The Kernel Zerocopy Bug That Only Tracked the Last Fragment
The virtio-vsock send loop attached a zerocopy completion structure only to the last skb of a multi-fragment message, so earlier fragments pinned userspace pages without matching completion tracking. Repeated sends could drive the page pin count to zero while userspace still held a writable alias, creating a use-after-free that could lead to local privilege escalation.
Published on medium.com
Cybersecurity
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This CVE is not a web-application flaw. The attack surface is kernel socket buffer (skb) reference counting, and the victim is the kernel of the machine itself. AF_VSOCK is a socket family that lets a VM and its host, or processes on the same machine, communicate without going through the TCP/IP stack. MSG_ZEROCOPY speeds that communication up by pinning userspace pages directly instead of copying data into kernel buffers.
Pinning a page is a guarantee: that page will not be reused for anything else until the transfer finishes. Break that guarantee and you have the setup for a Use-After-Free-class memory corruption: userspace still believes it can write to the page, while the kernel has already handed the same physical page off for something else. This CVE starts with the fact that, when a large message gets split into multiple skbs, pin-release tracking worked correctly for only one of them.

Setup
The flaw lives in virtio-vsock's virtio_transport_send_pkt_info(). That function fills outgoing skbs sized to fit the virtqueue, one at a time, as it works through the message being sent. For a MSG_ZEROCOPY transfer, each skb that pins a userspace page needs a ubuf_info structure (commonly shortened to uarg) attached to it. The uarg carries the completion notification telling userspace that this skb has been transmitted, so the page it pinned can be reused.
The affected code path is only reachable in environments that actually use MSG_ZEROCOPY over virtio-vsock (or vhost-vsock). Systems that do not use AF_VSOCK at all are not affected.
Finding it
The basic contract of MSG_ZEROCOPY is simple: pin a page to send it, and the skb carrying that page must fire its completion callback exactly once, either when it is actually transmitted or when it is discarded, and the pin gets released inside that callback. Existing transports such as TCP honour this contract by attaching a uarg to every single skb, no exceptions.
In virtio-vsock's send loop, the pre-fix code only created and attached a uarg under one specific condition. The report reconstructs it from the diff published in the official kernel patch email:
while (total_len > 0) { skb = virtio_transport_alloc_skb(...); ... if (info->msg && info->msg->msg_flags & MSG_ZEROCOPY && skb_len == rest_len && info->op == VIRTIO_VSOCK_OP_RW) { if (virtio_transport_init_zcopy_skb(vsk, skb, info->msg, pkt_len, can_zcopy)) { kfree_skb(skb); ret = -ENOMEM; break; } } virtio_transport_inc_tx_pkt(vvs, skb); ...}
Inside virtio_transport_init_zcopy_skb(), a uarg gets allocated via msg_zerocopy_realloc() and attached with skb_zcopy_init(skb, uarg). That entire call only happens when skb_len == rest_len, meaning that filling this skb brings the remaining length to zero, so this is the true last fragment of the message. Whenever a message does not fit in a single skb and gets split into several, every skb except the last one skips this block entirely. Those skbs still pin userspace pages exactly the same way and get queued for transmission, but nothing tracks the completion that pin is supposed to be paired with.

Exploitation
Step 1: the correct design
Pinning and completion notification must be paired 1:1. The skb carrying a pinned page fires its completion callback exactly once, and the pin is released inside that callback. TCP honours this by attaching a uarg to every skb.
Step 2: the flaw
The uarg is attached only to the last skb, as shown in the loop above. Every mid-sequence skb pins pages without any tracking structure.
Step 3: the root cause
The problem is not just that mid-sequence skbs have no uarg, it is what happens when those skbs get freed normally. Even without a uarg, once transmission finishes the kernel frees the skb the ordinary way, and as part of that it calls put_page() on the page it was holding. On the correct path (TCP, for example), the reference bumped at pin time is matched exactly once by the completion callback decrementing it back. On this flawed path, the completion callback that is supposed to be the matching half simply does not exist, and put_page() fires on its own.
Correct path (has a uarg): pin(+1) → skb transmitted → zerocopy completion fires(-1) → ref hits 0, safely releasedFlawed path (no uarg): pin(+1) → skb just gets freed → only put_page() fires → extra, unpaired decrement
Every repeated MSG_ZEROCOPY transfer adds one more decrement that was never in the original accounting, for each mid-sequence skb. Repeat enough multi-skb sends against the same userspace buffer, and the kernel's pin count (bias) for that page reaches zero faster than userspace could ever expect.
Step 4: the page looks free
Once the pin count reaches zero, the kernel assumes nobody is using the page anymore and can route it back through its normal page-reclaim paths, the per-CPU free list for instance. In reality, userspace, the attacker, still holds an alias to that page and can still write to it. This is the boundary where things become a textbook Use-After-Free problem: the same physical page is simultaneously a buffer the attacker can write to and a resource the kernel believes is entirely free and has reallocated.
A published PoC is reported to have carried this race condition all the way to local privilege escalation, and Red Hat's advisory itself states that this issue "could lead to local privilege escalation". The specific technique for steering the reallocated page toward a chosen target, such as the cached contents of another file, and winning the necessary timing, is memory-grooming and race-condition territory and is not covered in the report. The goal there is understanding the root cause: missing completion tracking.

Root cause
The send loop treated the uarg as something needed once, at the last fragment, rather than as a per-skb lifetime object. Because the pin is taken for every skb but the matching completion only exists for the last one, each mid-sequence skb contributes an unpaired decrement when it is freed. The kernel's accounting for the page therefore drifts downward with every multi-skb MSG_ZEROCOPY send, and the page is released back to the allocator while userspace still maps it.
Impact
The flaw lets the pin count of a userspace page drift to zero while userspace still holds an alias to it, so the page can be reclaimed while still writable. Red Hat's advisory states the issue "could lead to local privilege escalation", and a published PoC is reported to have reached local privilege escalation. The report does not detail the grooming or timing technique. Systems that do not use AF_VSOCK are not affected.
Fix
The kernel patch restructures virtio_transport_send_pkt_info() itself. Instead of allocating the uarg when filling the last skb, it is now allocated once, before entering the send loop, and inside the loop every skb calls skb_zcopy_set(skb, uarg, NULL) to add one more reference.
uarg = msg_zerocopy_realloc(sk_vsock(vsk), total_len, NULL, false);...while (total_len > 0) { skb = virtio_transport_alloc_skb(...); ... skb_zcopy_set(skb, uarg, NULL); virtio_transport_inc_tx_pkt(vvs, skb); ...}
With this change, each skb's completion decrements the uarg's reference count by exactly one, and userspace only receives the completion notification once the total reference count hits zero, which now happens precisely when every skb has actually finished transmitting. If the loop exits early without sending any data, the allocated uarg is cleanly torn down via net_zcopy_put_abort(), so no reference is left dangling.
The principle: when code can split one logical transfer into several sub-units (skbs here), resource lifetime management, pin release in this instance, has to be designed around the entire logical transfer, not any single piece of it. The assumption that we only need to handle this once, at the last fragment, easily overlooks the fact that every other fragment is holding the exact same resource in the meantime.
Remediation steps from the report:
- Update the kernel to 7.0.11, 6.12.97, or whichever backported version your distribution has released for this CVE.
- Remember that the affected code path is only reachable in environments that actually use
MSG_ZEROCOPYover virtio-vsock (or vhost-vsock); systems that do not useAF_VSOCKat all are not affected. - On a multi-user system where an immediate update is not feasible, restricting
/dev/vsockaccess to the users or groups that actually need it can serve as a temporary mitigation. Quite a few distributions ship it at mode0666by default. - If you expose
io_uringto unprivileged user namespaces inside containers or VMs, keep in mind that doing so widens the attack surface for this entire class of local privilege-escalation bug.
What happened, in plain words
Most of the security stories on this blog are about websites: someone sends a clever request to a web server and gets something they should not have. This one is different. The thing that was broken is not a website but the kernel, the core program of an operating system that sits between your applications and the hardware. The victim is not a server on the internet; it is the machine itself.
To understand the bug you need three ideas: a socket, a page, and a reference count. A socket is a channel two programs use to talk to each other. A page is the smallest block of memory the kernel hands out, usually a few kilobytes. A reference count is a tally the kernel keeps of how many things are currently using a page; when the tally reaches zero, the kernel assumes nobody needs the page any more and gives it to someone else.
The bug is in a feature called MSG_ZEROCOPY, which is a way of sending data quickly by letting the kernel use the sender's memory directly instead of making a copy. To do that safely, the kernel "pins" the memory: it promises not to reuse that page until the transfer is finished. When a large message is split into several pieces, the code that keeps track of those promises only worked for the last piece. The other pieces still used the memory, but nothing kept the promise bookkeeping straight, so the kernel's tally for the page drifted downwards. Once the tally hit zero, the kernel handed the page to someone else while the original program could still write into it. That is a Use-After-Free: using memory after the system has decided it is free. It is the kind of flaw that can lead to local privilege escalation.

Overview

This CVE is a different kind of CVE than the web-application flaws covered so far on this blog. A CVE is a public identifier given to a known security flaw, so that everyone can refer to the same bug by the same name. The attack surface here is not an HTTP request, it is kernel socket buffer (skb) reference counting, and the victim is not a server, it is the kernel of the machine itself.
Let us unpack those terms slowly.
- Kernel: the central part of an operating system. It manages memory, decides which program runs when, and talks to hardware. If the kernel is compromised, everything on the machine is compromised, because every program depends on it.
- Socket: a two-way channel for sending data between programs. When your browser talks to a website, it uses a socket. Sockets also let programs on the same machine talk to each other.
AF_VSOCK: a particular family of socket that lets a virtual machine and its host, or processes on the same machine, communicate without going through the normal networking stack (the TCP/IP machinery used for internet traffic). Think of it as a private corridor between rooms in the same building, rather than sending a letter through the post.MSG_ZEROCOPY: a speed feature. Normally, when a program sends data, the kernel copies the data from the program's memory into its own buffer. Copying is safe but slow.MSG_ZEROCOPYskips the copy and lets the kernel use the program's memory directly, which is faster but requires careful bookkeeping.- skb (socket buffer): the kernel's container for a chunk of data being sent or received. A large message is broken into several skbs, like a long letter split across several envelopes.
- Reference counting: a tally of how many users a resource currently has. When the tally reaches zero, the resource can be freed. If the tally is wrong, the resource can be freed too early, or never.
Pinning a page is a guarantee: that page will not be reused for anything else until the transfer finishes. Break that guarantee and you have exactly the setup for a classic Use-After-Free-class memory corruption: userspace (the ordinary programs you run) still believes it can write to the page, while the kernel has already handed the same physical page off for something else. This CVE starts with the fact that, when a large message gets split into multiple skbs, pin-release tracking worked correctly for only one of them.
Where the flaw lives: the send loop that splits a large message into skbs
The flaw lives in virtio-vsock's virtio_transport_send_pkt_info(). That function fills outgoing skbs sized to fit the virtqueue, one at a time, as it works through the message being sent. For a MSG_ZEROCOPY transfer, each skb that pins a userspace page needs a ubuf_info structure (commonly shortened to uarg) attached to it. The uarg carries the completion notification telling userspace that this skb has been transmitted, so the page it pinned can be reused.
A few more terms before we go on:
- virtio-vsock: the driver that implements
AF_VSOCKfor virtual machines. It is the piece of code that actually moves the data. - virtqueue: a queue of buffers shared between a virtual machine and its host. The driver fills it with data to be sent. Each skb has to fit in one slot of this queue, which is why large messages get split.
ubuf_info/uarg: a small bookkeeping record attached to an skb. It is the receipt that says "when this skb is done, tell the sender so the memory can be released". Without it, the kernel has no way to send that notification.- Completion notification: the message back to the sending program saying "your data has gone out, you can reuse that memory now".
The affected code path is only reachable in environments that actually use MSG_ZEROCOPY over virtio-vsock (or vhost-vsock). Systems that do not use AF_VSOCK at all are not affected. In plain terms: if your machine never uses this private corridor between a VM and its host, this bug cannot be triggered on it.
Finding it
The basic contract of MSG_ZEROCOPY is simple: pin a page to send it, and the skb carrying that page must fire its completion callback exactly once, either when it is actually transmitted or when it is discarded, and the pin gets released inside that callback. Existing transports such as TCP honour this contract by attaching a uarg to every single skb, no exceptions.
Think of it like a library. Every time you borrow a book, the librarian writes a slip. When you return the book, the slip is matched and thrown away. If a book leaves the library without a slip, the librarian's count of books on loan is wrong, and eventually the library believes a book is back on the shelf while you still have it at home.
In virtio-vsock's send loop, the pre-fix code only created and attached a uarg under one specific condition. The report reconstructs it from the diff published in the official kernel patch email:
while (total_len > 0) { skb = virtio_transport_alloc_skb(...); ... if (info->msg && info->msg->msg_flags & MSG_ZEROCOPY && skb_len == rest_len && info->op == VIRTIO_VSOCK_OP_RW) { if (virtio_transport_init_zcopy_skb(vsk, skb, info->msg, pkt_len, can_zcopy)) { kfree_skb(skb); ret = -ENOMEM; break; } } virtio_transport_inc_tx_pkt(vvs, skb); ...}
Line by line, in plain words:
while (total_len > 0) {starts a loop that keeps going while there is still data left to send. Each pass through the loop handles one piece of the message.skb = virtio_transport_alloc_skb(...);creates a new empty skb (an envelope) to hold the next piece.if (info->msg && info->msg->msg_flags & MSG_ZEROCOPY && skb_len == rest_len && info->op == VIRTIO_VSOCK_OP_RW) {is the condition that decides whether to attach the bookkeeping record. It checks four things: that there is a message, that the message asked for the fast zero-copy path, that this skb is the last one (skb_len == rest_lenmeans filling this skb brings the remaining length to zero), and that the operation is a normal read/write data operation.if (virtio_transport_init_zcopy_skb(vsk, skb, info->msg, pkt_len, can_zcopy)) {calls the function that actually allocates and attaches theuarg. If it fails, the next lines run.kfree_skb(skb);frees the skb that could not be set up.ret = -ENOMEM;records an out-of-memory error.break;leaves the loop.virtio_transport_inc_tx_pkt(vvs, skb);increments the transmit packet count for the skb.
The key line is the condition. Inside virtio_transport_init_zcopy_skb(), a uarg gets allocated via msg_zerocopy_realloc() and attached with skb_zcopy_init(skb, uarg). That entire call only happens when skb_len == rest_len, meaning that filling this skb brings the remaining length to zero, so this is the true last fragment of the message. Whenever a message does not fit in a single skb and gets split into several, every skb except the last one skips this block entirely. Those skbs still pin userspace pages exactly the same way and get queued for transmission, but nothing tracks the completion that pin is supposed to be paired with.

Exploitation
Step 1: the correct design
Pinning and completion notification must be paired 1:1. The skb carrying a pinned page fires its completion callback exactly once, and the pin is released inside that callback. TCP honours this by attaching a uarg to every skb.
Why does this matter? Because the kernel's tally for a page is only correct if every increase is matched by exactly one decrease. Pin the page, that is +1. Finish the transfer, that is -1. If you pin five times and only decrement four times, the tally is wrong by one, and the page is treated as still in use when it is not, or the other way round. The pairing is the whole safety property.
Step 2: the flaw
The uarg is attached only to the last skb, as shown in the loop above. Every mid-sequence skb pins pages without any tracking structure. In library terms, the librarian writes a slip only for the last book in a stack, and lets the others walk out the door with no record at all.
Step 3: the root cause
The problem is not just that mid-sequence skbs have no uarg, it is what happens when those skbs get freed normally. Even without a uarg, once transmission finishes the kernel frees the skb the ordinary way, and as part of that it calls put_page() on the page it was holding. On the correct path (TCP, for example), the reference bumped at pin time is matched exactly once by the completion callback decrementing it back. On this flawed path, the completion callback that is supposed to be the matching half simply does not exist, and put_page() fires on its own.
Correct path (has a uarg): pin(+1) → skb transmitted → zerocopy completion fires(-1) → ref hits 0, safely releasedFlawed path (no uarg): pin(+1) → skb just gets freed → only put_page() fires → extra, unpaired decrement
Reading that diagram in plain words:
- On the correct path, the page is pinned (tally goes up by one), the skb is transmitted, the completion callback fires (tally goes down by one), and the tally reaches zero at the right moment, so the page is safely released.
- On the flawed path, the page is pinned (tally goes up by one), the skb is simply freed, and only
put_page()fires. That is a decrement with no matching increment in the bookkeeping, so the tally drops by one more than it should.
Every repeated MSG_ZEROCOPY transfer adds one more decrement that was never in the original accounting, for each mid-sequence skb. Repeat enough multi-skb sends against the same userspace buffer, and the kernel's pin count (bias) for that page reaches zero faster than userspace could ever expect. The word bias here just means the kernel's internal tally for that page.
Step 4: the page looks free
Once the pin count reaches zero, the kernel assumes nobody is using the page anymore and can route it back through its normal page-reclaim paths, the per-CPU free list for instance. In reality, userspace, the attacker, still holds an alias to that page and can still write to it. This is the boundary where things become a textbook Use-After-Free problem: the same physical page is simultaneously a buffer the attacker can write to and a resource the kernel believes is entirely free and has reallocated.
A per-CPU free list is a small pool of free pages that each processor core keeps to itself, so it can hand out memory quickly without asking the rest of the kernel. If a page ends up on that list, the kernel is effectively saying "this memory is available for anyone".
A published PoC is reported to have carried this race condition all the way to local privilege escalation, and Red Hat's advisory itself states that this issue "could lead to local privilege escalation". A PoC (proof of concept) is a small program that demonstrates a bug is real. Local privilege escalation means an ordinary user on the machine can become an administrator, which is the difference between a nuisance and a full compromise. The specific technique for steering the reallocated page toward a chosen target, such as the cached contents of another file, and winning the necessary timing, is memory-grooming and race-condition territory and is not covered in the report. The goal there is understanding the root cause: missing completion tracking.

Root cause
The send loop treated the uarg as something needed once, at the last fragment, rather than as a per-skb lifetime object. Because the pin is taken for every skb but the matching completion only exists for the last one, each mid-sequence skb contributes an unpaired decrement when it is freed. The kernel's accounting for the page therefore drifts downward with every multi-skb MSG_ZEROCOPY send, and the page is released back to the allocator while userspace still maps it.
Impact
The flaw lets the pin count of a userspace page drift to zero while userspace still holds an alias to it, so the page can be reclaimed while still writable. Red Hat's advisory states the issue "could lead to local privilege escalation", and a published PoC is reported to have reached local privilege escalation. The report does not detail the grooming or timing technique. Systems that do not use AF_VSOCK are not affected.
The patch: adopt what TCP already does
The kernel patch restructures virtio_transport_send_pkt_info() itself. Instead of allocating the uarg when filling the last skb, it is now allocated once, before entering the send loop, and inside the loop every skb calls skb_zcopy_set(skb, uarg, NULL) to add one more reference.
uarg = msg_zerocopy_realloc(sk_vsock(vsk), total_len, NULL, false);...while (total_len > 0) { skb = virtio_transport_alloc_skb(...); ... skb_zcopy_set(skb, uarg, NULL); virtio_transport_inc_tx_pkt(vvs, skb); ...}
Line by line:
uarg = msg_zerocopy_realloc(sk_vsock(vsk), total_len, NULL, false);allocates the bookkeeping record once, before the loop starts, for the whole message (total_len).while (total_len > 0) {starts the same loop as before, one pass per piece of the message.skb = virtio_transport_alloc_skb(...);creates the next skb.skb_zcopy_set(skb, uarg, NULL);attaches the shared record to this skb and adds one more reference to it. Every skb now has a receipt.
With this change, each skb's completion decrements the uarg's reference count by exactly one, and userspace only receives the completion notification once the total reference count hits zero, which now happens precisely when every skb has actually finished transmitting. If the loop exits early without sending any data, the allocated uarg is cleanly torn down via net_zcopy_put_abort(), so no reference is ever left dangling.
The principle: when code can split one logical transfer into several sub-units (skbs here), resource lifetime management, pin release in this instance, has to be designed around the entire logical transfer, not any single piece of it. The assumption that we only need to handle this once, at the last fragment, easily overlooks the fact that every other fragment is holding the exact same resource in the meantime.
Remediation
- Update the kernel to 7.0.11, 6.12.97, or whichever backported version your distribution has released for this CVE. A backport is a fix taken from a newer kernel and applied to an older one that many people still run.
- Remember that the affected code path is only reachable in environments that actually use
MSG_ZEROCOPYover virtio-vsock (or vhost-vsock); systems that do not useAF_VSOCKat all are not affected. - On a multi-user system where an immediate update is not feasible, restricting
/dev/vsockaccess to the users or groups that actually need it can serve as a temporary mitigation./dev/vsockis a special file that programs open to use the vsock feature; if only trusted users can open it, ordinary users cannot reach the buggy code. Quite a few distributions ship it at mode0666by default, which means every user on the machine can open it. - If you expose
io_uringto unprivileged user namespaces inside containers or VMs, keep in mind that doing so widens the attack surface for this entire class of local privilege-escalation bug.io_uringis a newer Linux interface for doing many input/output operations efficiently; a user namespace is a way of giving a process its own isolated view of users and permissions, often used inside containers.
Glossary
- AF_VSOCK: a socket family that lets a virtual machine and its host, or processes on the same machine, communicate without going through the TCP/IP stack.
- Backport: a fix taken from a newer version of software and applied to an older version that many people still use.
- Bias: in this context, the kernel's internal tally of how many references a page currently has.
- Completion callback: the function that runs when a transfer finishes, releasing the memory that was pinned for it.
- Completion notification: the message sent back to a program saying its data has been transmitted and its memory can be reused.
- CVE: a public identifier given to a known security vulnerability so everyone can refer to the same bug by the same name.
- io_uring: a Linux interface for performing many input/output operations efficiently.
- Kernel: the core part of an operating system that manages memory, processes and hardware.
- Local privilege escalation: turning an ordinary user account into an administrator account on the same machine.
- MSG_ZEROCOPY: a feature that speeds up sending by letting the kernel use a program's memory directly instead of copying it.
- Page: the smallest block of memory the kernel hands out, usually a few kilobytes.
- Per-CPU free list: a small pool of free pages kept by each processor core for fast allocation.
- Pin (a page): to promise the kernel will not reuse a page until a transfer finishes.
- PoC (proof of concept): a small program that demonstrates a bug is real.
- put_page(): the kernel function that decrements a page's reference count when a holder is done with it.
- Reference counting: a tally of how many users a resource has; when it reaches zero, the resource can be freed.
- uarg / ubuf_info: a small bookkeeping record attached to an skb that carries the completion notification for a pinned page.
- Use-After-Free: a memory corruption flaw where a program keeps using memory after the system has decided it is free and handed it to someone else.
- User namespace: a way of giving a process its own isolated view of users and permissions, often used inside containers.
- virtqueue: a queue of buffers shared between a virtual machine and its host, used to move data.
- vhost-vsock: the host-side counterpart of virtio-vsock.