netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] net/hyperv: Add support for vlan trunking from guests
@ 2012-03-12 20:20 Haiyang Zhang
  2012-03-12 20:20 ` [PATCH 1/2] net/hyperv: Fix data corruption in rndis_filter_receive() Haiyang Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Haiyang Zhang @ 2012-03-12 20:20 UTC (permalink / raw)
  To: haiyangz, kys, davem, netdev, linux-kernel, devel

This patch series add vlan trunking feature from guests. With this feature,
a Linux guest can now configure multiple vlans through a single synthetic
NIC on Win8 Hyper-V host.

Note: Both patches should go to the 'net-next' tree. The patch [1/2] is
required by the vlan trunking feature [2/2]. So they should go together.

The bug in rndis_filter_receive() does NOT happen until we start to use 
'per-packet-data' by the vlan trunking feature, so the bug fix [1/2] isn't
urgent to be applied into 'net' tree.


Haiyang Zhang (2):
  net/hyperv: Fix data corruption in rndis_filter_receive()
  net/hyperv: Add support for vlan trunking from guests

 drivers/net/hyperv/hyperv_net.h   |   34 +++++++++++++-
 drivers/net/hyperv/netvsc.c       |    3 +-
 drivers/net/hyperv/netvsc_drv.c   |    8 ++-
 drivers/net/hyperv/rndis_filter.c |   93 +++++++++++++++++++++++++++----------
 4 files changed, 110 insertions(+), 28 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 11+ messages in thread
* [PATCH 1/2] net/hyperv: Fix data corruption in rndis_filter_receive()
@ 2012-03-09 21:27 Haiyang Zhang
  2012-03-09 21:51 ` David Miller
  2012-03-11 22:51 ` David Miller
  0 siblings, 2 replies; 11+ messages in thread
From: Haiyang Zhang @ 2012-03-09 21:27 UTC (permalink / raw)
  To: haiyangz, kys, davem, netdev, linux-kernel, devel

Limiting the memcpy to be the sizeof(struct rndis_message) can truncate
the message if there are Per-Packet-Info or Out-of-Band data.

In my earlier patch (commit 45326342), the unnecessary kmap_atomic and
kunmap_atomic surrounding this memcpy have been removed because the memory
in the receive buffer is always mapped. This memcpy is not necessary
either. To fix the bug, I removed the memcpy.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/net/hyperv/rndis_filter.c |   33 +++++++++------------------------
 1 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 136efd8..0c3d7d9 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -352,8 +352,7 @@ int rndis_filter_receive(struct hv_device *dev,
 {
 	struct netvsc_device *net_dev = hv_get_drvdata(dev);
 	struct rndis_device *rndis_dev;
-	struct rndis_message rndis_msg;
-	struct rndis_message *rndis_hdr;
+	struct rndis_message *rndis_msg;
 	struct net_device *ndev;
 
 	if (!net_dev)
@@ -375,46 +374,32 @@ int rndis_filter_receive(struct hv_device *dev,
 		return -ENODEV;
 	}
 
-	rndis_hdr = pkt->data;
-
-	/* Make sure we got a valid rndis message */
-	if ((rndis_hdr->ndis_msg_type != REMOTE_NDIS_PACKET_MSG) &&
-	    (rndis_hdr->msg_len > sizeof(struct rndis_message))) {
-		netdev_err(ndev, "incoming rndis message buffer overflow "
-			   "detected (got %u, max %zu)..marking it an error!\n",
-			   rndis_hdr->msg_len,
-			   sizeof(struct rndis_message));
-	}
+	rndis_msg = pkt->data;
 
-	memcpy(&rndis_msg, rndis_hdr,
-		(rndis_hdr->msg_len > sizeof(struct rndis_message)) ?
-			sizeof(struct rndis_message) :
-			rndis_hdr->msg_len);
+	dump_rndis_message(dev, rndis_msg);
 
-	dump_rndis_message(dev, &rndis_msg);
-
-	switch (rndis_msg.ndis_msg_type) {
+	switch (rndis_msg->ndis_msg_type) {
 	case REMOTE_NDIS_PACKET_MSG:
 		/* data msg */
-		rndis_filter_receive_data(rndis_dev, &rndis_msg, pkt);
+		rndis_filter_receive_data(rndis_dev, rndis_msg, pkt);
 		break;
 
 	case REMOTE_NDIS_INITIALIZE_CMPLT:
 	case REMOTE_NDIS_QUERY_CMPLT:
 	case REMOTE_NDIS_SET_CMPLT:
 		/* completion msgs */
-		rndis_filter_receive_response(rndis_dev, &rndis_msg);
+		rndis_filter_receive_response(rndis_dev, rndis_msg);
 		break;
 
 	case REMOTE_NDIS_INDICATE_STATUS_MSG:
 		/* notification msgs */
-		rndis_filter_receive_indicate_status(rndis_dev, &rndis_msg);
+		rndis_filter_receive_indicate_status(rndis_dev, rndis_msg);
 		break;
 	default:
 		netdev_err(ndev,
 			"unhandled rndis message (type %u len %u)\n",
-			   rndis_msg.ndis_msg_type,
-			   rndis_msg.msg_len);
+			   rndis_msg->ndis_msg_type,
+			   rndis_msg->msg_len);
 		break;
 	}
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-03-13  0:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-12 20:20 [PATCH 0/2] net/hyperv: Add support for vlan trunking from guests Haiyang Zhang
2012-03-12 20:20 ` [PATCH 1/2] net/hyperv: Fix data corruption in rndis_filter_receive() Haiyang Zhang
2012-03-12 20:20 ` [PATCH 2/2] net/hyperv: Add support for vlan trunking from guests Haiyang Zhang
2012-03-13  0:06 ` [PATCH 0/2] " David Miller
  -- strict thread matches above, loose matches on Subject: below --
2012-03-09 21:27 [PATCH 1/2] net/hyperv: Fix data corruption in rndis_filter_receive() Haiyang Zhang
2012-03-09 21:51 ` David Miller
2012-03-09 21:55   ` Haiyang Zhang
2012-03-11 22:51 ` David Miller
2012-03-12 15:39   ` Haiyang Zhang
2012-03-12 19:51     ` David Miller
2012-03-12 19:52       ` Haiyang Zhang

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).