]> 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)
commit2cc152ef98af7d062ac43fcd031aa4a873448ec1
treeee15ff76a8631132a43ed543c75a373e07aa23db
parentc2fe646296f30b0aff6042b25f960d9a6935289c
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: 526a3ab7ec39 ("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