Re: [PATCH bpf-next 4/7] bpf: Attachment verification for BPF_MODIFY_RETURN

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

 



On Wed, Mar 04, 2020 at 12:21:51AM +0100, KP Singh wrote:
> 
> > > +                       t = btf_type_skip_modifiers(btf, t->type, NULL);
> > > +                       if (!btf_type_is_int(t)) {
> > 
> > Should the size of int be verified here? E.g., if some function
> > returns u8, is that ok for BPF program to return, say, (1<<30) ?
> 
> Would this work?
> 
>        if (size != t->size) {
>                bpf_log(log,
>                        "size accessed = %d should be %d\n",
>                        size, t->size);
>                return false;
>        }

It will cause spurious failures later when llvm optimizes
if (ret & 0xff) into u8 load.
I think btf_type_is_int() is enough as-is.



[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