From: KP Singh <kpsingh@chromium.org>
To: Kees Cook <keescook@chromium.org>
Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
linux-security-module@vger.kernel.org,
Brendan Jackman <jackmanb@google.com>,
Florent Revest <revest@google.com>, Yonghong Song <yhs@fb.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
James Morris <jmorris@namei.org>, Paul Turner <pjt@google.com>,
Jann Horn <jannh@google.com>,
Florent Revest <revest@chromium.org>,
Brendan Jackman <jackmanb@chromium.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH bpf-next v6 3/8] bpf: lsm: provide attachment points for BPF LSM programs
Date: Wed, 25 Mar 2020 21:14:56 +0100 [thread overview]
Message-ID: <20200325201456.GA30568@chromium.org> (raw)
In-Reply-To: <202003251257.AD4381C861@keescook>
On 25-Mär 13:07, Kees Cook wrote:
> On Wed, Mar 25, 2020 at 08:39:56PM +0100, KP Singh wrote:
> > On 25-Mär 12:28, Kees Cook wrote:
> > > On Wed, Mar 25, 2020 at 04:26:24PM +0100, KP Singh wrote:
> > > > +noinline __weak RET bpf_lsm_##NAME(__VA_ARGS__) \
> > >
> > > I don't think the __weak is needed any more here?
> >
> > This was suggested in:
> >
> > https://lore.kernel.org/bpf/20200221022537.wbmhdfkdbfvw2pww@ast-mbp/
> >
> > "I think I saw cases when gcc ignored 'noinline' when function is
> > defined in the same file and still performed inlining while keeping
> > the function body. To be safe I think __weak is necessary. That will
> > guarantee noinline."
> >
> > It happened to work nicely with the previous approach for the special
> > hooks but the actual reason for adding the __weak was to guarrantee
> > that these functions don't get inlined.
>
> Oh, hrm. Well, okay. That rationale would imply that the "noinline"
> macro needs adjustment instead, but that can be separate, something like:
>
> include/linux/compiler_attributes.h
>
> -#define noinline __attribute__((__noinline__))
> +#define noinline __attribute__((__noinline__)) __attribute__((__weak__))
>
> With a comment, etc...
Sounds reasonable, I will drop the __weak from this and send a
separate patch for this.
- KP
>
> -Kees
>
> >
> > >
> > > > +{ \
> > > > + return DEFAULT; \
> > >
> > > I'm impressed that LSM_RET_VOID actually works. :)
> >
> > All the credit goes to Andrii :)
> >
> > - KP
> >
> > >
> > > -Kees
> > >
> > > > +}
> > > > +
> > > > +#include <linux/lsm_hook_defs.h>
> > > > +#undef LSM_HOOK
> > > >
> > > > const struct bpf_prog_ops lsm_prog_ops = {
> > > > };
> > > > --
> > > > 2.20.1
> > > >
> > >
> > > --
> > > Kees Cook
>
> --
> Kees Cook
next prev parent reply other threads:[~2020-03-25 20:15 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-25 15:26 [PATCH bpf-next v6 0/8] MAC and Audit policy using eBPF (KRSI) KP Singh
2020-03-25 15:26 ` [PATCH bpf-next v6 1/8] bpf: Introduce BPF_PROG_TYPE_LSM KP Singh
2020-03-26 1:51 ` Andrii Nakryiko
2020-03-26 13:11 ` KP Singh
2020-03-25 15:26 ` [PATCH bpf-next v6 2/8] security: Refactor declaration of LSM hooks KP Singh
2020-03-25 22:25 ` Casey Schaufler
2020-03-25 23:46 ` KP Singh
2020-03-25 15:26 ` [PATCH bpf-next v6 3/8] bpf: lsm: provide attachment points for BPF LSM programs KP Singh
2020-03-25 19:28 ` Kees Cook
2020-03-25 19:39 ` KP Singh
2020-03-25 20:07 ` Kees Cook
2020-03-25 20:14 ` KP Singh [this message]
2020-03-25 15:26 ` [PATCH bpf-next v6 4/8] bpf: lsm: Implement attach, detach and execution KP Singh
2020-03-26 1:49 ` Andrii Nakryiko
2020-03-26 13:35 ` KP Singh
2020-03-25 15:26 ` [PATCH bpf-next v6 5/8] bpf: lsm: Initialize the BPF LSM hooks KP Singh
2020-03-25 19:30 ` Kees Cook
2020-03-25 15:26 ` [PATCH bpf-next v6 6/8] tools/libbpf: Add support for BPF_PROG_TYPE_LSM KP Singh
2020-03-26 1:56 ` Andrii Nakryiko
2020-03-25 15:26 ` [PATCH bpf-next v6 7/8] bpf: lsm: Add selftests " KP Singh
2020-03-26 2:01 ` Andrii Nakryiko
2020-03-26 13:36 ` KP Singh
2020-03-25 15:26 ` [PATCH bpf-next v6 8/8] bpf: lsm: Add Documentation KP Singh
2020-03-25 19:24 ` [PATCH bpf-next v6 0/8] MAC and Audit policy using eBPF (KRSI) Kees Cook
2020-03-25 19:42 ` KP Singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200325201456.GA30568@chromium.org \
--to=kpsingh@chromium.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=gregkh@linuxfoundation.org \
--cc=jackmanb@chromium.org \
--cc=jackmanb@google.com \
--cc=jannh@google.com \
--cc=jmorris@namei.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=pjt@google.com \
--cc=revest@chromium.org \
--cc=revest@google.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).