Re: [PATCH] Remove module reference counting.

From: Greg KH (greg@kroah.com)
Date: Fri Jul 25 2003 - 12:54:47 EST


On Fri, Jul 25, 2003 at 04:00:18AM +1000, Rusty Russell wrote:
> Hi all,
>
> When the initial module patch was submitted, it made modules
> start isolated, so they would not be accessible until (if)
> initialization had succeeded. This broke partition scanning, and was
> immediately reverted, leaving us with a module reference count scheme
> identical to the previous one (just a faster implementation): we still
> have cases where modules can be access on failed load.
>
> Then Dave decided that the work of reference counting network
> driver modules everywhere is too invasive, so network driver modules
> now have zero reference counts always. The idea is that if you don't
> want the module removed, don't do it. ie. only remove the module if
> there's a bug, or you want to replace it.

Hm, as long as we add a kobject to the module structure, so that users
of a module can be tracked somehow to know if it is safe to unload the
module or not.

This is because there is a difference between device reference counts,
and code reference counts, which is why I added the module owner logic
to sysfs attributes, to prevent code from being unloaded when the device
might already be gone.

So can the following situation still work with this proposed patch:
        - device created
        - sysfs files created associated with that device
        - user opens sysfs file
        - user disconnects sysfs files.
        - device goes away, driver no longer references device, but
          kobject count is still incremented.
        - driver associated with device is unloaded.
        - user reads sysfs file previously opened (which calls into
          module memory that is now gone.)

Can we still prevent this from happening now? I think if we add a
kobject (or something, we still need a kobject to get module
parameters so might as well use that), we might be safe.

thanks,

greg k-h
-
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/



This archive was generated by hypermail 2b29 : Thu Jul 31 2003 - 22:00:26 EST