lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 19 Aug 2020 13:23:25 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc:     Yonghong Song <yhs@...com>, Andrii Nakryiko <andriin@...com>,
        bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Kernel Team <kernel-team@...com>
Subject: Re: [PATCH bpf-next 4/7] libbpf: sanitize BPF program code for bpf_probe_read_{kernel,user}[_str]

On Wed, Aug 19, 2020 at 1:15 PM Alexei Starovoitov
<alexei.starovoitov@...il.com> wrote:
>
> On Wed, Aug 19, 2020 at 1:13 PM Andrii Nakryiko
> <andrii.nakryiko@...il.com> wrote:
> >
> > On Tue, Aug 18, 2020 at 6:42 PM Yonghong Song <yhs@...com> wrote:
> > >
> > >
> > >
> > > On 8/18/20 2:33 PM, Andrii Nakryiko wrote:
> > > > Add BPF program code sanitization pass, replacing calls to BPF
> > > > bpf_probe_read_{kernel,user}[_str]() helpers with bpf_probe_read[_str](), if
> > > > libbpf detects that kernel doesn't support new variants.
> > >
> > > I know this has been merged. The whole patch set looks good to me.
> > > A few nit or questions below.
> > >
> > > >
> > > > Signed-off-by: Andrii Nakryiko <andriin@...com>
> > > > ---
> > > >   tools/lib/bpf/libbpf.c | 80 ++++++++++++++++++++++++++++++++++++++++++
> > > >   1 file changed, 80 insertions(+)
> > > >
> > > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > > > index ab0c3a409eea..bdc08f89a5c0 100644
> > > > --- a/tools/lib/bpf/libbpf.c
> > > > +++ b/tools/lib/bpf/libbpf.c
> > > > @@ -180,6 +180,8 @@ enum kern_feature_id {
> > > >       FEAT_ARRAY_MMAP,
> > > >       /* kernel support for expected_attach_type in BPF_PROG_LOAD */
> > > >       FEAT_EXP_ATTACH_TYPE,
> > > > +     /* bpf_probe_read_{kernel,user}[_str] helpers */
> > > > +     FEAT_PROBE_READ_KERN,
> > > >       __FEAT_CNT,
> > > >   };
> > > >
> > > > @@ -3591,6 +3593,27 @@ static int probe_kern_exp_attach_type(void)
> > > >       return probe_fd(bpf_load_program_xattr(&attr, NULL, 0));
> > > >   }
> > > >
> > > [...]
> > > >
> > > > +static bool insn_is_helper_call(struct bpf_insn *insn, enum bpf_func_id *func_id)
> > > > +{
> > > > +     __u8 class = BPF_CLASS(insn->code);
> > > > +
> > > > +     if ((class == BPF_JMP || class == BPF_JMP32) &&
> > >
> > > Do we support BPF_JMP32 + BPF_CALL ... as a helper call?
> > > I am not aware of this.
> >
> > Verifier seems to support both. Check do_check in
> > kernel/bpf/verifier.c, around line 9000. So I decided to also support
> > it, even if Clang doesn't emit it (yet?).
>
> please check few lines below 9000 ;)
> jmp32 | call is rejected.
> I would remove that from libbpf as well.

I've stared at that condition multiple times and didn't notice the
"class == BPF_JMP32" part... Yeah, sure, I'll drop that, of course.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ