diff options
author | subashab@codeaurora.org <subashab@codeaurora.org> | 2015-01-23 17:26:02 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-27 03:04:53 -0500 |
commit | fc752f1f43c1c038a2c6ae58cc739ebb5953ccb0 (patch) | |
tree | 4766edc6b35f44ab035c41d60d0d9b8212b6e52d /net/ipv4 | |
parent | 86f3cddbc3037882414c7308973530167906b7e9 (diff) |
ping: Fix race in free in receive path
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>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/ping.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index c0d82f78d364..2a3720fb5a5f 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c | |||
@@ -966,8 +966,11 @@ bool ping_rcv(struct sk_buff *skb) | |||
966 | 966 | ||
967 | sk = ping_lookup(net, skb, ntohs(icmph->un.echo.id)); | 967 | sk = ping_lookup(net, skb, ntohs(icmph->un.echo.id)); |
968 | if (sk != NULL) { | 968 | if (sk != NULL) { |
969 | struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); | ||
970 | |||
969 | pr_debug("rcv on socket %p\n", sk); | 971 | pr_debug("rcv on socket %p\n", sk); |
970 | ping_queue_rcv_skb(sk, skb_get(skb)); | 972 | if (skb2) |
973 | ping_queue_rcv_skb(sk, skb2); | ||
971 | sock_put(sk); | 974 | sock_put(sk); |
972 | return true; | 975 | return true; |
973 | } | 976 | } |