[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4Bzaxg5P2kdoSVK+Tuch5hQVhSXS6c4fWYrLOSc=eWDdfqQ@mail.gmail.com>
Date: Wed, 29 Apr 2020 13:46:26 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Yonghong Song <yhs@...com>
Cc: Andrii Nakryiko <andriin@...com>, bpf <bpf@...r.kernel.org>,
Martin KaFai Lau <kafai@...com>,
Networking <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Kernel Team <kernel-team@...com>
Subject: Re: [PATCH bpf-next v1 09/19] bpf: add PTR_TO_BTF_ID_OR_NULL support
On Mon, Apr 27, 2020 at 1:13 PM Yonghong Song <yhs@...com> wrote:
>
> Add bpf_reg_type PTR_TO_BTF_ID_OR_NULL support.
> For tracing/iter program, the bpf program context
> definition, e.g., for previous bpf_map target, looks like
> struct bpf_iter_bpf_map {
> struct bpf_dump_meta *meta;
> struct bpf_map *map;
> };
>
> The kernel guarantees that meta is not NULL, but
> map pointer maybe NULL. The NULL map indicates that all
> objects have been traversed, so bpf program can take
> proper action, e.g., do final aggregation and/or send
> final report to user space.
>
> Add btf_id_or_null_non0_off to prog->aux structure, to
> indicate that for tracing programs, if the context access
> offset is not 0, set to PTR_TO_BTF_ID_OR_NULL instead of
> PTR_TO_BTF_ID. This bit is set for tracing/iter program.
>
> Signed-off-by: Yonghong Song <yhs@...com>
> ---
> include/linux/bpf.h | 2 ++
> kernel/bpf/btf.c | 5 ++++-
> kernel/bpf/verifier.c | 19 ++++++++++++++-----
> 3 files changed, 20 insertions(+), 6 deletions(-)
>
[...]
>
> static bool reg_may_point_to_spin_lock(const struct bpf_reg_state *reg)
> @@ -410,7 +411,8 @@ static bool reg_type_may_be_refcounted_or_null(enum bpf_reg_type type)
> return type == PTR_TO_SOCKET ||
> type == PTR_TO_SOCKET_OR_NULL ||
> type == PTR_TO_TCP_SOCK ||
> - type == PTR_TO_TCP_SOCK_OR_NULL;
> + type == PTR_TO_TCP_SOCK_OR_NULL ||
> + type == PTR_TO_BTF_ID_OR_NULL;
BTF_ID is not considered to be refcounted for the purpose of verifier,
unless I'm missing something?
> }
>
> static bool arg_type_may_be_refcounted(enum bpf_arg_type type)
> @@ -462,6 +464,7 @@ static const char * const reg_type_str[] = {
> [PTR_TO_TP_BUFFER] = "tp_buffer",
> [PTR_TO_XDP_SOCK] = "xdp_sock",
> [PTR_TO_BTF_ID] = "ptr_",
> + [PTR_TO_BTF_ID_OR_NULL] = "ptr_or_null_",
> };
>
[...]
Powered by blists - more mailing lists