diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-04-03 05:20:25 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-04-04 03:44:35 +0200 |
commit | f7d65b3268ec8f11d0fbf455ce8f7b00b0f79c47 (patch) | |
tree | e7ddc04349076e5432dd196a4472e04b8bd4811b /src/socket.c | |
parent | bf71248a46a64955c53b59fe6bcbc9c35094d1c6 (diff) |
locking: always use _bh
All locks are potentially between user context and softirq,
which means we need to take the _bh variant.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/socket.c')
-rw-r--r-- | src/socket.c | 14 |
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); |