Преглед изворни кода

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: Felix Fietkau <[email protected]>
Felix Fietkau пре 3 година
родитељ
комит
ebe0b2af65

+ 6 - 5
target/linux/generic/hack-5.10/650-netfilter-add-xt_FLOWOFFLOAD-target.patch

@@ -98,7 +98,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
  obj-$(CONFIG_NETFILTER_XT_TARGET_LED) += xt_LED.o
 --- /dev/null
 +++ b/net/netfilter/xt_FLOWOFFLOAD.c
-@@ -0,0 +1,656 @@
+@@ -0,0 +1,657 @@
 +/*
 + * Copyright (C) 2018-2021 Felix Fietkau <[email protected]>
 + *
@@ -575,16 +575,17 @@ Signed-off-by: Felix Fietkau <[email protected]>
 +	}
 +
 +	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)
 +		goto err_flow_add;
 +
 +	xt_flowoffload_check_device(table, devs[0]);
 +	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);
 +