aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/noise.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-06-23 19:02:18 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-23 19:12:51 +0200
commit68441fb05412baebbd17f407bf984ad7a81af630 (patch)
tree71fefcc3710232dea912be362cb83f383720edc0 /src/noise.c
parentglobal: use ktime boottime instead of jiffies (diff)
downloadwireguard-monolithic-historical-68441fb05412baebbd17f407bf984ad7a81af630.tar.xz
wireguard-monolithic-historical-68441fb05412baebbd17f407bf984ad7a81af630.zip
global: use fast boottime instead of normal boottime
Generally if we're inaccurate by a few nanoseconds, it doesn't matter.
Diffstat (limited to 'src/noise.c')
-rw-r--r--src/noise.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/noise.c b/src/noise.c
index 7b3c4d6..84bde39 100644
--- a/src/noise.c
+++ b/src/noise.c
@@ -284,7 +284,7 @@ static void symmetric_key_init(struct noise_symmetric_key *key)
spin_lock_init(&key->counter.receive.lock);
atomic64_set(&key->counter.counter, 0);
memset(key->counter.receive.backtrack, 0, sizeof(key->counter.receive.backtrack));
- key->birthdate = ktime_get_boottime();
+ key->birthdate = ktime_get_boot_fast_ns();
key->is_valid = true;
}
@@ -461,7 +461,7 @@ struct wireguard_peer *noise_handshake_consume_initiation(struct message_handsha
down_read(&handshake->lock);
replay_attack = memcmp(t, handshake->latest_timestamp, NOISE_TIMESTAMP_LEN) <= 0;
- flood_attack = ktime_after(ktime_add_ns(handshake->last_initiation_consumption, NSEC_PER_SEC / INITIATIONS_PER_SECOND), ktime_get_boottime());
+ flood_attack = handshake->last_initiation_consumption + NSEC_PER_SEC / INITIATIONS_PER_SECOND > ktime_get_boot_fast_ns();
up_read(&handshake->lock);
if (replay_attack || flood_attack) {
peer_put(wg_peer);
@@ -476,7 +476,7 @@ struct wireguard_peer *noise_handshake_consume_initiation(struct message_handsha
memcpy(handshake->hash, hash, NOISE_HASH_LEN);
memcpy(handshake->chaining_key, chaining_key, NOISE_HASH_LEN);
handshake->remote_index = src->sender_index;
- handshake->last_initiation_consumption = ktime_get_boottime();
+ handshake->last_initiation_consumption = ktime_get_boot_fast_ns();
handshake->state = HANDSHAKE_CONSUMED_INITIATION;
up_write(&handshake->lock);