kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Safe registration of procfs entries in LKM
@ 2022-02-24 14:12 Torin Carey
  2022-03-01 16:56 ` Torin Carey
  0 siblings, 1 reply; 2+ messages in thread
From: Torin Carey @ 2022-02-24 14:12 UTC (permalink / raw)
  To: kernelnewbies

Hello,

I was wondering how a loadable (and specifically unloadable) kernel
module can safely provide a procfs entry.

The procfs code switched from `struct file_operations`, which has a
`struct module *owner` member to using `struct proc_ops`, which doesn't.
This member allowed the core code to `try_module_get()` the module
before calling the operation, so that we can avoid calling it if the
module is in the process of being removed and increase the module use
count to prevent the module from being unloaded while the open file
description exists.  The procfs code did previously use
`struct file_operations`, but it looks like it didn't honour this member
then.

Does this mean procfs is not meant for loadable modules?

Thanks,
Torin


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-01 16:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-24 14:12 Safe registration of procfs entries in LKM Torin Carey
2022-03-01 16:56 ` Torin Carey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).