| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use C23 typeof to eliminate redundant type parameters from the RCU
macros.
Also, drop mention of hoping to use alignas in TODO.md. It only goes on
members of structs, not the struct type itself, which I find
syntactically annoying, and it doesn't really confer any additional real
benefits.
Moving to C23 means that we must use __VA_OPT__.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This restores 217922a ("driver: device: hack around broken IP notifier
by hijacking \Device\Nsi"), but does it right, hopefully.
Since we're attaching to \Device\Nsi as a filter, we increment the
refcount of the driver, which means Unload doesn't get called until we
detach filtering. So we attach and detach on first and last device
creation and destruction.
A limitation of the old commit is that it missed notifications from
netsh, because netsh sets the subinterface mtu, not the interface mtu.
I've now updated the code to catch both updates. For WireGuard, they are
effectively the same.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
| |
This makes the re-arm logic work better.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
| |
This avoids having to cleanup if the version is wrong.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
| |
This matches the behavior on Linux and other operating systems. Before,
you could append a bunch of cruft, which would then not get copied to
the header, while the MAC checker would still look at the end of the
NBL, hashing garbage.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Bad flow:
- new event, Done
- first op finishes sync, so STATUS_SUCCESS, which isn't pending, Done
isn't consumed.
- next op finishes async, so STATUS_PENDING, so we wait on it, but it's
already consumed from before, so it doesn't wait.
Fix this the easy way by always resetting the event always.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
| |
Otherwise we leak table.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
| |
If port 0 is passed, for a random port, it gets assigned on v4
allocation, and then can fail on v6 allocation it's already in use. In
that case, set the port back to 0 so that it can try a new random port.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
| |
This is better than returning garbage, in case we extend this later.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
| |
That's what we do for the others, so why not this one?
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The issue faced by 4309390 ("driver: ioctl: restore usage of
FunctionalDeviceObject->Reserved") wasn't that Windows 10 RTM didn't
have NdisWdfGetAdapterContextFromAdapterHandle(), but rather that
DispatchPnp was being called very early with a different device object.
We can fix this by simply testing to see if we have the right type of
device.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
| |
Further experiments with NdisWdfGetAdapterContextFromAdapterHandle
indicate it's probably less reliable than using ->Reserved, because it
means dereferencing DeviceExension.
Also get rid of the awkward IoctlHalt.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
| |
The stub device only exists momentarily to create the software registry
key for SuggestedInstanceId. Setting SWDeviceCapabilitiesDriverRequired
with empty hardware IDs violates the SwDeviceCreate API contract and
causes PnP to needlessly search for a driver for this transient device.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
| |
If SnapshotConfigurationAndState fails, Configuration is left NULL, but
RestoreConfigurationAndState was called unconditionally, passing the
NULL pointer to DeviceIoControl.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
| |
The return code before was wrong, because WaitForSingleObject returns
WAIT_OBJECT_0 on success, not TRUE.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
| |
This eliminates the need for a cross signing certificate, which is no
longer needed in the kernel and was never useful in userspace. And it
does the timestamp server correctly.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Otherwise, on Windows 10 RTM,
nt!KeBugCheckEx
nt!KiBugCheckDispatch+0x69
nt!KiPageFault+0x248
nt!KiTryUnwaitThread+0x35
nt!KeSetEvent+0x188
wireguard!DispatchPnp+0x50 [driver\ioctl.c @ 677]
nt!PnpAsynchronousCall+0xe5
nt!PiIrpQueryRemoveDevice+0x8c
nt!PnpQueryRemoveLockedDeviceNode+0x69
nt!PnpDeleteLockedDeviceNode+0x84
nt!PnpDeleteLockedDeviceNodes+0xb1
nt!PnpProcessQueryRemoveAndEject+0x3d1
nt!PnpProcessTargetDeviceEvent+0xd9
nt!PnpDeviceEventWorker+0x33c
nt!ExpWorkerThread+0xe9
nt!PspSystemThreadStartup+0x58
nt!KiStartSystemThread+0x16
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
| |
Microsoft is getting rid of it! Yikes.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
| |
These are kind of bogus and use a variation of styles. Bah!
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
| |
We're allocating the IRP on the stack, so this shouldn't be a real
issue.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
| |
api\configuration.c(45,39): error C2220: the following warning is treated as an error [api\api.vcxproj]
api\configuration.c(45,39): warning C5287: operands are different enum types 'WG_IOCTL_INTERFACE_FLAG' and 'WIREGUARD_INTERFACE_FLAG'; use an explicit cast to silence this warning [api\api.vcxproj]
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
| |
The other enums aren't using these.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
| |
This was used in the Linux implementation for resuming iterations over
netlink, but wound up finding no use case on NT.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
| |
This allows removing individual allowed IPs without having to clear them
all out and dropping packets or relying on a dummy peer to have move
semantics.
Suggested-by: Jordan Rife <jordan@jrife.io>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
| |
This aligns with conventions in other projects, like Linux and OpenSSL.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
| |
This follows Linux's unification of conventions and is indeed more
clear.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Packets bound for peers can queue up prior to the device private key
being set. For example, if persistent keepalive is set, a packet is
queued up to be sent as soon as the device comes up. However, if the
private key hasn't been set yet, the handshake message never sends, and
no timer is armed to retry, since that would be pointless.
But, if a user later sets a private key, the expectation is that those
queued packets, such as a persistent keepalive, are actually sent. So
adjust the configuration logic to account for this edge case, and add a
test case to make sure this works.
Maxim noticed this with a wg-quick(8) config to the tune of:
[Interface]
PostUp = wg set %i private-key somefile
[Peer]
PublicKey = ...
Endpoint = ...
PersistentKeepalive = 25
Here, the private key gets set after the device comes up using a PostUp
script, triggering the bug.
Reported-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Link: https://lore.kernel.org/wireguard/87fs7xtqrv.fsf@gmail.com/
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|