aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/socket.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-04-03 05:20:25 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-04-04 03:44:35 +0200
commit293e9d604f949db9501d0ce01570350198e59c0b (patch)
treed9d02ae5be1ebc9eb7e76c90baa781e45e9189fe /src/socket.c
parentqemu: new stable kernel (diff)
downloadwireguard-monolithic-historical-293e9d604f949db9501d0ce01570350198e59c0b.tar.xz
wireguard-monolithic-historical-293e9d604f949db9501d0ce01570350198e59c0b.zip
locking: always use _bh
All locks are potentially between user context and softirq, which means we need to take the _bh variant.
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/socket.c b/src/socket.c
index a2b64b3..54b1ba2 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -30,8 +30,8 @@ static inline int send4(struct wireguard_device *wg, struct sk_buff *skb, struct
skb->next = skb->prev = NULL;
skb->dev = netdev_pub(wg);
- rcu_read_lock();
- sock = rcu_dereference(wg->sock4);
+ rcu_read_lock_bh();
+ sock = rcu_dereference_bh(wg->sock4);
if (unlikely(!sock)) {
ret = -ENONET;
@@ -73,7 +73,7 @@ static inline int send4(struct wireguard_device *wg, struct sk_buff *skb, struct
err:
kfree_skb(skb);
out:
- rcu_read_unlock();
+ rcu_read_unlock_bh();
return ret;
}
@@ -97,8 +97,8 @@ static inline int send6(struct wireguard_device *wg, struct sk_buff *skb, struct
skb->next = skb->prev = NULL;
skb->dev = netdev_pub(wg);
- rcu_read_lock();
- sock = rcu_dereference(wg->sock6);
+ rcu_read_lock_bh();
+ sock = rcu_dereference_bh(wg->sock6);
if (unlikely(!sock)) {
ret = -ENONET;
@@ -139,7 +139,7 @@ static inline int send6(struct wireguard_device *wg, struct sk_buff *skb, struct
err:
kfree_skb(skb);
out:
- rcu_read_unlock();
+ rcu_read_unlock_bh();
return ret;
#else
return -EAFNOSUPPORT;
@@ -377,7 +377,7 @@ void socket_uninit(struct wireguard_device *wg)
rcu_assign_pointer(wg->sock4, NULL);
rcu_assign_pointer(wg->sock6, NULL);
mutex_unlock(&wg->socket_update_lock);
- synchronize_rcu();
+ synchronize_rcu_bh();
synchronize_net();
sock_free(old4);
sock_free(old6);