From patchwork Fri Sep 25 23:25:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pravin B Shelar X-Patchwork-Id: 523034 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 323E5140281 for ; Sat, 26 Sep 2015 09:26:05 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 0E3E910C36; Fri, 25 Sep 2015 16:26:04 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 39ADC10C35 for ; Fri, 25 Sep 2015 16:26:03 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 9D1281E04BF for ; Fri, 25 Sep 2015 17:26:02 -0600 (MDT) X-ASG-Debug-ID: 1443223539-09eadd11e04bf470001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar5.cudamail.com with ESMTP id z65nfu3lbcE6TKaq (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 25 Sep 2015 17:25:40 -0600 (MDT) X-Barracuda-Envelope-From: pshelar@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO mail-pa0-f44.google.com) (209.85.220.44) by mx1-pf1.cudamail.com with ESMTPS (RC4-SHA encrypted); 25 Sep 2015 23:25:39 -0000 Received-SPF: unknown (mx1-pf1.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.44 Received: by pablk4 with SMTP id lk4so21384645pab.3 for ; Fri, 25 Sep 2015 16:25:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3Dpbfkk/jM/EP1jQXLt1SMbJEQVTgF938iwgl1t9Mro=; b=Q/euyspX491fj8QTU+89yIsObMa5y1CMK3UfyhznT4FBYP4+mbyXG4OBC3mOYNdWsB KwcDiuvjyqzgLbyUb4hEOIvYhORdEZxtKf8RRF+mlFvs5QDQn24f7a91HmxRTDC4kBfd 2oX/NU/eXmOBlgPb4xSu+ReG2Xt9q93vkGJwA014C5dUIuODD82wdoBoxkO3OzEkCM+g 0dormtfHu3b0wtKXe70JNekgpZ6rBxJSMSfodhVHx5iwsXtpeiUel/8uCWGe+o12WtsP UqYOWHloYw6UPooN+/R8xjDpUJO0MyNsYlDJzqme+Uly12wqYiFmHa6Xg0Tu/QOTYlPy 3iZw== X-Gm-Message-State: ALoCoQkiZt0HU82E7U1rBGB8gxN2sJbVKgNYBSqMcihPkQy3SDghRsP/v4Cj4LAfuKN8YQM8a0Pu X-Received: by 10.66.252.131 with SMTP id zs3mr10390531pac.75.1443223539079; Fri, 25 Sep 2015 16:25:39 -0700 (PDT) Received: from localhost ([208.91.2.3]) by smtp.gmail.com with ESMTPSA id cs5sm5861367pbc.15.2015.09.25.16.25.38 (version=TLS1_1 cipher=AES128-SHA bits=128/128); Fri, 25 Sep 2015 16:25:38 -0700 (PDT) X-CudaMail-Envelope-Sender: pshelar@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.2.3 From: Pravin B Shelar To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E1-924090102 X-CudaMail-DTE: 092515 X-CudaMail-Originating-IP: 209.85.220.44 Date: Fri, 25 Sep 2015 16:25:10 -0700 X-ASG-Orig-Subj: [##CM-E1-924090102##][PATCH] datapath: Backport "skbuff: Fix skb checksum flag on skb pull" Message-Id: <1443223510-1810-1-git-send-email-pshelar@nicira.com> X-Mailer: git-send-email 1.7.1 X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1443223540 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 0 Subject: [ovs-dev] [PATCH] datapath: Backport "skbuff: Fix skb checksum flag on skb pull" X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Upstream commit: VXLAN device can receive skb with checksum partial. But the checksum offset could be in outer header which is pulled on receive. This results in negative checksum offset for the skb. Such skb can cause the assert failure in skb_checksum_help(). Following patch fixes the bug by setting checksum-none while pulling outer header. Following is the kernel panic msg from old kernel hitting the bug. ------------[ cut here ]------------ kernel BUG at net/core/dev.c:1906! RIP: 0010:[] skb_checksum_help+0x144/0x150 Call Trace: [] queue_userspace_packet+0x408/0x470 [openvswitch] [] ovs_dp_upcall+0x5d/0x60 [openvswitch] [] ovs_dp_process_packet_with_key+0xe6/0x100 [openvswitch] [] ovs_dp_process_received_packet+0x4b/0x80 [openvswitch] [] ovs_vport_receive+0x2a/0x30 [openvswitch] [] vxlan_rcv+0x53/0x60 [openvswitch] [] vxlan_udp_encap_recv+0x8b/0xf0 [openvswitch] [] udp_queue_rcv_skb+0x2dc/0x3b0 [] __udp4_lib_rcv+0x1cf/0x6c0 [] udp_rcv+0x1a/0x20 [] ip_local_deliver_finish+0xdd/0x280 [] ip_local_deliver+0x88/0x90 [] ip_rcv_finish+0x10d/0x370 [] ip_rcv+0x235/0x300 [] __netif_receive_skb+0x55d/0x620 [] netif_receive_skb+0x80/0x90 [] virtnet_poll+0x555/0x6f0 [] net_rx_action+0x134/0x290 [] __do_softirq+0xa8/0x210 [] call_softirq+0x1c/0x30 [] do_softirq+0x65/0xa0 [] irq_exit+0x8e/0xb0 [] do_IRQ+0x63/0xe0 [] common_interrupt+0x6e/0x6e Reported-by: Anupam Chanda Signed-off-by: Pravin B Shelar Acked-by: Tom Herbert Signed-off-by: David S. Miller Upstream: 6ae459bdaae ("skbuff: Fix skb checksum flag on skb pull") Signed-off-by: Pravin B Shelar Acked-by: Jesse Gross --- datapath/linux/compat/include/linux/skbuff.h | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/datapath/linux/compat/include/linux/skbuff.h b/datapath/linux/compat/include/linux/skbuff.h index 1a576a0..23b13b8 100644 --- a/datapath/linux/compat/include/linux/skbuff.h +++ b/datapath/linux/compat/include/linux/skbuff.h @@ -372,4 +372,28 @@ int rpl_skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci); void rpl_kfree_skb_list(struct sk_buff *segs); #define kfree_skb_list rpl_kfree_skb_list #endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0) +#define skb_postpull_rcsum rpl_skb_postpull_rcsum +static inline void skb_postpull_rcsum(struct sk_buff *skb, + const void *start, unsigned int len) +{ + if (skb->ip_summed == CHECKSUM_COMPLETE) + skb->csum = csum_sub(skb->csum, csum_partial(start, len, 0)); + else if (skb->ip_summed == CHECKSUM_PARTIAL && + skb_checksum_start_offset(skb) <= len) + skb->ip_summed = CHECKSUM_NONE; +} + +#define skb_pull_rcsum rpl_skb_pull_rcsum +static inline unsigned char *skb_pull_rcsum(struct sk_buff *skb, unsigned int len) +{ + BUG_ON(len > skb->len); + skb->len -= len; + BUG_ON(skb->len < skb->data_len); + skb_postpull_rcsum(skb, skb->data, len); + return skb->data += len; +} + +#endif #endif