From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: netdev@vger.kernel.org, alexei.starovoitov@gmail.com,
oss-drivers@netronome.com, kafai@fb.com
Subject: Re: [PATCH net-next] bpf: add helper capable of reading out instructions
Date: Tue, 25 Jul 2017 11:20:06 -0700 [thread overview]
Message-ID: <20170725112006.261bf04f@cakuba.netronome.com> (raw)
In-Reply-To: <59777477.7050609@iogearbox.net>
On Tue, 25 Jul 2017 18:40:23 +0200, Daniel Borkmann wrote:
> [ +Martin ]
Sorry, I thought I CCed Martin.
> On 07/24/2017 11:22 PM, Jakub Kicinski wrote:
> > To read translated and jited instructions from the kernel,
> > one has to set certain pointers of struct bpf_prog_info to
> > pre-allocated user buffers. Unfortunately, the existing
> > bpf_obj_get_info_by_fd() helper zeros struct bpf_prog_info
> > before passing it to the kernel.
> >
> > Keeping the zeroing seems like a good idea in general, since
> > kernel will check if the structure was zeroed. Add a new
> > helper for those more advanced users who can be trusted to
> > take care of zeroing themselves.
> >
> > Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> > ---
> > I'm happy to change the name of the new function.
> >
> > tools/lib/bpf/bpf.c | 10 ++++++++--
> > tools/lib/bpf/bpf.h | 2 ++
> > 2 files changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> > index 412a7c82995a..2703fa282b65 100644
> > --- a/tools/lib/bpf/bpf.c
> > +++ b/tools/lib/bpf/bpf.c
> > @@ -308,13 +308,12 @@ int bpf_map_get_fd_by_id(__u32 id)
> > return sys_bpf(BPF_MAP_GET_FD_BY_ID, &attr, sizeof(attr));
> > }
> >
> > -int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len)
> > +int __bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len)
> > {
> > union bpf_attr attr;
> > int err;
> >
> > bzero(&attr, sizeof(attr));
> > - bzero(info, *info_len);
>
> Looks a bit unintentional to me, e.g. 95b9afd3987f ("bpf: Test for bpf
> ID") did set up pointers in test_bpf_obj_id(), but later only checked
> for the {jited,xlated}_prog_len.
>
> Clearing out the pointers looks not to useful. Lets just push the need
> for bzero() to call-sites in general in this case.
Should I target this at net then? To avoid backwards compatibility
issues?
next prev parent reply other threads:[~2017-07-25 18:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 21:22 [PATCH net-next] bpf: add helper capable of reading out instructions Jakub Kicinski
2017-07-25 16:40 ` Daniel Borkmann
2017-07-25 18:20 ` Jakub Kicinski [this message]
2017-07-25 18:25 ` Daniel Borkmann
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=20170725112006.261bf04f@cakuba.netronome.com \
--to=jakub.kicinski@netronome.com \
--cc=alexei.starovoitov@gmail.com \
--cc=daniel@iogearbox.net \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.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.