Re: [PATCH bpf-next 4/5] bpf: allow kind_flag for BTF type and decl tags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday, January 22nd, 2025 at 3:09 AM, Alan Maguire <alan.maguire@xxxxxxxxxx> wrote:

> 
> 
> On 22/01/2025 02:53, Ihor Solodrai wrote:
> 
> > BTF type tags and decl tags now may have info->kflag set to 1,
> > changing the semantics of the tag.
> > 
> > Change BTF verification to permit BTF that makes use of this feature:
> > * remove kflag check in btf_decl_tag_check_meta(), as both values
> > are valid
> > * allow kflag to be set for BTF_KIND_TYPE_TAG type in
> > btf_ref_type_check_meta()
> > 
> > Modify a selftest checking for kflag in decl_tag accordingly.
> > 
> > Signed-off-by: Ihor Solodrai ihor.solodrai@xxxxx
> 
> 
> Looks good, but I have a few questions here. Today in btf_struct_walk()
> we check pointer type tags like this:
> 
> /* check type tag */
> t = btf_type_by_id(btf, mtype->type);
> 
> if (btf_type_is_type_tag(t)) {
> tag_value = __btf_name_by_offset(btf,
> t->name_off);
> 
> /* check __user tag /
> if (strcmp(tag_value, "user") == 0)
> tmp_flag = MEM_USER;
> / check __percpu tag /
> if (strcmp(tag_value, "percpu") == 0)
> tmp_flag = MEM_PERCPU;
> / check __rcu tag */
> if (strcmp(tag_value, "rcu") == 0)
> tmp_flag = MEM_RCU;
> }
> 
> 
> Do we need to add in a check for kind_flag == 0 here to ensure it's a
> BTF type tag attribute? Similar question for type tag kptr checking in
> btf_find_kptr() (we could perhaps add a btf_type_is_btf_type_tag() or
> something to include the kind_flag == 0 check).

Yes, we should check for kflag here. Thanks for pointing this out.

    __attribute__((user))
vs
    __attribute__((bpf_type_tag("user")))

are very different things.

> 
> And I presume the btf_check_type_tags() logic still applies for generic
> attributes - i.e. that they always precede the modifiers in the chain?

Yes, that is my understanding too.

> 
> [...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux