@@ -288,10 +288,6 @@ int sys_enter_rename(struct syscall_enter_args *args)
288288 augmented_args -> arg .size = PERF_ALIGN (oldpath_len + 1 , sizeof (u64 ));
289289 len += augmented_args -> arg .size ;
290290
291- /* Every read from userspace is limited to value size */
292- if (augmented_args -> arg .size > sizeof (augmented_args -> arg .value ))
293- return 1 ; /* Failure: don't filter */
294-
295291 struct augmented_arg * arg2 = (void * )& augmented_args -> arg .value + augmented_args -> arg .size ;
296292
297293 newpath_len = augmented_arg__read_str (arg2 , newpath_arg , sizeof (augmented_args -> arg .value ));
@@ -319,10 +315,6 @@ int sys_enter_renameat2(struct syscall_enter_args *args)
319315 augmented_args -> arg .size = PERF_ALIGN (oldpath_len + 1 , sizeof (u64 ));
320316 len += augmented_args -> arg .size ;
321317
322- /* Every read from userspace is limited to value size */
323- if (augmented_args -> arg .size > sizeof (augmented_args -> arg .value ))
324- return 1 ; /* Failure: don't filter */
325-
326318 struct augmented_arg * arg2 = (void * )& augmented_args -> arg .value + augmented_args -> arg .size ;
327319
328320 newpath_len = augmented_arg__read_str (arg2 , newpath_arg , sizeof (augmented_args -> arg .value ));
@@ -431,9 +423,8 @@ static bool pid_filter__has(struct pids_filtered *pids, pid_t pid)
431423static int augment_sys_enter (void * ctx , struct syscall_enter_args * args )
432424{
433425 bool augmented , do_output = false;
434- int zero = 0 , size , aug_size , index ,
426+ int zero = 0 , size , aug_size , index , output = 0 ,
435427 value_size = sizeof (struct augmented_arg ) - offsetof(struct augmented_arg , value );
436- u64 output = 0 ; /* has to be u64, otherwise it won't pass the verifier */
437428 unsigned int nr , * beauty_map ;
438429 struct beauty_payload_enter * payload ;
439430 void * arg , * payload_offset ;
@@ -499,25 +490,18 @@ static int augment_sys_enter(void *ctx, struct syscall_enter_args *args)
499490 }
500491 }
501492
502- /* Augmented data size is limited to sizeof(augmented_arg->unnamed union with value field) */
503- if (aug_size > value_size )
504- aug_size = value_size ;
505-
506493 /* write data to payload */
507494 if (augmented ) {
508495 int written = offsetof(struct augmented_arg , value ) + aug_size ;
509496
510- if (written < 0 || written > sizeof (struct augmented_arg ))
511- return 1 ;
512-
513497 ((struct augmented_arg * )payload_offset )-> size = aug_size ;
514498 output += written ;
515499 payload_offset += written ;
516500 do_output = true;
517501 }
518502 }
519503
520- if (!do_output || ( sizeof ( struct syscall_enter_args ) + output ) > sizeof ( struct beauty_payload_enter ) )
504+ if (!do_output )
521505 return 1 ;
522506
523507 return augmented__beauty_output (ctx , payload , sizeof (struct syscall_enter_args ) + output );
0 commit comments