@@ -339,6 +339,11 @@ struct bpf_kfunc_call_arg_meta {
339
339
340
340
struct btf *btf_vmlinux;
341
341
342
+ static const char *btf_type_name(const struct btf *btf, u32 id)
343
+ {
344
+ return btf_name_by_offset(btf, btf_type_by_id(btf, id)->name_off);
345
+ }
346
+
342
347
static DEFINE_MUTEX(bpf_verifier_lock);
343
348
static DEFINE_MUTEX(bpf_percpu_ma_lock);
344
349
@@ -418,6 +423,17 @@ static bool subprog_is_global(const struct bpf_verifier_env *env, int subprog)
418
423
return aux && aux[subprog].linkage == BTF_FUNC_GLOBAL;
419
424
}
420
425
426
+ static const char *subprog_name(const struct bpf_verifier_env *env, int subprog)
427
+ {
428
+ struct bpf_func_info *info;
429
+
430
+ if (!env->prog->aux->func_info)
431
+ return "";
432
+
433
+ info = &env->prog->aux->func_info[subprog];
434
+ return btf_type_name(env->prog->aux->btf, info->type_id);
435
+ }
436
+
421
437
static bool reg_may_point_to_spin_lock(const struct bpf_reg_state *reg)
422
438
{
423
439
return btf_record_has_field(reg_btf_record(reg), BPF_SPIN_LOCK);
@@ -587,11 +603,6 @@ static int iter_get_spi(struct bpf_verifier_env *env, struct bpf_reg_state *reg,
587
603
return stack_slot_obj_get_spi(env, reg, "iter", nr_slots);
588
604
}
589
605
590
- static const char *btf_type_name(const struct btf *btf, u32 id)
591
- {
592
- return btf_name_by_offset(btf, btf_type_by_id(btf, id)->name_off);
593
- }
594
-
595
606
static enum bpf_dynptr_type arg_to_dynptr_type(enum bpf_arg_type arg_type)
596
607
{
597
608
switch (arg_type & DYNPTR_TYPE_FLAG_MASK) {
@@ -9269,13 +9280,16 @@ static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
9269
9280
if (err == -EFAULT)
9270
9281
return err;
9271
9282
if (subprog_is_global(env, subprog)) {
9283
+ const char *sub_name = subprog_name(env, subprog);
9284
+
9272
9285
if (err) {
9273
- verbose(env, "Caller passes invalid args into func#%d\n", subprog);
9286
+ verbose(env, "Caller passes invalid args into func#%d ('%s')\n",
9287
+ subprog, sub_name);
9274
9288
return err;
9275
9289
}
9276
9290
9277
- if (env->log.level & BPF_LOG_LEVEL)
9278
- verbose(env, "Func#%d is global and valid. Skipping.\n", subprog );
9291
+ verbose (env, "Func#%d ('%s') is global and assumed valid.\n",
9292
+ subprog, sub_name );
9279
9293
clear_caller_saved_regs(env, caller->regs);
9280
9294
9281
9295
/* All global functions return a 64-bit SCALAR_VALUE */
@@ -19893,9 +19907,8 @@ static int do_check_subprogs(struct bpf_verifier_env *env)
19893
19907
if (ret) {
19894
19908
return ret;
19895
19909
} else if (env->log.level & BPF_LOG_LEVEL) {
19896
- verbose(env,
19897
- "Func#%d is safe for any args that match its prototype\n",
19898
- i);
19910
+ verbose(env, "Func#%d ('%s') is safe for any args that match its prototype\n",
19911
+ i, subprog_name(env, i));
19899
19912
}
19900
19913
}
19901
19914
return 0;
0 commit comments