mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Andy Adamson <andros@citi.umich.edu>,
	"J. Bruce Fields" <bfields@citi.umich.edu>,
	Olaf Kirch <okir@monad.swb.de>
Subject: Re: [PATCH 2/2] auth_gss: unregister gss_domain when unloading module
Date: Mon, 30 Oct 2006 10:17:29 -0500	[thread overview]
Message-ID: <1162221449.5517.70.camel@lade.trondhjem.org> (raw)
In-Reply-To: <20061030145404.GA7258@localhost>

On Mon, 2006-10-30 at 23:54 +0900, Akinobu Mita wrote:
> On Sun, Oct 29, 2006 at 03:15:59PM -0500, Trond Myklebust wrote:
> 
> > > +void svcauth_gss_unregister_pseudoflavor(char *name)
> > > +{
> > > +	struct auth_domain *dom;
> > > +
> > > +	dom = auth_domain_find(name);
> > > +	if (dom) {
> > > +		auth_domain_put(dom);
> > > +		auth_domain_put(dom);
> > > +	}
> > > +}
> > 
> > Strictly speaking, if you want to be smp-safe, you probably need
> > something like the following:
> > 
> > 	dom = auth_domain_find(name);
> > 	if (dom) {
> > 		spin_lock(&auth_domain_lock);
> > 		if (!hlist_unhashed(dom->hash)) {
> > 			hlist_del_init(dom->hash);
> > 			spin_unlock(&auth_domain_lock);
> > 			auth_domain_put(dom);
> > 		} else
> > 			spin_unlock(&auth_domain_lock);
> > 		auth_domain_put(dom);
> > 	}
> > 
> > and then add a test for hlist_unhashed into auth_domain_put(). If not,
> > some other processor could race you inside
> > svcauth_gss_unregister_pseudoflavor.
> 
> But auth_domain_table is protected by auth_domain_lock while we are
> using auth_domain_put()/auth_domain_lookup()/auth_domain_find().
> So I think there is not big difference.

No. The auth_domain_lock was released after the call to
auth_domain_find(), and thus there is no guarantee that the entry is
still referenced when you get round to that second call to
auth_domain_put(). Testing for hlist_unhashed() and then removing the
entry from the lookup table while under the spin lock fixes this
problem: it ensures that you only call auth_domain_put() once if some
other process has raced you.

Actually, making a helper "auth_domain_find_and_unhash()" would probably
be even more efficient in this case, since that would enable you to
reduce the auth_domain_lock usage further.

Cheers,
  Trond

  reply	other threads:[~2006-10-30 15:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-28 18:55 [PATCH] " Akinobu Mita
2006-10-29 13:35 ` Akinobu Mita
2006-10-29 13:37   ` [PATCH 1/2] sunrpc: add missing spin_unlock Akinobu Mita
2006-10-29 13:38     ` [PATCH 2/2] auth_gss: unregister gss_domain when unloading module Akinobu Mita
2006-10-29 20:15       ` Trond Myklebust
2006-10-30 14:54         ` Akinobu Mita
2006-10-30 15:17           ` Trond Myklebust [this message]
2006-10-31  3:15             ` Akinobu Mita
2006-10-31  4:13               ` Neil Brown
2006-10-29 20:21     ` [PATCH 1/2] sunrpc: add missing spin_unlock Trond Myklebust
2006-10-30  5:43       ` Neil Brown
2006-10-30 14:57         ` [PATCH -mm] sunrpc/auth_gss: auth_domain refcount fix Akinobu Mita
2006-11-05 16:35     ` [PATCH 1/2] sunrpc: add missing spin_unlock Peter Zijlstra
2006-11-05 19:45       ` Andrew Morton
2006-11-05 19:58         ` Peter Zijlstra
2006-11-05 22:04         ` Elimar Riesebieter
2006-10-29 19:46 ` [PATCH] auth_gss: unregister gss_domain when unloading module Trond Myklebust

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=1162221449.5517.70.camel@lade.trondhjem.org \
    --to=trond.myklebust@netapp.com \
    --cc=akinobu.mita@gmail.com \
    --cc=andros@citi.umich.edu \
    --cc=bfields@citi.umich.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=okir@monad.swb.de \
    /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®