All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: fix oom roll-back of __vmalloc_area_node
Date: Thu, 13 Jul 2006 09:38:38 +0200	[thread overview]
Message-ID: <44B5F87E.6020708@web.de> (raw)
In-Reply-To: <20060713001433.801fa304.akpm@osdl.org>

Andrew Morton wrote:

> On Tue, 11 Jul 2006 21:37:08 +0200
> Jan Kiszka <jan.kiszka@web.de> wrote:
>
>   
>> __vunmap must not rely on area->nr_pages when picking the
>> release methode for area->pages. It may be too small when
>> __vmalloc_area_node failed early due to lacking memory.
>> Instead, use a flag in vmstruct to differentiate.
>>     
>
> So you mean that when this:
>
> 		if (unlikely(!area->pages[i])) {
> 			/* Successfully allocated i pages, free them in __vunmap() */
> 			area->nr_pages = i;
> 			goto fail;
>
> happens, it could be that i <= PAGE_SIZE/sizeof(struct page *) and __vunmap
> kfree()s something which it should have vfree()d, yes?
>
>   

Yes, exactly. It then causes some BUG in kfree during unroll.


> That sounds like a dead box, or worse.
>
>   
Someone triggered a too large vmalloc request, that was the scenario here.

> I think the change would be a good one even if it didn't fix a bug, thanks.
>
>   
Meanwhile I thought about an even simpler solution:


__vunmap must not rely on area->nr_pages when picking the
release methode for area->pages. It may be too small when
__vmalloc_area_node failed due to lacking memory. Check
for the vmalloc address range instead.

Signed-off by: Jan Kiszka <jan.kiszka@web.de>

Index: linux-2.6/mm/vmalloc.c
===================================================================
--- linux-2.6.orig/mm/vmalloc.c
+++ linux-2.6/mm/vmalloc.c
@@ -340,7 +340,7 @@ void __vunmap(void *addr, int deallocate
 			__free_page(area->pages[i]);
 		}
 
-		if (area->nr_pages > PAGE_SIZE/sizeof(struct page *))
+		if (area->pages >= VMALLOC_START && area->pages < VMALLOC_END)
 			vfree(area->pages);
 		else
 			kfree(area->pages);



  reply	other threads:[~2006-07-13  7:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-11 19:37 [PATCH] mm: fix oom roll-back of __vmalloc_area_node Jan Kiszka
2006-07-13  7:14 ` Andrew Morton
2006-07-13  7:38   ` Jan Kiszka [this message]
2006-07-13  7:47     ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44B5F87E.6020708@web.de \
    --to=jan.kiszka@web.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.