Skip to content

Commit a18d436

Browse files
zhangckidjasowang
authored andcommitted
net/colo: Fix a "double free" crash to clear the conn_list
We notice the QEMU may crash when the guest has too many incoming network connections with the following log: [email protected]:colo_proxy_main : colo proxy connection hashtable full, clear it free(): invalid pointer [1] 15195 abort (core dumped) qemu-system-x86_64 .... This is because we create the s->connection_track_table with g_hash_table_new_full() which is defined as: GHashTable * g_hash_table_new_full (GHashFunc hash_func, GEqualFunc key_equal_func, GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func); The fourth parameter connection_destroy() will be called to free the memory allocated for all 'Connection' values in the hashtable when we call g_hash_table_remove_all() in the connection_hashtable_reset(). But both connection_track_table and conn_list reference to the same conn instance. It will trigger double free in conn_list clear. So this patch remove free action on hash table side to avoid double free the conn. Signed-off-by: Like Xu <[email protected]> Signed-off-by: Zhang Chen <[email protected]> Signed-off-by: Jason Wang <[email protected]>
1 parent 669846c commit a18d436

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

net/colo-compare.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
13231323
s->connection_track_table = g_hash_table_new_full(connection_key_hash,
13241324
connection_key_equal,
13251325
g_free,
1326-
connection_destroy);
1326+
NULL);
13271327

13281328
colo_compare_iothread(s);
13291329

net/filter-rewriter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ static void colo_rewriter_setup(NetFilterState *nf, Error **errp)
383383
s->connection_track_table = g_hash_table_new_full(connection_key_hash,
384384
connection_key_equal,
385385
g_free,
386-
connection_destroy);
386+
NULL);
387387
s->incoming_queue = qemu_new_net_queue(qemu_netfilter_pass_to_next, nf);
388388
}
389389

0 commit comments

Comments
 (0)