@@ -1026,7 +1026,7 @@ static void slab_bug(struct kmem_cache *s, char *fmt, ...)
1026
1026
vaf .fmt = fmt ;
1027
1027
vaf .va = & args ;
1028
1028
pr_err ("=============================================================================\n" );
1029
- pr_err ("BUG %s (%s): %pV\n" , s -> name , print_tainted (), & vaf );
1029
+ pr_err ("BUG %s (%s): %pV\n" , s ? s -> name : "<unknown>" , print_tainted (), & vaf );
1030
1030
pr_err ("-----------------------------------------------------------------------------\n\n" );
1031
1031
va_end (args );
1032
1032
}
@@ -1085,8 +1085,6 @@ static void print_trailer(struct kmem_cache *s, struct slab *slab, u8 *p)
1085
1085
/* Beginning of the filler is the free pointer */
1086
1086
print_section (KERN_ERR , "Padding " , p + off ,
1087
1087
size_from_object (s ) - off );
1088
-
1089
- dump_stack ();
1090
1088
}
1091
1089
1092
1090
static void object_err (struct kmem_cache * s , struct slab * slab ,
@@ -1098,6 +1096,8 @@ static void object_err(struct kmem_cache *s, struct slab *slab,
1098
1096
slab_bug (s , "%s" , reason );
1099
1097
print_trailer (s , slab , object );
1100
1098
add_taint (TAINT_BAD_PAGE , LOCKDEP_NOW_UNRELIABLE );
1099
+
1100
+ WARN_ON (1 );
1101
1101
}
1102
1102
1103
1103
static bool freelist_corrupted (struct kmem_cache * s , struct slab * slab ,
@@ -1114,6 +1114,17 @@ static bool freelist_corrupted(struct kmem_cache *s, struct slab *slab,
1114
1114
return false;
1115
1115
}
1116
1116
1117
+ static void __slab_err (struct slab * slab )
1118
+ {
1119
+ if (slab_in_kunit_test ())
1120
+ return ;
1121
+
1122
+ print_slab_info (slab );
1123
+ add_taint (TAINT_BAD_PAGE , LOCKDEP_NOW_UNRELIABLE );
1124
+
1125
+ WARN_ON (1 );
1126
+ }
1127
+
1117
1128
static __printf (3 , 4 ) void slab_err (struct kmem_cache * s , struct slab * slab ,
1118
1129
const char * fmt , ...)
1119
1130
{
@@ -1127,9 +1138,7 @@ static __printf(3, 4) void slab_err(struct kmem_cache *s, struct slab *slab,
1127
1138
vsnprintf (buf , sizeof (buf ), fmt , args );
1128
1139
va_end (args );
1129
1140
slab_bug (s , "%s" , buf );
1130
- print_slab_info (slab );
1131
- dump_stack ();
1132
- add_taint (TAINT_BAD_PAGE , LOCKDEP_NOW_UNRELIABLE );
1141
+ __slab_err (slab );
1133
1142
}
1134
1143
1135
1144
static void init_object (struct kmem_cache * s , void * object , u8 val )
@@ -1302,9 +1311,10 @@ slab_pad_check(struct kmem_cache *s, struct slab *slab)
1302
1311
while (end > fault && end [-1 ] == POISON_INUSE )
1303
1312
end -- ;
1304
1313
1305
- slab_err ( s , slab , "Padding overwritten. 0x%p-0x%p @offset=%tu" ,
1306
- fault , end - 1 , fault - start );
1314
+ slab_bug ( s , "Padding overwritten. 0x%p-0x%p @offset=%tu" ,
1315
+ fault , end - 1 , fault - start );
1307
1316
print_section (KERN_ERR , "Padding " , pad , remainder );
1317
+ __slab_err (slab );
1308
1318
1309
1319
restore_bytes (s , "slab padding" , POISON_INUSE , fault , end );
1310
1320
}
@@ -1620,12 +1630,12 @@ static inline int free_consistency_checks(struct kmem_cache *s,
1620
1630
slab_err (s , slab , "Attempt to free object(0x%p) outside of slab" ,
1621
1631
object );
1622
1632
} else if (!slab -> slab_cache ) {
1623
- pr_err ("SLUB <none>: no slab for object 0x%p.\n" ,
1624
- object );
1625
- dump_stack ();
1626
- } else
1633
+ slab_err (NULL , slab , "No slab cache for object 0x%p" ,
1634
+ object );
1635
+ } else {
1627
1636
object_err (s , slab , object ,
1628
- "page slab pointer corrupt." );
1637
+ "page slab pointer corrupt." );
1638
+ }
1629
1639
return 0 ;
1630
1640
}
1631
1641
return 1 ;
@@ -5728,14 +5738,14 @@ static int calculate_sizes(struct kmem_cache_args *args, struct kmem_cache *s)
5728
5738
return !!oo_objects (s -> oo );
5729
5739
}
5730
5740
5731
- static void list_slab_objects (struct kmem_cache * s , struct slab * slab ,
5732
- const char * text )
5741
+ static void list_slab_objects (struct kmem_cache * s , struct slab * slab )
5733
5742
{
5734
5743
#ifdef CONFIG_SLUB_DEBUG
5735
5744
void * addr = slab_address (slab );
5736
5745
void * p ;
5737
5746
5738
- slab_err (s , slab , text , s -> name );
5747
+ if (!slab_add_kunit_errors ())
5748
+ slab_bug (s , "Objects remaining on __kmem_cache_shutdown()" );
5739
5749
5740
5750
spin_lock (& object_map_lock );
5741
5751
__fill_map (object_map , s , slab );
@@ -5750,6 +5760,8 @@ static void list_slab_objects(struct kmem_cache *s, struct slab *slab,
5750
5760
}
5751
5761
}
5752
5762
spin_unlock (& object_map_lock );
5763
+
5764
+ __slab_err (slab );
5753
5765
#endif
5754
5766
}
5755
5767
@@ -5770,8 +5782,7 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n)
5770
5782
remove_partial (n , slab );
5771
5783
list_add (& slab -> slab_list , & discard );
5772
5784
} else {
5773
- list_slab_objects (s , slab ,
5774
- "Objects remaining in %s on __kmem_cache_shutdown()" );
5785
+ list_slab_objects (s , slab );
5775
5786
}
5776
5787
}
5777
5788
spin_unlock_irq (& n -> list_lock );
0 commit comments