Re: [PATCH bpf-next] bpf: Add the missing types in the logs

From: Mykyta Yatsenko

Date: Wed Jan 28 2026 - 09:13:02 EST


On 1/28/26 08:58, Feng Yang wrote:
From: Feng Yang <yangfeng@xxxxxxxxxx>

Add the missing types to avoid such uninformative errors as shown below:
R1 type=ptr_ expected=ptr_

Signed-off-by: Feng Yang <yangfeng@xxxxxxxxxx>
---
kernel/bpf/log.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/log.c b/kernel/bpf/log.c
index a0c3b35de2ce..6fee3d8b3703 100644
--- a/kernel/bpf/log.c
+++ b/kernel/bpf/log.c
@@ -473,14 +473,26 @@ const char *reg_type_str(struct bpf_verifier_env *env, enum bpf_reg_type type)
strscpy(postfix, "_or_null");
}
- snprintf(prefix, sizeof(prefix), "%s%s%s%s%s%s%s",
+ snprintf(prefix, sizeof(prefix), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
type & MEM_RDONLY ? "rdonly_" : "",
type & MEM_RINGBUF ? "ringbuf_" : "",
type & MEM_USER ? "user_" : "",
type & MEM_PERCPU ? "percpu_" : "",
type & MEM_RCU ? "rcu_" : "",
type & PTR_UNTRUSTED ? "untrusted_" : "",
- type & PTR_TRUSTED ? "trusted_" : ""
+ type & PTR_TRUSTED ? "trusted_" : "",
+ type & MEM_UNINIT ? "uninit_" : "",
+ type & DYNPTR_TYPE_LOCAL ? "dynptr_local_" : "",
+ type & DYNPTR_TYPE_RINGBUF ? "dynptr_ringbuf_" : "",
+ type & MEM_FIXED_SIZE ? "fixed_size_" : "",
+ type & MEM_ALLOC ? "alloc_" : "",
+ type & NON_OWN_REF ? "non_own_ref_" : "",
+ type & DYNPTR_TYPE_SKB ? "dynptr_skb_" : "",
+ type & DYNPTR_TYPE_XDP ? "dynptr_xdp_" : "",
+ type & MEM_ALIGNED ? "aligned_" : "",
+ type & MEM_WRITE ? "write_" : "",
+ type & DYNPTR_TYPE_SKB_META ? "dynptr_skb_meta_" : "",
+ type & DYNPTR_TYPE_FILE ? "dynptr_file_" : ""
);
Maybe it'll be good to decrease the number of the %s
and also group up the strings, for example:
const char *dynptr_reg_type(...)
{
    if (type & DYNPTR_TYPE_SKB) return "dynptr_skb_"; if (type & DYNPTR_TYPE_XDP) return "dynptr_xdp_";} so later we can substitute multiple %s with just one, corresponding to the dynptr type, this also ensures dynptr type is always in the same place, relative to other things. This can also be applied to (MEM_RDONLY, MEM_WRITE), (PTR_TRUSTED, PTR_UNTRUSTED) and so on.
snprintf(env->tmp_str_buf, TMP_STR_BUF_LEN, "%s%s%s",