Re: [PATCH v3 09/10] module: Remove module_disable_ro()

From: Jessica Yu
Date: Tue Apr 28 2020 - 14:56:49 EST


+++ Josh Poimboeuf [28/04/20 12:03 -0500]:
On Tue, Apr 28, 2020 at 06:41:55PM +0200, Jessica Yu wrote:
+++ Josh Poimboeuf [28/04/20 11:36 -0500]:
> On Tue, Apr 28, 2020 at 06:25:05PM +0200, Jessica Yu wrote:
> > +++ Josh Poimboeuf [25/04/20 06:07 -0500]:
> > > module_disable_ro() has no more users. Remove it.
> > >
> > > Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> > > Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> >
> > Hm, I guess this means we can also remove the module_enable_ro() stubs
> > in module.h and make it a static function again (like the other
> > module_enable_* functions) as there are no more outside users. I have to
> > remind myself after this patchset is merged :-)
>
> Ah, true. I'm respinning the patch set anyway, I can just add this as a
> another patch.

That would be great. Thanks!

Sneak preview:

From: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Subject: [PATCH] module: Make module_enable_ro() static again

Now that module_enable_ro() has no more external users, make it static
again.

Suggested-by: Jessica Yu <jeyu@xxxxxxxxxx>
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
include/linux/module.h | 6 ------
kernel/module.c | 4 ++--
2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/include/linux/module.h b/include/linux/module.h
index e4ef7b36feda..2c2e988bcf10 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -858,12 +858,6 @@ extern int module_sysfs_initialized;

#define __MODULE_STRING(x) __stringify(x)

-#ifdef CONFIG_STRICT_MODULE_RWX
-extern void module_enable_ro(const struct module *mod, bool after_init);
-#else
-static inline void module_enable_ro(const struct module *mod, bool after_init) { }
-#endif
-
#ifdef CONFIG_GENERIC_BUG
void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
struct module *);
diff --git a/kernel/module.c b/kernel/module.c
index f0e414a01d91..6d8aab60943e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2016,7 +2016,7 @@ static void frob_writable_data(const struct module_layout *layout,
(layout->size - layout->ro_after_init_size) >> PAGE_SHIFT);
}

-void module_enable_ro(const struct module *mod, bool after_init)
+static void module_enable_ro(const struct module *mod, bool after_init)
{
if (!rodata_enabled)
return;
@@ -2057,7 +2057,7 @@ static int module_enforce_rwx_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
}

#else /* !CONFIG_STRICT_MODULE_RWX */
-/* module_{enable,disable}_ro() stubs are in module.h */
+void module_enable_ro(const struct module *mod, bool after_init) {}

Missing static here, but otherwise looks good. Thanks!

static void module_enable_nx(const struct module *mod) { }
static int module_enforce_rwx_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
char *secstrings, struct module *mod)
--
2.21.1