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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <3dd566e33bcf1fc1ff9d3c0ba67b697e7df00ec6.1310339688.git.mirq-linux@rere.qmqm.pl>
Date:	Mon, 11 Jul 2011 02:52:50 +0200 (CEST)
From:	Michał Mirosław <mirq-linux@...e.qmqm.pl>
To:	netdev@...r.kernel.org
Subject: [PATCH v2 14/46] net: sunbmac: cleanup magic '34'

Offset of 34 bytes (32+2) after aligning the skb->data to 64 looks
suspicious. Remove the alignment, and use NET_IP_ALIGN instead of the magic.

Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
---
 drivers/net/sunbmac.c |   32 ++++++++++++++------------------
 1 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index e28d3ea..efc5389 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -228,24 +228,21 @@ static void bigmac_init_rings(struct bigmac *bp, int from_irq)
 	for (i = 0; i < RX_RING_SIZE; i++) {
 		struct sk_buff *skb;
 
-		skb = __netdev_alloc_skb_aligned(dev,
-						 RX_BUF_ALLOC_SIZE,
-						 SUNBMAC_RX_ALIGNMENT,
-						 gfp_flags);
+		skb = __netdev_alloc_skb(dev, RX_BUF_ALLOC_SIZE,
+					 gfp_flags);
 		if (!skb)
 			continue;
 
 		bp->rx_skbs[i] = skb;
-
-		skb_reserve(skb, 34);
+		skb_reserve(skb, NET_IP_ALIGN);
 
 		bb->be_rxd[i].rx_addr =
 			dma_map_single(&bp->bigmac_op->dev,
 				       skb->data,
-				       RX_BUF_ALLOC_SIZE - 34,
+				       RX_BUF_ALLOC_SIZE - NET_IP_ALIGN,
 				       DMA_FROM_DEVICE);
 		bb->be_rxd[i].rx_flags =
-			(RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH));
+			(RXD_OWN | ((RX_BUF_ALLOC_SIZE - NET_IP_ALIGN) & RXD_LENGTH));
 	}
 
 	for (i = 0; i < TX_RING_SIZE; i++)
@@ -820,7 +817,7 @@ static void bigmac_rx(struct bigmac *bp)
 			/* Return it to the BigMAC. */
 			bp->enet_stats.rx_dropped++;
 			this->rx_flags =
-				(RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH));
+				(RXD_OWN | ((RX_BUF_ALLOC_SIZE - NET_IP_ALIGN) & RXD_LENGTH));
 			goto next;
 		}
 		skb = bp->rx_skbs[elem];
@@ -828,27 +825,26 @@ static void bigmac_rx(struct bigmac *bp)
 			struct sk_buff *new_skb;
 
 			/* Now refill the entry, if we can. */
-			new_skb = __netdev_alloc_skb_aligned(dev,
-							     RX_BUF_ALLOC_SIZE,
-							     SUNBMAC_RX_ALIGNMENT,
-							     GFP_ATOMIC);
+			new_skb = __netdev_alloc_skb(dev,
+						     RX_BUF_ALLOC_SIZE,
+						     GFP_ATOMIC);
 			if (new_skb == NULL) {
 				drops++;
 				goto drop_it;
 			}
 			dma_unmap_single(&bp->bigmac_op->dev,
 					 this->rx_addr,
-					 RX_BUF_ALLOC_SIZE - 34,
+					 RX_BUF_ALLOC_SIZE - NET_IP_ALIGN,
 					 DMA_FROM_DEVICE);
 			bp->rx_skbs[elem] = new_skb;
-			skb_reserve(new_skb, 34);
+			skb_reserve(new_skb, NET_IP_ALIGN);
 			this->rx_addr =
 				dma_map_single(&bp->bigmac_op->dev,
 					       new_skb->data,
-					       RX_BUF_ALLOC_SIZE - 34,
+					       RX_BUF_ALLOC_SIZE - NET_IP_ALIGN,
 					       DMA_FROM_DEVICE);
 			this->rx_flags =
-				(RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH));
+				(RXD_OWN | ((RX_BUF_ALLOC_SIZE - NET_IP_ALIGN) & RXD_LENGTH));
 
 			skb_put(skb, len);
 		} else {
@@ -870,7 +866,7 @@ static void bigmac_rx(struct bigmac *bp)
 
 			/* Reuse original ring buffer. */
 			this->rx_flags =
-				(RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH));
+				(RXD_OWN | ((RX_BUF_ALLOC_SIZE - NET_IP_ALIGN) & RXD_LENGTH));
 
 			skb = copy_skb;
 		}
-- 
1.7.5.4

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