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: <CAHA+R7OLnrujsinNhwVvZyJDz+BrTxYmw0gWeSSyq+dJ2LF9qg@mail.gmail.com>
Date:	Tue, 4 Feb 2014 10:25:33 -0800
From:	Cong Wang <cwang@...pensource.com>
To:	"Eric W. Biederman" <ebiederm@...ssion.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	linux-fsdevel@...r.kernel.org, netdev <netdev@...r.kernel.org>,
	linux-mm@...ck.org
Subject: Re: [PATCH] fdtable: Avoid triggering OOMs from alloc_fdmem

On Mon, Feb 3, 2014 at 9:26 PM, Eric W. Biederman <ebiederm@...ssion.com> wrote:
> diff --git a/fs/file.c b/fs/file.c
> index 771578b33fb6..db25c2bdfe46 100644
> --- a/fs/file.c
> +++ b/fs/file.c
> @@ -34,7 +34,7 @@ static void *alloc_fdmem(size_t size)
>          * vmalloc() if the allocation size will be considered "large" by the VM.
>          */
>         if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
> -               void *data = kmalloc(size, GFP_KERNEL|__GFP_NOWARN);
> +               void *data = kmalloc(size, GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY);
>                 if (data != NULL)
>                         return data;
>         }

Or try again without __GFP_NORETRY like we do in nelink mmap?

diff --git a/fs/file.c b/fs/file.c
index 771578b..5c7a7b5 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -29,16 +29,20 @@ int sysctl_nr_open_max = 1024 * 1024; /* raised later */

 static void *alloc_fdmem(size_t size)
 {
+       void *data;
        /*
         * Very large allocations can stress page reclaim, so fall back to
         * vmalloc() if the allocation size will be considered "large"
by the VM.
         */
        if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
-               void *data = kmalloc(size, GFP_KERNEL|__GFP_NOWARN);
+               data = kmalloc(size, GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY);
                if (data != NULL)
                        return data;
        }
-       return vmalloc(size);
+       data = vmalloc(size);
+       if (data != NULL)
+               return data;
+       return kmalloc(size, GFP_KERNEL|__GFP_NOWARN);
 }

 static void free_fdmem(void *ptr)
--
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