Re: [PATCH v3 bpf-next 3/4] bpf: Support pointers in global func args

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

 



On Sat, Feb 13, 2021 at 12:56:41AM +0400, Dmitrii Banshchikov wrote:
> Add an ability to pass a pointer to a type with known size in arguments
> of a global function. Such pointers may be used to overcome the limit on
> the maximum number of arguments, avoid expensive and tricky workarounds
> and to have multiple output arguments.

Thanks a lot for adding this feature and exhaustive tests.
It's a massive improvement in function-by-function verification.
Hopefully it will increase its adoption.
I've applied the set to bpf-next.

> @@ -5349,10 +5352,6 @@ int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,
>  			goto out;
>  		}
>  		if (btf_type_is_ptr(t)) {
> -			if (reg->type == SCALAR_VALUE) {
> -				bpf_log(log, "R%d is not a pointer\n", i + 1);
> -				goto out;
> -			}

Thanks for nuking this annoying warning along the way.
People complained that the verification log for normal static functions
contains above inexplicable message.

>  			/* If function expects ctx type in BTF check that caller
>  			 * is passing PTR_TO_CTX.
>  			 */
> @@ -5367,6 +5366,25 @@ int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,
>  					goto out;
>  				continue;
>  			}
> +
> +			if (!is_global)
> +				goto out;
> +
> +			t = btf_type_skip_modifiers(btf, t->type, NULL);
> +
> +			ref_t = btf_resolve_size(btf, t, &type_size);
> +			if (IS_ERR(ref_t)) {
> +				bpf_log(log,
> +				    "arg#%d reference type('%s %s') size cannot be determined: %ld\n",
> +				    i, btf_type_str(t), btf_name_by_offset(btf, t->name_off),
> +					PTR_ERR(ref_t));

Hopefully one annoying message won't get replaced with this annoying message :)
I think the type size should be known most of the time. So it should be fine.

> +		if (btf_type_is_ptr(t)) {
> +			if (btf_get_prog_ctx_type(log, btf, t, prog_type, i)) {
> +				reg->type = PTR_TO_CTX;
> +				continue;
> +			}

Do you think it would make sense to nuke another message in btf_get_prog_ctx_type ?
With this newly gained usability of global function the message
"arg#0 type is not a struct"
is not useful.
It was marginally useful in the past. Because global funcs supported
ptr_to_ctx only it wasn't seen as often.
Now this message probably can simply be removed. wdyt?



[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