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:   Sat, 23 Nov 2019 13:52:47 -0800
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>,
        Johannes Weiner <hannes@...xchg.org>
Subject: Re: [PATCH bpf-next] bpf: fail mmap without CONFIG_MMU

On Sat, Nov 23, 2019 at 1:15 PM Daniel Borkmann <daniel@...earbox.net> wrote:
>
> On 11/23/19 9:56 PM, Andrii Nakryiko wrote:
> > mmap() support for BPF array depends on vmalloc_user_node_flags, which is
> > available only on CONFIG_MMU configurations. Fail mmap-able allocations if no
> > CONFIG_MMU is set.
> >
> > Cc: Johannes Weiner <hannes@...xchg.org>
> > Reported-by: kbuild test robot <lkp@...el.com>
> > Signed-off-by: Andrii Nakryiko <andriin@...com>
> > ---
> >   kernel/bpf/syscall.c | 4 ++++
> >   1 file changed, 4 insertions(+)
> >
> > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> > index bb002f15b32a..242a06fbdf18 100644
> > --- a/kernel/bpf/syscall.c
> > +++ b/kernel/bpf/syscall.c
> > @@ -156,8 +156,12 @@ static void *__bpf_map_area_alloc(u64 size, int numa_node, bool mmapable)
> >       }
> >       if (mmapable) {
> >               BUG_ON(!PAGE_ALIGNED(size));
> > +#ifndef CONFIG_MMU
> > +             return NULL;
> > +#else
> >               return vmalloc_user_node_flags(size, numa_node, GFP_KERNEL |
> >                                              __GFP_RETRY_MAYFAIL | flags);
>
> Hmm, this should rather live in include/linux/vmalloc.h, otherwise every future
> user of vmalloc_user_node_flags() would need to add this ifdef? vmalloc.h has
> the below, so perhaps this could be added there instead:

Ok, I finally untangled this all. The real fix is to implement
vmalloc_user_node_flags() in mm/no_mmu.c. Took me a bit to understand
how all this stuff is supposed to compile. If you take a look at
vmalloc.h, you'll see that most variants of vmalloc() are not
conditionally defined like __vmalloc_node_flags_caller. I'll send a
different patch with proper fix in few minutes.

>
> [..]
> #ifndef CONFIG_MMU
> extern void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags);
> static inline void *__vmalloc_node_flags_caller(unsigned long size, int node,
>                                                  gfp_t flags, void *caller)
> {
>          return __vmalloc_node_flags(size, node, flags);
> }
> #else
> extern void *__vmalloc_node_flags_caller(unsigned long size,
>                                           int node, gfp_t flags, void *caller);
> #endif
> [..]
>
> > +#endif
> >       }
> >       return __vmalloc_node_flags_caller(size, numa_node,
> >                                          GFP_KERNEL | __GFP_RETRY_MAYFAIL |
> >
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ