Re: [PATCH bpf-next v5 7/9] selftests/bpf: Test kptr arrays and kptrs in nested struct fields.

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

 



On Fri, 2024-05-10 at 16:17 -0700, Eduard Zingerman wrote:
> On Fri, 2024-05-10 at 16:04 -0700, Kui-Feng Lee wrote:
> 
> [...]
> 
> 
> > I am not sure if I read you question correctly.
> > 
> > For example, we have 3 correct info.
> > 
> >   [info(offset=0x8), info(offset=0x10), info(offset=0x18)]
> > 
> > And We have program that includes 3 instructions to access the offset 
> > 0x8, 0x10, and 0x18. (let's assume these load instructions would be 
> > checked against infos)
> > 
> >   load r1, [0x8]
> >   load r1, [0x10]
> >   load r1, [0x18]
> > 
> > If everything works as expected, the verifier would accept the program.
> > 
> > Otherwise, like you said, all 3 info are pointing to the same offset.
> > 
> >   [info(0offset=0x8), info(offset=0x8), info(offset=0x8)]
> > 
> > Then, the later two instructions should fail the check.

Ok, what you are saying is possible not with load but with some kfunc
that accepts a special pointer. E.g. when verifier.c:check_kfunc_args()
expects an argument of KF_ARG_PTR_TO_LIST_HEAD type it would report an
error if special field is not found.

So the structure of the test would be:
- define a nested data structure with list head at some leafs;
- in the BPF program call a kfunc accessing each of the list heads;
- if all offsets are computed correctly there would be no load time error;
- this is a load time test, no need to actually run the BPF program.

[...]





[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