2019-11-25 23:42:30

by John Hubbard

[permalink] [raw]
Subject: [PATCH] bpf: fix a no-mmu build failure by providing a stub allocator

Commit fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
added code that calls vmalloc_user_node_flags() and therefore requires
mm/vmalloc.c. However, that file is not built for the !CONFIG_MMU case.
This leads to a build failure when using ARM with the config provided
by at least one particular kbuild test robot report [1].

[1] https://lore/kernel.org/r/201911251639.UWS3hE3Y%[email protected]

Fix the build by providing a stub function for __bpf_map_area_alloc().

Fixes: fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
Reported-by: kbuild test robot <[email protected]>
Cc: Andrii Nakryiko <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: Song Liu <[email protected]>
Cc: John Fastabend <[email protected]>
Cc: Johannes Weiner <[email protected]>
Signed-off-by: John Hubbard <[email protected]>
---
kernel/bpf/syscall.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index e3461ec59570..cb3e13ee4123 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -128,6 +128,7 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr)
return map;
}

+#ifdef CONFIG_MMU
static void *__bpf_map_area_alloc(u64 size, int numa_node, bool mmapable)
{
/* We really just want to fail instead of triggering OOM killer
@@ -162,6 +163,12 @@ static void *__bpf_map_area_alloc(u64 size, int numa_node, bool mmapable)
GFP_KERNEL | __GFP_RETRY_MAYFAIL |
flags, __builtin_return_address(0));
}
+#else /* CONFIG_MMU */
+static void *__bpf_map_area_alloc(u64 size, int numa_node, bool mmapable)
+{
+ return NULL;
+}
+#endif /* !CONFIG_MMU */

void *bpf_map_area_alloc(u64 size, int numa_node)
{
--
2.24.0


2019-11-25 23:46:14

by Daniel Borkmann

[permalink] [raw]
Subject: Re: [PATCH] bpf: fix a no-mmu build failure by providing a stub allocator

On 11/26/19 12:41 AM, John Hubbard wrote:
> Commit fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
> added code that calls vmalloc_user_node_flags() and therefore requires
> mm/vmalloc.c. However, that file is not built for the !CONFIG_MMU case.
> This leads to a build failure when using ARM with the config provided
> by at least one particular kbuild test robot report [1].
>
> [1] https://lore/kernel.org/r/201911251639.UWS3hE3Y%[email protected]
>
> Fix the build by providing a stub function for __bpf_map_area_alloc().
>
> Fixes: fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
> Reported-by: kbuild test robot <[email protected]>
> Cc: Andrii Nakryiko <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: Song Liu <[email protected]>
> Cc: John Fastabend <[email protected]>
> Cc: Johannes Weiner <[email protected]>
> Signed-off-by: John Hubbard <[email protected]>

Thanks for the patch, already fixed via:

https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=ed81745a4c96841937f1da35c0eb66ac312e1480

2019-11-25 23:47:21

by John Hubbard

[permalink] [raw]
Subject: Re: [PATCH] bpf: fix a no-mmu build failure by providing a stub allocator

On 11/25/19 3:43 PM, Daniel Borkmann wrote:
> On 11/26/19 12:41 AM, John Hubbard wrote:
>> Commit fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
>> added code that calls vmalloc_user_node_flags() and therefore requires
>> mm/vmalloc.c. However, that file is not built for the !CONFIG_MMU case.
>> This leads to a build failure when using ARM with the config provided
>> by at least one particular kbuild test robot report [1].
>>
>> [1] https://lore/kernel.org/r/201911251639.UWS3hE3Y%[email protected]
>>
>> Fix the build by providing a stub function for __bpf_map_area_alloc().
>>
>> Fixes: fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
>> Reported-by: kbuild test robot <[email protected]>
>> Cc: Andrii Nakryiko <[email protected]>
>> Cc: Daniel Borkmann <[email protected]>
>> Cc: Song Liu <[email protected]>
>> Cc: John Fastabend <[email protected]>
>> Cc: Johannes Weiner <[email protected]>
>> Signed-off-by: John Hubbard <[email protected]>
>
> Thanks for the patch, already fixed via:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=ed81745a4c96841937f1da35c0eb66ac312e1480

OK, good, that's a better fix, too. Appreciate the quick answers!


thanks,
--
John Hubbard
NVIDIA