[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzZFi_h_9t+u=BSOLA8KYxs2BsnFywLOrhvKckD2xDuLpg@mail.gmail.com>
Date: Mon, 23 Dec 2019 22:44:54 -0800
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: KP Singh <kpsingh@...omium.org>
Cc: open list <linux-kernel@...r.kernel.org>,
bpf <bpf@...r.kernel.org>, linux-security-module@...r.kernel.org,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
James Morris <jmorris@...ei.org>,
Kees Cook <keescook@...omium.org>,
Thomas Garnier <thgarnie@...omium.org>,
Michael Halcrow <mhalcrow@...gle.com>,
Paul Turner <pjt@...gle.com>,
Brendan Gregg <brendan.d.gregg@...il.com>,
Jann Horn <jannh@...gle.com>,
Matthew Garrett <mjg59@...gle.com>,
Christian Brauner <christian@...uner.io>,
Mickaël Salaün <mic@...ikod.net>,
Florent Revest <revest@...omium.org>,
Brendan Jackman <jackmanb@...omium.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
"Serge E. Hallyn" <serge@...lyn.com>,
Mauro Carvalho Chehab <mchehab+samsung@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Nicolas Ferre <nicolas.ferre@...rochip.com>,
Stanislav Fomichev <sdf@...gle.com>,
Quentin Monnet <quentin.monnet@...ronome.com>,
Andrey Ignatov <rdna@...com>, Joe Stringer <joe@...d.net.nz>
Subject: Re: [PATCH bpf-next v1 11/13] tools/libbpf: Add bpf_program__attach_lsm
On Fri, Dec 20, 2019 at 7:42 AM KP Singh <kpsingh@...omium.org> wrote:
>
> From: KP Singh <kpsingh@...gle.com>
>
> Add functionality in libbpf to attach eBPF program to LSM hooks.
>
> Signed-off-by: KP Singh <kpsingh@...gle.com>
> ---
> tools/lib/bpf/libbpf.c | 127 +++++++++++++++++++++++++++++++++++++--
> tools/lib/bpf/libbpf.h | 2 +
> tools/lib/bpf/libbpf.map | 1 +
> 3 files changed, 126 insertions(+), 4 deletions(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index b0b27d8e5a37..ab2b23b4f21f 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -5122,8 +5122,8 @@ int libbpf_prog_type_by_name(const char *name, enum bpf_prog_type *prog_type,
> return -ESRCH;
> }
>
> -static inline int __btf__typdef_with_prefix(struct btf *btf, const char *name,
> - const char *prefix)
> +static inline int __btf__type_with_prefix(struct btf *btf, const char *name,
> + const char *prefix)
Please do this rename in a patch that introduced this function, there
is no need to split such changes between two patches. See also my
request to rename and generalize it a bit.
> {
>
> size_t prefix_len = strlen(prefix);
> @@ -5149,9 +5149,9 @@ int libbpf_find_vmlinux_btf_id(const char *name,
> }
>
[...]
>
> +
> +static int bpf_link__destroy_lsm(struct bpf_link *link)
> +{
> + struct bpf_link_lsm *ll = container_of(link, struct bpf_link_lsm, link);
struct bpf_link link being a first field is a requirement for
bpf_link, so you don't need container_of, just cast link to your type.
> + char errmsg[STRERR_BUFSIZE];
> + int ret;
> +
> + ret = bpf_prog_detach2(ll->prog_fd, ll->hook_fd, BPF_LSM_MAC);
> + if (ret < 0) {
> + ret = -errno;
> + pr_warn("failed to detach from hook: %s\n",
> + libbpf_strerror_r(ret, errmsg, sizeof(errmsg)));
> + return ret;
> + }
> + close(ll->hook_fd);
> + return 0;
> +}
> +
> +static const char *__lsm_hook_name(const char *title)
> +{
> +
> + int i;
> +
> + if (!title)
> + return ERR_PTR(-EINVAL);
> +
> + for (i = 0; i < ARRAY_SIZE(section_names); i++) {
section_names have been renamed to section_defs a while ago, please rebase
> + if (section_names[i].prog_type != BPF_PROG_TYPE_LSM)
> + continue;
> +
[...]
Powered by blists - more mailing lists