OSDN Git Service

bpf: Fix bpf_prog_pack for multi-node setup
authorSong Liu <song@kernel.org>
Mon, 21 Mar 2022 18:00:08 +0000 (11:00 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 21 Mar 2022 20:53:45 +0000 (13:53 -0700)
commit96805674e5624b3c79780a2b41c7a3d6bc38dc76
treecb5323fa83da01aa49d7388482850e53fc6c627f
parentd56c9fe6a06820d5ef8188d96bf4345c7bdba249
bpf: Fix bpf_prog_pack for multi-node setup

module_alloc requires num_online_nodes * PMD_SIZE to allocate huge pages.
bpf_prog_pack uses pack of size num_online_nodes * PMD_SIZE.
OTOH, module_alloc returns addresses that are PMD_SIZE aligned (instead of
num_online_nodes * PMD_SIZE aligned). Therefore, PMD_MASK should be used
to calculate pack_ptr in bpf_prog_pack_free().

Fixes: ef078600eec2 ("bpf: Select proper size for bpf_prog_pack")
Reported-by: syzbot+c946805b5ce6ab87df0b@syzkaller.appspotmail.com
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220321180009.1944482-2-song@kernel.org
kernel/bpf/core.c