Skip to contentSkip to conversation

openvswitch: syzbot splat fix and introduce selftest

PATCH Applied Aaron Conole 3 participants 5 messages Oct 25, 2022 – Oct 27, 2022

Subsystems (4)
lore
Share & tools
lore

Aaron Conole

author maintainer
#0 lore raw

v2 cover openvswitch: syzbot splat fix and introduce selftest

Syzbot recently caught a splat when dropping features from openvswitch datapaths that are in-use. The WARN() call is definitely too large a hammer for the situation, so change to pr_warn.

Second patch in the series introduces a new selftest suite which can help show that an issue is fixed. This change might be more suited to net-next tree, so it has been separated out as an additional patch and can be either applied to either tree based on preference.

Aaron Conole (2):
openvswitch: switch from WARN to pr_warn
selftests: add openvswitch selftest suite

 MAINTAINERS                                   |   1 +
 net/openvswitch/datapath.c                    |   3 +-
 tools/testing/selftests/Makefile              |   1 +
 .../selftests/net/openvswitch/Makefile        |  13 +
 .../selftests/net/openvswitch/openvswitch.sh  | 218 +++++++++++
 .../selftests/net/openvswitch/ovs-dpctl.py    | 351 ++++++++++++++++++
 6 files changed, 586 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/net/openvswitch/Makefile
 create mode 100755 tools/testing/selftests/net/openvswitch/openvswitch.sh
 create mode 100644 tools/testing/selftests/net/openvswitch/ovs-dpctl.py
Signature · 1 line
2.34.3
author maintainer
#1 lore raw

PATCH v2 1/2 openvswitch: switch from WARN to pr_warn

As noted by Paolo Abeni, pr_warn doesn't generate any splat and can still preserve the warning to the user that feature downgrade occurred. We likely cannot introduce other kinds of checks / enforcement here because syzbot can generate different genl versions to the datapath.

Reported-by [email protected]
Fixes 44da5ae5fbea ("openvswitch: Drop user features if old user space attempted to create datapath")
Cc Thomas Graf <[email protected]>
---
 net/openvswitch/datapath.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/openvswitch/datapath.c +2 -1
index c8a9075ddd0a..155263e73512 100644
@@ -1616,7 +1616,8 @@ static void ovs_dp_reset_user_features(struct sk_buff *skb,
 	if (IS_ERR(dp))
 		return;
 
-	WARN(dp->user_features, "Dropping previously announced user features\n");
+	pr_warn("%s: Dropping previously announced user features\n",
+		ovs_dp_name(dp));
 	dp->user_features = 0;
 }
 
Signature · 1 line
2.34.3
maintainer Acked-by on v2 1/2
#2 lore raw

Re: [PATCH v2 net 1/2] openvswitch: switch from WARN to pr_warn

Quoted 18 lines · Aaron Conole

As noted by Paolo Abeni, pr_warn doesn't generate any splat and can still preserve the warning to the user that feature downgrade occurred. We likely cannot introduce other kinds of checks / enforcement here because syzbot can generate different genl versions to the datapath.

Reported-by [email protected]
Fixes 44da5ae5fbea ("openvswitch: Drop user features if old user space attempted to create datapath")
Cc Thomas Graf <[email protected]>
---
 net/openvswitch/datapath.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/openvswitch/datapath.c +0 -0
index c8a9075ddd0a..155263e73512 100644

net/openvswitch/datapath.c static void ovs_dp_reset_user_features(struct sk_buff *skb, · line 1623

Quoted 9 lines
net/openvswitch/datapath.c +2 -1
@@ -1616,7 +1616,8 @@ static void ovs_dp_reset_user_features(struct sk_buff *skb,
 	if (IS_ERR(dp))
 		return;
 
-	WARN(dp->user_features, "Dropping previously announced user features\n");
+	pr_warn("%s: Dropping previously announced user features\n",
+		ovs_dp_name(dp));
 	dp->user_features = 0;
 }
 

Nothing changed here since v1, so

author maintainer
#3 lore raw

PATCH v2 2/2 selftests: add openvswitch selftest suite

In reply to Aaron Conole

Previous commit resolves a WARN splat that can be difficult to reproduce, but with the ovs-dpctl.py utility, it can be trivial. Introduce a test case which creates a DP, and then downgrades the feature set. This will include a utility 'ovs-dpctl.py' that can be extended to do additional tests and diagnostics.

---
v1->v2: Convert to using pyroute2 for netlink messages
Dropped Keving Sprague (since ovs-dpctl.py was rewritten) Re-ran flake8 and also ran black against ovs-dpctl.py

 MAINTAINERS                                   |   1 +
 tools/testing/selftests/Makefile              |   1 +
 .../selftests/net/openvswitch/Makefile        |  13 +
 .../selftests/net/openvswitch/openvswitch.sh  | 218 +++++++++++
 .../selftests/net/openvswitch/ovs-dpctl.py    | 351 ++++++++++++++++++
 5 files changed, 584 insertions(+)
 create mode 100644 tools/testing/selftests/net/openvswitch/Makefile
 create mode 100755 tools/testing/selftests/net/openvswitch/openvswitch.sh
 create mode 100644 tools/testing/selftests/net/openvswitch/ovs-dpctl.py
MAINTAINERS +1 -0
index abbe88e1c50b..295a6b0fbe26 100644
@@ -15434,6 +15434,7 @@ S:	Maintained
 W:	http://openvswitch.org
 F:	include/uapi/linux/openvswitch.h
 F:	net/openvswitch/
+F:	tools/testing/selftests/net/openvswitch/
 
 OPERATING PERFORMANCE POINTS (OPP)
 M:	Viresh Kumar <[email protected]>
tools/testing/selftests/Makefile +1 -0
index 0464b2c6c1e4..f07aef7c592c 100644
@@ -49,6 +49,7 @@ TARGETS += net
 TARGETS += net/af_unix
 TARGETS += net/forwarding
 TARGETS += net/mptcp
+TARGETS += net/openvswitch
 TARGETS += netfilter
 TARGETS += nsfs
 TARGETS += pidfd
tools/testing/selftests/net/openvswitch/Makefile new file +13 -0
new file mode 100644
index 000000000000..2f1508abc826
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0
+
+top_srcdir = ../../../../..
+
+CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
+
+TEST_PROGS := openvswitch.sh
+
+TEST_FILES := ovs-dpctl.py
+
+EXTRA_CLEAN := test_netlink_checks
+
+include ../../lib.mk
tools/testing/selftests/net/openvswitch/openvswitch.sh new file +218 -0

218 lines not on this page · raw message

tools/testing/selftests/net/openvswitch/ovs-dpctl.py new file +351 -0

351 lines not on this page · raw message

Signature · 1 line
2.34.3
#4 lore raw
In reply to Aaron Conole
This series was applied to netdev/net.git (master) by Paolo Abeni <[email protected]>:

Hello:

This series was applied to netdev/net.git (master) by Paolo Abeni <[email protected]>:

Quoted 5 lines · On Tue, 25 Oct 2022 06:50:16 -0400 you wrote:

Syzbot recently caught a splat when dropping features from openvswitch datapaths that are in-use. The WARN() call is definitely too large a hammer for the situation, so change to pr_warn.

Quoted 7 lines

Second patch in the series introduces a new selftest suite which can help show that an issue is fixed. This change might be more suited to net-next tree, so it has been separated out as an additional patch and can be either applied to either tree based on preference.

[...]

Here is the summary with links:
- [v2,net,1/2] openvswitch: switch from WARN to pr_warn

    https://git.kernel.org/netdev/net/c/fd954cc1919e
  - [v2,net,2/2] selftests: add openvswitch selftest suite
    https://git.kernel.org/netdev/net/c/25f16c873fb1

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html