kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Torin Carey <torin@tcarey.uk>
To: kernelnewbies@kernelnewbies.org
Subject: Safe registration of procfs entries in LKM
Date: Thu, 24 Feb 2022 14:12:57 +0000	[thread overview]
Message-ID: <YheSXjPdHUMz/jwK@kappa> (raw)

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

             reply	other threads:[~2022-02-24 14:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-24 14:12 Torin Carey [this message]
2022-03-01 16:56 ` Safe registration of procfs entries in LKM Torin Carey

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=YheSXjPdHUMz/jwK@kappa \
    --to=torin@tcarey.uk \
    --cc=kernelnewbies@kernelnewbies.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;
as well as URLs for NNTP newsgroup(s).