@@ -10428,22 +10428,13 @@ static int check_struct_ops_btf_id(struct bpf_verifier_env *env)
10428
10428
}
10429
10429
#define SECURITY_PREFIX "security_"
10430
10430
10431
- static int check_attach_modify_return (struct bpf_verifier_env * env )
10431
+ static int check_attach_modify_return (struct bpf_prog * prog , unsigned long addr )
10432
10432
{
10433
- struct bpf_prog * prog = env -> prog ;
10434
- unsigned long addr = (unsigned long ) prog -> aux -> trampoline -> func .addr ;
10435
-
10436
- /* This is expected to be cleaned up in the future with the KRSI effort
10437
- * introducing the LSM_HOOK macro for cleaning up lsm_hooks.h.
10438
- */
10439
10433
if (within_error_injection_list (addr ) ||
10440
10434
!strncmp (SECURITY_PREFIX , prog -> aux -> attach_func_name ,
10441
10435
sizeof (SECURITY_PREFIX ) - 1 ))
10442
10436
return 0 ;
10443
10437
10444
- verbose (env , "fmod_ret attach_btf_id %u (%s) is not modifiable\n" ,
10445
- prog -> aux -> attach_btf_id , prog -> aux -> attach_func_name );
10446
-
10447
10438
return - EINVAL ;
10448
10439
}
10449
10440
@@ -10654,11 +10645,18 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
10654
10645
goto out ;
10655
10646
}
10656
10647
}
10648
+
10649
+ if (prog -> expected_attach_type == BPF_MODIFY_RETURN ) {
10650
+ ret = check_attach_modify_return (prog , addr );
10651
+ if (ret )
10652
+ verbose (env , "%s() is not modifiable\n" ,
10653
+ prog -> aux -> attach_func_name );
10654
+ }
10655
+
10656
+ if (ret )
10657
+ goto out ;
10657
10658
tr -> func .addr = (void * )addr ;
10658
10659
prog -> aux -> trampoline = tr ;
10659
-
10660
- if (prog -> expected_attach_type == BPF_MODIFY_RETURN )
10661
- ret = check_attach_modify_return (env );
10662
10660
out :
10663
10661
mutex_unlock (& tr -> mutex );
10664
10662
if (ret )
0 commit comments