bpf: reorganize struct bpf_reg_state fields
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 23 Dec 2022 05:49:16 +0000 (21:49 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 28 Dec 2022 01:37:07 +0000 (17:37 -0800)
commita73bf9f2d969cbb04d5ca778f2a224060cda1027
tree0ca09c6ab86d829b8b6a991419473dad92a45416
parente8f55fcf77794c9867a5edbcb84baf21609465a7
bpf: reorganize struct bpf_reg_state fields

Move id and ref_obj_id fields after scalar data section (var_off and
ranges). This is necessary to simplify next patch which will change
regsafe()'s logic to be safer, as it makes the contents that has to be
an exact match (type-specific parts, off, type, and var_off+ranges)
a single sequential block of memory, while id and ref_obj_id should
always be remapped and thus can't be memcp()'ed.

There are few places that assume that var_off is after id/ref_obj_id to
clear out id/ref_obj_id with the single memset(0). These are changed to
explicitly zero-out id/ref_obj_id fields. Other places are adjusted to
preserve exact byte-by-byte comparison behavior.

No functional changes.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20221223054921.958283-3-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf_verifier.h
kernel/bpf/verifier.c