aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/queueing.h
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
commit6c51343dba4d3059e18b047ee52d1219c2ab7816 (patch)
treeb40bf8a9c937622d7c22824490a6e9057ceeb6b0 /src/queueing.h
parentqueueing: document double-adding and reference conditions (diff)
downloadwireguard-monolithic-historical-6c51343dba4d3059e18b047ee52d1219c2ab7816.tar.xz
wireguard-monolithic-historical-6c51343dba4d3059e18b047ee52d1219c2ab7816.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>
Diffstat (limited to 'src/queueing.h')
-rw-r--r--src/queueing.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/queueing.h b/src/queueing.h
index 52cac40..6a1de33 100644
--- a/src/queueing.h
+++ b/src/queueing.h
@@ -120,7 +120,7 @@ static inline int queue_enqueue_per_device_and_peer(struct crypt_queue *device_q
{
int cpu;
- atomic_set(&PACKET_CB(skb)->state, PACKET_STATE_UNCRYPTED);
+ atomic_set_release(&PACKET_CB(skb)->state, PACKET_STATE_UNCRYPTED);
/* We first queue this up for the peer ingestion, but the consumer
* will wait for the state to change to CRYPTED or DEAD before.
*/
@@ -142,7 +142,7 @@ static inline void queue_enqueue_per_peer(struct crypt_queue *queue, struct sk_b
* peer can be freed from below us.
*/
struct wireguard_peer *peer = peer_get(PACKET_PEER(skb));
- atomic_set(&PACKET_CB(skb)->state, state);
+ atomic_set_release(&PACKET_CB(skb)->state, state);
queue_work_on(cpumask_choose_online(&peer->serial_work_cpu, peer->internal_id), peer->device->packet_crypt_wq, &queue->work);
peer_put(peer);
}
@@ -153,7 +153,7 @@ static inline void queue_enqueue_per_peer_napi(struct crypt_queue *queue, struct
* peer can be freed from below us.
*/
struct wireguard_peer *peer = peer_get(PACKET_PEER(skb));
- atomic_set(&PACKET_CB(skb)->state, state);
+ atomic_set_release(&PACKET_CB(skb)->state, state);
napi_schedule(&peer->napi);
peer_put(peer);
}