mm: kmemleak: slob: respect SLAB_NOLEAKTRACE flag
Subsystems (2)
PATCH 1/1 mm: kmemleak: slob: respect SLAB_NOLEAKTRACE flag
When kmemleak is enabled for SLOB, system does not boot and does not print anything to the console. At the very early stage in the boot process we hit infinite recursion from kmemleak_init() and eventually kernel crashes.kmemleak_init() specifies SLAB_NOLEAKTRACE for KMEM_CACHE(), but kmem_cache_create_usercopy() removes it because CACHE_CREATE_MASK is not valid for SLOB.
Let's fix CACHE_CREATE_MASK and make kmemleak work with SLOB
--- mm/slab.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/slab.h +1 -1
@@ -147,7 +147,7 @@ static inline slab_flags_t kmem_cache_flags(unsigned int object_size,#define SLAB_CACHE_FLAGS (SLAB_NOLEAKTRACE | SLAB_RECLAIM_ACCOUNT | \ SLAB_TEMPORARY | SLAB_ACCOUNT)#else -#define SLAB_CACHE_FLAGS (0) +#define SLAB_CACHE_FLAGS (SLAB_NOLEAKTRACE)#endif /* Common flags available with current configuration */
Signature · 1 line
2.30.2
Quoted 11 lines · Rustam Kovhaev
When kmemleak is enabled for SLOB, system does not boot and does not print anything to the console. At the very early stage in the boot process we hit infinite recursion from
kmemleak_init()and eventually kernel crashes.kmemleak_init()specifiesSLAB_NOLEAKTRACEforKMEM_CACHE(), butkmem_cache_create_usercopy()removes it becauseCACHE_CREATE_MASKis not valid for SLOB.
Let's fixCACHE_CREATE_MASKand make kmemleak work with SLOBFixes d8843922fba4 ("slab: Ignore internal flags in cache creation")Signed-off-by Rustam Kovhaev <[email protected]>
Quoted 18 lines
--- mm/slab.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/slab.h +1
-1@@ -147,7 +147,7 @@ static inline slab_flags_t kmem_cache_flags(unsigned int object_size,#define SLAB_CACHE_FLAGS (SLAB_NOLEAKTRACE | SLAB_RECLAIM_ACCOUNT | \ SLAB_TEMPORARY | SLAB_ACCOUNT)#else -#define SLAB_CACHE_FLAGS (0) +#define SLAB_CACHE_FLAGS (SLAB_NOLEAKTRACE)#endif /* Common flags available with current configuration */
Quoted 10 lines · Rustam Kovhaev
When kmemleak is enabled for SLOB, system does not boot and does not print anything to the console. At the very early stage in the boot process we hit infinite recursion from
kmemleak_init()and eventually kernel crashes.kmemleak_init()specifiesSLAB_NOLEAKTRACEforKMEM_CACHE(), butkmem_cache_create_usercopy()removes it becauseCACHE_CREATE_MASKis not valid for SLOB.
Let's fixCACHE_CREATE_MASKand make kmemleak work with SLOB
Quoted 2 lines
Fixes d8843922fba4 ("slab: Ignore internal flags in cache creation")Signed-off-by Rustam Kovhaev <[email protected]>
Thanks.