From patchwork Mon Nov 3 01:29:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenweilong X-Patchwork-Id: 405997 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id F068914008C for ; Mon, 3 Nov 2014 12:30:02 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752967AbaKCB35 (ORCPT ); Sun, 2 Nov 2014 20:29:57 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:56042 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751752AbaKCB3z (ORCPT ); Sun, 2 Nov 2014 20:29:55 -0500 Received: from 172.24.2.119 (EHLO szxeml404-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AWN43484; Mon, 03 Nov 2014 09:29:41 +0800 (CST) Received: from localhost (10.177.37.162) by szxeml404-hub.china.huawei.com (10.82.67.59) with Microsoft SMTP Server id 14.3.158.1; Mon, 3 Nov 2014 09:29:34 +0800 From: Chen Weilong To: , , , , CC: , Subject: [PATCH] ipv4: avoid divide 0 error in tcp_incr_quickack Date: Mon, 3 Nov 2014 09:29:33 +0800 Message-ID: <1414978173-6948-1-git-send-email-chenweilong@huawei.com> X-Mailer: git-send-email 1.8.1.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.177.37.162] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.5456DA87.0179, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 705713a5fb7d6524b485d12019f131e8 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Weilong Chen We got a problem like this: [ffff8801c1a05570] machine_kexec at ffffffff81025039 [ffff8801c1a055d0] crash_kexec at ffffffff8109b253 [ffff8801c1a056a0] oops_end at ffffffff81442aed [ffff8801c1a056d0] die at ffffffff81005603 [ffff8801c1a05700] do_trap at ffffffff81442448 [ffff8801c1a05760] do_divide_error at ffffffff81002c10 [ffff8801c1a05888] tcp_send_dupack at ffffffff81385e44 [ffff8801c1a058c8] tcp_validate_incoming at ffffffff813886b5 [ffff8801c1a05908] tcp_rcv_state_process at ffffffff8138d0b7 [ffff8801c1a05958] tcp_child_process at ffffffff81397255 [ffff8801c1a05988] tcp_v4_do_rcv at ffffffff81395a70 [ffff8801c1a059d8] tcp_v4_rcv at ffffffff81396fc8 [ffff8801c1a05a48] ip_local_deliver_finish at ffffffff813746e9 [ffff8801c1a05a78] ip_local_deliver at ffffffff81374a20 [ffff8801c1a05aa8] ip_rcv_finish at ffffffff81374389 [ffff8801c1a05ad8] ip_rcv at ffffffff81374c78 There was a wrong ack packet coming during TCP handshake. The socket's state was TCP_SYN_RECV, its rcv_mss was not initialize yet. So tcp_send_dupack -> tcp_enter_quickack_mode got a divide 0 error. This patch add a state check before tcp_enter_quickack_mode. Signed-off-by: Weilong Chen --- net/ipv4/tcp_input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 4e4617e..9eb56dc 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -3986,7 +3986,8 @@ static void tcp_send_dupack(struct sock *sk, const struct sk_buff *skb) if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq && before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_DELAYEDACKLOST); - tcp_enter_quickack_mode(sk); + if (sk->sk_state != TCP_SYN_RECV) + tcp_enter_quickack_mode(sk); if (tcp_is_sack(tp) && sysctl_tcp_dsack) { u32 end_seq = TCP_SKB_CB(skb)->end_seq;