<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wintun/driver, branch master</title>
<subtitle>Layer 3 TUN Driver for Windows</subtitle>
<id>https://git.zx2c4.com/wintun/atom/driver?h=master</id>
<link rel='self' href='https://git.zx2c4.com/wintun/atom/driver?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/'/>
<updated>2026-03-18T17:49:30Z</updated>
<entry>
<title>driver: fix missed-wakeup race in ring buffer Alertable signaling</title>
<updated>2026-03-18T17:49:30Z</updated>
<author>
<name>Simon Rozman</name>
<email>simon.rozman@amebis.si</email>
</author>
<published>2026-02-24T23:47:17Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=ec0a6b98456fe1ba52567bb2add4bbf5f64315a1'/>
<id>urn:sha1:ec0a6b98456fe1ba52567bb2add4bbf5f64315a1</id>
<content type='text'>
Add MemoryBarrier() between store-load pairs in the Dekker-style
synchronization used by the Receive ring's Alertable/Tail protocol.

On x86-64, WriteRelease/ReadAcquire only prevent compiler reordering and
provide acquire/release semantics, but do not emit MFENCE — the only
instruction that prevents store-load reordering across cores. Without a
full barrier, both the userspace producer and the kernel consumer can
simultaneously read stale values:

  Userspace: STORE(Tail)  ...  LOAD(Alertable) -&gt; sees FALSE (stale)
  Driver:    STORE(Alertable=TRUE) ... LOAD(Tail) -&gt; sees old tail

The driver then enters KeWaitForMultipleObjects with no pending
SetEvent, sleeping until a TCP retransmission (typically 4-5s later)
re-triggers the send path and wins the race.

The fix adds MemoryBarrier() (MFENCE on x86) on both sides:
- api/session.c WintunSendPacket: between WriteULongRelease(Tail) and
  ReadAcquire(Alertable)
- driver/twintun.c TunProcessReceiveData: between
  WriteRelease(Alertable, TRUE) and ReadULongAcquire(Tail)

This guarantees that at least one side always observes the other's
store, preventing the missed wakeup while preserving the Alertable
optimization that avoids unnecessary SetEvent syscalls.

Reported-by: Alexey Lapuka &lt;alexey@twingate.com&gt;
Reference: https://lists.zx2c4.com/pipermail/wireguard/2026-February/009523.html
Signed-off-by: Simon Rozman &lt;simon.rozman@amebis.si&gt;
</content>
</entry>
<entry>
<title>driver: fix race condition at Ring-&gt;Head</title>
<updated>2026-02-20T13:30:57Z</updated>
<author>
<name>Simon Rozman</name>
<email>simon.rozman@amebis.si</email>
</author>
<published>2026-02-19T19:32:54Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=dd050927f42081dce7c2ae262be55ffd8210c11a'/>
<id>urn:sha1:dd050927f42081dce7c2ae262be55ffd8210c11a</id>
<content type='text'>
This PR fixes a critical race condition in the Wintun driver that causes
ring buffer overruns when multiple UDP senders operate in parallel. The
issue occurred because multiple threads could read the same Ring-&gt;Head
value without synchronization, leading to concurrent modifications that
corrupted the ring buffer and resulted in ERROR_INVALID_DATA errors.

In order to prevent buffer overrun (which was observed while sending
multiple high throughput UDP streams from different threads) I move the
driver spinlock to protect Ring buffer Head.

I observed that the Ring-&gt;Head was taken and manipulated later on with
just a `ReadULongAcquire` which isn't OK when 2 are trying to manipulate
it later on based on the same received value.

A fix was provided in 4fc590853b8281552631b79dacda484a5782f3bf, but it
didn't solve the issue.

Reported-by: odedkatz &lt;katz.oded@gmail.com&gt;
Reference: https://lists.zx2c4.com/pipermail/wireguard/2026-February/009489.html
Reference: https://lists.zx2c4.com/pipermail/wireguard/2026-February/009510.html
Signed-off-by: Simon Rozman &lt;simon.rozman@amebis.si&gt;
</content>
</entry>
<entry>
<title>driver: explicitly terminate NBL</title>
<updated>2026-02-20T13:10:55Z</updated>
<author>
<name>Simon Rozman</name>
<email>simon.rozman@amebis.si</email>
</author>
<published>2026-02-09T11:13:01Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=4fc590853b8281552631b79dacda484a5782f3bf'/>
<id>urn:sha1:4fc590853b8281552631b79dacda484a5782f3bf</id>
<content type='text'>
The ActiveNbls list uses MINIPORT_RESERVED[1] as the next pointer, but
never NULL-terminates the tail entry. It was never observed the
allocated NBL would contain a non-zero MiniportReserved array, but this
being unspecified in the official documentation, let's stay out of
"unspecified" area.

Reference: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/nbl/ns-nbl-net_buffer_list
Signed-off-by: Simon Rozman &lt;simon.rozman@amebis.si&gt;
</content>
</entry>
<entry>
<title>driver: introduce NET_BUFFER_LIST_OFFSET helper</title>
<updated>2026-02-09T11:41:08Z</updated>
<author>
<name>Simon Rozman</name>
<email>simon.rozman@amebis.si</email>
</author>
<published>2026-02-09T11:39:51Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=d36f37582da4c0cc7b3cd49ccc38fe2fc18f17b3'/>
<id>urn:sha1:d36f37582da4c0cc7b3cd49ccc38fe2fc18f17b3</id>
<content type='text'>
Since NET_BUFFER_LIST_MINIPORT_RESERVED[1] is assigned our next NBL
pointer and we have a macro for it (NET_BUFFER_LIST_NEXT_NBL_EX), let's
have a macro for NET_BUFFER_LIST_MINIPORT_RESERVED[0], we assigned NBL
offset and flags to, too.

Signed-off-by: Simon Rozman &lt;simon.rozman@amebis.si&gt;
</content>
</entry>
<entry>
<title>driver: fix spelling mistakes in comments</title>
<updated>2022-05-23T13:57:34Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-05-23T13:57:34Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=41624504341307f7f55afe72e86d5d8c76f81c0e'/>
<id>urn:sha1:41624504341307f7f55afe72e86d5d8c76f81c0e</id>
<content type='text'>
Suggested-by: Dimitri Papadopoulos &lt;dimitri.papadopoulos@cea.fr&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>driver: address Code Analysis warning</title>
<updated>2021-10-17T11:25:14Z</updated>
<author>
<name>Simon Rozman</name>
<email>simon@rozman.si</email>
</author>
<published>2021-10-17T11:25:14Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=c20b8346741437b653a8cd25116e67f4f2cdbc50'/>
<id>urn:sha1:c20b8346741437b653a8cd25116e67f4f2cdbc50</id>
<content type='text'>
In this case, we're referencing objects by handle for closing user space
handles. Should be UserMode, not Irp-&gt;RequestorMode as C28126 suggests.

Signed-off-by: Simon Rozman &lt;simon@rozman.si&gt;
</content>
</entry>
<entry>
<title>driver: allow ring registration from kernel</title>
<updated>2021-10-17T11:21:38Z</updated>
<author>
<name>Simon Rozman</name>
<email>simon@rozman.si</email>
</author>
<published>2021-10-17T11:21:38Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=c7b20de96c1671d66ef7f856aecb5d8dde416c8f'/>
<id>urn:sha1:c7b20de96c1671d66ef7f856aecb5d8dde416c8f</id>
<content type='text'>
Signed-off-by: Simon Rozman &lt;simon@rozman.si&gt;
</content>
</entry>
<entry>
<title>driver: address Code Analysis warnings</title>
<updated>2021-10-17T11:11:42Z</updated>
<author>
<name>Simon Rozman</name>
<email>simon@rozman.si</email>
</author>
<published>2021-10-17T11:11:42Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=4c9511554d9c0aec52c76bd64198de45ce524cc9'/>
<id>urn:sha1:4c9511554d9c0aec52c76bd64198de45ce524cc9</id>
<content type='text'>
Signed-off-by: Simon Rozman &lt;simon@rozman.si&gt;
</content>
</entry>
<entry>
<title>driver: automatically close long-lived handle</title>
<updated>2021-10-12T18:55:24Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-10-12T18:44:42Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=d8fe1419fb480ec5fc4dd0c4bc49f1d1a1a90663'/>
<id>urn:sha1:d8fe1419fb480ec5fc4dd0c4bc49f1d1a1a90663</id>
<content type='text'>
There's only one handle that's likely to be open in a long lived way:
the tun registration handle. So we can force that closed automatically
when the device is about to close, if it's been improperly left open.
Other handles will indeed hold up closing, but if those exist, they're a
sign of a larger bug elsewhere that should be addressed. On the other
hand, tun registration handles might legitimately be open during driver
upgrades. This also saves us the trouble of dereferencing a freed
FileObject as in the general case.

Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>api: rewrite based on SwDevice</title>
<updated>2021-10-12T18:54:20Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-10-12T05:21:31Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=544fdaaf8fb970d9657a59c1fc4c4569de4f2d3e'/>
<id>urn:sha1:544fdaaf8fb970d9657a59c1fc4c4569de4f2d3e</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
</feed>
