Skip to content

Commit a810471

Browse files
lxinummakynes
authored andcommitted
netfilter: flowtable_offload: fix using __this_cpu_add in preemptible
flow_offload_queue_work() can be called in workqueue without bh disabled, like the call trace showed in my act_ct testing, calling NF_FLOW_TABLE_STAT_INC() there would cause a call trace: BUG: using __this_cpu_add() in preemptible [00000000] code: kworker/u4:0/138560 caller is flow_offload_queue_work+0xec/0x1b0 [nf_flow_table] Workqueue: act_ct_workqueue tcf_ct_flow_table_cleanup_work [act_ct] Call Trace: <TASK> dump_stack_lvl+0x33/0x46 check_preemption_disabled+0xc3/0xf0 flow_offload_queue_work+0xec/0x1b0 [nf_flow_table] nf_flow_table_iterate+0x138/0x170 [nf_flow_table] nf_flow_table_free+0x140/0x1a0 [nf_flow_table] tcf_ct_flow_table_cleanup_work+0x2f/0x2b0 [act_ct] process_one_work+0x6a3/0x1030 worker_thread+0x8a/0xdf0 This patch fixes it by using NF_FLOW_TABLE_STAT_INC_ATOMIC() instead in flow_offload_queue_work(). Note that for FLOW_CLS_REPLACE branch in flow_offload_queue_work(), it may not be called in preemptible path, but it's good to use NF_FLOW_TABLE_STAT_INC_ATOMIC() for all cases in flow_offload_queue_work(). Fixes: b038177 ("netfilter: nf_flow_table: count pending offload workqueue tasks") Signed-off-by: Xin Long <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 97d4d39 commit a810471

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/netfilter/nf_flow_table_offload.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,13 +997,13 @@ static void flow_offload_queue_work(struct flow_offload_work *offload)
997997
struct net *net = read_pnet(&offload->flowtable->net);
998998

999999
if (offload->cmd == FLOW_CLS_REPLACE) {
1000-
NF_FLOW_TABLE_STAT_INC(net, count_wq_add);
1000+
NF_FLOW_TABLE_STAT_INC_ATOMIC(net, count_wq_add);
10011001
queue_work(nf_flow_offload_add_wq, &offload->work);
10021002
} else if (offload->cmd == FLOW_CLS_DESTROY) {
1003-
NF_FLOW_TABLE_STAT_INC(net, count_wq_del);
1003+
NF_FLOW_TABLE_STAT_INC_ATOMIC(net, count_wq_del);
10041004
queue_work(nf_flow_offload_del_wq, &offload->work);
10051005
} else {
1006-
NF_FLOW_TABLE_STAT_INC(net, count_wq_stats);
1006+
NF_FLOW_TABLE_STAT_INC_ATOMIC(net, count_wq_stats);
10071007
queue_work(nf_flow_offload_stats_wq, &offload->work);
10081008
}
10091009
}

0 commit comments

Comments
 (0)