Re: [PATCH bpf-next v6 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 Mon, 2024-05-20 at 13:40 -0700, Kui-Feng Lee wrote:
> Make sure that BPF programs can declare global kptr arrays and kptr fields
> in struct types that is the type of a global variable or the type of a
> nested descendant field in a global variable.
> 
> An array with only one element is special case, that it treats the element
> like a non-array kptr field. Nested arrays are also tested to ensure they
> are handled properly.
> 
> Signed-off-by: Kui-Feng Lee <thinker.li@xxxxxxxxx>
> ---

Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx>

[...]

> +/* Ensure that the field->offset has been correctly advanced from one
> + * nested struct or array sub-tree to another. In the case of
> + * kptr_nested_deep, it comprises two sub-trees: ktpr_1 and kptr_2.  By
> + * calling bpf_kptr_xchg() on every single kptr in both nested sub-trees,
> + * the verifier should reject the program if the field->offset of any kptr
> + * is incorrect.
> + *
> + * For instance, if we have 10 kptrs in a nested struct and a program that
> + * accesses each kptr individually with bpf_kptr_xchg(), the compiler
> + * should emit instructions to access 10 different offsets if it works
> + * correctly. If the field->offset values of any pair of them are
> + * incorrectly the same, the number of unique offsets in btf_record for
> + * this nested struct should be less than 10. The verifier should fail to
> + * discover some of the offsets emitted by the compiler.
> + *
> + * Even if the field->offset values of kptrs are not duplicated, the
> + * verifier should fail to find a btf_field for the instruction accessing a
> + * kptr if the corresponding field->offset is pointing to a random
> + * incorrect offset.
> + */
> +SEC("tp_btf/task_newtask")
> +int BPF_PROG(test_global_mask_nested_deep_rcu, struct task_struct *task, u64 clone_flags)

Thank you for adding this test.

[...]





[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