aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/noise.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* blake2s: remove outlen parameter from finalJason A. Donenfeld2019-03-271-2/+2
|
* peerlookup: rename from hashtablesJason A. Donenfeld2019-03-251-1/+1
|
* global: the _bh variety of rcu helpers have been unifiedJason A. Donenfeld2019-03-171-1/+1
|
* noise: store clamped key instead of raw keyJason A. Donenfeld2019-02-031-0/+1
|
* hashtables: decouple hashtable allocations from the main device allocationSultan Alsawaf2019-02-031-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The hashtable allocations are quite large, and cause the device allocation in the net framework to stall sometimes while it tries to find a contiguous region that can fit the device struct: [<0000000000000000>] __switch_to+0x94/0xb8 [<0000000000000000>] __alloc_pages_nodemask+0x764/0x7e8 [<0000000000000000>] kmalloc_order+0x20/0x40 [<0000000000000000>] __kmalloc+0x144/0x1a0 [<0000000000000000>] alloc_netdev_mqs+0x5c/0x368 [<0000000000000000>] rtnl_create_link+0x48/0x180 [<0000000000000000>] rtnl_newlink+0x410/0x708 [<0000000000000000>] rtnetlink_rcv_msg+0x190/0x1f8 [<0000000000000000>] netlink_rcv_skb+0x4c/0xf8 [<0000000000000000>] rtnetlink_rcv+0x30/0x40 [<0000000000000000>] netlink_unicast+0x18c/0x208 [<0000000000000000>] netlink_sendmsg+0x19c/0x348 [<0000000000000000>] sock_sendmsg+0x3c/0x58 [<0000000000000000>] ___sys_sendmsg+0x290/0x2b0 [<0000000000000000>] __sys_sendmsg+0x58/0xa0 [<0000000000000000>] SyS_sendmsg+0x10/0x20 [<0000000000000000>] el0_svc_naked+0x34/0x38 [<0000000000000000>] 0xffffffffffffffff To fix the allocation stalls, decouple the hashtable allocations from the device allocation and allocate the hashtables with kvmalloc's implicit __GFP_NORETRY so that the allocations fall back to vmalloc with little resistance. Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
* noise: whiten the nanoseconds portion of the timestampJason A. Donenfeld2019-02-031-0/+9
| | | | | This mitigates unrelated sidechannel attacks that think they can turn WireGuard into a useful time oracle.
* noise: replace getnstimeofday64 with ktime_get_real_ts64Jason A. Donenfeld2019-01-231-1/+1
| | | | | | | | | The former was just a wrapper around the latter, and so upstream is now removing it. Also adjust the compat kludge to deal with this. Reported-by: Alex Xu <alex@alxu.ca>
* global: update copyrightJason A. Donenfeld2019-01-071-1/+1
|
* global: various formatting tweeksJason A. Donenfeld2018-11-131-0/+1
|
* global: do not allow compiler to reorder is_valid or is_deadJason A. Donenfeld2018-10-251-2/+2
| | | | Suggested-by: Jann Horn <jann@thejh.net>
* peer: another peer_remove cleanupJason A. Donenfeld2018-10-251-4/+12
|
* global: give if statements brackets and other cleanupsJason A. Donenfeld2018-10-091-1/+2
|
* global: more nitsJason A. Donenfeld2018-10-081-3/+4
|
* global: rename struct wireguard_ to struct wg_Jason A. Donenfeld2018-10-081-12/+12
| | | | | | This required a bit of pruning of our christmas trees. Suggested-by: Jiri Pirko <jiri@resnulli.us>
* global: change BUG_ON to WARN_ONJason A. Donenfeld2018-10-021-7/+6
| | | | Suggested-by: Andrew Lunn <andrew@lunn.ch>
* global: prefix all functions with wg_Jason A. Donenfeld2018-10-021-47/+50
| | | | | | | | | | | | | I understand why this must be done, though I'm not so happy about having to do it. In some places, it puts us over 80 chars and we have to break lines up in further ugly ways. And in general, I think this makes things harder to read. Yet another thing we must do to please upstream. Maybe this can be replaced in the future by some kind of automatic module namespacing logic in the linker, or even combined with LTO and aggressive symbol stripping. Suggested-by: Andrew Lunn <andrew@lunn.ch>
* crypto: make constant naming scheme consistentJason A. Donenfeld2018-09-251-15/+15
|
* global: put SPDX identifier on its own lineJason A. Donenfeld2018-09-201-2/+2
| | | | | The kernel has very specific rules correlating file type with comment type, and also SPDX identifiers can't be merged with other comments.
* global: prefer sizeof(*pointer) when possibleJason A. Donenfeld2018-09-041-3/+2
| | | | Suggested-by: Sultan Alsawaf <sultanxda@gmail.com>
* global: run through clang-formatJason A. Donenfeld2018-08-281-113/+247
| | | | | | | This is the worst commit in the whole repo, making the code much less readable, but so it goes with upstream maintainers. We are now woefully wrapped at 80 columns.
* peer: ensure destruction doesn't raceJason A. Donenfeld2018-08-031-28/+30
| | | | | Completely rework peer removal to ensure peers don't jump between contexts and create races.
* noise: free peer references on failureJason A. Donenfeld2018-08-021-11/+11
|
* cookie: returned keypair might disappear if rcu lock not heldJason A. Donenfeld2018-08-021-1/+1
| | | | | | And in general it's good to prefer dereferencing entry.peer from a handshake object rather than a keypair object, when possible, since keypairs could disappear before their underlying peer.
* allowedips: prevent double read in krefJason A. Donenfeld2018-08-011-6/+6
| | | | | | | | | | | | | | | | | 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>
* noise: use hex constant for tai64n offsetJason A. Donenfeld2018-07-311-1/+1
| | | | Suggested-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
* global: use fast boottime instead of normal boottimeJason A. Donenfeld2018-06-231-3/+3
| | | | Generally if we're inaccurate by a few nanoseconds, it doesn't matter.
* global: use ktime boottime instead of jiffiesJason A. Donenfeld2018-06-231-3/+3
| | | | | | | | 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.
* noise: wait for crng before taking locksJason A. Donenfeld2018-06-181-0/+10
| | | | | | | Otherwise, get_random_bytes_wait gets called from curve25519_generate_secret, and at the same time, a user might use the wg(8) utility, which then wants to grab a read lock for what we're write locking.
* netlink: maintain static_identity lock over entire private key updateJason A. Donenfeld2018-06-181-4/+2
| | | | | We don't want the local private key to not correspond with a precomputed ss or precomputed cookie hash at any intermediate point.
* noise: take locks for ss precomputationJason A. Donenfeld2018-06-181-3/+9
| | | | | | | Usually this is called from handshake_init, where locking doesn't matter because nothing references it yet, but it's also called when changing the device private key, so it's probably a good thing to not process a handshake with a ss precomputation that's part old and part new.
* global: year bumpJason A. Donenfeld2018-01-031-1/+1
|
* global: add SPDX tags to all filesGreg Kroah-Hartman2017-12-091-1/+4
| | | | | | | | | | | | | It's good to have SPDX identifiers in all files as the Linux kernel developers are working to add these identifiers to all files. Update all files with the correct SPDX license identifier based on the license text of the project or based on the license in the file itself. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Modified-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: switch from timeval to timespecJason A. Donenfeld2017-11-221-3/+3
| | | | | | | | | | | | | | | | | | | This gets us nanoseconds instead of microseconds, which is better, and we can do this pretty much without freaking out existing userspace, which doesn't actually make use of the nano/micro seconds field: zx2c4@thinkpad ~ $ cat a.c void main() { puts(sizeof(struct timeval) == sizeof(struct timespec) ? "success" : "failure"); } zx2c4@thinkpad ~ $ gcc a.c -m64 && ./a.out success zx2c4@thinkpad ~ $ gcc a.c -m32 && ./a.out success This doesn't solve y2038 problem, but timespec64 isn't yet a thing in userspace.
* global: revert checkpatch.pl changesJason A. Donenfeld2017-11-021-1/+1
| | | | | These changes were suggested by checkpatch.pl, but actually cause big problems depending on the options. Revert.
* global: use fewer BUG_ONsJason A. Donenfeld2017-10-311-0/+2
| | | | Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* global: style nitsJason A. Donenfeld2017-10-311-6/+12
|
* global: accept decent check_patch.pl suggestionsJason A. Donenfeld2017-10-311-3/+3
|
* noise: no need to take the RCU lock if we're not dereferencingJason A. Donenfeld2017-10-171-4/+2
|
* noise: handshake constants can be read-only after initJason A. Donenfeld2017-10-171-2/+2
|
* global: add space around variable declarationsJason A. Donenfeld2017-10-031-0/+11
|
* noise: use spinlock for rotating keysJason A. Donenfeld2017-10-021-19/+27
| | | | | This should only really be contended in extremely exceptional cases, so changing from a mutex to a spinlock is likely fine.
* netlink: switch from ioctl to netlink for configurationJason A. Donenfeld2017-10-021-9/+4
|
* queue: entirely rework parallel systemJason A. Donenfeld2017-09-181-1/+1
| | | | | | | | | | This removes our dependency on padata and moves to a different mode of multiprocessing that is more efficient. This began as Samuel Holland's GSoC project and was gradually reworked/redesigned/rebased into this present commit, which is a combination of his initial contribution and my subsequent rewriting and redesigning.
* noise: infer initiator or not from handshake stateJason A. Donenfeld2017-08-041-3/+3
| | | | Suggested-by: Mathias Hall-Andersen <mathias@hall-andersen.dk>
* global: use pointer to net_deviceJason A. Donenfeld2017-07-201-2/+2
| | | | | | DaveM prefers it to be this way per [1]. [1] http://www.spinics.net/lists/netdev/msg443992.html
* main: annotate init/exit functions to save memoryJason A. Donenfeld2017-06-241-1/+1
|
* noise: fix race when replacing handshakeJason A. Donenfeld2017-06-081-9/+19
| | | | | | | | Replacing an entry that's already been replaced is something that could happen when processing handshake messages in parallel, when starting up multiple instances on the same machine. Reported-by: Hubert Goisern <zweizweizwoelf@gmail.com>
* debug: print interface name in dmesgJason A. Donenfeld2017-05-311-2/+2
|
* peer: use iterator macro instead of callbackJason A. Donenfeld2017-05-301-4/+4
|
* noise: precompute static-static ECDH operationJason A. Donenfeld2017-05-301-10/+18
|