aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/noise.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2018-08-01queueing: document double-adding and reference conditionsJason A. Donenfeld1-0/+12
2018-08-01peer: ensure resources are freed when creation failsJason A. Donenfeld1-13/+19
And in general tighten up the logic of peer creation.
2018-08-01queueing: keep reference to peer after setting atomic state bitJason A. Donenfeld2-3/+8
After we atomic_set, the peer is allowed to be freed, which means if we want to continue to reference it, we need to bump the reference count. This was introduced a few commits ago by b713ab0e when implementing some simplification suggestions.
2018-08-01allowedips: free root inside of RCU callbackJason A. Donenfeld1-8/+10
This reduces the amount of call_rcu invocations considerably. Suggested-by: Stephen Hemminger <stephen@networkplumber.org>
2018-08-01hashtables: document immediate zeroing semanticsJason A. Donenfeld1-0/+6
Suggested-by: Jann Horn <jann@thejh.net>
2018-08-01allowedips: avoid window of disappeared peerJann Horn1-1/+5
If a peer is removed, it's possible for a lookup to momentarily return NULL, resulting in needless -ENOKEY returns. Signed-off-by: Jann Horn <jannh@google.com>
2018-08-01allowedips: prevent double read in krefJason A. Donenfeld2-17/+17
Blocks like: if (node_placement(*trie, key, cidr, bits, &node, lock)) { node->peer = peer; return 0; } May result in a double read when adjusting the refcount, in the highly unlikely case of LTO and an overly smart compiler. While we're at it, replace rcu_assign_pointer(X, NULL); with RCU_INIT_POINTER. Reported-by: Jann Horn <jann@thejh.net>
2018-07-31chacha20poly1305: selftest: split up test vector constantsJason A. Donenfeld1-69/+210
2018-07-31version: bump snapshot0.0.20180731Jason A. Donenfeld2-2/+2
2018-07-31device: adjust commentJason A. Donenfeld1-1/+1
Suggested-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
2018-07-31noise: use hex constant for tai64n offsetJason A. Donenfeld1-1/+1
Suggested-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
2018-07-31main: properly name labelJason A. Donenfeld1-2/+2
2018-07-31noise: remove outdated commentJason A. Donenfeld2-5/+0
docs/protocol.md hasn't existed for 3 years.
2018-07-31send: address of variable is never nullJason A. Donenfeld1-1/+1
Reported-by: Jann Horn <jann@thejh.net>
2018-07-31peer: simplify rcu reference countsJason A. Donenfeld9-30/+23
Use RCU reference counts only when we must, and otherwise use a more reasonably named function. Reported-by: Jann Horn <jann@thejh.net>
2018-07-31ratelimiter: prevent init/uninit raceJason A. Donenfeld2-4/+8
Fixes a classic ABA problem that isn't actually reachable because of rtnl_lock, but it's good to be correct anyway. Reported-by: Jann Horn <jann@thejh.net>
2018-07-31main: add missing chacha20poly1305 headerJason A. Donenfeld3-3/+2
2018-07-28curve25519-x86_64: tighten reductions modulo 2^256-38Samuel Neves1-21/+18
At this stage the value if C[4] is at most ((2^256-1) + 38*(2^256-1)) / 2^256 = 38, so there is no need to use a wide multiplication. Change inspired by Andy Polyakov's OpenSSL implementation. Signed-off-by: Samuel Neves <sneves@dei.uc.pt>
2018-07-28curve25519-x86_64: simplify the final reduction by adding 19 beforehandSamuel Neves1-40/+26
Correctness can be quickly verified with the following z3py script: >>> from z3 import * >>> x = BitVec("x", 256) # any 256-bit value >>> ref = URem(x, 2**255 - 19) # correct value >>> t = Extract(255, 255, x); x &= 2**255 - 1; # btrq $63, %3 >>> u = If(t != 0, BitVecVal(38, 256), BitVecVal(19, 256)) # cmovncl %k5, %k4 >>> x += u # addq %4, %0; adcq $0, %1; adcq $0, %2; adcq $0, %3; >>> t = Extract(255, 255, x); x &= 2**255 - 1; # btrq $63, %3 >>> u = If(t != 0, BitVecVal(0, 256), BitVecVal(19, 256)) # cmovncl %k5, %k4 >>> x -= u # subq %4, %0; sbbq $0, %1; sbbq $0, %2; sbbq $0, %3; >>> prove(x == ref) proved Change inspired by Andy Polyakov's OpenSSL implementation. Signed-off-by: Samuel Neves <sneves@dei.uc.pt>
2018-07-28curve25519-x86_64: tighten the x25519 assemblySamuel Neves1-3/+3
The wide multiplication by 38 in mul_a24_eltfp25519_1w is redundant: (2^256-1) * 121666 / 2^256 is at most 121665, and therefore a 64-bit multiplication can never overflow. Change inspired by Andy Polyakov's OpenSSL implementation. Signed-off-by: Samuel Neves <sneves@dei.uc.pt>
2018-07-24qemu: update musl and kernelJason A. Donenfeld1-2/+2
2018-07-24wg-quick: android: remove compat codeJason A. Donenfeld1-10/+0
2018-07-24wg-quick: android: allow package to be overriddenJason A. Donenfeld1-4/+9
2018-07-24qemu: show log if process crashesJason A. Donenfeld1-10/+16
2018-07-24embeddable-wg-library: do not left shift negative numbersJason A. Donenfeld1-7/+2
Otherwise we incur undefined behavior.
2018-07-24receive: check against proper return value typeJason A. Donenfeld1-1/+1
2018-07-18version: bump snapshot0.0.20180718Jason A. Donenfeld2-2/+2
2018-07-18recieve: disable NAPI busy pollingThomas Gschwantner2-0/+10
This avoids adding one reference per peer to the napi_hash hashtable, as normally done by netif_napi_add(). Since we potentially could have up to 2^20 peers this would make busy polling very slow globally. This approach is preferable to having only a single napi struct because we get one gro_list per peer, which means packets can be combined nicely even if we have a large number of peers. This is also done by gro_cells_init() in net/core/gro_cells.c . Signed-off-by: Thomas Gschwantner <tharre3@gmail.com>
2018-07-18device: destroy workqueue before freeing queueJason A. Donenfeld1-1/+1
2018-07-16wg-quick: allow link local default gatewayJason A. Donenfeld3-3/+0
It's unclear why it was like this in the first place, but it apparently broke certain IPv6 setups. Reported-by: Jonas Blahut <j@die-blahuts.de>
2018-07-12receive: use gro call instead of plain callJason A. Donenfeld1-1/+1
2018-07-11receive: account for zero or negative budgetJason A. Donenfeld1-0/+3
Suggested-by: Thomas Gschwantner <tharre3@gmail.com>
2018-07-08tools: only error on wg show if all interfaces failJason A. Donenfeld1-1/+4
2018-07-08version: bump snapshot0.0.20180708Jason A. Donenfeld2-2/+2
2018-07-08receive: use NAPI on the receive pathJonathan Neuschäfer6-17/+45
Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com> [Jason: fixed up the flushing of the rx_queue in peer_remove] Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
2018-07-06qemu: decide debug kernel based on KERNEL_VERSIONJason A. Donenfeld1-8/+8
If KERNEL_VERSION ends in -debug, then automatically set DEBUG_KERNEL If DEBUG_KERNEL is set, now the debug kernel will be built in a separate directory from the normal kernel, so that it's easy to toggle back and forth.
2018-07-06qemu: bump default kernel versionJason A. Donenfeld1-1/+1
This fixes DEBUG_KERNEL=yes due to dd275caf4a0d9b219fffe49288b6cc33cd564312 being backported to 4.17.4.
2018-07-06selftest: ratelimiter: improve chance of success via retryJason A. Donenfeld1-1/+6
2018-07-05wg-quick: android: support excluding applicationsJason A. Donenfeld1-9/+102
2018-07-04receive: styleJason A. Donenfeld1-1/+1
2018-07-04device: print daddr not saddr in missing peer errorJason A. Donenfeld1-1/+4
2018-06-25version: bump snapshot0.0.20180625Jason A. Donenfeld2-2/+2
2018-06-25wg-quick: android: prevent outgoing handshake packets from being droppedJason A. Donenfeld1-0/+4
2018-06-24compat: more robust ktime backportJason A. Donenfeld1-3/+8
This is needed for frankenkernels, like android-common.
2018-06-23global: use fast boottime instead of normal boottimeJason A. Donenfeld12-26/+26
Generally if we're inaccurate by a few nanoseconds, it doesn't matter.
2018-06-23global: use ktime boottime instead of jiffiesJason A. Donenfeld15-64/+69
Since this is a network protocol, expirations need to be accounted for, even across system suspend. On real systems, this isn't a problem, since we're clearing all keys before suspend. But on Android, where we don't do that, this is something of a problem. So, we switch to using boottime instead of jiffies.
2018-06-22tools: fix misspelling of strchrnul in commentJonathan Neuschäfer1-1/+1
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
2018-06-22manpages: eliminate whitespace at the end of the lineJonathan Neuschäfer2-26/+26
This eliminates a few style warnings from "mandoc -T lint src/tools/wg*.8". Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
2018-06-22global: fix a few typosJonathan Neuschäfer2-2/+2
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
2018-06-22simd: add missing headerJason A. Donenfeld1-0/+1
Suggested-by: Shlomi Steinberg <shlomi@shlomisteinberg.com>