Re: [PATCH bpf-next v4 4/9] bpf: create repeated fields for arrays.

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

 



On Tue, 2024-05-07 at 23:32 -0700, Kui-Feng Lee wrote:
> The verifier uses field information for certain special types, such as
> kptr, rbtree root, and list head. These types are treated
> differently. However, we did not previously support these types in
> arrays. This update examines arrays and duplicates field information the
> same number of times as the length of the array if the element type is one
> of the special types.
> 
> Signed-off-by: Kui-Feng Lee <thinker.li@xxxxxxxxx>
> ---

Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx>

[...]

> @@ -3504,6 +3539,19 @@ static int btf_find_field_one(const struct btf *btf,
>  {
>  	int ret, align, sz, field_type;
>  	struct btf_field_info tmp;
> +	const struct btf_array *array;
> +	u32 i, nelems = 1;
> +
> +	/* Walk into array types to find the element type and the number of
> +	 * elements in the (flattened) array.
> +	 */
> +	for (i = 0; i < MAX_RESOLVE_DEPTH && btf_type_is_array(var_type); i++) {
> +		array = btf_array(var_type);
> +		nelems *= array->nelems;
> +		var_type = btf_type_by_id(btf, array->type);
> +	}

Nit: still think that error should be reported when i == MAX_RESOLVE_DEPTH.

> +	if (nelems == 0)
> +		return 0;
>
>  	field_type = btf_get_field_type(__btf_name_by_offset(btf, var_type->name_off),
>  					field_mask, seen_mask, &align, &sz);

[...]





[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