From patchwork Tue Mar 14 08:29:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6auY5bOw?= X-Patchwork-Id: 738587 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vj7QP1L2rz9s3l for ; Tue, 14 Mar 2017 19:37:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750849AbdCNIhQ (ORCPT ); Tue, 14 Mar 2017 04:37:16 -0400 Received: from smtpbg278.qq.com ([113.108.11.203]:33111 "EHLO smtpbg278.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750824AbdCNIhQ (ORCPT ); Tue, 14 Mar 2017 04:37:16 -0400 X-Greylist: delayed 470 seconds by postgrey-1.27 at vger.kernel.org; Tue, 14 Mar 2017 04:37:15 EDT X-QQ-mid: bizesmtp15t1489480157tjmfcnbq Received: from ikuai8.com (unknown [114.242.17.234]) by esmtp4.qq.com (ESMTP) with id ; Tue, 14 Mar 2017 16:29:06 +0800 (CST) X-QQ-SSF: 01400000002000F0FI40000A0000000 X-QQ-FEAT: UtFeP4UTPIeNhHfp4eGXMa5gbvDleszBxF1nFMsc1dk0dSuT4BKzxZ/Sexkyh g1MgJ8/R0/pSSLPhtspPbwIXxMapukD98O8jb8w3quqywZMGYvlBzMLxvDCtEYRyRKIs7Dn aF2XCq6JvugWGgaC73MeoOJBw+vcCf3UHWw/Q0b0d/tc2HhoDI77EJKtGXVbsbbv5pHHMeg p/BgXPhmZsgw97rGkrw78fUfT53NMTmzqtgI5DhFPe7UHiM+G8cTa9Of34ooQIAfHxAC1fy U0I7cO18KuaXb4h/fGCKZrjDg= X-QQ-GoodBg: 2 From: fgao@ikuai8.com To: pablo@netfilter.org, netfilter-devel@vger.kernel.org, gfree.wind@gmail.com Cc: Gao Feng Subject: [PATCH net-next 1/1] netfilter: helper: Remove the rcu lock in nf_ct_helper_expectfn_find_by_name and nf_ct_helper_expectfn_find_by_symbol. Date: Tue, 14 Mar 2017 16:29:05 +0800 Message-Id: <1489480145-54411-1-git-send-email-fgao@ikuai8.com> X-Mailer: git-send-email 1.9.1 X-QQ-SENDSIZE: 520 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org From: Gao Feng Because these two functions return the nf_ct_helper_expectfn pointer which should be protected by rcu lock. So it should makes sure the caller should hold the rcu lock, not inside these functions. Signed-off-by: Gao Feng --- net/netfilter/nf_conntrack_helper.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c index 6dc44d9..bce3d1f 100644 --- a/net/netfilter/nf_conntrack_helper.c +++ b/net/netfilter/nf_conntrack_helper.c @@ -311,38 +311,36 @@ void nf_ct_helper_expectfn_unregister(struct nf_ct_helper_expectfn *n) } EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_unregister); +/* Caller should hold the rcu lock */ struct nf_ct_helper_expectfn * nf_ct_helper_expectfn_find_by_name(const char *name) { struct nf_ct_helper_expectfn *cur; bool found = false; - rcu_read_lock(); list_for_each_entry_rcu(cur, &nf_ct_helper_expectfn_list, head) { if (!strcmp(cur->name, name)) { found = true; break; } } - rcu_read_unlock(); return found ? cur : NULL; } EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_find_by_name); +/* Caller should hold the rcu lock */ struct nf_ct_helper_expectfn * nf_ct_helper_expectfn_find_by_symbol(const void *symbol) { struct nf_ct_helper_expectfn *cur; bool found = false; - rcu_read_lock(); list_for_each_entry_rcu(cur, &nf_ct_helper_expectfn_list, head) { if (cur->expectfn == symbol) { found = true; break; } } - rcu_read_unlock(); return found ? cur : NULL; } EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_find_by_symbol);