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

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