- Fix memory corruption in slbq
PATCH 1/1 - Fix memory corruption in slbq
Fix memory corruption caused by slqb overrunning the end of the page allocated in kmem_cache_dyn_array_alloc() for initial caches.
--- mm/slqb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
mm/slqb.c +2 -3
@@ -2194,15 +2194,14 @@ static void *kmem_cache_dyn_array_alloc(* never get freed by definition so we can do it rather * simply. */ -if (!nextmem) { +if (!nextmem ||offset_in_page (nextmem) + size >PAGE_SIZE ) { nextmem =alloc_pages_exact (size,GFP_KERNEL );if (!nextmem)return NULL ; } ret = nextmem; nextmem = (void *)((unsigned long )ret + size); -if ((unsigned long )ret >>PAGE_SHIFT != - (unsigned long )nextmem >>PAGE_SHIFT ) +if (offset_in_page (ret) + size >=PAGE_SIZE ) nextmem =NULL ;memset (ret,0 , size);return ret;
Hi Jack,
(Please cc me when sending patches to SL*B.)
Quoted 22 lines · Jack Steiner
Fix memory corruption caused by slqb overrunning the end of the page allocated in
kmem_cache_dyn_array_alloc()for initial caches.Signed-off-by Jack Steiner <[email protected]>---
mm/slqb.c | 5 ++---1 file changed, 2 insertions(+), 3 deletions(-)Index:
linux/mm/slqb.c
===================================================================mm/slqb.c 2009-04-30 19:08:33.000000000 -0500 renamed from mm/slqb.c 2009-04-30 15:47:16.000000000 -0500 +1
-1@@ -2194,15 +2194,14 @@ static void *kmem_cache_dyn_array_alloc( * never get freed by definition so we can do it rather * simply. */ - if (!nextmem) { + if (!nextmem || offset_in_page(nextmem) + size > PAGE_SIZE) { nextmem = alloc_pages_exact(size, GFP_KERNEL); if (!nextmem)
mm/slqb.c 2009-04-30 19:08:33.000000000 -0500 static void *kmem_cache_dyn_array_alloc( · line 2207
Quoted 10 lines
mm/slqb.c 2009-04-30 19:08:33.000000000 -0500 renamed from mm/slqb.c 2009-04-30 15:47:16.000000000 -0500 +1
-2return NULL; } ret = nextmem; nextmem = (void *)((unsigned long)ret + size); - if ((unsigned long)ret >> PAGE_SHIFT != - (unsigned long)nextmem >> PAGE_SHIFT) + if (offset_in_page(ret) + size >= PAGE_SIZE) nextmem = NULL; memset(ret, 0, size); return ret;
I don't think this is needed now that commit 8804e6f ("SLQB: fix dumb early allocation cache") is merged:
Or do you still see the corruption with it?
Pekka
Quoted 7 lines
I don't think this is needed now that commit 8804e6f ("SLQB: fix dumb early allocation cache") is merged:
Or do you still see the corruption with it?
No. The above patch is an equivalent ( & better) fix. for the problem. You can ignore the patch that I sent.
--- jack
Hi Jack,
Quoted 9 lines · Jack Steiner
Quoted 6 lines
I don't think this is needed now that commit 8804e6f ("SLQB: fix dumb early allocation cache") is merged:
Or do you still see the corruption with it?
No. The above patch is an equivalent ( & better) fix. for the problem. You can ignore the patch that I sent.
OK, thanks for the patch anyway!
Pekka