aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsubashab@codeaurora.org <subashab@codeaurora.org>2015-01-23 22:26:02 +0000
committerJiri Slaby <jslaby@suse.cz>2015-02-10 11:16:50 +0100
commit757651a70148d9e1695daa6709988e09fd940cec (patch)
treeff1db09e58ae4eb9da0753cb9888d4d9bc9bccde
parentfd09a4de42024767c0fb9ea797e96454b0054130 (diff)
ping: Fix race in free in receive path
[ Upstream commit fc752f1f43c1c038a2c6ae58cc739ebb5953ccb0 ] An exception is seen in ICMP ping receive path where the skb destructor sock_rfree() tries to access a freed socket. This happens because ping_rcv() releases socket reference with sock_put() and this internally frees up the socket. Later icmp_rcv() will try to free the skb and as part of this, skb destructor is called and which leads to a kernel panic as the socket is freed already in ping_rcv(). -->|exception -007|sk_mem_uncharge -007|sock_rfree -008|skb_release_head_state -009|skb_release_all -009|__kfree_skb -010|kfree_skb -011|icmp_rcv -012|ip_local_deliver_finish Fix this incorrect free by cloning this skb and processing this cloned skb instead. This patch was suggested by Eric Dumazet Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org> Cc: Eric Dumazet <edumazet@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
-rw-r--r--net/ipv4/ping.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 8bd51f49aa96..81c92f61d77c 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -959,8 +959,11 @@ void ping_rcv(struct sk_buff *skb)
sk = ping_lookup(net, skb, ntohs(icmph->un.echo.id));
if (sk != NULL) {
+ struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
+
pr_debug("rcv on socket %p\n", sk);
- ping_queue_rcv_skb(sk, skb_get(skb));
+ if (skb2)
+ ping_queue_rcv_skb(sk, skb2);
sock_put(sk);
return;
}