diff options
author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2022-11-03 20:09:51 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-11-04 03:31:17 +0100 |
commit | 23da464dd6b8935b66f4ee306ad8947fd32ccd75 (patch) | |
tree | c6374961daa5a9d76af819da69d114d628ca30ee /kernel | |
parent | bpf: Document UAPI details for special BPF types (diff) | |
download | linux-23da464dd6b8935b66f4ee306ad8947fd32ccd75.tar.xz linux-23da464dd6b8935b66f4ee306ad8947fd32ccd75.zip |
bpf: Allow specifying volatile type modifier for kptrs
This is useful in particular to mark the pointer as volatile, so that
compiler treats each load and store to the field as a volatile access.
The alternative is having to define and use READ_ONCE and WRITE_ONCE in
the BPF program.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Acked-by: David Vernet <void@manifault.com>
Link: https://lore.kernel.org/r/20221103191013.1236066-3-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/btf.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 35c07afac924..f4d21eef6ebd 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -3225,6 +3225,9 @@ static int btf_find_kptr(const struct btf *btf, const struct btf_type *t, enum bpf_kptr_type type; u32 res_id; + /* Permit modifiers on the pointer itself */ + if (btf_type_is_volatile(t)) + t = btf_type_by_id(btf, t->type); /* For PTR, sz is always == 8 */ if (!btf_type_is_ptr(t)) return BTF_FIELD_IGNORE; |