Skip to content

Commit 4a36fda

Browse files
keesgregkh
authored andcommitted
mm/slub: clarify verification reporting
commit 8669dba upstream. Patch series "Actually fix freelist pointer vs redzoning", v4. This fixes redzoning vs the freelist pointer (both for middle-position and very small caches). Both are "theoretical" fixes, in that I see no evidence of such small-sized caches actually be used in the kernel, but that's no reason to let the bugs continue to exist, especially since people doing local development keep tripping over it. :) This patch (of 3): Instead of repeating "Redzone" and "Poison", clarify which sides of those zones got tripped. Additionally fix column alignment in the trailer. Before: BUG test (Tainted: G B ): Redzone overwritten ... Redzone (____ptrval____): bb bb bb bb bb bb bb bb ........ Object (____ptrval____): f6 f4 a5 40 1d e8 ...@.. Redzone (____ptrval____): 1a aa .. Padding (____ptrval____): 00 00 00 00 00 00 00 00 ........ After: BUG test (Tainted: G B ): Right Redzone overwritten ... Redzone (____ptrval____): bb bb bb bb bb bb bb bb ........ Object (____ptrval____): f6 f4 a5 40 1d e8 ...@.. Redzone (____ptrval____): 1a aa .. Padding (____ptrval____): 00 00 00 00 00 00 00 00 ........ The earlier commits that slowly resulted in the "Before" reporting were: d86bd1b ("mm/slub: support left redzone") ffc79d2 ("slub: use print_hex_dump") 2492268 ("SLUB: change error reporting format to follow lockdep loosely") Link: https://lkml.kernel.org/r/20210608183955.280836-1-keescook@chromium.org Link: https://lkml.kernel.org/r/20210608183955.280836-2-keescook@chromium.org Link: https://lore.kernel.org/lkml/cfdb11d7-fb8e-e578-c939-f7f5fb69a6bd@suse.cz/ Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Marco Elver <elver@google.com> Cc: "Lin, Zhenpeng" <zplin@psu.edu> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: David Rientjes <rientjes@google.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Roman Gushchin <guro@fb.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 12eb3c2 commit 4a36fda

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

‎Documentation/vm/slub.rst‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,18 @@ SLUB Debug output
181181
Here is a sample of slub debug output::
182182

183183
====================================================================
184-
BUG kmalloc-8: Redzone overwritten
184+
BUG kmalloc-8: Right Redzone overwritten
185185
--------------------------------------------------------------------
186186

187187
INFO: 0xc90f6d28-0xc90f6d2b. First byte 0x00 instead of 0xcc
188188
INFO: Slab 0xc528c530 flags=0x400000c3 inuse=61 fp=0xc90f6d58
189189
INFO: Object 0xc90f6d20 @offset=3360 fp=0xc90f6d58
190190
INFO: Allocated in get_modalias+0x61/0xf5 age=53 cpu=1 pid=554
191191

192-
Bytes b4 0xc90f6d10: 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ
193-
Object 0xc90f6d20: 31 30 31 39 2e 30 30 35 1019.005
194-
Redzone 0xc90f6d28: 00 cc cc cc .
195-
Padding 0xc90f6d50: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ
192+
Bytes b4 (0xc90f6d10): 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ
193+
Object (0xc90f6d20): 31 30 31 39 2e 30 30 35 1019.005
194+
Redzone (0xc90f6d28): 00 cc cc cc .
195+
Padding (0xc90f6d50): 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ
196196

197197
[<c010523d>] dump_trace+0x63/0x1eb
198198
[<c01053df>] show_trace_log_lvl+0x1a/0x2f

‎mm/slub.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -698,15 +698,15 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p)
698698
p, p - addr, get_freepointer(s, p));
699699

700700
if (s->flags & SLAB_RED_ZONE)
701-
print_section(KERN_ERR, "Redzone ", p - s->red_left_pad,
701+
print_section(KERN_ERR, "Redzone ", p - s->red_left_pad,
702702
s->red_left_pad);
703703
else if (p > addr + 16)
704704
print_section(KERN_ERR, "Bytes b4 ", p - 16, 16);
705705

706-
print_section(KERN_ERR, "Object ", p,
706+
print_section(KERN_ERR, "Object ", p,
707707
min_t(unsigned int, s->object_size, PAGE_SIZE));
708708
if (s->flags & SLAB_RED_ZONE)
709-
print_section(KERN_ERR, "Redzone ", p + s->object_size,
709+
print_section(KERN_ERR, "Redzone ", p + s->object_size,
710710
s->inuse - s->object_size);
711711

712712
off = get_info_end(s);
@@ -718,7 +718,7 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p)
718718

719719
if (off != size_from_object(s))
720720
/* Beginning of the filler is the free pointer */
721-
print_section(KERN_ERR, "Padding ", p + off,
721+
print_section(KERN_ERR, "Padding ", p + off,
722722
size_from_object(s) - off);
723723

724724
dump_stack();
@@ -895,11 +895,11 @@ static int check_object(struct kmem_cache *s, struct page *page,
895895
u8 *endobject = object + s->object_size;
896896

897897
if (s->flags & SLAB_RED_ZONE) {
898-
if (!check_bytes_and_report(s, page, object, "Redzone",
898+
if (!check_bytes_and_report(s, page, object, "Left Redzone",
899899
object - s->red_left_pad, val, s->red_left_pad))
900900
return 0;
901901

902-
if (!check_bytes_and_report(s, page, object, "Redzone",
902+
if (!check_bytes_and_report(s, page, object, "Right Redzone",
903903
endobject, val, s->inuse - s->object_size))
904904
return 0;
905905
} else {
@@ -914,7 +914,7 @@ static int check_object(struct kmem_cache *s, struct page *page,
914914
if (val != SLUB_RED_ACTIVE && (s->flags & __OBJECT_POISON) &&
915915
(!check_bytes_and_report(s, page, p, "Poison", p,
916916
POISON_FREE, s->object_size - 1) ||
917-
!check_bytes_and_report(s, page, p, "Poison",
917+
!check_bytes_and_report(s, page, p, "End Poison",
918918
p + s->object_size - 1, POISON_END, 1)))
919919
return 0;
920920
/*

0 commit comments

Comments
 (0)