Received: by 10.192.165.156 with SMTP id m28csp1624040imm; Wed, 18 Apr 2018 12:49:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+8Wi1pN7nJNvg94pPyB7/kPecquLjQMVDCn3hEBwEUsbDtATgMIVQD0ryYaVQi08kSomRn X-Received: by 10.99.42.206 with SMTP id q197mr2781333pgq.60.1524080981515; Wed, 18 Apr 2018 12:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524080981; cv=none; d=google.com; s=arc-20160816; b=oHUvCPYI7DrResx2H/bZU60FgPQFnehEh4HLr8NMMzW15SjRfTW8JKl7VGeAwqCT93 sYMeHAlNpZmDYEiY+LmplinxhgLm0PBXUEAxKad/810JmlHB4Gc2GoSRcc7ZOyouO4Wc gkWE3SuFllmQE3tngaZY42Q5+028Y6O7bhLV/BBH1fq/p+TMpPZIf7IH/8HvikCTQDZC c5UA78g8582qzsN3uWdSxvatovLxl7L1yfb+2W70xRCcHKbzojgqjPp30JF+v62Ax5ld Ia1ofSTTay3K8wh25lMO/FWXUj0BrdL2rZv3ccdTF3qFMssb+x9zZVabe1NsKgPOTvH+ Q/mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=CCiZCg6q+DkEhPHB7iO+Z0rTxUcbExpMl+cFY9jwK8E=; b=wg9KdIwCKyl/VqpGgLzGZkJH0yD9cGVhU43VtrAKF7FXEU/KF8yarCCpCvEDBYszf9 49Oqg+4TMzREWHBiKhQx8OhgEy78Vaq6Fjrw2RxhOwyDM6NAXMeFNG5lYySdWqlT7R0v MMVz7ni132M9JRiBr/1CU3ozk3K+3sOJ8L9IouS/V37PjiVHTK06p4xoyp2FxlQZL9KC 0qBgpmCQZuCgWo1CyP8b20sQZiaf/HLrk0atgTkArNUTP/gNAxksf5VQAPVAudj+s/xC sh1YfLzQOVgGS+YTUg0Xb85sglbPBik+w87x8yKnSdg0cuaBls38ep4358a16MQjFLZv jU+Q== 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 e63si1624502pfg.344.2018.04.18.12.49.27; Wed, 18 Apr 2018 12:49:41 -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 S1752463AbeDRTsU (ORCPT + 99 others); Wed, 18 Apr 2018 15:48:20 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:14218 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750824AbeDRTsT (ORCPT ); Wed, 18 Apr 2018 15:48:19 -0400 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Wed, 18 Apr 2018 12:48:14 -0700 Received: from ubuntu.eng.vmware.com (unknown [10.33.74.215]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 8FD49B1610; Wed, 18 Apr 2018 12:48:18 -0700 (PDT) From: Ronak Doshi To: CC: Ronak Doshi , "VMware, Inc." , open list Subject: [PATCH net] vmxnet3: fix incorrect dereference when rxvlan is disabled Date: Wed, 18 Apr 2018 12:48:04 -0700 Message-ID: <20180418194805.29119-1-doshir@vmware.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: None (EX13-EDG-OU-001.vmware.com: doshir@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org vmxnet3_get_hdr_len() is used to calculate the header length which in turn is used to calculate the gso_size for skb. When rxvlan offload is disabled, vlan tag is present in the header and the function references ip header from sizeof(ethhdr) and leads to incorrect pointer reference. This patch fixes this issue by taking sizeof(vlan_ethhdr) into account if vlan tag is present and correctly references the ip hdr. Signed-off-by: Ronak Doshi Acked-by: Guolin Yang Acked-by: Louis Luo --- drivers/net/vmxnet3/vmxnet3_drv.c | 17 +++++++++++++---- drivers/net/vmxnet3/vmxnet3_int.h | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index e04937f44f33..9ebe2a689966 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c @@ -1218,6 +1218,7 @@ vmxnet3_get_hdr_len(struct vmxnet3_adapter *adapter, struct sk_buff *skb, union { void *ptr; struct ethhdr *eth; + struct vlan_ethhdr *veth; struct iphdr *ipv4; struct ipv6hdr *ipv6; struct tcphdr *tcp; @@ -1228,16 +1229,24 @@ vmxnet3_get_hdr_len(struct vmxnet3_adapter *adapter, struct sk_buff *skb, if (unlikely(sizeof(struct iphdr) + sizeof(struct tcphdr) > maplen)) return 0; + if (skb->protocol == cpu_to_be16(ETH_P_8021Q) || + skb->protocol == cpu_to_be16(ETH_P_8021AD)) + hlen = sizeof(struct vlan_ethhdr); + else + hlen = sizeof(struct ethhdr); + hdr.eth = eth_hdr(skb); if (gdesc->rcd.v4) { - BUG_ON(hdr.eth->h_proto != htons(ETH_P_IP)); - hdr.ptr += sizeof(struct ethhdr); + BUG_ON(hdr.eth->h_proto != htons(ETH_P_IP) && + hdr.veth->h_vlan_encapsulated_proto != htons(ETH_P_IP)); + hdr.ptr += hlen; BUG_ON(hdr.ipv4->protocol != IPPROTO_TCP); hlen = hdr.ipv4->ihl << 2; hdr.ptr += hdr.ipv4->ihl << 2; } else if (gdesc->rcd.v6) { - BUG_ON(hdr.eth->h_proto != htons(ETH_P_IPV6)); - hdr.ptr += sizeof(struct ethhdr); + BUG_ON(hdr.eth->h_proto != htons(ETH_P_IPV6) && + hdr.veth->h_vlan_encapsulated_proto != htons(ETH_P_IPV6)); + hdr.ptr += hlen; /* Use an estimated value, since we also need to handle * TSO case. */ diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h index 59ec34052a65..a3326463b71f 100644 --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h @@ -69,10 +69,10 @@ /* * Version numbers */ -#define VMXNET3_DRIVER_VERSION_STRING "1.4.13.0-k" +#define VMXNET3_DRIVER_VERSION_STRING "1.4.14.0-k" /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ -#define VMXNET3_DRIVER_VERSION_NUM 0x01040d00 +#define VMXNET3_DRIVER_VERSION_NUM 0x01040e00 #if defined(CONFIG_PCI_MSI) /* RSS only makes sense if MSI-X is supported. */ -- 2.11.0