Linux Netfilter development
 help / color / mirror / Atom feed
* [PATCH] segtree: bail out on concatenations
@ 2020-04-02 21:49 Pablo Neira Ayuso
  2020-04-03  0:54 ` Stefano Brivio
  2020-04-03 12:03 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 10+ messages in thread
From: Pablo Neira Ayuso @ 2020-04-02 21:49 UTC (permalink / raw)
  To: netfilter-devel; +Cc: fw

This patch adds a lazy check to validate that the first element is not a
concatenation. The segtree code does not support for concatenations,
bail out with EOPNOTSUPP.

 # nft add element x y { 10.0.0.0/8 . 192.168.1.3-192.168.1.9 . 1024-65535 }
 Error: Could not process rule: Operation not supported
 add element x y { 10.0.0.0/8 . 192.168.1.3-192.168.1.9 . 1024-65535 }
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Otherwise, the segtree code barfs with:

 BUG: invalid range expression type concat

Reported-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/segtree.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/segtree.c b/src/segtree.c
index 8d79332d8578..85310f62c429 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -419,6 +419,17 @@ static int set_to_segtree(struct list_head *msgs, struct set *set,
 	unsigned int n;
 	int err;
 
+	/* Probe for the first element to check for concatenations, this code
+	 * does not support for intervals and concatenations.
+	 */
+	if (init) {
+		i = list_first_entry(&init->expressions, struct expr, list);
+		if (i->key->etype == EXPR_CONCAT) {
+			errno = EOPNOTSUPP;
+			return -1;
+		}
+	}
+
 	/* We are updating an existing set with new elements, check if the new
 	 * interval overlaps with any of the existing ones.
 	 */
-- 
2.11.0


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

end of thread, other threads:[~2020-04-03 14:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-02 21:49 [PATCH] segtree: bail out on concatenations Pablo Neira Ayuso
2020-04-03  0:54 ` Stefano Brivio
2020-04-03 10:39   ` Pablo Neira Ayuso
2020-04-03 10:43     ` Stefano Brivio
2020-04-03 12:03 ` Pablo Neira Ayuso
2020-04-03 12:05   ` Pablo Neira Ayuso
2020-04-03 12:27   ` Stefano Brivio
2020-04-03 12:50     ` Pablo Neira Ayuso
2020-04-03 13:33       ` Stefano Brivio
2020-04-03 14:12         ` Stefano Brivio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox