Skip to contentSkip to conversation

netfilter: fix a use-after-free in mtype_destroy()

PATCH Applied Cong Wang 2 participants 2 messages Jan 10, 2020 – Jan 13, 2020

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 netfilter: fix a use-after-free in mtype_destroy()

map->members is freed by ip_set_free() right before using it in mtype_ext_cleanup() again. So we just have to move it down.

Reported-by [email protected]
Fixes 40cd63bf33b2 ("netfilter: ipset: Support extensions which need a per data destroy function")
Cc Pablo Neira Ayuso <[email protected]>
---
 net/netfilter/ipset/ip_set_bitmap_gen.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipset/ip_set_bitmap_gen.h +1 -1
index 1abd6f0dc227..077a2cb65fcb 100644
@@ -60,9 +60,9 @@ mtype_destroy(struct ip_set *set)
 	if (SET_WITH_TIMEOUT(set))
 		del_timer_sync(&map->gc);
 
-	ip_set_free(map->members);
 	if (set->dsize && set->extensions & IPSET_EXT_DESTROY)
 		mtype_ext_cleanup(set);
+	ip_set_free(map->members);
 	ip_set_free(map);
 
 	set->data = NULL;
Signature · 1 line
2.21.1
maintainer Applied
#1 lore raw
Quoted 2 lines · Cong Wang

map->members is freed by ip_set_free() right before using it in mtype_ext_cleanup() again. So we just have to move it down.

Applied, thanks.