Re: [PATCH bpf-next v4 12/21] bpf: add PTR_TO_BTF_ID_OR_NULL support

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

 



On Sat, May 09, 2020 at 10:59:12AM -0700, Yonghong Song wrote:
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index a2cfba89a8e1..c490fbde22d4 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -3790,7 +3790,10 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,
>  		return true;
>  
>  	/* this is a pointer to another type */
> -	info->reg_type = PTR_TO_BTF_ID;
> +	if (off != 0 && prog->aux->btf_id_or_null_non0_off)
> +		info->reg_type = PTR_TO_BTF_ID_OR_NULL;
> +	else
> +		info->reg_type = PTR_TO_BTF_ID;

I think the verifier should be smarter than this.
It's too specific and inflexible. All ctx fields of bpf_iter execpt first
will be such ? let's figure out a different way to tell verifier about this.
How about using typedef with specific suffix? Like:
typedef struct bpf_map *bpf_map_or_null;
 struct bpf_iter__bpf_map {
   struct bpf_iter_meta *meta;
   bpf_map_or_null map;
 };
or use a union with specific second member? Like:
 struct bpf_iter__bpf_map {
   struct bpf_iter_meta *meta;
   union {
     struct bpf_map *map;
     long null;
   };
 };



[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