aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/receive.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-08-01 19:09:18 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-08-02 07:40:26 +0200
commit2b4023d7cadae4a712de768196171bafc2af24b7 (patch)
treee61235dc1e757050192e14dbe1f21d64bec8d18b /src/receive.c
parentqueueing: document double-adding and reference conditions (diff)
downloadwireguard-linux-compat-2b4023d7cadae4a712de768196171bafc2af24b7.tar.xz
wireguard-linux-compat-2b4023d7cadae4a712de768196171bafc2af24b7.zip
queueing: ensure strictly ordered loads and stores
We don't want a consumer to read plaintext when it's supposed to be reading ciphertext, which means we need to synchronize across cores. Suggested-by: Jann Horn <jann@thejh.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/receive.c')
-rw-r--r--src/receive.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/receive.c b/src/receive.c
index 5e231c9..12af8ed 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -382,7 +382,7 @@ int packet_rx_poll(struct napi_struct *napi, int budget)
if (unlikely(budget <= 0))
return 0;
- while ((skb = __ptr_ring_peek(&queue->ring)) != NULL && (state = atomic_read(&PACKET_CB(skb)->state)) != PACKET_STATE_UNCRYPTED) {
+ while ((skb = __ptr_ring_peek(&queue->ring)) != NULL && (state = atomic_read_acquire(&PACKET_CB(skb)->state)) != PACKET_STATE_UNCRYPTED) {
__ptr_ring_discard_one(&queue->ring);
peer = PACKET_PEER(skb);
keypair = PACKET_CB(skb)->keypair;