From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0C30FC433EF for ; Thu, 24 Feb 2022 14:13:22 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1nNErm-0003kJ-KQ; Thu, 24 Feb 2022 09:13:10 -0500 Received: from mail-4018.proton.ch ([185.70.40.18]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nNEri-0003jt-4o for kernelnewbies@kernelnewbies.org; Thu, 24 Feb 2022 09:13:06 -0500 Date: Thu, 24 Feb 2022 14:12:57 +0000 Authentication-Results: mail-4018.proton.ch; dkim=none To: kernelnewbies@kernelnewbies.org From: Torin Carey Subject: Safe registration of procfs entries in LKM Message-ID: MIME-Version: 1.0 X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Torin Carey Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org 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