If we early-demux bind a TCP_TIMEWAIT socket to an skb and then orphan it
(as we need to do in the ipvs forwarding case), sock_wfree and sock_rfree
are going to reach into the inet_timewait_sock and mess with fields that
don't exist.

Signed-off-by: Alex Gartrell <agartr...@fb.com>
---
 net/core/sock.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/core/sock.c b/net/core/sock.c
index 1e1fe9a..b37328f 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1620,6 +1620,9 @@ void sock_wfree(struct sk_buff *skb)
        struct sock *sk = skb->sk;
        unsigned int len = skb->truesize;
 
+       if (sk->sk_state == TCP_TIME_WAIT)
+               return;
+
        if (!sock_flag(sk, SOCK_USE_WRITE_QUEUE)) {
                /*
                 * Keep a reference on sk_wmem_alloc, this will be released
@@ -1665,6 +1668,9 @@ void sock_rfree(struct sk_buff *skb)
        struct sock *sk = skb->sk;
        unsigned int len = skb->truesize;
 
+       if (sk->sk_state == TCP_TIME_WAIT)
+               return;
+
        atomic_sub(len, &sk->sk_rmem_alloc);
        sk_mem_uncharge(sk, len);
 }
-- 
Alex Gartrell <agartr...@fb.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to