]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Add MEM_UNINIT as a bpf_type_flag
authorJoanne Koong <joannelkoong@gmail.com>
Mon, 9 May 2022 22:42:52 +0000 (15:42 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 13 May 2022 22:56:26 +0000 (15:56 -0700)
commit8ae7f123be9015f7b587670f5e8fb03c9cb25612
tree06eea0a042db79e3c6e86201c77de9cf70772f36
parentc253587dceaea7c63742b3bf6d97b9b3607608f2
bpf: Add MEM_UNINIT as a bpf_type_flag

Instead of having uninitialized versions of arguments as separate
bpf_arg_types (eg ARG_PTR_TO_UNINIT_MEM as the uninitialized version
of ARG_PTR_TO_MEM), we can instead use MEM_UNINIT as a bpf_type_flag
modifier to denote that the argument is uninitialized.

Doing so cleans up some of the logic in the verifier. We no longer
need to do two checks against an argument type (eg "if
(base_type(arg_type) == ARG_PTR_TO_MEM || base_type(arg_type) ==
ARG_PTR_TO_UNINIT_MEM)"), since uninitialized and initialized
versions of the same argument type will now share the same base type.

In the near future, MEM_UNINIT will be used by dynptr helper functions
as well.

Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: David Vernet <void@manifault.com>
Link: https://lore.kernel.org/r/20220509224257.3222614-2-joannelkoong@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf.h
kernel/bpf/helpers.c
kernel/bpf/verifier.c