]> git.baikalelectronics.ru Git - kernel.git/commit
cpumap: Avoid warning when CONFIG_DEBUG_PER_CPU_MAPS is enabled
authorToke Høiland-Jørgensen <toke@redhat.com>
Thu, 16 Apr 2020 08:31:20 +0000 (10:31 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 21 Apr 2020 01:38:04 +0000 (18:38 -0700)
commit8353d64404b5852a7ab1c6f7334d6c911685a075
treed9b55b22a3c6429936b2b7d5d5b3b6b129845a1b
parent4e9d399d869388f44e1dd6256c7be3fa291e76ab
cpumap: Avoid warning when CONFIG_DEBUG_PER_CPU_MAPS is enabled

When the kernel is built with CONFIG_DEBUG_PER_CPU_MAPS, the cpumap code
can trigger a spurious warning if CONFIG_CPUMASK_OFFSTACK is also set. This
happens because in this configuration, NR_CPUS can be larger than
nr_cpumask_bits, so the initial check in cpu_map_alloc() is not sufficient
to guard against hitting the warning in cpumask_check().

Fix this by explicitly checking the supplied key against the
nr_cpumask_bits variable before calling cpu_possible().

Fixes: 04bfdfb3d276 ("bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP")
Reported-by: Xiumei Mu <xmu@redhat.com>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: Xiumei Mu <xmu@redhat.com>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20200416083120.453718-1-toke@redhat.com
kernel/bpf/cpumap.c