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]
Message-ID: <CAEf4BzZDJyEfSqnnDv0pe6J8GZwQVE8tucJWs3hHNeQemwVN9w@mail.gmail.com>
Date:   Tue, 30 Jun 2020 08:15:33 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Daniel Borkmann <daniel@...earbox.net>
Cc:     Andrii Nakryiko <andriin@...com>, bpf <bpf@...r.kernel.org>,
        Networking <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...com>,
        Kernel Team <kernel-team@...com>
Subject: Re: [PATCH v2 bpf] bpf: enforce BPF ringbuf size to be the power of 2

On Tue, Jun 30, 2020 at 7:52 AM Daniel Borkmann <daniel@...earbox.net> wrote:
>
> On 6/30/20 8:15 AM, Andrii Nakryiko wrote:
> > BPF ringbuf assumes the size to be a multiple of page size and the power of
> > 2 value. The latter is important to avoid division while calculating position
> > inside the ring buffer and using (N-1) mask instead. This patch fixes omission
> > to enforce power-of-2 size rule.
> >
> > Fixes: 457f44363a88 ("bpf: Implement BPF ring buffer and verifier support for it")
> > Signed-off-by: Andrii Nakryiko <andriin@...com>
>
> Lgtm, applied, thanks!
>

Thanks, Daniel!

> [...]
> > @@ -166,9 +157,16 @@ static struct bpf_map *ringbuf_map_alloc(union bpf_attr *attr)
> >               return ERR_PTR(-EINVAL);
> >
> >       if (attr->key_size || attr->value_size ||
> > -         attr->max_entries == 0 || !PAGE_ALIGNED(attr->max_entries))
> > +         !is_power_of_2(attr->max_entries) ||
> > +         !PAGE_ALIGNED(attr->max_entries))
>
> Technically !IS_ALIGNED(attr->max_entries, PAGE_SIZE) might have been a bit cleaner
> since PAGE_ALIGNED() is only intended for pointers, though, not wrong here given
> max_entries is u32.

I've found a bunch of uses on non-pointers, e.g., `if
(!PAGE_ALIGNED(fs_info->nodesize)) {` in BTRFS code, so assumed it's
intended to be used more generically. But let me know if you want me
to do IS_ALIGNED change.

>
> Thanks,
> Daniel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ