Skip to contentSkip to conversation

src: fix double free on xt stmt destruction

PATCH In review Florian Westphal 2 participants 2 messages Apr 23, 2019 – Apr 30, 2019 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 src: fix double free on xt stmt destruction

'nft monitor' dies with:
*** Error in `/sbin/nft': double free or corruption (fasttop): 0x000055f8ba57b750 ***

... when the iptables-nft test suite is running in parallel, because xfree(stmt->xt.name) gets called twice.

Fixes 4ac11b890fe870 ("src: missing destroy function in statement definitions")
---
 include/xt.h    | 2 +-
 src/statement.c | 6 ------
 src/xt.c        | 2 +-
 3 files changed, 2 insertions(+), 8 deletions(-)
include/xt.h +1 -1
index ab59bb3d45a4..9fc515084d59 100644
@@ -9,7 +9,7 @@ struct rule;
 struct output_ctx;
 
 void xt_stmt_xlate(const struct stmt *stmt, struct output_ctx *octx);
-void xt_stmt_release(const struct stmt *stmt);
+void xt_stmt_destroy(struct stmt *stmt);
 
 void netlink_parse_target(struct netlink_parse_ctx *ctx,
 			  const struct location *loc,
src/statement.c +0 -6
index b2370f8710a4..7f9c10b38244 100644
@@ -866,12 +866,6 @@ static void xt_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
 	xt_stmt_xlate(stmt, octx);
 }
 
-static void xt_stmt_destroy(struct stmt *stmt)
-{
-	xfree(stmt->xt.name);
-	xt_stmt_release(stmt);
-}
-
 static const struct stmt_ops xt_stmt_ops = {
 	.type		= STMT_XT,
 	.name		= "xt",
src/xt.c +1 -1
index 906b2fde10e1..b0f5a30c46b5 100644
@@ -78,7 +78,7 @@ void xt_stmt_xlate(const struct stmt *stmt, struct output_ctx *octx)
 #endif
 }
 
-void xt_stmt_release(const struct stmt *stmt)
+void xt_stmt_destroy(struct stmt *stmt)
 {
 #ifdef HAVE_LIBXTABLES
 	switch (stmt->xt.type) {
Signature · 1 line
2.21.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Florian Westphal

'nft monitor' dies with:
*** Error in `/sbin/nft': double free or corruption (fasttop): 0x000055f8ba57b750 ***

... when the iptables-nft test suite is running in parallel, because xfree(stmt->xt.name) gets called twice.

Fixes 4ac11b890fe870 ("src: missing destroy function in statement definitions")