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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 11 Mar 2015 13:23:14 -0700
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Martin Lau <kafai@...com>
Cc:	Amir Vadai <amirv@...lanox.com>,
	Or Gerlitz <ogerlitz@...lanox.com>, netdev@...r.kernel.org,
	kernel-team@...com
Subject: Re: [Question] net/mlx4_en: Memory consumption issue with mlx4_en
 driver

On Wed, 2015-03-11 at 13:21 -0700, Eric Dumazet wrote:

> You know, even the order-3 allocations done for regular skb allocations
> will hurt you : a single copybreaked skb stored a long time in a tcp
> receive queue will hold 32KB of memory.
> 
> Even 4KB can lead to disasters.
> 
> You could lower tcp_rmem so that collapsing happens sooner.

I also played with following :

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 6af09a597d4f..118568267a2a 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -458,10 +458,17 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
                                   unsigned int length, gfp_t gfp_mask)
 {
        struct sk_buff *skb = NULL;
-       unsigned int fragsz = SKB_DATA_ALIGN(length + NET_SKB_PAD) +
-                             SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
+       unsigned int fragsz;
 
-       if (fragsz <= PAGE_SIZE && !(gfp_mask & (__GFP_WAIT | GFP_DMA))) {
+       length = SKB_DATA_ALIGN(length + NET_SKB_PAD);
+       fragsz = length + SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
+       /* if fragment is smaller than struct skb_shared_info overhead,
+        * do not bother use a page fragment, because malicious traffic
+        * could hold a full page (order-0 or order-3)
+        */
+       if (fragsz <= PAGE_SIZE &&
+           length > SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) &&
+           !(gfp_mask & (__GFP_WAIT | GFP_DMA))) {
                void *data;
 
                if (sk_memalloc_socks())



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