linux/arch/arm64
Aijun Sun 19f68ed6dc bpf, arm64: Allocate program buffer using kvcalloc instead of kcalloc
It is not necessary to allocate contiguous physical memory for BPF
program buffer using kcalloc. When the BPF program is large more than
memory page size, kcalloc allocates multiple memory pages from buddy
system. If the device can not provide sufficient memory, for example
in low-end android devices [0], memory allocation for BPF program is
likely to fail.

Test cases in lib/test_bpf.c all pass on ARM64 QEMU.

[0]
  AndroidTestSuit: page allocation failure: order:4,
  mode:0x40dc0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null),cpuset=foreground,mems_allowed=0
  Call trace:
   dump_stack+0xa4/0x114
   warn_alloc+0xf8/0x14c
   __alloc_pages_slowpath+0xac8/0xb14
   __alloc_pages_nodemask+0x194/0x3d0
   kmalloc_order_trace+0x44/0x1e8
   __kmalloc+0x29c/0x66c
   bpf_int_jit_compile+0x17c/0x568
   bpf_prog_select_runtime+0x4c/0x1b0
   bpf_prepare_filter+0x5fc/0x6bc
   bpf_prog_create_from_user+0x118/0x1c0
   seccomp_set_mode_filter+0x1c4/0x7cc
   __do_sys_prctl+0x380/0x1424
   __arm64_sys_prctl+0x20/0x2c
   el0_svc_common+0xc8/0x22c
   el0_svc_handler+0x1c/0x28
   el0_svc+0x8/0x100

Signed-off-by: Aijun Sun <aijun.sun@unisoc.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220804025442.22524-1-aijun.sun@unisoc.com
2022-08-08 16:42:43 +02:00
..
boot Networking changes for 6.0. 2022-08-03 16:29:08 -07:00
configs ARM: new SoC support for 6.0 2022-08-02 08:29:18 -07:00
crypto crypto: arm64/poly1305 - fix a read out-of-bound 2022-07-29 18:29:17 +08:00
hyperv arm64: hyperv: Initialize hypervisor on boot 2021-08-04 16:54:36 +00:00
include Networking changes for 6.0. 2022-08-03 16:29:08 -07:00
kernel RCU pull request for v5.20 (or whatever) 2022-08-02 19:12:45 -07:00
kvm arm64 updates for 5.20 2022-08-01 10:37:00 -07:00
lib Networking changes for 6.0. 2022-08-03 16:29:08 -07:00
mm EFI updates for v5.20 2022-08-03 14:38:02 -07:00
net bpf, arm64: Allocate program buffer using kvcalloc instead of kcalloc 2022-08-08 16:42:43 +02:00
tools Merge branch 'for-next/cpufeature' into for-next/core 2022-07-25 10:58:10 +01:00
xen xen: allow pv-only hypercalls only with CONFIG_XEN_PV 2021-11-02 08:11:01 -05:00
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kconfig RCU pull request for v5.20 (or whatever) 2022-08-02 19:12:45 -07:00
Kconfig.debug
Kconfig.platforms ARM: new SoC support for 6.0 2022-08-02 08:29:18 -07:00
Makefile kbuild: factor out the common installation code into scripts/install.sh 2022-05-11 21:45:53 +09:00