diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 98be25d13325..0f4090837908 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -1397,7 +1397,6 @@ __printf(4, 5) static void __btf_verifier_log_type(struct btf_verifier_env *env, const char *fmt, ...) { struct bpf_verifier_log *log = &env->log; - u8 kind = BTF_INFO_KIND(t->info); struct btf *btf = env->btf; va_list args; @@ -1411,14 +1410,15 @@ __printf(4, 5) static void __btf_verifier_log_type(struct btf_verifier_env *env, if (log->level == BPF_LOG_KERNEL && !fmt) return; - __btf_verifier_log(log, "[%u] %s %s%s", + __btf_verifier_log(log, "[%u] %s", env->log_type_id, - btf_kind_str[kind], - __btf_name_by_offset(btf, t->name_off), - log_details ? " " : ""); + btf_type_str(t)); - if (log_details) + if (log_details) { + __btf_verifier_log(log, " %s", + __btf_name_by_offset(btf, t->name_off)); btf_type_ops(t)->log_details(env, t); + } if (fmt && *fmt) { __btf_verifier_log(log, " "); @@ -3898,7 +3898,7 @@ static s32 btf_func_proto_check_meta(struct btf_verifier_env *env, } if (t->name_off) { - btf_verifier_log_type(env, t, "Invalid name"); + btf_verifier_log_basic(env, t, "Should not have a name"); return -EINVAL; } @@ -5427,7 +5427,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, if (!btf_type_is_small_int(t)) { bpf_log(log, "ret type %s not allowed for fmod_ret\n", - btf_kind_str[BTF_INFO_KIND(t->info)]); + btf_type_str(t)); return false; } break; @@ -5454,7 +5454,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, "func '%s' arg%d '%s' has type %s. Only pointer access is allowed\n", tname, arg, __btf_name_by_offset(btf, t->name_off), - btf_kind_str[BTF_INFO_KIND(t->info)]); + btf_type_str(t)); return false; } @@ -5538,11 +5538,11 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, if (!btf_type_is_struct(t)) { bpf_log(log, "func '%s' arg%d type %s is not a struct\n", - tname, arg, btf_kind_str[BTF_INFO_KIND(t->info)]); + tname, arg, btf_type_str(t)); return false; } bpf_log(log, "func '%s' arg%d has btf_id %d type %s '%s'\n", - tname, arg, info->btf_id, btf_kind_str[BTF_INFO_KIND(t->info)], + tname, arg, info->btf_id, btf_type_str(t), __btf_name_by_offset(btf, t->name_off)); return true; } @@ -5950,7 +5950,7 @@ int btf_distill_func_proto(struct bpf_verifier_log *log, if (ret < 0 || __btf_type_is_struct(t)) { bpf_log(log, "The function %s return type %s is unsupported.\n", - tname, btf_kind_str[BTF_INFO_KIND(t->info)]); + tname, btf_type_str(t)); return -EINVAL; } m->ret_size = ret; @@ -5968,7 +5968,7 @@ int btf_distill_func_proto(struct bpf_verifier_log *log, if (ret < 0 || ret > 16) { bpf_log(log, "The function %s arg%d type %s is unsupported.\n", - tname, i, btf_kind_str[BTF_INFO_KIND(t->info)]); + tname, i, btf_type_str(t)); return -EINVAL; } if (ret == 0) { @@ -6727,7 +6727,7 @@ int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog, continue; } bpf_log(log, "Arg#%d type %s in %s() is not supported yet.\n", - i, btf_kind_str[BTF_INFO_KIND(t->info)], tname); + i, btf_type_str(t), tname); return -EINVAL; } return 0;