]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix ref_obj_id for dynptr data slices in verifier
authorJoanne Koong <joannelkoong@gmail.com>
Tue, 9 Aug 2022 21:40:54 +0000 (14:40 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 10 Aug 2022 01:38:12 +0000 (18:38 -0700)
commita3bf6334b89cc04b65d8314acd9315acaa7dfa9e
treeee15ff76a8631132a43ed543c75a373e07aa23db
parent3fd0264e5f1773b338cec6f91a29becf74cd418b
bpf: Fix ref_obj_id for dynptr data slices in verifier

When a data slice is obtained from a dynptr (through the bpf_dynptr_data API),
the ref obj id of the dynptr must be found and then associated with the data
slice.

The ref obj id of the dynptr must be found *before* the caller saved regs are
reset. Without this fix, the ref obj id tracking is not correct for
dynptrs that are at an offset from the frame pointer.

Please also note that the data slice's ref obj id must be assigned after the
ret types are parsed, since RET_PTR_TO_ALLOC_MEM-type return regs get
zero-marked.

Fixes: 26527b33af98 ("bpf: Add dynptr data slices")
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Acked-by: David Vernet <void@manifault.com>
Link: https://lore.kernel.org/r/20220809214055.4050604-1-joannelkoong@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c