]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Support bitfield read access in btf_struct_access
authorMartin KaFai Lau <kafai@fb.com>
Thu, 9 Jan 2020 00:35:01 +0000 (16:35 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 9 Jan 2020 16:46:18 +0000 (08:46 -0800)
commita327aa07df0768e01459af74abef2ff432fc1e5c
treecfd45993bac0afa64b8bc0ae9685c2ad6273d7b1
parenta8e2301a6574de6eb79a8dfe1c24ce6f4c5f19b2
bpf: Support bitfield read access in btf_struct_access

This patch allows bitfield access as a scalar.

It checks "off + size > t->size" to avoid accessing bitfield
end up accessing beyond the struct.  This check is done
outside of the loop since it is applicable to all access.

It also takes this chance to break early on the "off < moff" case.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20200109003501.3855427-1-kafai@fb.com
kernel/bpf/btf.c