diff options
-rw-r--r-- | include/net/sock.h | 10 | ||||
-rw-r--r-- | net/core/datagram.c | 10 | ||||
-rw-r--r-- | net/ipv4/udp.c | 12 | ||||
-rw-r--r-- | net/ipv6/udp.c | 4 |
4 files changed, 25 insertions, 11 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index cf12b1e61fa6..d361c7769fe0 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -1021,6 +1021,16 @@ extern void release_sock(struct sock *sk); | |||
1021 | SINGLE_DEPTH_NESTING) | 1021 | SINGLE_DEPTH_NESTING) |
1022 | #define bh_unlock_sock(__sk) spin_unlock(&((__sk)->sk_lock.slock)) | 1022 | #define bh_unlock_sock(__sk) spin_unlock(&((__sk)->sk_lock.slock)) |
1023 | 1023 | ||
1024 | static inline void lock_sock_bh(struct sock *sk) | ||
1025 | { | ||
1026 | spin_lock_bh(&sk->sk_lock.slock); | ||
1027 | } | ||
1028 | |||
1029 | static inline void unlock_sock_bh(struct sock *sk) | ||
1030 | { | ||
1031 | spin_unlock_bh(&sk->sk_lock.slock); | ||
1032 | } | ||
1033 | |||
1024 | extern struct sock *sk_alloc(struct net *net, int family, | 1034 | extern struct sock *sk_alloc(struct net *net, int family, |
1025 | gfp_t priority, | 1035 | gfp_t priority, |
1026 | struct proto *prot); | 1036 | struct proto *prot); |
diff --git a/net/core/datagram.c b/net/core/datagram.c index 5574a5ddf908..95b851f3d713 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c | |||
@@ -229,9 +229,13 @@ EXPORT_SYMBOL(skb_free_datagram); | |||
229 | 229 | ||
230 | void skb_free_datagram_locked(struct sock *sk, struct sk_buff *skb) | 230 | void skb_free_datagram_locked(struct sock *sk, struct sk_buff *skb) |
231 | { | 231 | { |
232 | lock_sock(sk); | 232 | lock_sock_bh(sk); |
233 | skb_free_datagram(sk, skb); | 233 | skb_orphan(skb); |
234 | release_sock(sk); | 234 | sk_mem_reclaim_partial(sk); |
235 | unlock_sock_bh(sk); | ||
236 | |||
237 | /* skb is now orphaned, might be freed outside of locked section */ | ||
238 | consume_skb(skb); | ||
235 | } | 239 | } |
236 | EXPORT_SYMBOL(skb_free_datagram_locked); | 240 | EXPORT_SYMBOL(skb_free_datagram_locked); |
237 | 241 | ||
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 63eb56b2d873..1f86965ba7d7 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -1062,10 +1062,10 @@ static unsigned int first_packet_length(struct sock *sk) | |||
1062 | spin_unlock_bh(&rcvq->lock); | 1062 | spin_unlock_bh(&rcvq->lock); |
1063 | 1063 | ||
1064 | if (!skb_queue_empty(&list_kill)) { | 1064 | if (!skb_queue_empty(&list_kill)) { |
1065 | lock_sock(sk); | 1065 | lock_sock_bh(sk); |
1066 | __skb_queue_purge(&list_kill); | 1066 | __skb_queue_purge(&list_kill); |
1067 | sk_mem_reclaim_partial(sk); | 1067 | sk_mem_reclaim_partial(sk); |
1068 | release_sock(sk); | 1068 | unlock_sock_bh(sk); |
1069 | } | 1069 | } |
1070 | return res; | 1070 | return res; |
1071 | } | 1071 | } |
@@ -1196,10 +1196,10 @@ out: | |||
1196 | return err; | 1196 | return err; |
1197 | 1197 | ||
1198 | csum_copy_err: | 1198 | csum_copy_err: |
1199 | lock_sock(sk); | 1199 | lock_sock_bh(sk); |
1200 | if (!skb_kill_datagram(sk, skb, flags)) | 1200 | if (!skb_kill_datagram(sk, skb, flags)) |
1201 | UDP_INC_STATS_USER(sock_net(sk), UDP_MIB_INERRORS, is_udplite); | 1201 | UDP_INC_STATS_USER(sock_net(sk), UDP_MIB_INERRORS, is_udplite); |
1202 | release_sock(sk); | 1202 | unlock_sock_bh(sk); |
1203 | 1203 | ||
1204 | if (noblock) | 1204 | if (noblock) |
1205 | return -EAGAIN; | 1205 | return -EAGAIN; |
@@ -1624,9 +1624,9 @@ int udp_rcv(struct sk_buff *skb) | |||
1624 | 1624 | ||
1625 | void udp_destroy_sock(struct sock *sk) | 1625 | void udp_destroy_sock(struct sock *sk) |
1626 | { | 1626 | { |
1627 | lock_sock(sk); | 1627 | lock_sock_bh(sk); |
1628 | udp_flush_pending_frames(sk); | 1628 | udp_flush_pending_frames(sk); |
1629 | release_sock(sk); | 1629 | unlock_sock_bh(sk); |
1630 | } | 1630 | } |
1631 | 1631 | ||
1632 | /* | 1632 | /* |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 3ead20ad9d07..91c60f0090a4 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -424,7 +424,7 @@ out: | |||
424 | return err; | 424 | return err; |
425 | 425 | ||
426 | csum_copy_err: | 426 | csum_copy_err: |
427 | lock_sock(sk); | 427 | lock_sock_bh(sk); |
428 | if (!skb_kill_datagram(sk, skb, flags)) { | 428 | if (!skb_kill_datagram(sk, skb, flags)) { |
429 | if (is_udp4) | 429 | if (is_udp4) |
430 | UDP_INC_STATS_USER(sock_net(sk), | 430 | UDP_INC_STATS_USER(sock_net(sk), |
@@ -433,7 +433,7 @@ csum_copy_err: | |||
433 | UDP6_INC_STATS_USER(sock_net(sk), | 433 | UDP6_INC_STATS_USER(sock_net(sk), |
434 | UDP_MIB_INERRORS, is_udplite); | 434 | UDP_MIB_INERRORS, is_udplite); |
435 | } | 435 | } |
436 | release_sock(sk); | 436 | unlock_sock_bh(sk); |
437 | 437 | ||
438 | if (flags & MSG_DONTWAIT) | 438 | if (flags & MSG_DONTWAIT) |
439 | return -EAGAIN; | 439 | return -EAGAIN; |