mm/slab.c: check pointer slabp before using it in alloc_slabmgmt()
Subsystems (2)
PATCH 1/1 mm/slab.c: check pointer slabp before using it in alloc_slabmgmt()
Move the NULL check of slabp to the right place before refer its memeber in function alloc_slabmgmt().
This bug may be introduced by rewriting of funcion kmemleak_scan_area(), the first parameter changed from slabp to &slabp->list.
--- mm/slab.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/slab.c +2 -2
@@ -2612,6 +2612,8 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,/* Slab management obj is off-slab. */ slabp =kmem_cache_alloc_node (cachep->slabp_cache, local_flags, nodeid); +if (!slabp) +return NULL ;/* * If the first object in the slab is leaked (it's allocated * but no one has a reference to it), we want to make sure
@@ -2620,8 +2622,6 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,*/ kmemleak_scan_area (&slabp->list,sizeof (struct list_head ), local_flags); -if (!slabp) -return NULL ; }else { slabp = objp + colour_off; colour_off += cachep->slab_size;
Signature · 1 line
1.8.3.4 (Apple Git-47)
Quoted 2 lines · ethan.zhao
Move the NULL check of slabp to the right place before refer its memeber in function
alloc_slabmgmt().
I am having trouble to find the code you are modifying. Which kernel release is this? The code you are referring to has been rewritten in the meantime or this is some other code basis.
Christoph,
Found in the latest stable release V3.12.3, yes, changed in
3.12.4. not needed for later release anymore.
Thanks,
Ethan
Quoted 9 lines · Christoph Lameter
Quoted 2 lines · ethan.zhao
Move the NULL check of slabp to the right place before refer its memeber in function
alloc_slabmgmt().I am having trouble to find the code you are modifying. Which kernel release is this? The code you are referring to has been rewritten in the meantime or this is some other code basis.
Christoph,
No, stable 3.12.4 and 3.12.3 need this patch. 3.13RC doesn't
need it anymore.
Thanks,
Ethan
Quoted 18 lines · Ethan Zhao
Christoph,
Found in the latest stable release V3.12.3, yes, changed in
3.12.4. not needed for later release anymore.Thanks,
EthanQuoted 9 lines · Christoph Lameter
Quoted 2 lines · ethan.zhao
Move the NULL check of slabp to the right place before refer its memeber in function
alloc_slabmgmt().I am having trouble to find the code you are modifying. Which kernel release is this? The code you are referring to has been rewritten in the meantime or this is some other code basis.
Quoted 2 lines · Ethan Zhao
No, stable 3.12.4 and 3.12.3 need this patch. 3.13RC doesn'tneed it anymore.
Hmmm.. Then this commit may have fixed it:
commit 0172f779e4314639a8ed440082cfe9e3450954e8
Author: Joonsoo Kim <[email protected]> Date: Wed Oct 30 19:04:00 2013 +0900
slab: fix to calm down kmemleak warning
After using struct page as slab management, we should not call kmemleak_scan_area(), since struct page isn't the tracking object of kmemleak. Without this patch and if CONFIG_DEBUG_KMEMLEAK is enabled, so many kmemleak warnings are printed.
mm/slab.c +0 -0
@@ -2531,14 +2531,6 @@ static struct freelist *alloc_slabmgmt(struct
kmem_cache *cachep,
/* Slab management obj is off-slab. */
freelist = kmem_cache_alloc_node(cachep->freelist_cache,
local_flags, nodeid);
- /*
- * If the first object in the slab is leaked (it's allocated
- * but no one has a reference to it), we want to make sure
- * kmemleak does not treat the ->s_mem pointer as a reference
- * to the object. Otherwise we will not report the leak.
- */
- kmemleak_scan_area(&page->lru, sizeof(struct list_head),
- local_flags);
if (!freelist)
return NULL;
} else {Quoted 6 lines · Christoph Lameter
Quoted 2 lines · Ethan Zhao
No, stable 3.12.4 and 3.12.3 need this patch. 3.13RC doesn'tneed it anymore.
Hmmm.. Then this commit may have fixed it:
Cross-threaded from [Re: Slab BUG with DEBUG_* options ]
Quoted 4 lines · Meelis Roos
ldata alloc change + your second slab patch + slab debug: hang on boot after
console [tty0] enabled, bootconsole disabled
(after that, I should see all the dmesg again on serial but I do not).
Meelis,
Please grab this patch below and see if it fixes your 'hang on boot' with Christoph's other slab patch + slab debug.
Regards,
Peter Hurley
Quoted 35 lines
commit
0172f779e4314639a8ed440082cfe9e3450954e8Author: Joonsoo Kim <[email protected]> Date: Wed Oct 30 19:04:00 2013 +0900slab: fix to calm down kmemleak warning
After using struct page as slab management, we should not call
kmemleak_scan_area(), since struct page isn't the tracking object of kmemleak. Without this patch and ifCONFIG_DEBUG_KMEMLEAKis enabled, so many kmemleak warnings are printed.Signed-off-by Joonsoo Kim <[email protected]>Signed-off-by Pekka Enberg <[email protected]>mm/slab.c +0
-8@@ -2531,14 +2531,6 @@ static struct freelist *alloc_slabmgmt(structkmem_cache *cachep,/* Slab management obj is off-slab. */ freelist =kmem_cache_alloc_node (cachep->freelist_cache, local_flags, nodeid); -/* -* If the first object in the slab is leaked (it's allocated -* but no one has a reference to it), we want to make sure -* kmemleak does not treat the ->s_mem pointer as a reference -* to the object. Otherwise we will not report the leak. -*/ -kmemleak_scan_area (&page->lru,sizeof (struct list_head ), - local_flags);if (!freelist)return NULL ;} else {
Quoted 15 lines
Quoted 6 lines · Ethan Zhao
Quoted 3 lines
No, stable 3.12.4 and 3.12.3 need this patch. 3.13RC doesn'tneed it anymore.
Hmmm.. Then this commit may have fixed it:
Cross-threaded from [Re: Slab BUG with DEBUG_* options ]
Quoted 4 lines · Meelis Roos
ldata alloc change + your second slab patch + slab debug: hang on boot after
console [tty0] enabled, bootconsole disabled
(after that, I should see all the dmesg again on serial but I do not).
Quoted 4 lines
Meelis,
Please grab this patch below and see if it fixes your 'hang on boot' with Christoph's other slab patch + slab debug.
Tried it on top of 3.12 + second slab patch + ldata alloc change, and lsab debug conf. No change - still hangs on boot.
Signature · 1 line
Meelis Roos ([email protected])
Quoted 2 lines · ethan.zhao
Move the NULL check of slabp to the right place before refer its memeber in function
alloc_slabmgmt().
Ok this patch is needed for 2.6.30 to 3.12