aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorHsiuWen Yen <y.hsiuwen@gmail.com>2019-06-21 00:44:42 +0800
committerPetr Štetiar <ynezz@true.cz>2019-06-24 18:34:04 +0200
commitd344591e72e5ca96a2bf70a2df38961553185ce8 (patch)
treed4ef4d3600c587bddd60a934657b0b51119d6f78 /target/linux
parent545bfbc3a922facfe52e9397da56605be33ff49a (diff)
downloadupstream-d344591e72e5ca96a2bf70a2df38961553185ce8.tar.gz
upstream-d344591e72e5ca96a2bf70a2df38961553185ce8.tar.bz2
upstream-d344591e72e5ca96a2bf70a2df38961553185ce8.zip
netfilter: fix crash in flow offload by adding netns support
Commit fcb41decf6c6 ("config: enable some useful features on !SMALL_FLASH devices") enabled netns, which in turn lead to the crash in the flow offload target. When the flow offloading framework intends to delete a flow from the hardware table, it is necessary to retrieve the namespace from nf_flowtable->ft_net. However, no one ever wrote the namespace into nf_flowtable->ft_net in advance. So the framework will mistakenly use a NULL namespace to execute dev_get_by_index_rcu(net, ifindex), leading to the kernel panic. Ref: FS#2321 Fixes: fcb41decf6c6 ("config: enable some useful features on !SMALL_FLASH devices") Tested-by: Simon Tretter <simon@mediaarchitectu.re> Signed-off-by: HsiuWen Yen <y.hsiuwen@gmail.com> [merged patch into offload patch, fix for 4.19, SOB fix, commit subj/msg touches] Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/generic/hack-4.14/650-netfilter-add-xt_OFFLOAD-target.patch9
-rw-r--r--target/linux/generic/hack-4.19/650-netfilter-add-xt_OFFLOAD-target.patch7
2 files changed, 13 insertions, 3 deletions
diff --git a/target/linux/generic/hack-4.14/650-netfilter-add-xt_OFFLOAD-target.patch b/target/linux/generic/hack-4.14/650-netfilter-add-xt_OFFLOAD-target.patch
index b78ba1f53f..9692aa8a2b 100644
--- a/target/linux/generic/hack-4.14/650-netfilter-add-xt_OFFLOAD-target.patch
+++ b/target/linux/generic/hack-4.14/650-netfilter-add-xt_OFFLOAD-target.patch
@@ -98,7 +98,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
obj-$(CONFIG_NETFILTER_XT_TARGET_LED) += xt_LED.o
--- /dev/null
+++ b/net/netfilter/xt_FLOWOFFLOAD.c
-@@ -0,0 +1,403 @@
+@@ -0,0 +1,408 @@
+/*
+ * Copyright (C) 2018 Felix Fietkau <nbd@nbd.name>
+ *
@@ -342,12 +342,13 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+flowoffload_tg(struct sk_buff *skb, const struct xt_action_param *par)
+{
+ const struct xt_flowoffload_target_info *info = par->targinfo;
++ const struct nf_conn_help *help;
+ enum ip_conntrack_info ctinfo;
+ enum ip_conntrack_dir dir;
+ struct nf_flow_route route;
+ struct flow_offload *flow;
+ struct nf_conn *ct;
-+ const struct nf_conn_help *help;
++ struct net *net;
+
+ if (xt_flowoffload_skip(skb))
+ return XT_CONTINUE;
@@ -396,6 +397,10 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+ xt_flowoffload_check_device(xt_in(par));
+ xt_flowoffload_check_device(xt_out(par));
+
++ net = read_pnet(&nf_flowtable.ft_net);
++ if (!net)
++ write_pnet(&nf_flowtable.ft_net, xt_net(par));
++
+ if (info->flags & XT_FLOWOFFLOAD_HW)
+ nf_flow_offload_hw_add(xt_net(par), flow, ct);
+
diff --git a/target/linux/generic/hack-4.19/650-netfilter-add-xt_OFFLOAD-target.patch b/target/linux/generic/hack-4.19/650-netfilter-add-xt_OFFLOAD-target.patch
index 8ebea32a82..b207f9d084 100644
--- a/target/linux/generic/hack-4.19/650-netfilter-add-xt_OFFLOAD-target.patch
+++ b/target/linux/generic/hack-4.19/650-netfilter-add-xt_OFFLOAD-target.patch
@@ -98,7 +98,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
obj-$(CONFIG_NETFILTER_XT_TARGET_LED) += xt_LED.o
--- /dev/null
+++ b/net/netfilter/xt_FLOWOFFLOAD.c
-@@ -0,0 +1,366 @@
+@@ -0,0 +1,371 @@
+/*
+ * Copyright (C) 2018 Felix Fietkau <nbd@nbd.name>
+ *
@@ -344,6 +344,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+ struct nf_flow_route route;
+ struct flow_offload *flow;
+ struct nf_conn *ct;
++ struct net *net;
+
+ if (xt_flowoffload_skip(skb))
+ return XT_CONTINUE;
@@ -391,6 +392,10 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+ xt_flowoffload_check_device(xt_in(par));
+ xt_flowoffload_check_device(xt_out(par));
+
++ net = read_pnet(&nf_flowtable.ft_net);
++ if (!net)
++ write_pnet(&nf_flowtable.ft_net, xt_net(par));
++
+ if (info->flags & XT_FLOWOFFLOAD_HW)
+ nf_flow_offload_hw_add(xt_net(par), flow, ct);
+