@@ -391,14 +391,20 @@ extract_arg_depth(u32 i, struct extract_arg_data *data)
391391{
392392 if (i >= MAX_BTF_ARG_DEPTH || !data -> btf_config [i ].is_initialized )
393393 return 1 ;
394+ /* NULL pointer */
395+ if (* data -> arg == 0 ) {
396+ * data -> null_ptr_found = true;
397+ return 1 ;
398+ }
394399 * data -> arg = * data -> arg + data -> btf_config [i ].offset ;
395400 if (data -> btf_config [i ].is_pointer )
396401 probe_read ((void * )data -> arg , sizeof (char * ), (void * )* data -> arg );
397402 return 0 ;
398403}
399404
400405#ifdef __LARGE_BPF_PROG
401- FUNC_INLINE void extract_arg (struct event_config * config , int index , unsigned long * a )
406+ FUNC_INLINE void extract_arg (struct event_config * config , int index , unsigned long * a ,
407+ bool * null_ptr_found )
402408{
403409 struct config_btf_arg * btf_config ;
404410
@@ -413,6 +419,7 @@ FUNC_INLINE void extract_arg(struct event_config *config, int index, unsigned lo
413419 struct extract_arg_data extract_data = {
414420 .btf_config = btf_config ,
415421 .arg = a ,
422+ .null_ptr_found = null_ptr_found ,
416423 };
417424#ifndef __V61_BPF_PROG
418425#pragma unroll
@@ -426,7 +433,8 @@ FUNC_INLINE void extract_arg(struct event_config *config, int index, unsigned lo
426433 }
427434}
428435#else
429- FUNC_INLINE void extract_arg (struct event_config * config , int index , unsigned long * a ) {}
436+ FUNC_INLINE void extract_arg (struct event_config * config , int index , unsigned long * a ,
437+ bool * null_ptr_found ) {}
430438#endif /* __LARGE_BPF_PROG */
431439
432440FUNC_INLINE int arg_idx (int index )
@@ -471,9 +479,11 @@ FUNC_INLINE long generic_read_arg(void *ctx, int index, long off, struct bpf_map
471479 ty = config -> arg [index ];
472480 am = config -> arm [index ];
473481
482+ e -> resolve_null_ptr [index ] = false;
483+
474484#if defined(GENERIC_TRACEPOINT ) || defined(GENERIC_USDT )
475485 a = (& e -> a0 )[index ];
476- extract_arg (config , index , & a );
486+ extract_arg (config , index , & a , & e -> resolve_null_ptr [ index ] );
477487#else
478488 arg_index = config -> idx [index ];
479489 asm volatile ("%[arg_index] &= %1 ;\n"
@@ -491,7 +501,7 @@ FUNC_INLINE long generic_read_arg(void *ctx, int index, long off, struct bpf_map
491501 else
492502 a = (& e -> a0 )[arg_index ];
493503
494- extract_arg (config , index , & a );
504+ extract_arg (config , index , & a , & e -> resolve_null_ptr [ index ] );
495505
496506 if (should_offload_path (ty ))
497507 return generic_path_offload (ctx , ty , a , index , off , tailcals );
0 commit comments