@@ -119,16 +119,22 @@ const char *get_wild_bug_type(struct kasan_access_info *info)
119119 return bug_type ;
120120}
121121
122+ static const char * get_bug_type (struct kasan_access_info * info )
123+ {
124+ if (addr_has_shadow (info ))
125+ return get_shadow_bug_type (info );
126+ return get_wild_bug_type (info );
127+ }
128+
122129static void print_error_description (struct kasan_access_info * info )
123130{
124- const char * bug_type = get_shadow_bug_type (info );
131+ const char * bug_type = get_bug_type (info );
125132
126133 pr_err ("BUG: KASAN: %s in %pS at addr %p\n" ,
127- bug_type , (void * )info -> ip ,
128- info -> access_addr );
134+ bug_type , (void * )info -> ip , info -> access_addr );
129135 pr_err ("%s of size %zu by task %s/%d\n" ,
130- info -> is_write ? "Write" : "Read" ,
131- info -> access_size , current -> comm , task_pid_nr (current ));
136+ info -> is_write ? "Write" : "Read" , info -> access_size ,
137+ current -> comm , task_pid_nr (current ));
132138}
133139
134140static inline bool kernel_or_module_addr (const void * addr )
@@ -295,17 +301,11 @@ static void kasan_report_error(struct kasan_access_info *info)
295301
296302 kasan_start_report (& flags );
297303
304+ print_error_description (info );
305+
298306 if (!addr_has_shadow (info )) {
299- const char * bug_type = get_wild_bug_type (info );
300- pr_err ("BUG: KASAN: %s on address %p\n" ,
301- bug_type , info -> access_addr );
302- pr_err ("%s of size %zu by task %s/%d\n" ,
303- info -> is_write ? "Write" : "Read" ,
304- info -> access_size , current -> comm ,
305- task_pid_nr (current ));
306307 dump_stack ();
307308 } else {
308- print_error_description (info );
309309 print_address_description (info );
310310 print_shadow_for_address (info -> first_bad_addr );
311311 }
0 commit comments