lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 27 Oct 2022 13:15:37 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Rong Tao <rtoax@...mail.com>
Cc:     Rong Tao <rongtao@...tc.cn>, Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Martin KaFai Lau <martin.lau@...ux.dev>,
        Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>,
        Stanislav Fomichev <sdf@...gle.com>,
        Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
        "open list:BPF [GENERAL] (Safe Dynamic Programs and Tools)" 
        <bpf@...r.kernel.org>, open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH bpf-next] samples/bpf: Fix sockex3: missing BPF prog type

On Thu, Oct 27, 2022 at 6:38 AM Rong Tao <rtoax@...mail.com> wrote:
>
> From: Rong Tao <rongtao@...tc.cn>
>
> since commit 450b167fb9be("libbpf: clean up SEC() handling"),
> sec_def_matches() does not recognize "socket/xxx" as "socket", therefore,
> the BPF program type is not recognized, we should add a custom program
> type handler for "socket/xxx".

I don't think we should, we should just switch to SEC("socket") or
whatever the right annotation has to be. Let's fix the BPF-side code.

>
>  $ cd samples/bpf
>  $ sudo ./sockex3
>  libbpf: prog 'bpf_func_PARSE_IP': missing BPF prog type, check ELF section name 'socket/3'
>  libbpf: prog 'bpf_func_PARSE_IP': failed to load: -22
>  libbpf: failed to load object './sockex3_kern.o'
>  ERROR: loading BPF object file failed
>
> Signed-off-by: Rong Tao <rongtao@...tc.cn>
> ---
>  samples/bpf/sockex3_user.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/samples/bpf/sockex3_user.c b/samples/bpf/sockex3_user.c
> index cd6fa79df900..d18d7a3600b0 100644
> --- a/samples/bpf/sockex3_user.c
> +++ b/samples/bpf/sockex3_user.c
> @@ -22,6 +22,14 @@ struct pair {
>         __u64 bytes;
>  };
>
> +static int socket_prog_type_id;
> +
> +__attribute__((destructor))
> +static void unregister_socket_sec_handlers(void)
> +{
> +       libbpf_unregister_prog_handler(socket_prog_type_id);
> +}
> +
>  int main(int argc, char **argv)
>  {
>         int i, sock, key, fd, main_prog_fd, jmp_table_fd, hash_map_fd;
> @@ -31,6 +39,13 @@ int main(int argc, char **argv)
>         char filename[256];
>         FILE *f;
>
> +       LIBBPF_OPTS(libbpf_prog_handler_opts, socket_opts,
> +               .cookie = 1,
> +       );
> +
> +       socket_prog_type_id = libbpf_register_prog_handler("socket/",
> +                       BPF_PROG_TYPE_SOCKET_FILTER, 0, &socket_opts);
> +
>         snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
>
>         obj = bpf_object__open_file(filename, NULL);
> --
> 2.31.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ