mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: akpm@linux-foundation.org, "Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [16/84] macvtap: correctly linearize skb when zerocopy is used
Date: Wed, 31 Jul 2013 15:23:09 +0200	[thread overview]
Message-ID: <lsq.1375276989.808474785@decadent.org.uk> (raw)
In-Reply-To: <lsq.1375276989.251749228@decadent.org.uk>

3.2.50-rc1 review patch.  If anyone has any objections, please let me know.

------------------

From: Jason Wang <jasowang@redhat.com>

[ Upstream commit 61d46bf979d5cd7c164709a80ad5676a35494aae ]

Userspace may produce vectors greater than MAX_SKB_FRAGS. When we try to
linearize parts of the skb to let the rest of iov to be fit in
the frags, we need count copylen into linear when calling macvtap_alloc_skb()
instead of partly counting it into data_len. Since this breaks
zerocopy_sg_from_iovec() since its inner counter assumes nr_frags should
be zero at beginning. This cause nr_frags to be increased wrongly without
setting the correct frags.

This bug were introduced from b92946e2919134ebe2a4083e4302236295ea2a73
(macvtap: zerocopy: validate vectors before building skb).

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/net/macvtap.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index d91858e..96b9e3c 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -655,6 +655,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
 	int vnet_hdr_len = 0;
 	int copylen = 0;
 	bool zerocopy = false;
+	size_t linear;
 
 	if (q->flags & IFF_VNET_HDR) {
 		vnet_hdr_len = q->vnet_hdr_sz;
@@ -709,11 +710,14 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
 			copylen = vnet_hdr.hdr_len;
 		if (!copylen)
 			copylen = GOODCOPY_LEN;
-	} else
+		linear = copylen;
+	} else {
 		copylen = len;
+		linear = vnet_hdr.hdr_len;
+	}
 
 	skb = macvtap_alloc_skb(&q->sk, NET_IP_ALIGN, copylen,
-				vnet_hdr.hdr_len, noblock, &err);
+				linear, noblock, &err);
 	if (!skb)
 		goto err;
 


  parent reply	other threads:[~2013-07-31 13:37 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-31 13:23 [00/84] 3.2.50-rc1 review Ben Hutchings
2013-07-31 13:23 ` [04/84] ipv6: ip6_sk_dst_check() must not assume ipv6 dst Ben Hutchings
2013-07-31 13:23 ` [41/84] ALSA: asihpi: Fix unlocked snd_pcm_stop() call Ben Hutchings
2013-07-31 13:23 ` [70/84] USB: option: add D-Link DWM-152/C1 and DWM-156/C1 Ben Hutchings
2013-07-31 13:23 ` [01/84] bridge: fix switched interval for MLD Query types Ben Hutchings
2013-07-31 13:23 ` [42/84] ALSA: atiixp: Fix unlocked snd_pcm_stop() call Ben Hutchings
2013-07-31 13:23 ` [44/84] ASoC: max98088 - fix element type of the register cache Ben Hutchings
2013-07-31 13:23 ` [72/84] staging: comedi: fix a race between do_cmd_ioctl() and read/write Ben Hutchings
2013-07-31 13:23 ` [54/84] Btrfs: fix lock leak when resuming snapshot deletion Ben Hutchings
2013-07-31 13:23 ` [36/84] lockd: protect nlm_blocked access in nlmsvc_retry_blocked Ben Hutchings
2013-07-31 13:23 ` [37/84] ext4: don't allow ext4_free_blocks() to fail due to ENOMEM Ben Hutchings
2013-07-31 13:23 ` [38/84] ACPI / memhotplug: Fix a stale pointer in error path Ben Hutchings
2013-07-31 13:23 ` [32/84] xen/io/ring.h: new macro to detect whether there are too many requests on the ring Ben Hutchings
2013-07-31 13:23 ` [40/84] usb: dwc3: fix wrong bit mask in dwc3_event_type Ben Hutchings
2013-07-31 13:23 ` [35/84] ASoC: sglt5000: Fix SGTL5000_PLL_FRAC_DIV_MASK Ben Hutchings
2013-07-31 13:23 ` [83/84] USB: mos7840: fix memory leak in open Ben Hutchings
2013-07-31 13:23 ` [84/84] usb: Clear both buffers when clearing a control transfer TT buffer Ben Hutchings
2013-07-31 13:23 ` [29/84] [SCSI] Fix incorrect memset in bnx2fc_parse_fcp_rsp Ben Hutchings
2013-07-31 13:23 ` [26/84] ARM: OMAP: RX-51: change probe order of touchscreen and panel SPI devices Ben Hutchings
2013-08-01  5:49   ` Tomi Valkeinen
2013-08-01  9:32     ` Ben Hutchings
2013-08-02 20:14       ` Ben Hutchings
2013-07-31 13:23 ` [64/84] drm/radeon: improve dac adjust heuristics for legacy pdac Ben Hutchings
2013-07-31 13:23 ` [02/84] ipv6: don't call addrconf_dst_alloc again when enable lo Ben Hutchings
2013-07-31 13:23 ` [66/84] [SCSI] isci: Fix a race condition in the SSP task management path Ben Hutchings
2013-07-31 13:23 ` [45/84] ALSA: ua101: Fix unlocked snd_pcm_stop() call Ben Hutchings
2013-07-31 13:23 ` [74/84] powerpc/modules: Module CRC relocation fix causes perf issues Ben Hutchings
2013-07-31 13:23 ` [05/84] af_key: fix info leaks in notify messages Ben Hutchings
2013-07-31 13:23 ` [79/84] xhci: fix null pointer dereference on ring_doorbell_for_active_rings Ben Hutchings
2013-07-31 13:23 ` [52/84] ata: Fix DVD not dectected at some platform with Wellsburg PCH Ben Hutchings
2013-07-31 13:23 ` [73/84] usb: option: add TP-LINK MA260 Ben Hutchings
2013-07-31 13:23 ` [77/84] xhci: Avoid NULL pointer deref when host dies Ben Hutchings
2013-07-31 13:23 ` [78/84] usb: host: xhci: Enable XHCI_SPURIOUS_SUCCESS for all controllers with xhci 1.0 Ben Hutchings
2013-07-31 13:23 ` [75/84] USB: ti_usb_3410_5052: fix dynamic-id matching Ben Hutchings
2013-07-31 13:23 ` [51/84] ALSA: hda - Add new GPU codec ID to snd-hda Ben Hutchings
2013-07-31 13:23 ` [10/84] ipv6,mcast: always hold idev->lock before mca_lock Ben Hutchings
2013-07-31 13:23 ` [17/84] 9p: fix off by one causing access violations and memory corruption Ben Hutchings
2013-07-31 13:23 ` [12/84] ipv6: call udp_push_pending_frames when uncorking a socket with AF_INET pending data Ben Hutchings
2013-07-31 13:23 ` [50/84] ALSA: hda - Add new GPU codec ID to snd-hda Ben Hutchings
2013-07-31 13:23 ` [71/84] staging: comedi: COMEDI_CANCEL ioctl should wake up read/write Ben Hutchings
2013-07-31 13:23 ` [07/84] neighbour: fix a race in neigh_destroy() Ben Hutchings
2013-07-31 13:23 ` [39/84] usb: dwc3: gadget: don't prevent gadget from being probed if we fail Ben Hutchings
2013-07-31 13:23 ` [03/84] macvtap: fix recovery from gup errors Ben Hutchings
2013-07-31 13:23 ` [30/84] fanotify: info leak in copy_event_to_user() Ben Hutchings
2013-07-31 13:23 ` [49/84] staging: line6: Fix unlocked snd_pcm_stop() call Ben Hutchings
2013-07-31 13:23 ` [25/84] sparc: tsb must be flushed before tlb Ben Hutchings
2013-07-31 13:23 ` [65/84] drm/radeon: fix combios tables on older cards Ben Hutchings
2013-07-31 13:23 ` [18/84] dummy: fix oops when loading the dummy failed Ben Hutchings
2013-07-31 13:23 ` [13/84] ipv6: ip6_append_data_mtu did not care about pmtudisc and frag_size Ben Hutchings
2013-07-31 13:23 ` [48/84] ASoC: s6000: Fix unlocked snd_pcm_stop() call Ben Hutchings
2013-07-31 13:23 ` [56/84] ALSA: usb-audio: 6fire: return correct XRUN indication Ben Hutchings
2013-07-31 13:23 ` [21/84] atl1e: unmap partially mapped skb on dma error and free skb Ben Hutchings
2013-07-31 13:23 ` [53/84] ACPI / video: ignore BIOS initial backlight value for Fujitsu E753 Ben Hutchings
2013-08-02 13:46   ` Luis Henriques
2013-08-02 14:24     ` Ben Hutchings
2013-07-31 13:23 ` Ben Hutchings [this message]
2013-07-31 13:23 ` [15/84] ifb: fix rcu_sched self-detected stalls Ben Hutchings
2013-07-31 13:23 ` [62/84] USB: cp210x: add MMB and PI ZigBee USB Device Support Ben Hutchings
2013-07-31 13:23 ` [23/84] sparc32: vm_area_struct access for old Sun SPARCs Ben Hutchings
2013-07-31 13:23 ` [28/84] virtio_net: fix race in RX VQ processing Ben Hutchings
2013-07-31 13:23 ` [08/84] x25: Fix broken locking in ioctl error paths Ben Hutchings
2013-07-31 13:23 ` [31/84] tracing: Use current_uid() for critical time tracing Ben Hutchings
2013-07-31 13:23 ` [06/84] sh_eth: fix unhandled RFE interrupt Ben Hutchings
2013-07-31 13:23 ` [11/84] l2tp: add missing .owner to struct pppox_proto Ben Hutchings
2013-07-31 13:23 ` [55/84] Btrfs: re-add root to dead root list if we stop dropping it Ben Hutchings
2013-07-31 13:23 ` [43/84] ALSA: 6fire: Fix unlocked snd_pcm_stop() call Ben Hutchings
2013-07-31 13:23 ` [68/84] [SCSI] sd: fix crash when UA received on DIF enabled device Ben Hutchings
2013-07-31 13:23 ` [20/84] atl1e: fix dma mapping warnings Ben Hutchings
2013-07-31 13:23 ` [33/84] xen/blkback: Check for insane amounts of request on the ring (v6) Ben Hutchings
2013-07-31 13:23 ` [63/84] drm/radeon: Another card with wrong primary dac adj Ben Hutchings
2013-07-31 13:23 ` [81/84] usb: serial: option: add Olivetti Olicard 200 Ben Hutchings
2013-07-31 13:23 ` [19/84] ifb: fix oops when loading the ifb failed Ben Hutchings
2013-07-31 13:23 ` [24/84] sparc64 address-congruence property Ben Hutchings
2013-07-31 13:23 ` [59/84] USB: misc: Add Manhattan Hi-Speed USB DVI Converter to sisusbvga Ben Hutchings
2013-07-31 13:23 ` [60/84] USB: option: append Petatel NP10T device to GSM modems list Ben Hutchings
2013-07-31 13:23 ` [58/84] USB: storage: Add MicroVault Flash Drive to unusual_devs Ben Hutchings
2013-07-31 13:23 ` [46/84] ALSA: usx2y: Fix unlocked snd_pcm_stop() call Ben Hutchings
2013-07-31 13:23 ` [76/84] usb: serial: option: Add ONYX 3G device support Ben Hutchings
2013-07-31 13:23 ` [14/84] sunvnet: vnet_port_remove must call unregister_netdev Ben Hutchings
2013-07-31 13:23 ` [09/84] net: Swap ver and type in pppoe_hdr Ben Hutchings
2013-07-31 13:23 ` [47/84] ALSA: pxa2xx: Fix unlocked snd_pcm_stop() call Ben Hutchings
2013-07-31 13:23 ` [69/84] nfsd: nfsd_open: when dentry_open returns an error do not propagate as struct file Ben Hutchings
2013-07-31 13:23 ` [57/84] usb: serial: cp210x: Add USB ID for Netgear Switches embedded serial adapter Ben Hutchings
2013-07-31 13:23 ` [82/84] usb: serial: option.c: remove ONDA MT825UP product ID fromdriver Ben Hutchings
2013-07-31 13:23 ` [27/84] virtio: support unlocked queue poll Ben Hutchings
2013-07-31 13:23 ` [34/84] ASoC: sglt5000: Fix the default value of CHIP_SSS_CTRL Ben Hutchings
2013-07-31 13:23 ` [61/84] usb: cp210x support SEL C662 Vendor/Device Ben Hutchings
2013-07-31 13:23 ` [80/84] usb: serial: option: blacklist ONDA MT689DC QMI interface Ben Hutchings
2013-07-31 13:23 ` [22/84] vlan: fix a race in egress prio management Ben Hutchings
2013-07-31 13:23 ` [67/84] [SCSI] qla2xxx: Properly set the tagging for commands Ben Hutchings
2013-08-01  9:30 ` [00/84] 3.2.50-rc1 review Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=lsq.1375276989.808474785@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome