]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: add test case for flowtable with owner flag
authorFlorian Westphal <fw@strlen.de>
Tue, 22 Feb 2022 12:51:09 +0000 (13:51 +0100)
committerFlorian Westphal <fw@strlen.de>
Tue, 22 Feb 2022 13:06:14 +0000 (14:06 +0100)
BUG: KASAN: use-after-free in nf_hook_entries_grow+0x675/0x980
Read of size 4 at ... nft/19662
 nf_hook_entries_grow+0x675/0x980

This is fixed by kernel commit 6069da443bf
("netfilter: nf_tables: unregister flowtable hooks on netns exit").

The test case here uses owner flag, netlink event handler doesn't
release the flowtable, next attempt to add one then causes uaf because
of dangling ingress hook reference.

Signed-off-by: Florian Westphal <fw@strlen.de>
tests/shell/testcases/owner/0001-flowtable-uaf [new file with mode: 0755]

diff --git a/tests/shell/testcases/owner/0001-flowtable-uaf b/tests/shell/testcases/owner/0001-flowtable-uaf
new file mode 100755 (executable)
index 0000000..4efbe75
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+set -e
+
+$NFT -f - <<EOF
+table t {
+ flags owner
+ flowtable f {
+  devices = { lo }
+ }
+}
+EOF
+
+# trigger uaf.
+$NFT -f - <<EOF
+table t {
+ flags owner
+ flowtable f {
+  devices = { lo }
+ }
+}
+EOF