]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bpf: Free element after unlock in __htab_map_lookup_and_delete_elem()
authorHou Tao <houtao1@huawei.com>
Fri, 17 Jan 2025 10:18:14 +0000 (18:18 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 20 Jan 2025 17:09:01 +0000 (09:09 -0800)
commit47363f1553e69b8c2e3269f9883799a4ea898cd4
treed99b35e82c4ba442ed37549d2c2158a010146222
parent588c6ead325aecc9894c9925cf1f771b77437bee
bpf: Free element after unlock in __htab_map_lookup_and_delete_elem()

The freeing of special fields in map value may acquire a spin-lock
(e.g., the freeing of bpf_timer), however, the lookup_and_delete_elem
procedure has already held a raw-spin-lock, which violates the lockdep
rule.

The running context of __htab_map_lookup_and_delete_elem() has already
disabled the migration. Therefore, it is OK to invoke free_htab_elem()
after unlocking the bucket lock.

Fix the potential problem by freeing element after unlocking bucket lock
in __htab_map_lookup_and_delete_elem().

Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20250117101816.2101857-4-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/hashtab.c