Blame SOURCES/0068-tests-cover-baecd1cf2685-segtree-Fix-segfault-when-r.patch

8ff5ad
From cc6c59e683c503b461b4a80526f4bc9cbb0660bf Mon Sep 17 00:00:00 2001
8ff5ad
From: Phil Sutter <psutter@redhat.com>
8ff5ad
Date: Fri, 5 Nov 2021 16:06:45 +0100
8ff5ad
Subject: [PATCH] tests: cover baecd1cf2685 ("segtree: Fix segfault when
8ff5ad
 restoring a huge interval set")
8ff5ad
MIME-Version: 1.0
8ff5ad
Content-Type: text/plain; charset=UTF-8
8ff5ad
Content-Transfer-Encoding: 8bit
8ff5ad
8ff5ad
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1908127
8ff5ad
Upstream Status: nftables commit d8ccad2a2b73c
8ff5ad
8ff5ad
commit d8ccad2a2b73c4189934eb5fd0e3d096699b5043
8ff5ad
Author: Štěpán Němec <snemec@redhat.com>
8ff5ad
Date:   Wed Oct 20 14:42:20 2021 +0200
8ff5ad
8ff5ad
    tests: cover baecd1cf2685 ("segtree: Fix segfault when restoring a huge interval set")
8ff5ad
8ff5ad
    Test inspired by [1] with both the set and stack size reduced by the
8ff5ad
    same power of 2, to preserve the (pre-baecd1cf2685) segfault on one
8ff5ad
    hand, and make the test successfully complete (post-baecd1cf2685) in a
8ff5ad
    few seconds even on weaker hardware on the other.
8ff5ad
8ff5ad
    (The reason I stopped at 128kB stack size is that with 64kB I was
8ff5ad
    getting segfaults even with baecd1cf2685 applied.)
8ff5ad
8ff5ad
    [1] https://bugzilla.redhat.com/show_bug.cgi?id=1908127
8ff5ad
8ff5ad
    Signed-off-by: Štěpán Němec <snemec@redhat.com>
8ff5ad
    Helped-by: Phil Sutter <phil@nwl.cc>
8ff5ad
    Signed-off-by: Phil Sutter <phil@nwl.cc>
8ff5ad
---
8ff5ad
 .../sets/0068interval_stack_overflow_0        | 29 +++++++++++++++++++
8ff5ad
 1 file changed, 29 insertions(+)
8ff5ad
 create mode 100755 tests/shell/testcases/sets/0068interval_stack_overflow_0
8ff5ad
8ff5ad
diff --git a/tests/shell/testcases/sets/0068interval_stack_overflow_0 b/tests/shell/testcases/sets/0068interval_stack_overflow_0
8ff5ad
new file mode 100755
8ff5ad
index 0000000..134282d
8ff5ad
--- /dev/null
8ff5ad
+++ b/tests/shell/testcases/sets/0068interval_stack_overflow_0
8ff5ad
@@ -0,0 +1,29 @@
8ff5ad
+#!/bin/bash
8ff5ad
+
8ff5ad
+set -e
8ff5ad
+
8ff5ad
+ruleset_file=$(mktemp)
8ff5ad
+
8ff5ad
+trap 'rm -f "$ruleset_file"' EXIT
8ff5ad
+
8ff5ad
+{
8ff5ad
+	echo 'define big_set = {'
8ff5ad
+	for ((i = 1; i < 255; i++)); do
8ff5ad
+		for ((j = 1; j < 80; j++)); do
8ff5ad
+			echo "10.0.$i.$j,"
8ff5ad
+		done
8ff5ad
+	done
8ff5ad
+	echo '10.1.0.0/24 }'
8ff5ad
+} >"$ruleset_file"
8ff5ad
+
8ff5ad
+cat >>"$ruleset_file" <<\EOF
8ff5ad
+table inet test68_table {
8ff5ad
+	set test68_set {
8ff5ad
+		type ipv4_addr
8ff5ad
+		flags interval
8ff5ad
+		elements = { $big_set }
8ff5ad
+	}
8ff5ad
+}
8ff5ad
+EOF
8ff5ad
+
8ff5ad
+( ulimit -s 128 && "$NFT" -f "$ruleset_file" )
8ff5ad
-- 
8ff5ad
2.31.1
8ff5ad