From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A6D2C4332F for ; Mon, 28 Nov 2022 16:20:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232334AbiK1QUq (ORCPT ); Mon, 28 Nov 2022 11:20:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232168AbiK1QUp (ORCPT ); Mon, 28 Nov 2022 11:20:45 -0500 Received: from mail.netfilter.org (mail.netfilter.org [217.70.188.207]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B6D615F9F; Mon, 28 Nov 2022 08:20:43 -0800 (PST) Date: Mon, 28 Nov 2022 17:20:40 +0100 From: Pablo Neira Ayuso To: Xin Long Cc: netfilter-devel@vger.kernel.org, network dev , Florian Westphal , Jozsef Kadlecsik , davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni Subject: Re: [PATCH nf] netfilter: fix using __this_cpu_add in preemptible in nf_flow_table_offload Message-ID: References: <9fc554880eeb0bc9d1749d9577e3aa058eb9f61c.1669312450.git.lucien.xin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <9fc554880eeb0bc9d1749d9577e3aa058eb9f61c.1669312450.git.lucien.xin@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Nov 24, 2022 at 12:54:10PM -0500, Xin Long wrote: > 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: > > 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(). Applied, thanks