Re: [PATCH bpf-next v1 7/8] bpf: support for void/primitive __arg_untrusted global func params

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

 



On Wed, Jul 2, 2025 at 3:42 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
>
> Allow specifying __arg_untrusted for void */char */int */long *
> parameters. Treat such parameters as
> PTR_TO_MEM|MEM_RDONLY|PTR_UNTRUSTED of size zero.
> Intended usage is as follows:
>
>   int memcmp(char *a __arg_untrusted, char *b __arg_untrusted, size_t n) {
>     bpf_for(i, 0, n) {
>       if (a[i] - b[i])      // load at any offset is allowed
>         return a[i] - b[i];
>     }
>     return 0;
>   }

...

> +bool btf_type_is_primitive(const struct btf_type *t)
> +{
> +       return (btf_type_is_int(t) && btf_type_int_is_regular(t)) ||
> +              btf_is_any_enum(t);
> +}

Should array of primitive types be allowed as well ?
Since in C
   int memcmp(char a[] __arg_untrusted, char b[] __arg_untrusted, size_t n) {
     bpf_for(i, 0, n) {
       if (a[i] - b[i])      // load at any offset is allowed
         return a[i] - b[i];

will work just like 'char *'.





[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