[PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric Dumazet
Date: Friday, September 17, 2010 - 2:57 am

Amit, I noticed following bug in qlnic driver.

Also, skb->truesize should not be changed by drivers, unless dealing
with fragments.

When you have :
	skb->truesize = skb->len + sizeof(struct sk_buff);

you are lying to stack that can queue many "small" UDP packets,
accouting for small packets in socket rcvbuf, while the truesize was
really 1532 + sizeof(struct sk_buff)

Could you take a look ?

Thanks


[PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

qlcnic driver allocates rx skbs and gives to hardware too bytes of extra
storage, allowing for corruption of kernel data.

NET_IP_ALIGN being 0 on some platforms (including x86), drivers should
not assume it's 2.

rds_ring->skb_size = rds_ring->dma_size + NET_IP_ALIGN;
...
skb = dev_alloc_skb(rds_ring->skb_size);
skb_reserve(skb, 2);
pci_map_single(pdev, skb->data, rds_ring->dma_size, PCI_DMA_FROMDEVICE);

(and rds_ring->skb_size == rds_ring->dma_size) -> bug


Because of extra alignment (1500 + 32) -> four extra bytes are available
before the struct skb_shared_info, so corruption is not noticed.

Note: this driver could use netdev_alloc_skb_ip_align()

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
diff --git a/drivers/net/qlcnic/qlcnic_init.c b/drivers/net/qlcnic/qlcnic_init.c
index 75ba744..60ab753 100644
--- a/drivers/net/qlcnic/qlcnic_init.c
+++ b/drivers/net/qlcnic/qlcnic_init.c
@@ -1316,7 +1316,7 @@ qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter,
 		return -ENOMEM;
 	}
 
-	skb_reserve(skb, 2);
+	skb_reserve(skb, NET_IP_ALIGN);
 
 	dma = pci_map_single(pdev, skb->data,
 			rds_ring->dma_size, PCI_DMA_FROMDEVICE);


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCHv2 NEXT 0/5]qlcnic: vlan rx accleration support, Amit Kumar Salecha, (Thu Sep 16, 10:14 pm)
[PATCHv2 NEXT 1/5] qlcnic: support vlan rx accleration, Amit Kumar Salecha, (Thu Sep 16, 10:14 pm)
[PATCHv2 NEXT 4/5] qlcnic: remove fw version check, Amit Kumar Salecha, (Thu Sep 16, 10:14 pm)
[PATCHv2 NEXT 5/5] qlcnic: update version 5.0.10, Amit Kumar Salecha, (Thu Sep 16, 10:14 pm)
[PATCH] qlcnic: dont assume NET_IP_ALIGN is 2, Eric Dumazet, (Fri Sep 17, 2:57 am)
RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2, Amit Salecha, (Fri Sep 17, 3:53 am)
Re: [PATCHv2 NEXT 0/5]qlcnic: vlan rx accleration support, David Miller, (Fri Sep 17, 11:31 am)
Re: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2, David Miller, (Fri Sep 17, 10:58 pm)
RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2, Amit Salecha, (Mon Sep 20, 4:16 am)
RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2, Eric Dumazet, (Mon Sep 20, 5:18 am)
[PATCH net-next-2.6] qlnic: dont set skb-&gt;truesize, Eric Dumazet, (Mon Sep 20, 5:28 am)
Re: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2, David Miller, (Mon Sep 20, 8:58 am)
Re: [PATCH net-next-2.6] qlnic: dont set skb-&gt;truesize, David Miller, (Mon Sep 20, 10:09 am)
RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2, Amit Salecha, (Tue Sep 21, 1:19 am)
RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2, Eric Dumazet, (Tue Sep 21, 1:34 am)
RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2, Amit Salecha, (Tue Sep 21, 1:41 am)
RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2, Eric Dumazet, (Tue Sep 21, 2:23 am)
Re: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2, David Miller, (Tue Sep 21, 12:33 pm)
[PATCH] netxen: dont set skb-&gt;truesize, Eric Dumazet, (Tue Sep 21, 12:55 pm)
Re: [PATCH] netxen: dont set skb-&gt;truesize, David Miller, (Tue Sep 21, 1:04 pm)