bpf: Fix an error around PTR_UNTRUSTED
authorYafang Shao <laoar.shao@gmail.com>
Thu, 13 Jul 2023 02:56:39 +0000 (02:56 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 13 Jul 2023 23:24:29 +0000 (16:24 -0700)
commit7ce4dc3e4a9d954c8a1fb483c7a527e9b060b860
tree813bb3f4b15f5eb7548a4f6740bb8826a12b592a
parentf892cac2371447b3a26dad117c7bcdf2c93215e1
bpf: Fix an error around PTR_UNTRUSTED

Per discussion with Alexei, the PTR_UNTRUSTED flag should not been
cleared when we start to walk a new struct, because the struct in
question may be a struct nested in a union. We should also check and set
this flag before we walk its each member, in case itself is a union.
We will clear this flag if the field is BTF_TYPE_SAFE_RCU_OR_NULL.

Fixes: 6fcd486b3a0a ("bpf: Refactor RCU enforcement in the verifier.")
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Link: https://lore.kernel.org/r/20230713025642.27477-2-laoar.shao@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/btf.c
kernel/bpf/verifier.c