All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nft] tests: cover baecd1cf2685 ("segtree: Fix segfault when restoring a huge interval set")
@ 2021-10-20 12:42 Štěpán Němec
  2021-10-20 13:13 ` Phil Sutter
  0 siblings, 1 reply; 4+ messages in thread
From: Štěpán Němec @ 2021-10-20 12:42 UTC (permalink / raw)
  To: netfilter-devel, Pablo Neira Ayuso; +Cc: Phil Sutter

Test inspired by [1] with both the set and stack size reduced by the
same power of 2, to preserve the (pre-baecd1cf2685) segfault on one
hand, and make the test successfully complete (post-baecd1cf2685) in a
few seconds even on weaker hardware on the other.

(The reason I stopped at 128kB stack size is that with 64kB I was
getting segfaults even with baecd1cf2685 applied.)

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1908127

Signed-off-by: Štěpán Němec <snemec@redhat.com>
Helped-by: Phil Sutter <phil@nwl.cc>
---
 .../sets/0068interval_stack_overflow_0        | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100755 tests/shell/testcases/sets/0068interval_stack_overflow_0

diff --git a/tests/shell/testcases/sets/0068interval_stack_overflow_0 b/tests/shell/testcases/sets/0068interval_stack_overflow_0
new file mode 100755
index 000000000000..134282de2826
--- /dev/null
+++ b/tests/shell/testcases/sets/0068interval_stack_overflow_0
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+set -e
+
+ruleset_file=$(mktemp)
+
+trap 'rm -f "$ruleset_file"' EXIT
+
+{
+	echo 'define big_set = {'
+	for ((i = 1; i < 255; i++)); do
+		for ((j = 1; j < 80; j++)); do
+			echo "10.0.$i.$j,"
+		done
+	done
+	echo '10.1.0.0/24 }'
+} >"$ruleset_file"
+
+cat >>"$ruleset_file" <<\EOF
+table inet test68_table {
+	set test68_set {
+		type ipv4_addr
+		flags interval
+		elements = { $big_set }
+	}
+}
+EOF
+
+( ulimit -s 128 && "$NFT" -f "$ruleset_file" )

base-commit: 2139913694a9850c9160920b2c638aac4828f9bb
-- 
2.33.1


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

* Re: [PATCH nft] tests: cover baecd1cf2685 ("segtree: Fix segfault when restoring a huge interval set")
  2021-10-20 12:42 [PATCH nft] tests: cover baecd1cf2685 ("segtree: Fix segfault when restoring a huge interval set") Štěpán Němec
@ 2021-10-20 13:13 ` Phil Sutter
  2021-10-20 13:38   ` Štěpán Němec
  0 siblings, 1 reply; 4+ messages in thread
From: Phil Sutter @ 2021-10-20 13:13 UTC (permalink / raw)
  To: Štěpán Němec; +Cc: netfilter-devel, Pablo Neira Ayuso

Hi Stepan,

On Wed, Oct 20, 2021 at 02:42:20PM +0200, Štěpán Němec wrote:
> Test inspired by [1] with both the set and stack size reduced by the
> same power of 2, to preserve the (pre-baecd1cf2685) segfault on one
> hand, and make the test successfully complete (post-baecd1cf2685) in a
> few seconds even on weaker hardware on the other.
> 
> (The reason I stopped at 128kB stack size is that with 64kB I was
> getting segfaults even with baecd1cf2685 applied.)
> 
> [1] https://bugzilla.redhat.com/show_bug.cgi?id=1908127
> 
> Signed-off-by: Štěpán Němec <snemec@redhat.com>
> Helped-by: Phil Sutter <phil@nwl.cc>

Thanks for the patch, just one remark:

[...]
> +cat >>"$ruleset_file" <<\EOF
                          ~~~
Is this backslash a typo or intentional?

Cheers, Phil

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

* Re: [PATCH nft] tests: cover baecd1cf2685 ("segtree: Fix segfault when restoring a huge interval set")
  2021-10-20 13:13 ` Phil Sutter
@ 2021-10-20 13:38   ` Štěpán Němec
  2021-10-20 13:53     ` Phil Sutter
  0 siblings, 1 reply; 4+ messages in thread
From: Štěpán Němec @ 2021-10-20 13:38 UTC (permalink / raw)
  To: Phil Sutter; +Cc: netfilter-devel, Pablo Neira Ayuso

On Wed, 20 Oct 2021 15:13:54 +0200
Phil Sutter wrote:

> Thanks for the patch, just one remark:
>
> [...]
>> +cat >>"$ruleset_file" <<\EOF
>                           ~~~
> Is this backslash a typo or intentional?

It instructs the shell not to perform expansion on the heredoc lines
(which would include interpreting '$big_set' as a shell variable).

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04

-- 
Štěpán


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

* Re: [PATCH nft] tests: cover baecd1cf2685 ("segtree: Fix segfault when restoring a huge interval set")
  2021-10-20 13:38   ` Štěpán Němec
@ 2021-10-20 13:53     ` Phil Sutter
  0 siblings, 0 replies; 4+ messages in thread
From: Phil Sutter @ 2021-10-20 13:53 UTC (permalink / raw)
  To: Štěpán Němec; +Cc: netfilter-devel, Pablo Neira Ayuso

On Wed, Oct 20, 2021 at 03:38:01PM +0200, Štěpán Němec wrote:
> On Wed, 20 Oct 2021 15:13:54 +0200
> Phil Sutter wrote:
> 
> > Thanks for the patch, just one remark:
> >
> > [...]
> >> +cat >>"$ruleset_file" <<\EOF
> >                           ~~~
> > Is this backslash a typo or intentional?
> 
> It instructs the shell not to perform expansion on the heredoc lines
> (which would include interpreting '$big_set' as a shell variable).

Ah, I missed the part about quoting parts of 'word'. :)

Patch applied, thanks!

Cheers, Phil

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

end of thread, other threads:[~2021-10-20 13:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20 12:42 [PATCH nft] tests: cover baecd1cf2685 ("segtree: Fix segfault when restoring a huge interval set") Štěpán Němec
2021-10-20 13:13 ` Phil Sutter
2021-10-20 13:38   ` Štěpán Němec
2021-10-20 13:53     ` Phil Sutter

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.