nr_args--;
}
+ if (arg > nr_args) {
+ bpf_log(log, "func '%s' doesn't have %d-th argument\n",
+ tname, arg + 1);
+ return false;
+ }
+
if (arg == nr_args) {
- if (prog->expected_attach_type == BPF_TRACE_FEXIT ||
- prog->expected_attach_type == BPF_LSM_MAC) {
+ switch (prog->expected_attach_type) {
+ case BPF_LSM_MAC:
+ case BPF_TRACE_FEXIT:
/* When LSM programs are attached to void LSM hooks
* they use FEXIT trampolines and when attached to
* int LSM hooks, they use MODIFY_RETURN trampolines.
if (!t)
return true;
t = btf_type_by_id(btf, t->type);
- } else if (prog->expected_attach_type == BPF_MODIFY_RETURN) {
+ break;
+ case BPF_MODIFY_RETURN:
/* For now the BPF_MODIFY_RETURN can only be attached to
* functions that return an int.
*/
btf_kind_str[BTF_INFO_KIND(t->info)]);
return false;
}
+ break;
+ default:
+ bpf_log(log, "func '%s' doesn't have %d-th argument\n",
+ tname, arg + 1);
+ return false;
}
- } else if (arg >= nr_args) {
- bpf_log(log, "func '%s' doesn't have %d-th argument\n",
- tname, arg + 1);
- return false;
} else {
if (!t)
/* Default prog with 5 args */
return true;
t = btf_type_by_id(btf, args[arg].type);
}
+
/* skip modifiers */
while (btf_type_is_modifier(t))
t = btf_type_by_id(btf, t->type);