[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20211020180418.5sgoickl4pucrk52@ast-mbp.dhcp.thefacebook.com>
Date: Wed, 20 Oct 2021 11:04:18 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Kumar Kartikeya Dwivedi <memxor@...il.com>
Cc: bpf@...r.kernel.org, Song Liu <songliubraving@...com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>, Yonghong Song <yhs@...com>,
Jesper Dangaard Brouer <brouer@...hat.com>,
Toke Høiland-Jørgensen <toke@...hat.com>,
netdev@...r.kernel.org
Subject: Re: [PATCH bpf-next v3 1/8] bpf: Add bpf_kallsyms_lookup_name helper
On Fri, Oct 15, 2021 at 02:26:37AM +0530, Kumar Kartikeya Dwivedi wrote:
> This helper allows us to get the address of a kernel symbol from inside
> a BPF_PROG_TYPE_SYSCALL prog (used by gen_loader), so that we can
> relocate typeless ksym vars.
...
> +BPF_CALL_4(bpf_kallsyms_lookup_name, const char *, name, int, name_sz, int, flags, u64 *, res)
> +{
> + if (flags)
> + return -EINVAL;
> +
> + if (name_sz <= 1 || name[name_sz - 1])
> + return -EINVAL;
> +
> + *res = kallsyms_lookup_name(name);
> + return *res ? 0 : -ENOENT;
> +}
> +
> +const struct bpf_func_proto bpf_kallsyms_lookup_name_proto = {
> + .func = bpf_kallsyms_lookup_name,
> + .gpl_only = true,
When libbpf is processing of typeless ksyms it parses /proc/kallsyms.
There is no gpl-ness in the action of reading this file.
Hence above should be '= false' for consistency between
light and regular skeleton.
But different check is necessary.
This helper is available to syscall_bpf prog type (which is CAP_BPF)
and shouldn't be used to bypass kptr checks.
So bpf_kallsyms_lookup_name() should probably have:
if (!bpf_dump_raw_ok(current_cred())))
return -EPERM;
The rest of the patches look great.
Thank you for working on this!
Powered by blists - more mailing lists