Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2017863imu; Fri, 14 Dec 2018 04:34:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/VNUci9mcmboEAJVo3qlkFsojxqSIjNBinAPPX+Lf5EUG+I8JVQiHAkReMO0dNXcwpIUxxj X-Received: by 2002:a62:e201:: with SMTP id a1mr2610328pfi.75.1544790889406; Fri, 14 Dec 2018 04:34:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790889; cv=none; d=google.com; s=arc-20160816; b=M7r151ySWttZlJvV6kdAp1KPGurnSc19b5s+Yr76WpRfHdCpxvW6MrWdzyygJkS2GL G+29xECInckdoj8aNmbDgPPhPYUCEQr7c6+dAQsnaGxKfgLbkgb+6j3hJND8XlcoS8ZC 7GcUacDDC9dSdZkNN+I1PJzPCohc9DE/dRxfXmeJHBrMj7Z1vjor6BEVX1YxSTvrx78w XWnxLZZrTx20jYEUfdgjcNvOTSOMCIQLBB7YjkzUJLJrmzGRE604vGVlsRhUdZIwC23I v2c5C41YNDCHIEiqjr7/z7WpPZjiD0CIg3OIZqmyLhLY7qz5SNZzRtciRcPv80/lzqR5 KTBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uz5sidh79CAlAznSow+HrNaTnclybsl8Q939ny+OwAY=; b=ex9/qDCCLEh0WFwjTf13GBRlyYyLO/Tm0wpALPoZ1EpgyUXJXQ6CNtm7ZTD7xWf2+B CiH/0v8jZKIwIxlYcwV2MUTyslKkuYRMBXqFTssxwgDcyfxnt4BSl1Ry24C4x0ycbGQi 2DlvRp9eBgB+VTSM0S/MzJ+uROf8i6hU2gfZI/BsLsjWdYyHeWN2beY7jYJ9KNWfgc0f pNGrymNcDc9mjx410/dEhbynLKZJg7QSZTHYMAVdPIclvXF8z9iPuf71Muf7+hpr+3GC YSAcl0v1Db36vnKPHwI2i/7V35zKGnwLb6+lUI2FS3u/8yA+ozJg4BF6rQGNuTfyU0Ys 8ntQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="AQhPCMb/"; 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 c24si3941337pgk.269.2018.12.14.04.34.31; Fri, 14 Dec 2018 04:34:49 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b="AQhPCMb/"; 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 S1731392AbeLNMcV (ORCPT + 99 others); Fri, 14 Dec 2018 07:32:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:54732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730193AbeLNMJH (ORCPT ); Fri, 14 Dec 2018 07:09:07 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 E5E05214AE; Fri, 14 Dec 2018 12:09:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789346; bh=ZxIDy2AwHS5G0e2UD983MJJmIpaoe+37RDbW/ioDB44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AQhPCMb/wLxixEAC8oIezmycxTj0p7a708UCi2bKffSS/E1YNS8RETB/iGoSS/afQ 85OLpbme1/YKKnKblA02Z0ONmPu2ifFwoq6mswxJkWBOJUhM2LQYcoGIjwViFbYrWo 2ZdGyc5+Rf1+x2Cbapgw2U/qJynyLTolzIkO7Woc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Popa , Jason Wang , "David S. Miller" Subject: [PATCH 4.14 15/89] virtio-net: keep vnet header zeroed after processing XDP Date: Fri, 14 Dec 2018 12:59:28 +0100 Message-Id: <20181214115730.426980946@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115729.658859279@linuxfoundation.org> References: <20181214115729.658859279@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason Wang [ Upstream commit 436c9453a1ac0944b82870ef2e0d9be956b396d9 ] We copy vnet header unconditionally in page_to_skb() this is wrong since XDP may modify the packet data. So let's keep a zeroed vnet header for not confusing the conversion between vnet header and skb metadata. In the future, we should able to detect whether or not the packet was modified and keep using the vnet header when packet was not touched. Fixes: f600b6905015 ("virtio_net: Add XDP support") Reported-by: Pavel Popa Signed-off-by: Jason Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/virtio_net.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -309,7 +309,8 @@ static unsigned int mergeable_ctx_to_tru static struct sk_buff *page_to_skb(struct virtnet_info *vi, struct receive_queue *rq, struct page *page, unsigned int offset, - unsigned int len, unsigned int truesize) + unsigned int len, unsigned int truesize, + bool hdr_valid) { struct sk_buff *skb; struct virtio_net_hdr_mrg_rxbuf *hdr; @@ -331,7 +332,8 @@ static struct sk_buff *page_to_skb(struc else hdr_padded_len = sizeof(struct padded_vnet_hdr); - memcpy(hdr, p, hdr_len); + if (hdr_valid) + memcpy(hdr, p, hdr_len); len -= hdr_len; offset += hdr_padded_len; @@ -594,7 +596,8 @@ static struct sk_buff *receive_big(struc unsigned int len) { struct page *page = buf; - struct sk_buff *skb = page_to_skb(vi, rq, page, 0, len, PAGE_SIZE); + struct sk_buff *skb = page_to_skb(vi, rq, page, 0, len, + PAGE_SIZE, true); if (unlikely(!skb)) goto err; @@ -678,7 +681,8 @@ static struct sk_buff *receive_mergeable rcu_read_unlock(); put_page(page); head_skb = page_to_skb(vi, rq, xdp_page, - offset, len, PAGE_SIZE); + offset, len, + PAGE_SIZE, false); ewma_pkt_len_add(&rq->mrg_avg_pkt_len, len); return head_skb; } @@ -712,7 +716,7 @@ static struct sk_buff *receive_mergeable goto err_skb; } - head_skb = page_to_skb(vi, rq, page, offset, len, truesize); + head_skb = page_to_skb(vi, rq, page, offset, len, truesize, !xdp_prog); curr_skb = head_skb; if (unlikely(!curr_skb))