From: Eduard Zingerman <eddyz87@gmail.com>
To: Kui-Feng Lee <thinker.li@gmail.com>,
bpf@vger.kernel.org, ast@kernel.org, martin.lau@linux.dev,
song@kernel.org, kernel-team@meta.com, andrii@kernel.org
Cc: sinquersw@gmail.com, kuifeng@meta.com
Subject: Re: [PATCH bpf-next v6 7/9] selftests/bpf: Test kptr arrays and kptrs in nested struct fields.
Date: Tue, 21 May 2024 10:35:00 -0700 [thread overview]
Message-ID: <ef290f5f2b577ab0d232fdcaa08fe514ae26c694.camel@gmail.com> (raw)
In-Reply-To: <20240520204018.884515-8-thinker.li@gmail.com>
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@gmail.com>
> ---
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
[...]
> +/* 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.
[...]
next prev parent reply other threads:[~2024-05-21 17:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 20:40 [PATCH bpf-next v6 0/9] Enable BPF programs to declare arrays of kptr, bpf_rb_root, and bpf_list_head Kui-Feng Lee
2024-05-20 20:40 ` [PATCH bpf-next v6 1/9] bpf: Remove unnecessary checks on the offset of btf_field Kui-Feng Lee
2024-05-20 20:40 ` [PATCH bpf-next v6 2/9] bpf: Remove unnecessary call to btf_field_type_size() Kui-Feng Lee
2024-05-20 20:40 ` [PATCH bpf-next v6 3/9] bpf: refactor btf_find_struct_field() and btf_find_datasec_var() Kui-Feng Lee
2024-05-20 20:40 ` [PATCH bpf-next v6 4/9] bpf: create repeated fields for arrays Kui-Feng Lee
2024-05-20 20:40 ` [PATCH bpf-next v6 5/9] bpf: look into the types of the fields of a struct type recursively Kui-Feng Lee
2024-05-21 18:12 ` Eduard Zingerman
2024-05-23 16:59 ` Kui-Feng Lee
2024-05-20 20:40 ` [PATCH bpf-next v6 6/9] bpf: limit the number of levels of a nested struct type Kui-Feng Lee
2024-05-20 20:40 ` [PATCH bpf-next v6 7/9] selftests/bpf: Test kptr arrays and kptrs in nested struct fields Kui-Feng Lee
2024-05-21 17:35 ` Eduard Zingerman [this message]
2024-05-20 20:40 ` [PATCH bpf-next v6 8/9] selftests/bpf: Test global bpf_rb_root arrays and fields in nested struct types Kui-Feng Lee
2024-05-20 20:40 ` [PATCH bpf-next v6 9/9] selftests/bpf: Test global bpf_list_head arrays Kui-Feng Lee
2024-05-21 18:31 ` Eduard Zingerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef290f5f2b577ab0d232fdcaa08fe514ae26c694.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kernel-team@meta.com \
--cc=kuifeng@meta.com \
--cc=martin.lau@linux.dev \
--cc=sinquersw@gmail.com \
--cc=song@kernel.org \
--cc=thinker.li@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox