lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 9 Mar 2010 17:42:17 -0800
From:	Stephen Hemminger <shemminger@...tta.com>
To:	Hank Janssen <hjanssen@...rosoft.com>, Greg KH <gregkh@...e.de>
Cc:	netdev@...r.kernel.org
Subject: [PATCH 2/2] hv: handle skb allocation failure

Some fixes to receive handling:
  * Dieing with assertion failure when running out of memory is not ok
  * Use newer alloc function to get aligned skb
  * Dropped statistic is supposed to be incremented only by
    driver it was responsible for the drop.

Compile tested only.

Signed-off-by: Stephen Hemminger <shemminger@...tta.com>

---
 drivers/staging/hv/netvsc_drv.c |   32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

--- a/drivers/staging/hv/netvsc_drv.c	2010-03-09 17:27:57.263312289 -0800
+++ b/drivers/staging/hv/netvsc_drv.c	2010-03-09 17:34:45.012686682 -0800
@@ -292,7 +292,6 @@ static int netvsc_recv_callback(struct h
 	struct net_device_context *net_device_ctx;
 	struct sk_buff *skb;
 	void *data;
-	int ret;
 	int i;
 	unsigned long flags;
 
@@ -306,12 +305,12 @@ static int netvsc_recv_callback(struct h
 
 	net_device_ctx = netdev_priv(net);
 
-	/* Allocate a skb - TODO preallocate this */
-	/* Pad 2-bytes to align IP header to 16 bytes */
-	skb = dev_alloc_skb(packet->TotalDataBufferLength + 2);
-	ASSERT(skb);
-	skb_reserve(skb, 2);
-	skb->dev = net;
+	/* Allocate a skb - TODO direct I/O to pages? */
+	skb = netdev_alloc_skb_ip_align(net, packet->TotalDataBufferLength);
+	if (unlikely(!skb)) {
+		++net->stats.rx_dropped;
+		return 0;
+	}
 
 	/* for kmap_atomic */
 	local_irq_save(flags);
@@ -336,25 +335,18 @@ static int netvsc_recv_callback(struct h
 	local_irq_restore(flags);
 
 	skb->protocol = eth_type_trans(skb, net);
-
 	skb->ip_summed = CHECKSUM_NONE;
 
+	net->stats.rx_packets++;
+	net->stats.rx_bytes += skb->len;
+
 	/*
 	 * Pass the skb back up. Network stack will deallocate the skb when it
-	 * is done
+	 * is done.
+	 * TODO - use NAPI?
 	 */
-	ret = netif_rx(skb);
-
-	switch (ret) {
-	case NET_RX_DROP:
-		net->stats.rx_dropped++;
-		break;
-	default:
-		net->stats.rx_packets++;
-		net->stats.rx_bytes += skb->len;
-		break;
+	netif_rx(skb);
 
-	}
 	DPRINT_DBG(NETVSC_DRV, "# of recvs %lu total size %lu",
 		   net->stats.rx_packets, net->stats.rx_bytes);
 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ