Skip to content

Commit 3864e4d

Browse files
committed
slab: don't validate slab pointer in free_debug_processing()
The struct slab pointer has been obtained from the object being freed on all the paths that lead to this function. In all cases this already includes the test for slab type of the struct page which struct slab is overlaying. Thus we would not reach this function if it was not a valid slab pointer in the first place. One less obvious case is that kmem_cache_free() trusts virt_to_slab() blindly so it may be NULL if the slab type check is false. But with SLAB_CONSISTENCY_CHECKS, cache_from_obj() called also from kmem_cache_free() catches this and returns NULL, which terminates freeing immediately. Reviewed-by: Harry Yoo <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent a21fe7b commit 3864e4d

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

mm/slub.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3492,11 +3492,6 @@ static inline bool free_debug_processing(struct kmem_cache *s,
34923492
int cnt = 0;
34933493

34943494
if (s->flags & SLAB_CONSISTENCY_CHECKS) {
3495-
if (!validate_slab_ptr(slab)) {
3496-
slab_err(s, slab, "Not a valid slab page");
3497-
goto out;
3498-
}
3499-
35003495
if (!check_slab(s, slab))
35013496
goto out;
35023497
}

0 commit comments

Comments
 (0)