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: <484B1B7E-8B72-4BF1-A8DB-ECEEAC69E269@fb.com>
Date:   Fri, 8 Nov 2019 19:14:17 +0000
From:   Song Liu <songliubraving@...com>
To:     Alexei Starovoitov <ast@...com>
CC:     Alexei Starovoitov <ast@...nel.org>,
        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 v3 bpf-next 16/18] libbpf: Add support for attaching BPF
 programs to other BPF programs



> On Nov 8, 2019, at 11:13 AM, Alexei Starovoitov <ast@...com> wrote:
> 
> On 11/8/19 10:57 AM, Song Liu wrote:
>> 
>> 
>>> On Nov 7, 2019, at 10:40 PM, Alexei Starovoitov <ast@...nel.org> wrote:
>>> 
>>> Extend libbpf api to pass attach_prog_fd into bpf_object__open.
>>> 
>>> Signed-off-by: Alexei Starovoitov <ast@...nel.org>
>>> ---
>> 
>> [...]
>> 
>>> +static int libbpf_find_prog_btf_id(const char *name, __u32 attach_prog_fd)
>>> +{
>>> +	struct bpf_prog_info_linear *info_linear;
>>> +	struct bpf_prog_info *info;
>>> +	struct btf *btf = NULL;
>>> +	int err = -EINVAL;
>>> +
>>> +	info_linear = bpf_program__get_prog_info_linear(attach_prog_fd, 0);
>>> +	if (IS_ERR_OR_NULL(info_linear)) {
>>> +		pr_warn("failed get_prog_info_linear for FD %d\n",
>>> +			attach_prog_fd);
>>> +		return -EINVAL;
>>> +	}
>>> +	info = &info_linear->info;
>>> +	if (!info->btf_id) {
>>> +		pr_warn("The target program doesn't have BTF\n");
>>> +		goto out;
>>> +	}
>>> +	if (btf__get_from_id(info->btf_id, &btf)) {
>>> +		pr_warn("Failed to get BTF of the program\n");
>>> +		goto out;
>>> +	}
>>> +	err = btf__find_by_name_kind(btf, name, BTF_KIND_FUNC);
>>> +	btf__free(btf);
>>> +	if (err <= 0) {
>>> +		pr_warn("%s is not found in prog's BTF\n", name);
>>> +		goto out;
>> 		^^^ This goto doesn't really do much.
> 
> yeah. it does look a bit weird.
> I wanted to keep uniform error handling, but can remove it
> if you insist.

I think it is good as-is. 

Thanks,
Song

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ