From: Jiri Olsa <jolsa@redhat.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andriin@fb.com>,
Network Development <netdev@vger.kernel.org>,
bpf <bpf@vger.kernel.org>, Martin KaFai Lau <kafai@fb.com>,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>
Subject: Re: [PATCH bpf-next] selftests/bpf: Check trampoline execution in d_path test
Date: Tue, 15 Sep 2020 11:12:02 +0200 [thread overview]
Message-ID: <20200915091202.GA2171499@krava> (raw)
In-Reply-To: <CAADnVQKhf8X0zxcx5B9VsXM3Wesayk_Hbtu-zobqaZU09jNv7Q@mail.gmail.com>
On Mon, Sep 14, 2020 at 07:30:33PM -0700, Alexei Starovoitov wrote:
> On Fri, Sep 11, 2020 at 6:16 AM Jiri Olsa <jolsa@redhat.com> wrote:
> >
> > On Thu, Sep 10, 2020 at 05:46:21PM -0700, Alexei Starovoitov wrote:
> > > On Thu, Sep 10, 2020 at 5:22 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > > >
> > > > Some kernels builds might inline vfs_getattr call within
> > > > fstat syscall code path, so fentry/vfs_getattr trampoline
> > > > is not called.
> > > >
> > > > I'm not sure how to handle this in some generic way other
> > > > than use some other function, but that might get inlined at
> > > > some point as well.
> > >
> > > It's great that we had the test and it failed.
> > > Doing the test skipping will only hide the problem.
> > > Please don't do it here and in the future.
> > > Instead let's figure out the real solution.
> > > Assuming that vfs_getattr was added to btf_allowlist_d_path
> > > for a reason we have to make this introspection place
> > > reliable regardless of compiler inlining decisions.
> > > We can mark it as 'noinline', but that's undesirable.
> > > I suggest we remove it from the allowlist and replace it with
> > > security_inode_getattr.
> > > I think that is a better long term fix.
> >
> > in my case vfs_getattr got inlined in vfs_statx_fd and both
> > of them are defined in fs/stat.c
> >
> > so the idea is that inlining will not happen if the function
> > is defined in another object? or less likely..?
>
> when it's in a different .o file. yes.
> Very few folks build LTO kernels, so I propose to cross that bridge when
> we get there.
> Eventually we can replace security_inode_getattr
> with bpf_lsm_inode_getattr or simply add noinline to security_inode_getattr.
>
> > we should be safe when it's called from module
>
> what do you mean?
it's external call, so it will not get inlined
>
> > > While at it I would apply the same critical thinking to other
> > > functions in the allowlist. They might suffer the same issue.
> > > So s/vfs_truncate/security_path_truncate/ and so on?
> > > Things won't work when CONFIG_SECURITY is off, but that is a rare kernel config?
> > > Or add both security_* and vfs_* variants and switch tests to use security_* ?
> > > but it feels fragile to allow inline-able funcs in allowlist.
> >
> > hm, what's the difference between vfs_getattr and security_inode_getattr
> > in this regard? I'd expect compiler could inline it same way as for vfs_getattr
>
> not really because they're in different files and LTO is not on.
> Even with LTO the chances of inlining are small. The compiler will
> consider profitability of it. Since there is a loop inside, it's unlikely.
ok, thanks for info
I'll use that security_inode_getattr instead of vfs_getattr
jirka
prev parent reply other threads:[~2020-09-15 9:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-10 12:22 [PATCH bpf-next] selftests/bpf: Check trampoline execution in d_path test Jiri Olsa
2020-09-10 22:22 ` Andrii Nakryiko
2020-09-11 13:04 ` Jiri Olsa
2020-09-11 0:46 ` Alexei Starovoitov
2020-09-11 13:15 ` Jiri Olsa
2020-09-15 2:30 ` Alexei Starovoitov
2020-09-15 9:12 ` Jiri Olsa [this message]
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=20200915091202.GA2171499@krava \
--to=jolsa@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.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).