]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mm/slub: add taint after the errors are printed
authorGeorgi Djakov <quic_c_gdjako@quicinc.com>
Tue, 29 Jun 2021 02:34:58 +0000 (19:34 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 29 Jun 2021 17:53:47 +0000 (10:53 -0700)
When running the kernel with panic_on_taint, the usual slub debug error
messages are not being printed when object corruption happens.  That's
because we panic in add_taint(), which is called before printing the
additional information.  This is a bit unfortunate as the error messages
are actually very useful, especially before a panic.  Let's fix this by
moving add_taint() after the errors are printed on the console.

Link: https://lkml.kernel.org/r/1623860738-146761-1-git-send-email-quic_c_gdjako@quicinc.com
Signed-off-by: Georgi Djakov <quic_c_gdjako@quicinc.com>
Acked-by: Rafael Aquini <aquini@redhat.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Aaron Tomlin <atomlin@redhat.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/slub.c

index 70bb844a44d25c3f2b7751a023b55d2fb86f9faa..3bc8b940c933c68f7b65b81c3863f1df13210776 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -708,8 +708,6 @@ static void slab_bug(struct kmem_cache *s, char *fmt, ...)
        pr_err("=============================================================================\n");
        pr_err("BUG %s (%s): %pV\n", s->name, print_tainted(), &vaf);
        pr_err("-----------------------------------------------------------------------------\n\n");
-
-       add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
        va_end(args);
 }
 
@@ -790,6 +788,7 @@ void object_err(struct kmem_cache *s, struct page *page,
 
        slab_bug(s, "%s", reason);
        print_trailer(s, page, object);
+       add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
 }
 
 static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page,
@@ -807,6 +806,7 @@ static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page,
        slab_bug(s, "%s", buf);
        print_page_info(page);
        dump_stack();
+       add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
 }
 
 static void init_object(struct kmem_cache *s, void *object, u8 val)
@@ -858,6 +858,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page,
                                        fault, end - 1, fault - addr,
                                        fault[0], value);
        print_trailer(s, page, object);
+       add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
 
 skip_bug_print:
        restore_bytes(s, what, value, fault, end);