bpf: Fix map leak in HASH_OF_MAPS map
authorAndrii Nakryiko <andriin@fb.com>
Wed, 29 Jul 2020 04:09:12 +0000 (21:09 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Aug 2020 08:06:03 +0000 (10:06 +0200)
commit634d42cadc4771fbe3b70e0fa8b82b334fd41959
tree054525e876a4d411653ce7ed56b68bc555ecab4a
parent5858ad8d6af5bdb01c3766febf3d360aa21bdf25
bpf: Fix map leak in HASH_OF_MAPS map

[ Upstream commit 1d4e1eab456e1ee92a94987499b211db05f900ea ]

Fix HASH_OF_MAPS bug of not putting inner map pointer on bpf_map_elem_update()
operation. This is due to per-cpu extra_elems optimization, which bypassed
free_htab_elem() logic doing proper clean ups. Make sure that inner map is put
properly in optimized case as well.

Fixes: 8c290e60fa2a ("bpf: fix hashmap extra_elems logic")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20200729040913.2815687-1-andriin@fb.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/hashtab.c