bpf: Verifier cleanups
authorJoanne Koong <joannelkoong@gmail.com>
Tue, 2 Aug 2022 21:46:38 +0000 (14:46 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 8 Aug 2022 15:54:06 +0000 (17:54 +0200)
commit0c9a7a7e2049859d7869e15dd8f70ca5aeae460e
treef8280d59151514ccdfd2284e31a2441da7da7d4e
parente19db6762c18ab1ddf7a3ef4d0023780c24dc1e8
bpf: Verifier cleanups

This patch cleans up a few things in the verifier:

  * type_is_pkt_pointer():
    Future work (skb + xdp dynptrs [0]) will be using the reg type
    PTR_TO_PACKET | PTR_MAYBE_NULL. type_is_pkt_pointer() should return
    true for any type whose base type is PTR_TO_PACKET, regardless of
    flags attached to it.

  * reg_type_may_be_refcounted_or_null():
    Get the base type at the start of the function to avoid
    having to recompute it / improve readability

  * check_func_proto(): remove unnecessary 'meta' arg

  * check_helper_call():
    Use switch casing on the base type of return value instead of
    nested ifs on the full type

There are no functional behavior changes.

  [0] https://lore.kernel.org/bpf/20220726184706.954822-1-joannelkoong@gmail.com/

Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20220802214638.3643235-1-joannelkoong@gmail.com
kernel/bpf/verifier.c