Received: by 10.192.165.148 with SMTP id m20csp785925imm; Fri, 27 Apr 2018 07:30:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrnaETXfqmbj9iDEHk24NuQHytJ/DxHI+ptFkk9Ck2pzGcn+H1bkfk1M1y9iJyQlk8dlB+u X-Received: by 10.98.137.219 with SMTP id n88mr2407414pfk.11.1524839417611; Fri, 27 Apr 2018 07:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524839417; cv=none; d=google.com; s=arc-20160816; b=z4Xyyh1tHZCVXfHGguDcrevgZLCn1/stpouLVkox/jWiy5XfxmtQJH2dyxiQTQf54h evo5gZk4WckI6TXEzctgk5z8BjwZ4Ze68fdyuWFfA6pLXvcS+CMBeRsjtiVGgXubGegt dPIO706bR3AVv2H4eVkWxN7KWUZHqaOYW9pZ/nWTOPuzSV1SUdfFe75bpMjdoTPkgICn q8/PRfCIfhfupCq/dxpm9/pDqjxrpyda6rurguNk20K/o+eEQw4iqAlZtRKmP9+iDNIa V6O2v9qfDqoYKXNCe1IpIGjv+Tcacp2p2nrzxdt3qCvT684HbVv7NUW5IVKp44MTCIAg 5H3g== 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:dmarc-filter :arc-authentication-results; bh=QojBfPUZBw4payw+xmfOCFnwXhAVcVRdMf/tSulPdfE=; b=kZ2Osjvol6p1jFq7EzSqJcQhA0RNnzB6mPyb4snEjpg7Ae6uBM3w3y1d50FBKdtt8D lLhTeIx0fQoRgRh0kHaHfxM3Uqr4EqF2dCTJF5QjxDACyuaiiY829ZtKqkSk6I2Z6j8h luqnmQIXcHgn90S7tyA4+oYsvGZcIjeFKvZUQ6j23KapAQzb0hhYA5YXvEz7Z8rHl+iH yDXZBDd4y/bR90BtW1CP5wZVpkLt5VHR+FSJuGS3S0LIv4RndGbCXN35PRMBQgBICUJ7 P4nI/pAU5cQB47jPYAbS8ZAYaLi3OoETZo0gsMxesTXAES8zKTfTAiirrxh0VFqUl6Hf gkBQ== 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 e19si1353888pff.73.2018.04.27.07.30.03; Fri, 27 Apr 2018 07:30:17 -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 S935038AbeD0O3D (ORCPT + 99 others); Fri, 27 Apr 2018 10:29:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:56022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932916AbeD0OLJ (ORCPT ); Fri, 27 Apr 2018 10:11:09 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 855F72189E; Fri, 27 Apr 2018 14:11:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 855F72189E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ronak Doshi , Guolin Yang , Louis Luo , "David S. Miller" Subject: [PATCH 4.16 34/81] vmxnet3: fix incorrect dereference when rxvlan is disabled Date: Fri, 27 Apr 2018 15:58:36 +0200 Message-Id: <20180427135744.984141762@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135743.216853156@linuxfoundation.org> References: <20180427135743.216853156@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ronak Doshi [ Upstream commit 65ec0bd1c7c14522670a5294de35710fb577a7fd ] 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/vmxnet3/vmxnet3_drv.c | 17 +++++++++++++---- drivers/net/vmxnet3/vmxnet3_int.h | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c @@ -1218,6 +1218,7 @@ vmxnet3_get_hdr_len(struct vmxnet3_adapt 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_adapt 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. */ --- 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. */