bpf/docs: Document the nocast aliasing behavior of ___init
authorDavid Vernet <void@manifault.com>
Wed, 25 Jan 2023 14:38:16 +0000 (08:38 -0600)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 25 Jan 2023 15:57:50 +0000 (07:57 -0800)
commit027bdec89364e94753a2211ca87800c765fbd75d
treecf15beb62b62a44ac9b4e294f7cd3ccf43e7b2c0
parentd94cbde2183ff329f36ce1d8f99361a63da68a72
bpf/docs: Document the nocast aliasing behavior of ___init

When comparing BTF IDs for pointers being passed to kfunc arguments, the
verifier will allow pointer types that are equivalent according to the C
standard. For example, for:

struct bpf_cpumask {
cpumask_t cpumask;
refcount_t usage;
};

The verifier will allow a struct bpf_cpumask * to be passed to a kfunc
that takes a const struct cpumask * (cpumask_t is a typedef of struct
cpumask). The exception to this rule is if a type is suffixed with
___init, such as:

struct nf_conn___init {
struct nf_conn ct;
};

The verifier will _not_ allow a struct nf_conn___init * to be passed to
a kfunc that expects a struct nf_conn *. This patch documents this
behavior in the kfuncs documentation page.

Signed-off-by: David Vernet <void@manifault.com>
Link: https://lore.kernel.org/r/20230125143816.721952-8-void@manifault.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Documentation/bpf/kfuncs.rst