@@ -400,6 +400,20 @@ static bool process_string(const char *fmt, int len, struct trace_event_call *ca
400400 return true;
401401}
402402
403+ static void handle_dereference_arg (const char * arg_str , u64 string_flags , int len ,
404+ u64 * dereference_flags , int arg ,
405+ struct trace_event_call * call )
406+ {
407+ if (string_flags & (1ULL << arg )) {
408+ if (process_string (arg_str , len , call ))
409+ * dereference_flags &= ~(1ULL << arg );
410+ } else if (process_pointer (arg_str , len , call ))
411+ * dereference_flags &= ~(1ULL << arg );
412+ else
413+ pr_warn ("TRACE EVENT ERROR: Bad dereference argument: '%.*s'\n" ,
414+ len , arg_str );
415+ }
416+
403417/*
404418 * Examine the print fmt of the event looking for unsafe dereference
405419 * pointers using %p* that could be recorded in the trace event and
@@ -563,11 +577,9 @@ static void test_event_printk(struct trace_event_call *call)
563577 }
564578
565579 if (dereference_flags & (1ULL << arg )) {
566- if (string_flags & (1ULL << arg )) {
567- if (process_string (fmt + start_arg , e - start_arg , call ))
568- dereference_flags &= ~(1ULL << arg );
569- } else if (process_pointer (fmt + start_arg , e - start_arg , call ))
570- dereference_flags &= ~(1ULL << arg );
580+ handle_dereference_arg (fmt + start_arg , string_flags ,
581+ e - start_arg ,
582+ & dereference_flags , arg , call );
571583 }
572584
573585 start_arg = i ;
@@ -578,11 +590,9 @@ static void test_event_printk(struct trace_event_call *call)
578590 }
579591
580592 if (dereference_flags & (1ULL << arg )) {
581- if (string_flags & (1ULL << arg )) {
582- if (process_string (fmt + start_arg , i - start_arg , call ))
583- dereference_flags &= ~(1ULL << arg );
584- } else if (process_pointer (fmt + start_arg , i - start_arg , call ))
585- dereference_flags &= ~(1ULL << arg );
593+ handle_dereference_arg (fmt + start_arg , string_flags ,
594+ i - start_arg ,
595+ & dereference_flags , arg , call );
586596 }
587597
588598 /*
0 commit comments