stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Florian Westphal <fw@strlen.de>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-kselftest@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 08/69] selftests: add script to stress-test nft packet path vs. control plane
Date: Wed,  5 Dec 2018 04:41:46 -0500	[thread overview]
Message-ID: <20181205094247.6556-8-sashal@kernel.org> (raw)
In-Reply-To: <20181205094247.6556-1-sashal@kernel.org>

From: Florian Westphal <fw@strlen.de>

[ Upstream commit 25d8bcedbf4329895dbaf9dd67baa6f18dad918c ]

Start flood ping for each cpu while loading/flushing rulesets to make
sure we do not access already-free'd rules from nf_tables evaluation loop.

Also add this to TARGETS so 'make run_tests' in selftest dir runs it
automatically.

This would have caught the bug fixed in previous change
("netfilter: nf_tables: do not skip inactive chains during generation update")
sooner.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/selftests/Makefile              |  1 +
 tools/testing/selftests/netfilter/Makefile    |  6 ++
 tools/testing/selftests/netfilter/config      |  2 +
 .../selftests/netfilter/nft_trans_stress.sh   | 78 +++++++++++++++++++
 4 files changed, 87 insertions(+)
 create mode 100644 tools/testing/selftests/netfilter/Makefile
 create mode 100644 tools/testing/selftests/netfilter/config
 create mode 100755 tools/testing/selftests/netfilter/nft_trans_stress.sh

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index ea300e7818a7..10b89f5b9af7 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -20,6 +20,7 @@ TARGETS += memory-hotplug
 TARGETS += mount
 TARGETS += mqueue
 TARGETS += net
+TARGETS += netfilter
 TARGETS += nsfs
 TARGETS += powerpc
 TARGETS += pstore
diff --git a/tools/testing/selftests/netfilter/Makefile b/tools/testing/selftests/netfilter/Makefile
new file mode 100644
index 000000000000..47ed6cef93fb
--- /dev/null
+++ b/tools/testing/selftests/netfilter/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+# Makefile for netfilter selftests
+
+TEST_PROGS := nft_trans_stress.sh
+
+include ../lib.mk
diff --git a/tools/testing/selftests/netfilter/config b/tools/testing/selftests/netfilter/config
new file mode 100644
index 000000000000..1017313e41a8
--- /dev/null
+++ b/tools/testing/selftests/netfilter/config
@@ -0,0 +1,2 @@
+CONFIG_NET_NS=y
+NF_TABLES_INET=y
diff --git a/tools/testing/selftests/netfilter/nft_trans_stress.sh b/tools/testing/selftests/netfilter/nft_trans_stress.sh
new file mode 100755
index 000000000000..f1affd12c4b1
--- /dev/null
+++ b/tools/testing/selftests/netfilter/nft_trans_stress.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+#
+# This test is for stress-testing the nf_tables config plane path vs.
+# packet path processing: Make sure we never release rules that are
+# still visible to other cpus.
+#
+# set -e
+
+# Kselftest framework requirement - SKIP code is 4.
+ksft_skip=4
+
+testns=testns1
+tables="foo bar baz quux"
+
+nft --version > /dev/null 2>&1
+if [ $? -ne 0 ];then
+	echo "SKIP: Could not run test without nft tool"
+	exit $ksft_skip
+fi
+
+ip -Version > /dev/null 2>&1
+if [ $? -ne 0 ];then
+	echo "SKIP: Could not run test without ip tool"
+	exit $ksft_skip
+fi
+
+tmp=$(mktemp)
+
+for table in $tables; do
+	echo add table inet "$table" >> "$tmp"
+	echo flush table inet "$table" >> "$tmp"
+
+	echo "add chain inet $table INPUT { type filter hook input priority 0; }" >> "$tmp"
+	echo "add chain inet $table OUTPUT { type filter hook output priority 0; }" >> "$tmp"
+	for c in $(seq 1 400); do
+		chain=$(printf "chain%03u" "$c")
+		echo "add chain inet $table $chain" >> "$tmp"
+	done
+
+	for c in $(seq 1 400); do
+		chain=$(printf "chain%03u" "$c")
+		for BASE in INPUT OUTPUT; do
+			echo "add rule inet $table $BASE counter jump $chain" >> "$tmp"
+		done
+		echo "add rule inet $table $chain counter return" >> "$tmp"
+	done
+done
+
+ip netns add "$testns"
+ip -netns "$testns" link set lo up
+
+lscpu | grep ^CPU\(s\): | ( read cpu cpunum ;
+cpunum=$((cpunum-1))
+for i in $(seq 0 $cpunum);do
+	mask=$(printf 0x%x $((1<<$i)))
+        ip netns exec "$testns" taskset $mask ping -4 127.0.0.1 -fq > /dev/null &
+        ip netns exec "$testns" taskset $mask ping -6 ::1 -fq > /dev/null &
+done)
+
+sleep 1
+
+for i in $(seq 1 10) ; do ip netns exec "$testns" nft -f "$tmp" & done
+
+for table in $tables;do
+	randsleep=$((RANDOM%10))
+	sleep $randsleep
+	ip netns exec "$testns" nft delete table inet $table 2>/dev/null
+done
+
+randsleep=$((RANDOM%10))
+sleep $randsleep
+
+pkill -9 ping
+
+wait
+
+rm -f "$tmp"
+ip netns del "$testns"
-- 
2.17.1

  parent reply	other threads:[~2018-12-05  9:41 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-05  9:41 [PATCH AUTOSEL 4.14 01/69] ARM: OMAP2+: prm44xx: Fix section annotation on omap44xx_prm_enable_io_wakeup Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 02/69] ASoC: rsnd: fixup clock start checker Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 03/69] iio:st_magn: Fix enable device after trigger Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 04/69] staging: rtl8723bs: Fix the return value in case of error in 'rtw_wx_read32()' Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 05/69] ARM: dts: logicpd-somlv: Fix interrupt on mmc3_dat1 Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 06/69] ARM: OMAP1: ams-delta: Fix possible use of uninitialized field Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 07/69] sysv: return 'err' instead of 0 in __sysv_write_inode Sasha Levin
2018-12-05  9:41 ` Sasha Levin [this message]
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 09/69] netfilter: nf_tables: fix use-after-free when deleting compat expressions Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 10/69] hwmon (ina2xx) Fix NULL id pointer in probe() Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 11/69] ASoC: wm_adsp: Fix dma-unsafe read of scratch registers Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 12/69] s390/cpum_cf: Reject request for sampling in event initialization Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 13/69] hwmon: (ina2xx) Fix current value calculation Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 14/69] ASoC: omap-abe-twl6040: Fix missing audio card caused by deferred probing Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 15/69] ASoC: dapm: Recalculate audio map forcely when card instantiated Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 16/69] iio/hid-sensors: Fix IIO_CHAN_INFO_RAW returning wrong values for signed numbers Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 17/69] netfilter: xt_hashlimit: fix a possible memory leak in htable_create() Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 18/69] hwmon: (w83795) temp4_type has writable permission Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 19/69] perf tools: Restore proper cwd on return from mnt namespace Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 20/69] PCI: imx6: Fix link training status detection in link up check Sasha Levin
2018-12-05  9:41 ` [PATCH AUTOSEL 4.14 21/69] objtool: Fix double-free in .cold detection error path Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 22/69] objtool: Fix segfault in .cold detection with -ffunction-sections Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 23/69] ARM: dts: at91: sama5d2: use the divided clock for SMC Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 24/69] Btrfs: send, fix infinite loop due to directory rename dependencies Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 25/69] RDMA/mlx5: Fix fence type for IB_WR_LOCAL_INV WR Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 26/69] RDMA/rdmavt: Fix rvt_create_ah function signature Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 27/69] uprobes: Fix handle_swbp() vs. unregister() + register() race once more Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 28/69] ASoC: omap-mcbsp: Fix latency value calculation for pm_qos Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 29/69] ASoC: omap-mcpdm: Add pm_qos handling to avoid under/overruns with CPU_IDLE Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 30/69] ASoC: omap-dmic: Add pm_qos handling to avoid overruns " Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 31/69] exportfs: do not read dentry after free Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 32/69] bpf: fix check of allowed specifiers in bpf_trace_printk Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 33/69] ipvs: call ip_vs_dst_notifier earlier than ipv6_dev_notf Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 34/69] USB: omap_udc: use devm_request_irq() Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 35/69] USB: omap_udc: fix crashes on probe error and module removal Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 36/69] USB: omap_udc: fix omap_udc_start() on 15xx machines Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 37/69] USB: omap_udc: fix USB gadget functionality on Palm Tungsten E Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 38/69] USB: omap_udc: fix rejection of out transfers when DMA is used Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 39/69] drm/meson: add support for 1080p25 mode Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 40/69] netfilter: ipv6: Preserve link scope traffic original oif Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 41/69] IB/mlx5: Fix page fault handling for MW Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 42/69] KVM: x86: fix empty-body warnings Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 43/69] x86/kvm/vmx: fix old-style function declaration Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 44/69] net: thunderx: fix NULL pointer dereference in nic_remove Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 45/69] usb: gadget: u_ether: fix unsafe list iteration Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 46/69] netfilter: nf_tables: deactivate expressions in rule replecement routine Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 47/69] cachefiles: Fix page leak in cachefiles_read_backing_file while vmscan is active Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 48/69] igb: fix uninitialized variables Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 49/69] ixgbe: recognize 1000BaseLX SFP modules as 1Gbps Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 50/69] rapidio/rionet: do not free skb before reading its length Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 51/69] net: hisilicon: remove unexpected free_netdev Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 52/69] s390/qeth: fix length check in SNMP processing Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 53/69] drm/amdgpu: Add delay after enable RLC ucode Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 54/69] drm/ast: fixed reading monitor EDID not stable issue Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 55/69] xen: xlate_mmu: add missing header to fix 'W=1' warning Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 56/69] Revert "xen/balloon: Mark unallocated host memory as UNUSABLE" Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 57/69] pstore/ram: Correctly calculate usable PRZ bytes Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 58/69] fscache: fix race between enablement and dropping of object Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 59/69] fscache, cachefiles: remove redundant variable 'cache' Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 60/69] nvme: flush namespace scanning work just before removing namespaces Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 61/69] ACPI/IORT: Fix iort_get_platform_device_domain() uninitialized pointer value Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 62/69] test_hexdump: use memcpy instead of strncpy Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 63/69] unifdef: " Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 64/69] ocfs2: fix deadlock caused by ocfs2_defrag_extent() Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 65/69] mm/page_alloc.c: fix calculation of pgdat->nr_zones Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 66/69] hfs: do not free node before using Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 67/69] hfsplus: " Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 68/69] debugobjects: avoid recursive calls with kmemleak Sasha Levin
2018-12-05  9:42 ` [PATCH AUTOSEL 4.14 69/69] ocfs2: fix potential use after free Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181205094247.6556-8-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=fw@strlen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).