]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - net/dccp/ipv4.c
tcp/dccp: do not touch listener sk_refcnt under synflood
[mirror_ubuntu-zesty-kernel.git] / net / dccp / ipv4.c
index 9c67a961ba5382c8e3bf8c8a783224fd72b2c122..6438c5a7efc41192f5089c2004a333f4c3778469 100644 (file)
@@ -764,6 +764,7 @@ static int dccp_v4_rcv(struct sk_buff *skb)
 {
        const struct dccp_hdr *dh;
        const struct iphdr *iph;
+       bool refcounted;
        struct sock *sk;
        int min_cov;
 
@@ -801,7 +802,7 @@ static int dccp_v4_rcv(struct sk_buff *skb)
 
 lookup:
        sk = __inet_lookup_skb(&dccp_hashinfo, skb, __dccp_hdr_len(dh),
-                              dh->dccph_sport, dh->dccph_dport);
+                              dh->dccph_sport, dh->dccph_dport, &refcounted);
        if (!sk) {
                dccp_pr_debug("failed to look up flow ID in table and "
                              "get corresponding socket\n");
@@ -830,6 +831,7 @@ lookup:
                        goto lookup;
                }
                sock_hold(sk);
+               refcounted = true;
                nsk = dccp_check_req(sk, skb, req);
                if (!nsk) {
                        reqsk_put(req);
@@ -886,7 +888,8 @@ discard_it:
        return 0;
 
 discard_and_relse:
-       sock_put(sk);
+       if (refcounted)
+               sock_put(sk);
        goto discard_it;
 }