aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-11-01 08:56:59 -0400
committerDavid S. Miller <davem@davemloft.net>2011-11-02 00:51:27 -0400
commit0ad92ad03aa444b312bd318b0341011a8be09d13 (patch)
treea6acc6651c301af1a5c7edd4258a441da091bfd3 /net/ipv4
parent501e89d3aef10f9a5b79137fbb0bcd5bf9cac2ac (diff)
udp: fix a race in encap_rcv handling
udp_queue_rcv_skb() has a possible race in encap_rcv handling, since this pointer can be changed anytime. We should use ACCESS_ONCE() to close the race. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/udp.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 131d8a720086..ab0966df1e2a 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1397,6 +1397,8 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1397 nf_reset(skb); 1397 nf_reset(skb);
1398 1398
1399 if (up->encap_type) { 1399 if (up->encap_type) {
1400 int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
1401
1400 /* 1402 /*
1401 * This is an encapsulation socket so pass the skb to 1403 * This is an encapsulation socket so pass the skb to
1402 * the socket's udp_encap_rcv() hook. Otherwise, just 1404 * the socket's udp_encap_rcv() hook. Otherwise, just
@@ -1409,11 +1411,11 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1409 */ 1411 */
1410 1412
1411 /* if we're overly short, let UDP handle it */ 1413 /* if we're overly short, let UDP handle it */
1412 if (skb->len > sizeof(struct udphdr) && 1414 encap_rcv = ACCESS_ONCE(up->encap_rcv);
1413 up->encap_rcv != NULL) { 1415 if (skb->len > sizeof(struct udphdr) && encap_rcv != NULL) {
1414 int ret; 1416 int ret;
1415 1417
1416 ret = (*up->encap_rcv)(sk, skb); 1418 ret = encap_rcv(sk, skb);
1417 if (ret <= 0) { 1419 if (ret <= 0) {
1418 UDP_INC_STATS_BH(sock_net(sk), 1420 UDP_INC_STATS_BH(sock_net(sk),
1419 UDP_MIB_INDATAGRAMS, 1421 UDP_MIB_INDATAGRAMS,