From: Jiri Olsa <jolsa@redhat.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andriin@fb.com>,
Networking <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 RFC] bpf: Fix trampoline for functions with variable arguments
Date: Wed, 5 May 2021 14:42:47 +0200 [thread overview]
Message-ID: <YJKSx9qLB432dCWs@krava> (raw)
In-Reply-To: <CAADnVQ+V=2qOqkVMaC72uhQKEbC=2uFa80J57xdF_4ffoZHYNQ@mail.gmail.com>
On Tue, May 04, 2021 at 09:11:26PM -0700, Alexei Starovoitov wrote:
SNIP
> > > > >
> > > > > actualy looks like we need to disable functions with variable arguments
> > > > > completely, because we don't know how many arguments to save
> > > > >
> > > > > I tried to disable them in pahole and it's easy fix, will post new fix
> > > >
> > > > Can we still allow access to fixed arguments for such functions and
> > > > just disallow the vararg ones?
> > >
> > > the problem is that we should save all the registers for arguments,
> > > which is probably doable.. but if caller uses more than 6 arguments,
> > > we need stack data, which will be wrong because of the extra stack
> > > frame we do in bpf trampoline.. so we could crash
> > >
> > > the patch below prevents to attach these functions directly in kernel,
> > > so we could keep these functions in BTF
> > >
> > > jirka
> > >
> > >
> > > ---
> > > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> > > index 0600ed325fa0..f9709dc08c44 100644
> > > --- a/kernel/bpf/btf.c
> > > +++ b/kernel/bpf/btf.c
> > > @@ -5213,6 +5213,13 @@ int btf_distill_func_proto(struct bpf_verifier_log *log,
> > > tname, i, btf_kind_str[BTF_INFO_KIND(t->info)]);
> > > return -EINVAL;
> > > }
> > > + if (ret == 0) {
> > > + bpf_log(log,
> > > + "The function %s has variable args, it's unsupported.\n",
> > > + tname);
> > > + return -EINVAL;
> > > +
> > > + }
> >
> > this will work, but the explicit check for vararg should be `i ==
> > nargs - 1 && args[i].type == 0`. Everything else (if it happens) is
> > probably a bad BTF data.
>
> Jiri,
> could you please resubmit with the check like Andrii suggested?
> Thanks!
>
yes, will send it later today
jirka
prev parent reply other threads:[~2021-05-05 12:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-29 21:28 [PATCH RFC] bpf: Fix trampoline for functions with variable arguments Jiri Olsa
2021-05-02 21:16 ` Jiri Olsa
2021-05-03 22:32 ` Andrii Nakryiko
2021-05-04 13:27 ` Jiri Olsa
2021-05-04 22:37 ` Andrii Nakryiko
2021-05-05 4:11 ` Alexei Starovoitov
2021-05-05 12:42 ` 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=YJKSx9qLB432dCWs@krava \
--to=jolsa@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.