mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neil Horman <nhorman@tuxdriver.com>
To: Patrick McHardy <kaber@trash.net>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	adam@yggdrasil.com, jcm@jonmasters.org,
	netfilter-devel@lists.netfilter.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/2] Fix (improve) deadlock condition on module removal netfilter socket option removal
Date: Thu, 6 Sep 2007 07:08:36 -0400	[thread overview]
Message-ID: <20070906110836.GA31868@hmsreliant.think-freely.org> (raw)
In-Reply-To: <46DFD790.6040908@trash.net>

On Thu, Sep 06, 2007 at 12:33:52PM +0200, Patrick McHardy wrote:
> Neil Horman wrote:
> > On Thu, Sep 06, 2007 at 02:13:26AM +1000, Rusty Russell wrote:
> > 
> >>On Wed, 2007-09-05 at 17:22 +0200, Patrick McHardy wrote:
> >>
> >>>But I'm wondering, wouldn't module refcounting alone fix this problem?
> >>>If we make nf_sockopt() call try_module_get(ops->owner), remove_module()
> >>>on ip_tables.ko would simply fail because the refcount is above zero
> >>>(so it would fail at point 3 above). Am I missing something important?
> >>
> >>Yes, that seems the correct solution to me, too.  ISTR that this code
> >>predates the current module code.
> >>
> >>Rusty.
> > 
> > 
> > Thanks guys-
> > 	When I first started looking at this problem I would have agreed with
> > you, that module reference counting alone would fix the problem.  However,
> > delete_module can work in either a non-blocking or a blocking mode.  rmmod
> > passes O_NONBLOCK to delete module, and so is fine, but modprobe does not.  So
> > if you currently use modprobe -r to remove modules (as the iptables service
> > script nominally does), modprobe winds up waiting in the kernel for the module
> > reference count to become zero.  Since we can hold a reference to the module
> > being removed in the same path that forks a modprobe request to load that same
> > module (which then blocks on the first modprobes fcntl lock), we still get
> > deadlock.  The way I fixed this was by use of the second patch, which brings
> > modprobes behavior into line with the rmmod utility (which is to default to
> > non-blocking operation), leading to the remove_module failure and breaking of
> > the deadlock that you describe above.
> 
> 
> Thanks for the explanation, I've applied your patch.
Thanks Patrick!
Neil
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
/***************************************************
 *Neil Horman
 *Software Engineer
 *Red Hat, Inc.
 *nhorman@tuxdriver.com
 *gpg keyid: 1024D / 0x92A74FA1
 *http://pgp.mit.edu
 ***************************************************/

      reply	other threads:[~2007-09-06 11:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-04 20:24 Neil Horman
2007-09-05 15:22 ` Patrick McHardy
2007-09-05 16:13   ` Rusty Russell
2007-09-05 17:08     ` Neil Horman
2007-09-05 17:41       ` Rusty Russell
2007-09-05 18:19         ` Jon Masters
2007-09-05 19:27         ` Neil Horman
2007-09-05 20:17           ` Jon Masters
2007-09-05 20:51           ` Rusty Russell
2007-09-05 20:59             ` Jon Masters
2007-09-05 21:39           ` Jon Masters
2007-09-06  0:17             ` Neil Horman
2007-09-06 12:55             ` Neil Horman
2007-09-06 13:35               ` Jon Masters
2007-09-06 15:40                 ` Neil Horman
2007-09-06 10:33       ` Patrick McHardy
2007-09-06 11:08         ` Neil Horman [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=20070906110836.GA31868@hmsreliant.think-freely.org \
    --to=nhorman@tuxdriver.com \
    --cc=adam@yggdrasil.com \
    --cc=jcm@jonmasters.org \
    --cc=kaber@trash.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=rusty@rustcorp.com.au \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®