@@ -190,6 +190,34 @@ copy_iov_iter(void *ctx, long off, unsigned long arg, int argm, struct msg_gener
190190#define copy_iov_iter (ctx , orig_off , arg , argm , e ) 0
191191#endif /* __LARGE_BPF_PROG */
192192
193+ FUNC_INLINE bool is_read_arg_1 (long type )
194+ {
195+ switch (type ) {
196+ case iov_iter_type :
197+ case fd_ty :
198+ case filename_ty :
199+ case string_type :
200+ case net_dev_ty :
201+ case data_loc_type :
202+ case syscall64_type :
203+ case size_type :
204+ case s64_ty :
205+ case u64_ty :
206+ case int_type :
207+ case s32_ty :
208+ case u32_ty :
209+ case s16_ty :
210+ case u16_ty :
211+ case s8_ty :
212+ case u8_ty :
213+ case skb_type :
214+ case sock_type :
215+ case sockaddr_type :
216+ return true;
217+ }
218+ return false;
219+ }
220+
193221FUNC_INLINE long
194222__read_arg_1 (void * ctx , int type , long orig_off , unsigned long arg , int argm , char * args )
195223{
@@ -395,7 +423,7 @@ __read_arg_2(void *ctx, int type, long orig_off, unsigned long arg, int argm, ch
395423 * Returns the size of data appended to @args.
396424 */
397425FUNC_INLINE long
398- 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 )
399427{
400428 size_t min_size = type_to_min_size (type , argm );
401429 struct msg_generic_kprobe * e ;
@@ -422,6 +450,11 @@ read_arg(void *ctx, int index, int type, long orig_off, unsigned long arg, int a
422450 if (path_arg )
423451 return copy_path (args , path_arg );
424452
453+ if (process == __READ_ARG_1 )
454+ return __read_arg_1 (ctx , type , orig_off , arg , argm , args );
455+ if (process == __READ_ARG_2 )
456+ return __read_arg_2 (ctx , type , orig_off , arg , argm , args );
457+
425458 size = __read_arg_1 (ctx , type , orig_off , arg , argm , args );
426459 if (!size )
427460 size = __read_arg_2 (ctx , type , orig_off , arg , argm , args );
@@ -531,7 +564,8 @@ FUNC_INLINE long get_pt_regs_arg(struct pt_regs *ctx, struct event_config *confi
531564}
532565#endif /* __TARGET_ARCH_x86 && (GENERIC_KPROBE || GENERIC_UPROBE) */
533566
534- FUNC_INLINE long generic_read_arg (void * ctx , int index , long off , struct bpf_map_def * tailcals )
567+ FUNC_INLINE long generic_read_arg (void * ctx , int index , long off , struct bpf_map_def * tailcals ,
568+ int process )
535569{
536570 struct msg_generic_kprobe * e ;
537571 struct event_config * config ;
@@ -553,6 +587,13 @@ FUNC_INLINE long generic_read_arg(void *ctx, int index, long off, struct bpf_map
553587 ty = config -> arg [index ];
554588 am = config -> arm [index ];
555589
590+ #ifndef __LARGE_BPF_PROG
591+ #if defined(GENERIC_KPROBE ) || defined(GENERIC_UPROBE )
592+ if (!is_read_arg_1 (ty ) && process == __READ_ARG_1 )
593+ tail_call (ctx , tailcals , TAIL_CALL_PROCESS_2 );
594+ #endif
595+ #endif
596+
556597#if defined(GENERIC_TRACEPOINT ) || defined(GENERIC_USDT )
557598 a = (& e -> a0 )[index ];
558599 extract_arg (config , index , & a );
@@ -582,11 +623,11 @@ FUNC_INLINE long generic_read_arg(void *ctx, int index, long off, struct bpf_map
582623 return generic_path_offload (ctx , ty , a , index , off , tailcals );
583624#endif
584625
585- return read_arg (ctx , index , ty , off , a , am );
626+ return read_arg (ctx , index , ty , off , a , am , process );
586627}
587628
588629FUNC_INLINE int
589- generic_process_event (void * ctx , struct bpf_map_def * tailcals )
630+ generic_process_event (void * ctx , struct bpf_map_def * tailcals , int process )
590631{
591632 struct msg_generic_kprobe * e ;
592633 int index , zero = 0 ;
@@ -603,7 +644,7 @@ generic_process_event(void *ctx, struct bpf_map_def *tailcals)
603644 if (total < MAX_TOTAL ) {
604645 long errv ;
605646
606- errv = generic_read_arg (ctx , index , total , tailcals );
647+ errv = generic_read_arg (ctx , index , total , tailcals , process );
607648 if (errv > 0 )
608649 total += errv ;
609650 /* Follow filter lookup failed so lets abort the event.
@@ -1244,7 +1285,7 @@ FUNC_INLINE int generic_retprobe(void *ctx, struct bpf_map_def *calls, unsigned
12441285 ty_arg = config -> argreturn ;
12451286 do_copy = config -> argreturncopy ;
12461287 if (ty_arg ) {
1247- size += read_arg (ctx , 0 , ty_arg , size , ret , 0 );
1288+ size += read_arg (ctx , 0 , ty_arg , size , ret , 0 , __READ_ARG_ALL );
12481289#if defined(__LARGE_BPF_PROG ) && defined(GENERIC_KRETPROBE )
12491290 struct socket_owner owner ;
12501291
0 commit comments