From: Aaron Tomlin <atomlin@redhat.com>
To: mcgrof@kernel.org
Cc: cl@linux.com, pmladek@suse.com, mbenes@suse.cz,
christophe.leroy@csgroup.eu, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org,
atomlin@atomlin.com, ghalat@redhat.com, oleksandr@natalenko.name,
neelx@redhat.com
Subject: [PATCH v5 2/3] module: Move module_assert_mutex_or_preempt() to internal.h
Date: Mon, 2 May 2022 21:51:04 +0100 [thread overview]
Message-ID: <20220502205105.919523-3-atomlin@redhat.com> (raw)
In-Reply-To: <20220502205105.919523-1-atomlin@redhat.com>
No functional change.
This patch migrates module_assert_mutex_or_preempt() to internal.h.
So, the aforementiond function can be used outside of main/or core
module code yet will remain restricted for internal use only.
Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
---
kernel/module/internal.h | 12 ++++++++++++
kernel/module/main.c | 11 -----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/kernel/module/internal.h b/kernel/module/internal.h
index abbd1c5ef264..0bdf64c9dfb5 100644
--- a/kernel/module/internal.h
+++ b/kernel/module/internal.h
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/rculist.h>
+#include <linux/rcupdate.h>
#ifndef ARCH_SHF_SMALL
#define ARCH_SHF_SMALL 0
@@ -102,6 +103,17 @@ long module_get_offset(struct module *mod, unsigned int *size, Elf_Shdr *sechdr,
char *module_flags(struct module *mod, char *buf);
size_t module_flags_taint(unsigned long taints, char *buf);
+static inline void module_assert_mutex_or_preempt(void)
+{
+#ifdef CONFIG_LOCKDEP
+ if (unlikely(!debug_locks))
+ return;
+
+ WARN_ON_ONCE(!rcu_read_lock_sched_held() &&
+ !lockdep_is_held(&module_mutex));
+#endif
+}
+
static inline unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
{
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
diff --git a/kernel/module/main.c b/kernel/module/main.c
index 7dbdd098b995..7a0484900320 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -118,17 +118,6 @@ static void mod_update_bounds(struct module *mod)
#endif
}
-static void module_assert_mutex_or_preempt(void)
-{
-#ifdef CONFIG_LOCKDEP
- if (unlikely(!debug_locks))
- return;
-
- WARN_ON_ONCE(!rcu_read_lock_sched_held() &&
- !lockdep_is_held(&module_mutex));
-#endif
-}
-
/* Block module loading/unloading? */
int modules_disabled = 0;
core_param(nomodule, modules_disabled, bint, 0);
--
2.34.1
next prev parent reply other threads:[~2022-05-02 20:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-02 20:51 [PATCH v5 0/3] module: Introduce module unload taint tracking Aaron Tomlin
2022-05-02 20:51 ` [PATCH v5 1/3] module: Make module_flags_taint() accept a module's taints bitmap and usable outside core code Aaron Tomlin
2022-05-02 20:51 ` Aaron Tomlin [this message]
2022-05-02 20:52 ` [PATCH v5 3/3] module: Introduce module unload taint tracking Aaron Tomlin
2022-05-03 20:12 ` [PATCH v5 0/3] " Luis Chamberlain
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=20220502205105.919523-3-atomlin@redhat.com \
--to=atomlin@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=atomlin@atomlin.com \
--cc=christophe.leroy@csgroup.eu \
--cc=cl@linux.com \
--cc=ghalat@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=mcgrof@kernel.org \
--cc=neelx@redhat.com \
--cc=oleksandr@natalenko.name \
--cc=pmladek@suse.com \
/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).