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]
Message-ID: <7F2E3D6E-C85C-44E1-9A99-4B28B0B60931@fb.com>
Date:   Thu, 14 Nov 2019 23:30:29 +0000
From:   Song Liu <songliubraving@...com>
To:     Alexei Starovoitov <ast@...nel.org>
CC:     David Miller <davem@...emloft.net>,
        "daniel@...earbox.net" <daniel@...earbox.net>,
        "x86@...nel.org" <x86@...nel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "bpf@...r.kernel.org" <bpf@...r.kernel.org>,
        Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH v4 bpf-next 17/20] bpf: Support attaching tracing BPF
 program to other BPF programs



> On Nov 14, 2019, at 10:57 AM, Alexei Starovoitov <ast@...nel.org> wrote:
> 
> Allow FENTRY/FEXIT BPF programs to attach to other BPF programs of any type
> including their subprograms. This feature allows snooping on input and output
> packets in XDP, TC programs including their return values. In order to do that
> the verifier needs to track types not only of vmlinux, but types of other BPF
> programs as well. The verifier also needs to translate uapi/linux/bpf.h types
> used by networking programs into kernel internal BTF types used by FENTRY/FEXIT
> BPF programs. In some cases LLVM optimizations can remove arguments from BPF
> subprograms without adjusting BTF info that LLVM backend knows. When BTF info
> disagrees with actual types that the verifiers sees the BPF trampoline has to
> fallback to conservative and treat all arguments as u64. The FENTRY/FEXIT
> program can still attach to such subprograms, but it won't be able to recognize
> pointer types like 'struct sk_buff *' and it won't be able to pass them to
> bpf_skb_output() for dumping packets to user space. The FENTRY/FEXIT program
> would need to use bpf_probe_read_kernel() instead.
> 
> The BPF_PROG_LOAD command is extended with attach_prog_fd field. When it's set
> to zero the attach_btf_id is one vmlinux BTF type ids. When attach_prog_fd
> points to previously loaded BPF program the attach_btf_id is BTF type id of
> main function or one of its subprograms.
> 
> Signed-off-by: Alexei Starovoitov <ast@...nel.org>

Acked-by: Song Liu <songliubraving@...com>

[...]


> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 4620267b186e..40efde5eedcb 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -3530,6 +3530,20 @@ btf_get_prog_ctx_type(struct bpf_verifier_log *log, struct btf *btf,
> 	return ctx_type;
> }
> 

nit: maybe add a comment here or where we call btf_translate_to_vmlinux(). 

> +static int btf_translate_to_vmlinux(struct bpf_verifier_log *log,
> +				     struct btf *btf,
> +				     const struct btf_type *t,
> +				     enum bpf_prog_type prog_type)
> +{


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ