* [PATCH net] macvtap: always pass ethernet header in linear
@ 2016-03-08 20:18 Willem de Bruijn
2016-03-11 19:45 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Willem de Bruijn @ 2016-03-08 20:18 UTC (permalink / raw)
To: netdev; +Cc: davem, Willem de Bruijn
From: Willem de Bruijn <willemb@google.com>
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>
---
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 d636d05..95394ed 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -760,6 +760,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
macvtap16_to_cpu(q, vnet_hdr.hdr_len) : GOODCOPY_LEN;
if (copylen > good_linear)
copylen = good_linear;
+ else if (copylen < ETH_HLEN)
+ copylen = ETH_HLEN;
linear = copylen;
i = *from;
iov_iter_advance(&i, copylen);
@@ -769,10 +771,11 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
if (!zerocopy) {
copylen = len;
- if (macvtap16_to_cpu(q, vnet_hdr.hdr_len) > good_linear)
+ linear = macvtap16_to_cpu(q, vnet_hdr.hdr_len);
+ if (linear > good_linear)
linear = good_linear;
- else
- linear = macvtap16_to_cpu(q, vnet_hdr.hdr_len);
+ else if (linear < ETH_HLEN)
+ linear = ETH_HLEN;
}
skb = macvtap_alloc_skb(&q->sk, MACVTAP_RESERVE, copylen,
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] macvtap: always pass ethernet header in linear
2016-03-08 20:18 [PATCH net] macvtap: always pass ethernet header in linear Willem de Bruijn
@ 2016-03-11 19:45 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-03-11 19:45 UTC (permalink / raw)
To: willemdebruijn.kernel; +Cc: netdev, willemb
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: Tue, 8 Mar 2016 15:18:54 -0500
> From: Willem de Bruijn <willemb@google.com>
>
> 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>
Applied to net-next and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-11 19:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-08 20:18 [PATCH net] macvtap: always pass ethernet header in linear Willem de Bruijn
2016-03-11 19:45 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).