public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Anatol Pomozov <anatol.pomozov@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Salman Qazi <sqazi@google.com>,
	Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH] module: Fix race condition between load and unload module
Date: Sun, 14 Apr 2013 05:56:50 +0100	[thread overview]
Message-ID: <20130414045650.GG4068@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CAOMFOmVAbg3AVy95Q_O3ADf-kdaAGkBhNtqF6uc=TGZXWsXawA@mail.gmail.com>

On Sat, Apr 13, 2013 at 09:42:06PM -0700, Anatol Pomozov wrote:

> > in kobject_cleanup().  Why don't we require kobject_del() before the final
> > kobject_put(), if the sucker had been added?  FWIW, I thought it *was*
> > required all along...
> 
> But kobject_release/kobject_cleanup function is called as a result of
> atomic decrement_compare. Until we perform the atomic operation we
> don't know whether it is final kobject_put() or not.
> 
> kobject_put() {
>     if (atomic_sub_and_test(kobj->kref->refcount)) {
>         // refcounter is decremented to 0 so cleanup sysfs
>         kobject_release(kobj)
>     }
> }

Yes, of course, but WTF do we play with kobject_del() on that path at all?
Let the caller do it when it decides that object shouldn't be possible to
see anymore.  Which is not the same thing as "the last reference is gone"...

Sigh...  kobject model sucks, film at 11... ;-/

      reply	other threads:[~2013-04-14  4:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-12 22:32 [PATCH] module: Fix race condition between load and unload module Anatol Pomozov
2013-04-12 23:47 ` Linus Torvalds
2013-04-12 23:53   ` Greg Kroah-Hartman
2013-04-13  0:04     ` Anatol Pomozov
2013-04-13  0:11     ` Linus Torvalds
2013-04-13  0:48       ` Anatol Pomozov
2013-04-13 15:41   ` Anatol Pomozov
2013-04-13 17:53     ` Linus Torvalds
2013-04-13 21:10       ` Anatol Pomozov
2013-04-14  3:35   ` Al Viro
2013-04-14  4:42     ` Anatol Pomozov
2013-04-14  4:56       ` Al Viro [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=20130414045650.GG4068@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=anatol.pomozov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=sqazi@google.com \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox