@@ -423,7 +423,7 @@ __read_arg_2(void *ctx, int type, long orig_off, unsigned long arg, int argm, ch
423423 * Returns the size of data appended to @args.
424424 */
425425FUNC_INLINE long
426- read_arg (void * ctx , int index , int type , long orig_off , unsigned long arg , int argm )
426+ read_arg (void * ctx , int index , int type , long orig_off , unsigned long arg , int argm , int process )
427427{
428428 size_t min_size = type_to_min_size (type , argm );
429429 struct msg_generic_kprobe * e ;
@@ -449,6 +449,16 @@ read_arg(void *ctx, int index, int type, long orig_off, unsigned long arg, int a
449449 if (path_arg )
450450 return copy_path (args , path_arg );
451451
452+ /*
453+ * Separate argument processing based on the process const
454+ * for 4.19 kernels..
455+ */
456+ if (process == __READ_ARG_1 )
457+ return __read_arg_1 (ctx , type , orig_off , arg , argm , args );
458+ if (process == __READ_ARG_2 )
459+ return __read_arg_2 (ctx , type , orig_off , arg , argm , args );
460+
461+ /* .. and the rest of the world */
452462 if (is_read_arg_1 (type ))
453463 return __read_arg_1 (ctx , type , orig_off , arg , argm , args );
454464 else
@@ -558,7 +568,8 @@ FUNC_INLINE long get_pt_regs_arg(struct pt_regs *ctx, struct event_config *confi
558568}
559569#endif /* __TARGET_ARCH_x86 && (GENERIC_KPROBE || GENERIC_UPROBE) */
560570
561- FUNC_INLINE long generic_read_arg (void * ctx , int index , long off , struct bpf_map_def * tailcals )
571+ FUNC_INLINE long generic_read_arg (void * ctx , int index , long off , struct bpf_map_def * tailcals ,
572+ int process )
562573{
563574 struct msg_generic_kprobe * e ;
564575 struct event_config * config ;
@@ -580,6 +591,13 @@ FUNC_INLINE long generic_read_arg(void *ctx, int index, long off, struct bpf_map
580591 ty = config -> arg [index ];
581592 am = config -> arm [index ];
582593
594+ #ifndef __LARGE_BPF_PROG
595+ #if defined(GENERIC_KPROBE ) || defined(GENERIC_UPROBE )
596+ if (!is_read_arg_1 (ty ) && process == __READ_ARG_1 )
597+ tail_call (ctx , tailcals , TAIL_CALL_PROCESS_2 );
598+ #endif
599+ #endif
600+
583601#if defined(GENERIC_TRACEPOINT ) || defined(GENERIC_USDT )
584602 a = (& e -> a0 )[index ];
585603 extract_arg (config , index , & a );
@@ -609,11 +627,11 @@ FUNC_INLINE long generic_read_arg(void *ctx, int index, long off, struct bpf_map
609627 return generic_path_offload (ctx , ty , a , index , off , tailcals );
610628#endif
611629
612- return read_arg (ctx , index , ty , off , a , am );
630+ return read_arg (ctx , index , ty , off , a , am , process );
613631}
614632
615633FUNC_INLINE int
616- generic_process_event (void * ctx , struct bpf_map_def * tailcals )
634+ generic_process_event (void * ctx , struct bpf_map_def * tailcals , int process )
617635{
618636 struct msg_generic_kprobe * e ;
619637 int index , zero = 0 ;
@@ -630,7 +648,7 @@ generic_process_event(void *ctx, struct bpf_map_def *tailcals)
630648 if (total < MAX_TOTAL ) {
631649 long errv ;
632650
633- errv = generic_read_arg (ctx , index , total , tailcals );
651+ errv = generic_read_arg (ctx , index , total , tailcals , process );
634652 if (errv > 0 )
635653 total += errv ;
636654 /* Follow filter lookup failed so lets abort the event.
@@ -1271,7 +1289,7 @@ FUNC_INLINE int generic_retprobe(void *ctx, struct bpf_map_def *calls, unsigned
12711289 ty_arg = config -> argreturn ;
12721290 do_copy = config -> argreturncopy ;
12731291 if (ty_arg ) {
1274- size += read_arg (ctx , 0 , ty_arg , size , ret , 0 );
1292+ size += read_arg (ctx , 0 , ty_arg , size , ret , 0 , __READ_ARG_ALL );
12751293#if defined(__LARGE_BPF_PROG ) && defined(GENERIC_KRETPROBE )
12761294 struct socket_owner owner ;
12771295
0 commit comments