From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Patrick McHardy <kaber@trash.net>
Cc: Netfilter Development Mailinglist <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH 4/7] Helper modules load on-demand support for ctnetlink
Date: Thu, 31 Jul 2008 23:27:30 +0200 [thread overview]
Message-ID: <48922E42.5050005@netfilter.org> (raw)
In-Reply-To: <4891FBB5.1050803@netfilter.org>
[-- Attachment #1: Type: text/plain, Size: 1138 bytes --]
Pablo Neira Ayuso wrote:
> While reworking the patches to do it as you pointed out, I have concerns
> with the current RCU locking in ctnetlink_create_conntrack. This
> function calls nf_ct_helper_ext_add with GFP_KERNEL so that it may
> sleep. However, we hold the read-side lock. AFAIK, this is illegal.
> Therefore, whether we call it with GFP_ATOMIC or we have to perform
> another lookup.
>
> Moreover, I think that:
>
> rcu_assign_pointer(help->helper, helper);
>
> should be:
>
> help->helper = rcu_dereference(helper);
Sorry, this is bogus. As the comment states, we can remove completely
the rcu_assign_pointer, but not replace it with this.
> since we're fetching the pointer, not publishing a new object protected
> by RCU. BTW, why do we need rcu_read_unlock once the entry has been
> inserted? It should be fine to release it after the helper has been
> assigned.
This also, it's there to prevent preemption. As the helper removal can
modify the conntrack's pointer, the rcu protects also help section in
the conntrack.
But at least, the sleep is illegal.
--
"Los honestos son inadaptados sociales" -- Les Luthiers
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 909 bytes --]
[PATCH] Remove GFP_KERNEL allocation under read-side lock in ctnetlink
This patch fixes an illegal allocation with GFP_KERNEL (that may sleep)
while holding the read-side lock.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Index: net-next-2.6.git/net/netfilter/nf_conntrack_netlink.c
===================================================================
--- net-next-2.6.git.orig/net/netfilter/nf_conntrack_netlink.c 2008-07-31 19:41:43.000000000 +0200
+++ net-next-2.6.git/net/netfilter/nf_conntrack_netlink.c 2008-07-31 23:25:39.000000000 +0200
@@ -1154,7 +1154,8 @@ ctnetlink_create_conntrack(struct nlattr
rcu_read_lock();
helper = __nf_ct_helper_find(rtuple);
if (helper) {
- help = nf_ct_helper_ext_add(ct, GFP_KERNEL);
+ /* we cannot sleep holding the read-side lock */
+ help = nf_ct_helper_ext_add(ct, GFP_ATOMIC);
if (help == NULL) {
rcu_read_unlock();
err = -ENOMEM;
prev parent reply other threads:[~2008-07-31 21:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-30 11:03 [PATCH 4/7] Helper modules load on-demand support for ctnetlink Pablo Neira Ayuso
2008-07-30 11:10 ` Patrick McHardy
2008-07-30 11:29 ` Pablo Neira Ayuso
2008-07-30 11:33 ` Pablo Neira Ayuso
2008-07-30 13:35 ` Patrick McHardy
2008-07-31 8:36 ` Pablo Neira Ayuso
2008-07-31 8:46 ` Patrick McHardy
2008-07-31 9:44 ` Pablo Neira Ayuso
2008-07-31 17:51 ` Pablo Neira Ayuso
2008-07-31 21:27 ` Pablo Neira Ayuso [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48922E42.5050005@netfilter.org \
--to=pablo@netfilter.org \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.