public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Owens <kaos@ocs.com.au>
To: linux-kernel@vger.kernel.org
Subject: Re: RE2: [OKS] Module removal
Date: Tue, 02 Jul 2002 13:42:16 +1000	[thread overview]
Message-ID: <31775.1025581336@kao2.melbourne.sgi.com> (raw)
In-Reply-To: Your message of "Tue, 02 Jul 2002 00:11:52 -0300." <20020702001152.D2295@almesberger.net>

On Tue, 2 Jul 2002 00:11:52 -0300, 
Werner Almesberger <wa@almesberger.net> wrote:
>Keith Owens wrote:
>> This is just one symptom of the overall problem, which is module code
>> that adjusts its use count by executing code that belongs to the
>> module.  The same problem exists on entry to a module function, the
>> module can be removed before MOD_INC_USE_COUNT is reached.
>
>Ah yes, now I remember, thanks. I filed that under "improper reference
>tracking". After all, why would anybody hold an uncounted reference in
>the first place ?

All functions passed to registration routines by modules are uncounted
references.  A module is loaded, registers its operations and exits
from the cleanup routine.  At that point its use count is 0, even
though it there are references to the module from tables outside the
module.

When the open routine (or its equivalent) is called, then the use count
is incremented from within the module.  The executing code between

  if (ops->open)
  	ops->open();

and MOD_INC_USE_COUNT in the module's open routine is racy, there is no
lock that prevents the module being removed while the start of the open
routine is being executed.

Incrementing the use count at registration time is no good, it stops
the module being unloaded.  Operations are deregistered at rmmod time.
Setting the use count at registration prevents rmmod from removing the
module, so you cannot deregister the operations.  Catch 22.

Module unload is not racy on UP without preempt.  It is racy on SMP or
with preempt.  It used to be safe on SMP because almost everything was
under the BKL, but that protection no longer exists.


  reply	other threads:[~2002-07-02  3:39 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-01 20:21 RE2: [OKS] Module removal Michael Nguyen
2002-07-02  1:40 ` Werner Almesberger
2002-07-02  2:25   ` Keith Owens
2002-07-02  3:11     ` Werner Almesberger
2002-07-02  3:42       ` Keith Owens [this message]
2002-07-02  4:11         ` Werner Almesberger
2002-07-02 22:23         ` Alexander Viro
2002-07-09 19:23         ` Russ Lewis
2002-07-02  4:08     ` Brian Gerst
2002-07-02  4:53       ` Keith Owens
2002-07-02  5:43         ` Werner Almesberger
2002-07-02 16:36           ` Werner Almesberger
2002-07-02 16:50             ` Benjamin Herrenschmidt
2002-07-02 18:05               ` Werner Almesberger
2002-07-03  3:50               ` Pavel Machek
2002-07-04  4:11             ` Bill Davidsen
2002-07-04  6:29               ` Werner Almesberger
2002-07-04  6:50                 ` Werner Almesberger
2002-07-07 21:09                   ` Jamie Lokier
2002-07-07 21:41                     ` Oliver Neukum
2002-07-08  0:31                       ` Jamie Lokier
2002-07-08  6:42                         ` Oliver Neukum
2002-07-08  0:18                     ` Bill Davidsen
2002-07-08  0:46                       ` Jamie Lokier
2002-07-08  6:22                         ` Daniel Phillips
2002-07-08 10:16                           ` Bill Davidsen
2002-07-09  0:07                         ` Werner Almesberger
2002-07-09  0:27                           ` Keith Owens
2002-07-09  3:09                             ` Werner Almesberger
2002-07-09  6:25                             ` Roman Zippel
2002-07-09  8:59                               ` Kai Germaschewski
2002-07-09 11:06                                 ` Roman Zippel
2002-07-04 12:29                 ` Bill Davidsen
2002-07-09  1:50                 ` Kevin O'Connor
2002-07-09  2:37                   ` Werner Almesberger
2002-07-02 23:35         ` Alexander Viro
2002-07-02 22:41       ` RE2: " Alexander Viro
2002-07-02  8:52     ` Helge Hafting
2002-07-02 16:22       ` Werner Almesberger

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=31775.1025581336@kao2.melbourne.sgi.com \
    --to=kaos@ocs.com.au \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox