| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The Go crypto library used to be simple and nice and an example of how
to do things well. Unfortunately, the addition of FIPS140 to it has
brought disgusting enterprise patterns and gummed up the code. One place
this really comes out is in the insane infrastructure behind the RNG. It
really only should be calling the system random functions and nothing
more. But in contemporary Go, simply calling into the RNG brings along
with it in the binary:
- A bizarre voodoo magic userspace entropy collector
- A specialized SHA384 implementation for said entropy collector
- An AES implementation
- An AES-NI accelerated AES implementation
- A CTR implementation for AES
- A GCM implementation for AES
- Some CPU detection code
- An implementation of some FIPS-specified DRBG algorithm
- An HMAC implementation
- A SHA256 implementation
- An AVX2-accelerated SHA256 implementation
- A SHA3 implementation (including cSHAKE)
- An AVX2-accelerated SHA3 implementation
- A SHA512 implementation
- Some generic XOR-bytes routines
- The actual syscall wrappers for getting random numbers
Obviously this is completely insane. There's a tangled mess of
components including eachother, a disorganized patchwork of FIPS code
and BoringCrypto code and enterprisey API hooks and self checks and
auto-included initializers. It seems like a mess of a library these
days.
So, here we beat down this madness by using a Go build overlay to
replace various parts of the crypto library with stub functions. This is
pretty nasty. But at least it compiles out some of this junk.
I'm trying to fix this upstream in the meanwhile [1], and so we'll see
what comes of that.
Link: https://github.com/golang/go/issues/81639
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
| |
hmac.Equal is a wrapper around subtle.ConstantTimeCompare. Use the
comparison directly to preserve the same timing behavior without
importing crypto/hmac, so that we don't accidently drag in fips140
garbage.
Link: https://github.com/golang/go/issues/81639
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
| |
Keep the Go toolchain under .deps\go to match the Linux build layout.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
| |
Use crypto/ecdh directly, because the old x/crypto 25519 library was
wrapping it.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
| |
Part of the API contract, apparently.
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>
|
| |
|
|
|
|
|
|
| |
The CIDR byte follows the 16-byte address and two-byte address family,
placing it at offset 18. Add the missing flags field at offset 20 and
its Remove flag to match the native structure.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
| |
Publish the inevaluable state instead of returning early. Otherwise the
kill-switch checkbox keeps its previous state when Table = off is added.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
| |
Add each successfully imported name to the existing-name set, so a
later configuration in the same batch cannot overwrite it.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
| |
Holding the add/remove mutex while waiting for a callback can deadlock
if the callback registers or unregisters another callback. Defer the
wait until after the mutex is released in all three handlers.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
| |
Otherwise it gets appended again at the next peer section or EOF. This
also prevents the single-peer kill switch from being enabled.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
| |
If the flush fails, the data is not durably on disk, so the rename
must not be published. Delete it in this case.
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>
|
| |
|
|
|
|
|
| |
For languages that don't translate these, explicitly fall back to ", "
and " " rather than emitting the placeholder.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
gob is positional; continue on a half-read value leaves the decoder
mid-payload, and the next iteration reads what follows as if it were
a new NotificationType. Return on any Decode error and let the pipe
close take down the reader. The empty-tunnel-name check has to move
below all four field decodes for the same reason, or it desyncs the
stream just like the failure path used to.
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>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
releaseDriverAdapter was only called from the RuntimeConfig error
path, so a cleanly-running tunnel never had its cached *Adapter
dropped from the map. The finalizer attached in OpenAdapter
couldn't reach it, and the kernel handle leaked. A restart of the
same tunnel then kept hitting stale-handle errors against the
surviving cache entry.
Fix this by calling releaseDriverAdapter from tunneltracker on
every TunnelStopped transition, and closing the adapter inside
releaseDriverAdapter under the per-adapter lock.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
| |
A per-cert decode failure shouldn't abort the whole enumeration:
just continue to the next cert. As a side effect, the next
CertEnumCertificatesInStore call frees this cert via its
predecessor-free contract, so no explicit free is needed either.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
| |
Without the splat the appended slice is passed as a single argument
to log.Fatal, which renders it as "[Error: <err>]" with the brackets
and the leading slice formatting visible in the console output.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
| |
The writer publishes nextIndex and timeNs via atomic ops, but
WriteTo and FollowFromCursor used to memcpy the entire mapping and
then read those fields plain, which is a race. Drop the megabyte
snapshot and use matching atomic loads.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Falling through to the message pump after SetWinEventHook failure
wedges the secondary process forever, since the hook is the only
thing that would ever post WM_QUIT or signal the existing window.
GetMessage's -1 error return was also being treated as a normal
message and dispatched on uninitialised MSG state. Bail out with
os.Exit on the SetWinEventHook failure path, and on the message
loop translate WM_QUIT (m==0) and the GetMessage error (m<0) into
real exit codes so ExitProcess does not see them through a signed
cast that lands on 0xFFFFFFFF.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
| |
The route-change and interface-change callbacks run on separate
threads from the IP Helper notification pool and both touch the
same lastLUID/lastIndex/lastMTU state.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The RtlPcToFileHeader hook consults loadedAddressRanges to identify
PCs that belong to manually-loaded modules. Entries were appended
during LoadLibrary but never removed when the module was freed, so
once the underlying allocation was returned to the OS and possibly
reused, the hook would still claim those PCs as ours and substitute
in a sentinel address, breaking unwind metadata lookup for whatever
legitimate module ended up at that range.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
| |
RtlAddFunctionTable keeps a kernel-side pointer into the in-image
RUNTIME_FUNCTION array. Without a matching RtlDeleteFunctionTable,
freeing codeBase via VirtualFree leaves that pointer dangling.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
| |
The two checks collapsed into one || meant the second error message
was unreachable. Drop NumberOfNames from the first check so both
diagnostics are reachable for their respective cases.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
| |
WinHTTP can short-read across TLS or HTTP chunk boundaries, so a
single Read may truncate the signed file list. Signify verification
catches it, but the user sees a spurious update-check failure
instead of a successful fetch.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
| |
NTFS journals the rename's metadata change but does not journal user
data. Without an explicit flush a power loss between the cache
manager publishing the rename and writing back the file's pages can
leave the destination at its final name with zero or partial
contents, while the prior file is gone.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The watcher's setup is guarded by sync.Once, which is consumed the
moment the goroutine is spawned. If tunnelConfigurationsDirectory or
FindFirstChangeNotification fails on the first attempt the goroutine
exits, but every subsequent RegisterStoreChangeCallback sees the Once
already done and skips the spawn, so changes are silently never
reported again. Retry these initial failures on the existing
startover loop instead of bailing out.
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 fixes a bit of a race with interface attachment on old Windows
builds.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
| |
We had reports of it failing.
Reported-by: Ben Yoder <byoder@moltzconstructors.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
| |
|
|
|
|
|
| |
Not really reachable, but still this seems wrong not to check.
DeleteName checks it.
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>
|
| |
|
|
|
| |
Reported-by: Frank Rochlitzer <f.rochlitzer@b3-it.de>
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>
|
| |
|
|
| |
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|