Skip to content
Snippets Groups Projects
Commit ebe0b2af authored by Felix Fietkau's avatar Felix Fietkau
Browse files

kernel: fix a race condition leading to a crash in hw flow offloading


flowtable->net was initialized too late, and this could be triggered even
without hardware offload support on the device

Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 54e1a6fc
No related branches found
No related tags found
No related merge requests found
...@@ -98,7 +98,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> ...@@ -98,7 +98,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
obj-$(CONFIG_NETFILTER_XT_TARGET_LED) += xt_LED.o obj-$(CONFIG_NETFILTER_XT_TARGET_LED) += xt_LED.o
--- /dev/null --- /dev/null
+++ b/net/netfilter/xt_FLOWOFFLOAD.c +++ b/net/netfilter/xt_FLOWOFFLOAD.c
@@ -0,0 +1,656 @@ @@ -0,0 +1,657 @@
+/* +/*
+ * Copyright (C) 2018-2021 Felix Fietkau <nbd@nbd.name> + * Copyright (C) 2018-2021 Felix Fietkau <nbd@nbd.name>
+ * + *
...@@ -575,16 +575,17 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> ...@@ -575,16 +575,17 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+ } + }
+ +
+ table = &flowtable[!!(info->flags & XT_FLOWOFFLOAD_HW)]; + table = &flowtable[!!(info->flags & XT_FLOWOFFLOAD_HW)];
+
+ net = read_pnet(&table->ft.net);
+ if (!net)
+ write_pnet(&table->ft.net, xt_net(par));
+
+ if (flow_offload_add(&table->ft, flow) < 0) + if (flow_offload_add(&table->ft, flow) < 0)
+ goto err_flow_add; + goto err_flow_add;
+ +
+ xt_flowoffload_check_device(table, devs[0]); + xt_flowoffload_check_device(table, devs[0]);
+ xt_flowoffload_check_device(table, devs[1]); + xt_flowoffload_check_device(table, devs[1]);
+ +
+ net = read_pnet(&table->ft.net);
+ if (!net)
+ write_pnet(&table->ft.net, xt_net(par));
+
+ dst_release(route.tuple[dir].dst); + dst_release(route.tuple[dir].dst);
+ dst_release(route.tuple[!dir].dst); + dst_release(route.tuple[!dir].dst);
+ +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment