Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1385082

[PATCH 3.12 25/78] macvtap: always pass ethernet header in linear

From Jiri Slaby <jslaby@suse.cz>
Newsgroups linux.kernel
Subject [PATCH 3.12 25/78] macvtap: always pass ethernet header in linear
Date 2016-04-22 13:40 +0200
Message-ID <rqHBg-1eF-31@gated-at.bofh.it> (permalink)
References <rqH8d-ZP-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Willem de Bruijn <willemb@google.com>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

[ Upstream commit 8e2ad4113ce4671686740f808ff2795395c39eef ]

The stack expects link layer headers in the skb linear section.
Macvtap can create skbs with llheader in frags in edge cases:
when (IFF_VNET_HDR is off or vnet_hdr.hdr_len < ETH_HLEN) and
prepad + len > PAGE_SIZE and vnet_hdr.flags has no or bad csum.

Add checks to ensure linear is always at least ETH_HLEN.
At this point, len is already ensured to be >= ETH_HLEN.

For backwards compatiblity, rounds up short vnet_hdr.hdr_len.
This differs from tap and packet, which return an error.

Fixes b9fb9ee07e67 ("macvtap: add GSO/csum offload support")
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/net/macvtap.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index ee53a9d06e8e..98ce4feb9a79 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -688,6 +688,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
 		copylen = vnet_hdr.hdr_len ? vnet_hdr.hdr_len : GOODCOPY_LEN;
 		if (copylen > good_linear)
 			copylen = good_linear;
+		else if (copylen < ETH_HLEN)
+			copylen = ETH_HLEN;
 		linear = copylen;
 		if (iov_pages(iv, vnet_hdr_len + copylen, count)
 		    <= MAX_SKB_FRAGS)
@@ -696,10 +698,11 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
 
 	if (!zerocopy) {
 		copylen = len;
-		if (vnet_hdr.hdr_len > good_linear)
+		linear = vnet_hdr.hdr_len;
+		if (linear > good_linear)
 			linear = good_linear;
-		else
-			linear = vnet_hdr.hdr_len;
+		else if (linear < ETH_HLEN)
+			linear = ETH_HLEN;
 	}
 
 	skb = macvtap_alloc_skb(&q->sk, MACVTAP_RESERVE, copylen,
-- 
2.8.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 3.12 01/78] tunnel: Clear IPCB(skb)->opt before dst_link_failure called Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 12/78] qmi_wwan: add Sierra Wireless MC74xx/EM74xx Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 25/78] macvtap: always pass ethernet header in linear Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 24/78] sh_eth: fix NULL pointer dereference in sh_eth_ring_format() Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 09/78] qmi_wwan: Add support for Dell Wireless 5809e 4G Modem Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 15/78] net: qmi_wwan: Add SIMCom 7230E Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 05/78] net: qmi_wwan: add Netgear AirCard 341U Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 14/78] net: qmi_wwan: Add WeTelecom-WPD600N Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 16/78] Add Dell Wireless 5809e Gobi 4G HSPA+ Mobile Broadband Card (rev3) to qmi_wwan Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 10/78] net: qmi_wwan: add HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 08/78] qmi_wwan: add the second QMI/network interface for Sierra Wireless MC7305/MC7355 Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 13/78] net: qmi_wwan: remove 1199:9070 device id Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 07/78] net: qmi_wwan: interface #11 in Sierra Wireless MC73xx is not QMI Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200
  [PATCH 3.12 23/78] udp6: fix UDP/IPv6 encap resubmit path Jiri Slaby <jslaby@suse.cz> - 2016-04-22 13:40 +0200

csiph-web