Received: by 10.192.165.148 with SMTP id m20csp2475996imm; Sun, 22 Apr 2018 07:50:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx48n5rCwOXLl4LyvKIHmzKTtbXig9O/HcEhOqtzlRaRU41S+d1ED1Ib3KdGTPmEI1LPkfsW0 X-Received: by 10.98.88.194 with SMTP id m185mr16479897pfb.167.1524408633132; Sun, 22 Apr 2018 07:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524408633; cv=none; d=google.com; s=arc-20160816; b=Nv8QgT5wDxkbFVvOxpcNdyE0WWWSYRXeLUTtPEWv/uZ7IwJCvp2levAT5KLH76VxpY hHJMnH0X6PUozLkqJI8D96AoPLZnbfkHQn3qhFnwFOK5c+2lo4LZ1++aHEzL77jrQqSe yZM7PJSzawl4FyBqFXgYt3O03dpqpuAkvdNh3sSlknc3yfRIhALhMzQGU3rnFn06qpbO 7JP79YRTZXSbFOUDHT8CdQZxCEGYjolMf7Lq3eipgbzb8sxlKr6RFMJmlVmvVMR6JBzV sj7Zoopuvd42l47VwyzIyrs+5R8OXPCqpIui93F4NMCsNW1fqa1iaOhfIDRM9rx46Fkg 8P7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=SlJhF6G9JpoB0bKmwyjsvfA1RaQzZ6Lel4ZFB1TzoN8=; b=xNW+jD3nTRJrnnAWmDzL3SnMhT44aPd2oNW1L5DTZIZCKs3hegweXdsU46WRhOjFFU /knF+C2KcNNsMFQQ2ofsanIVX87DeUbrS0TZA9ct33zJ05gw2ko0veyqXsUv3SRE30M5 bCjCk1gBefx3ZPwiufwJKS8R5jdryScq60nuXr4MjOZ4zFRTMOyxsdnRsYkSmiesCt9X 8G2UEZNjiLkGDXwVBzwAPYvn1uEYXa/VPY5sS5v4xd3p8awSMaG9dYtK/YcQA5GLy82K 96uNjAn6Fh8oA4bQnjCbGslHmFM3/rjHHzlim3/i30/TaDMg7Y6oebkyoY9JrgUFm3ut wr/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1si8530933pgs.132.2018.04.22.07.50.19; Sun, 22 Apr 2018 07:50:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756577AbeDVOs5 (ORCPT + 99 others); Sun, 22 Apr 2018 10:48:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57028 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932178AbeDVOPt (ORCPT ); Sun, 22 Apr 2018 10:15:49 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id F302FCB9; Sun, 22 Apr 2018 14:15:48 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tejaswi Tanikella , "David S. Miller" Subject: [PATCH 4.4 17/97] slip: Check if rstate is initialized before uncompressing Date: Sun, 22 Apr 2018 15:52:55 +0200 Message-Id: <20180422135305.584991855@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135304.577223025@linuxfoundation.org> References: <20180422135304.577223025@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tejaswi Tanikella [ Upstream commit 3f01ddb962dc506916c243f9524e8bef97119b77 ] On receiving a packet the state index points to the rstate which must be used to fill up IP and TCP headers. But if the state index points to a rstate which is unitialized, i.e. filled with zeros, it gets stuck in an infinite loop inside ip_fast_csum trying to compute the ip checsum of a header with zero length. 89.666953: <2> [] slhc_uncompress+0x464/0x468 89.666965: <2> [] ppp_receive_nonmp_frame+0x3b4/0x65c 89.666978: <2> [] ppp_receive_frame+0x64/0x7e0 89.666991: <2> [] ppp_input+0x104/0x198 89.667005: <2> [] pppopns_recv_core+0x238/0x370 89.667027: <2> [] __sk_receive_skb+0xdc/0x250 89.667040: <2> [] pppopns_recv+0x44/0x60 89.667053: <2> [] __sock_queue_rcv_skb+0x16c/0x24c 89.667065: <2> [] sock_queue_rcv_skb+0x2c/0x38 89.667085: <2> [] raw_rcv+0x124/0x154 89.667098: <2> [] raw_local_deliver+0x1e0/0x22c 89.667117: <2> [] ip_local_deliver_finish+0x70/0x24c 89.667131: <2> [] ip_local_deliver+0x100/0x10c ./scripts/faddr2line vmlinux slhc_uncompress+0x464/0x468 output: ip_fast_csum at arch/arm64/include/asm/checksum.h:40 (inlined by) slhc_uncompress at drivers/net/slip/slhc.c:615 Adding a variable to indicate if the current rstate is initialized. If such a packet arrives, move to toss state. Signed-off-by: Tejaswi Tanikella Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/slip/slhc.c | 5 +++++ include/net/slhc_vj.h | 1 + 2 files changed, 6 insertions(+) --- a/drivers/net/slip/slhc.c +++ b/drivers/net/slip/slhc.c @@ -509,6 +509,10 @@ slhc_uncompress(struct slcompress *comp, if(x < 0 || x > comp->rslot_limit) goto bad; + /* Check if the cstate is initialized */ + if (!comp->rstate[x].initialized) + goto bad; + comp->flags &=~ SLF_TOSS; comp->recv_current = x; } else { @@ -673,6 +677,7 @@ slhc_remember(struct slcompress *comp, u if (cs->cs_tcp.doff > 5) memcpy(cs->cs_tcpopt, icp + ihl*4 + sizeof(struct tcphdr), (cs->cs_tcp.doff - 5) * 4); cs->cs_hsize = ihl*2 + cs->cs_tcp.doff*2; + cs->initialized = true; /* Put headers back on packet * Neither header checksum is recalculated */ --- a/include/net/slhc_vj.h +++ b/include/net/slhc_vj.h @@ -127,6 +127,7 @@ typedef __u32 int32; */ struct cstate { byte_t cs_this; /* connection id number (xmit) */ + bool initialized; /* true if initialized */ struct cstate *next; /* next in ring (xmit) */ struct iphdr cs_ip; /* ip/tcp hdr from most recent packet */ struct tcphdr cs_tcp;