From 293e9d604f949db9501d0ce01570350198e59c0b Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 3 Apr 2017 05:20:25 +0200 Subject: locking: always use _bh All locks are potentially between user context and softirq, which means we need to take the _bh variant. --- src/data.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/data.c') diff --git a/src/data.c b/src/data.c index dcbbd10..4751eb8 100644 --- a/src/data.c +++ b/src/data.c @@ -282,11 +282,11 @@ int packet_create_data(struct sk_buff_head *queue, struct wireguard_peer *peer, struct noise_keypair *keypair; struct sk_buff *skb; - rcu_read_lock(); - keypair = noise_keypair_get(rcu_dereference(peer->keypairs.current_keypair)); + rcu_read_lock_bh(); + keypair = noise_keypair_get(rcu_dereference_bh(peer->keypairs.current_keypair)); if (unlikely(!keypair)) goto err_rcu; - rcu_read_unlock(); + rcu_read_unlock_bh(); skb_queue_walk(queue, skb) { if (unlikely(!get_encryption_nonce(&PACKET_CB(skb)->nonce, &keypair->sending))) @@ -338,7 +338,7 @@ err: noise_keypair_put(keypair); return ret; err_rcu: - rcu_read_unlock(); + rcu_read_unlock_bh(); return ret; } @@ -421,9 +421,9 @@ void packet_consume_data(struct sk_buff *skb, struct wireguard_device *wg, packe __le32 idx = ((struct message_data *)skb->data)->key_idx; ret = -EINVAL; - rcu_read_lock(); + rcu_read_lock_bh(); keypair = noise_keypair_get((struct noise_keypair *)index_hashtable_lookup(&wg->index_hashtable, INDEX_HASHTABLE_KEYPAIR, idx)); - rcu_read_unlock(); + rcu_read_unlock_bh(); if (unlikely(!keypair)) goto err; -- cgit v1.2.3-59-g8ed1b