324841e
From 5edabca9d4cff7f1f2b68f0bac55ef99d9798ba4 Mon Sep 17 00:00:00 2001
324841e
From: Andrey Konovalov <andreyknvl@google.com>
324841e
Date: Thu, 16 Feb 2017 17:22:46 +0100
324841e
Subject: dccp: fix freeing skb too early for IPV6_RECVPKTINFO
324841e
324841e
In the current DCCP implementation an skb for a DCCP_PKT_REQUEST packet
324841e
is forcibly freed via __kfree_skb in dccp_rcv_state_process if
324841e
dccp_v6_conn_request successfully returns.
324841e
324841e
However, if IPV6_RECVPKTINFO is set on a socket, the address of the skb
324841e
is saved to ireq->pktopts and the ref count for skb is incremented in
324841e
dccp_v6_conn_request, so skb is still in use. Nevertheless, it gets freed
324841e
in dccp_rcv_state_process.
324841e
324841e
Fix by calling consume_skb instead of doing goto discard and therefore
324841e
calling __kfree_skb.
324841e
324841e
Similar fixes for TCP:
324841e
324841e
fb7e2399ec17f1004c0e0ccfd17439f8759ede01 [TCP]: skb is unexpectedly freed.
324841e
0aea76d35c9651d55bbaf746e7914e5f9ae5a25d tcp: SYN packets are now
324841e
simply consumed
324841e
324841e
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
324841e
Acked-by: Eric Dumazet <edumazet@google.com>
324841e
Signed-off-by: David S. Miller <davem@davemloft.net>
324841e
---
324841e
 net/dccp/input.c | 3 ++-
324841e
 1 file changed, 2 insertions(+), 1 deletion(-)
324841e
324841e
diff --git a/net/dccp/input.c b/net/dccp/input.c
324841e
index ba34718..8fedc2d 100644
324841e
--- a/net/dccp/input.c
324841e
+++ b/net/dccp/input.c
324841e
@@ -606,7 +606,8 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
324841e
 			if (inet_csk(sk)->icsk_af_ops->conn_request(sk,
324841e
 								    skb) < 0)
324841e
 				return 1;
324841e
-			goto discard;
324841e
+			consume_skb(skb);
324841e
+			return 0;
324841e
 		}
324841e
 		if (dh->dccph_type == DCCP_PKT_RESET)
324841e
 			goto discard;
324841e
-- 
324841e
cgit v0.12
324841e