All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] set: remove unused set_clone() function
@ 2015-01-12 10:02 Patrick McHardy
  2015-01-12 10:02 ` [PATCH 2/2] expr: fix crash when listing non-verdict mappings Patrick McHardy
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick McHardy @ 2015-01-12 10:02 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel

The set_clone() function was added by the event monitor patchset and is
unused. It is also broken since it simply initializes the list head to
the list of the original set, so remove it.

Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 include/rule.h |  1 -
 src/rule.c     | 18 ------------------
 2 files changed, 19 deletions(-)

diff --git a/include/rule.h b/include/rule.h
index 0c52315..491411e 100644
--- a/include/rule.h
+++ b/include/rule.h
@@ -203,7 +203,6 @@ struct set {
 extern struct set *set_alloc(const struct location *loc);
 extern struct set *set_get(struct set *set);
 extern void set_free(struct set *set);
-extern struct set *set_clone(const struct set *set);
 extern void set_add_hash(struct set *set, struct table *table);
 extern struct set *set_lookup(const struct table *table, const char *name);
 extern struct set *set_lookup_global(uint32_t family, const char *table,
diff --git a/src/rule.c b/src/rule.c
index dd39e8a..feafe26 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -80,24 +80,6 @@ void set_free(struct set *set)
 	xfree(set);
 }
 
-struct set *set_clone(const struct set *set)
-{
-	struct set *newset = set_alloc(&set->location);
-
-	newset->list = set->list;
-	handle_merge(&newset->handle, &set->handle);
-	newset->flags = set->flags;
-	newset->keytype = set->keytype;
-	newset->keylen = set->keylen;
-	newset->datatype = set->datatype;
-	newset->datalen = set->datalen;
-	newset->init = expr_clone(set->init);
-	newset->policy = set->policy;
-	newset->desc.size = set->desc.size;
-
-	return newset;
-}
-
 void set_add_hash(struct set *set, struct table *table)
 {
 	list_add_tail(&set->list, &table->sets);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] expr: fix crash when listing non-verdict mappings
  2015-01-12 10:02 [PATCH 1/2] set: remove unused set_clone() function Patrick McHardy
@ 2015-01-12 10:02 ` Patrick McHardy
  0 siblings, 0 replies; 2+ messages in thread
From: Patrick McHardy @ 2015-01-12 10:02 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel

Fix regression introduced by commit 87c2a2205:

  netlink_delinearize: clone on netlink_get_register(), release previous on _set()

When using a non-verdict mapping, the set ref expression is assigned to the
destination register. The next get_register() will attempt to clone it and
crash because of the missing ->clone() callback.

# nft filter input meta mark set ip daddr map { 192.168.0.1 : 123 }
# nft list table filter
Segmentation fault (core dumped)

Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 src/expression.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/expression.c b/src/expression.c
index 8ba2e8a..5b848da 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -858,6 +858,11 @@ static void set_ref_expr_print(const struct expr *expr)
 		printf("@%s", expr->set->handle.set);
 }
 
+static void set_ref_expr_clone(struct expr *new, const struct expr *expr)
+{
+	new->set = set_get(expr->set);
+}
+
 static void set_ref_expr_destroy(struct expr *expr)
 {
 	set_free(expr->set);
@@ -867,6 +872,7 @@ static const struct expr_ops set_ref_expr_ops = {
 	.type		= EXPR_SET_REF,
 	.name		= "set reference",
 	.print		= set_ref_expr_print,
+	.clone		= set_ref_expr_clone,
 	.destroy	= set_ref_expr_destroy,
 };
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-12 10:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-12 10:02 [PATCH 1/2] set: remove unused set_clone() function Patrick McHardy
2015-01-12 10:02 ` [PATCH 2/2] expr: fix crash when listing non-verdict mappings Patrick McHardy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.