Skip to contentSkip to conversation

module: Only declare set_module_sig_enforced when CONFIG_MODULE_SIG=y

PATCH Superseded Coiby Xu 4 participants 7 messages Oct 31, 2025 – Dec 22, 2025

Subsystems (2)
lore
Share & tools
lore

Coiby Xu

author
#0 lore raw

PATCH 1/1 module: Only declare set_module_sig_enforced when CONFIG_MODULE_SIG=y

Currently, set_module_sig_enforced is declared as long as CONFIG_MODULES is enabled. This can lead to a linking error if set_module_sig_enforced is called with CONFIG_MODULE_SIG=n,

ld: security/integrity/ima/ima_appraise.o: in function `ima_appraise_measurement':
security/integrity/ima/ima_appraise.c:587:(.text+0xbbb): undefined reference to `set_module_sig_enforced'

So only declare set_module_sig_enforced when CONFIG_MODULE_SIG is enabled.

Note this issue hasn't caused a real problem because all current callers of set_module_sig_enforced e.g. security/integrity/ima/ima_efi.c depend on CONFIG_MODULE_SIG=y.

---
 include/linux/module.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
include/linux/module.h +6 -6
index e135cc79acee..fa251958b138 100644
@@ -769,8 +769,6 @@ static inline bool is_livepatch_module(struct module *mod)
 #endif
 }
 
-void set_module_sig_enforced(void);
-
 void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data);
 
 #else /* !CONFIG_MODULES... */
@@ -865,10 +863,6 @@ static inline bool module_requested_async_probing(struct module *module)
 }
 
 
-static inline void set_module_sig_enforced(void)
-{
-}
-
 /* Dereference module function descriptor */
 static inline
 void *dereference_module_function_descriptor(struct module *mod, void *ptr)
@@ -924,6 +918,8 @@ static inline bool retpoline_module_ok(bool has_retpoline)
 #ifdef CONFIG_MODULE_SIG
 bool is_module_sig_enforced(void);
 
+void set_module_sig_enforced(void);
+
 static inline bool module_sig_ok(struct module *module)
 {
 	return module->sig_ok;
@@ -934,6 +930,10 @@ static inline bool is_module_sig_enforced(void)
 	return false;
 }
 
+static inline void set_module_sig_enforced(void)
+{
+}
+
 static inline bool module_sig_ok(struct module *module)
 {
 	return true;

base-commit: e53642b87a4f4b03a8d7e5f8507fc3cd0c595ea6

Signature · 1 line
2.51.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 66 lines · Coiby Xu

Currently, set_module_sig_enforced is declared as long as CONFIG_MODULES is enabled. This can lead to a linking error if set_module_sig_enforced is called with CONFIG_MODULE_SIG=n,

ld: security/integrity/ima/ima_appraise.o: in function `ima_appraise_measurement':
security/integrity/ima/ima_appraise.c:587:(.text+0xbbb): undefined reference to `set_module_sig_enforced'

So only declare set_module_sig_enforced when CONFIG_MODULE_SIG is enabled.

Note this issue hasn't caused a real problem because all current callers of set_module_sig_enforced e.g. security/integrity/ima/ima_efi.c depend on CONFIG_MODULE_SIG=y.

---
 include/linux/module.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
include/linux/module.h +6 -6
index e135cc79acee..fa251958b138 100644
@@ -769,8 +769,6 @@ static inline bool is_livepatch_module(struct module *mod)
 #endif
 }
 
-void set_module_sig_enforced(void);
-
 void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data);
 
 #else /* !CONFIG_MODULES... */
@@ -865,10 +863,6 @@ static inline bool module_requested_async_probing(struct module *module)
 }
 
 
-static inline void set_module_sig_enforced(void)
-{
-}
-
 /* Dereference module function descriptor */
 static inline
 void *dereference_module_function_descriptor(struct module *mod, void *ptr)
@@ -924,6 +918,8 @@ static inline bool retpoline_module_ok(bool has_retpoline)
 #ifdef CONFIG_MODULE_SIG
 bool is_module_sig_enforced(void);
 
+void set_module_sig_enforced(void);
+
 static inline bool module_sig_ok(struct module *module)
 {
 	return module->sig_ok;
@@ -934,6 +930,10 @@ static inline bool is_module_sig_enforced(void)
 	return false;
 }
 
+static inline void set_module_sig_enforced(void)
+{
+}
+
 static inline bool module_sig_ok(struct module *module)
 {
 	return true;
Quoted 5 lines

base-commit: e53642b87a4f4b03a8d7e5f8507fc3cd0c595ea6

Signature · 1 line
2.51.0

Looks good to me.

Signature · 1 line
Aaron Tomlin
author
#2 lore raw
Quoted 75 lines · Aaron Tomlin
Quoted 66 lines · Coiby Xu

Currently, set_module_sig_enforced is declared as long as CONFIG_MODULES is enabled. This can lead to a linking error if set_module_sig_enforced is called with CONFIG_MODULE_SIG=n,

ld: security/integrity/ima/ima_appraise.o: in function `ima_appraise_measurement':
security/integrity/ima/ima_appraise.c:587:(.text+0xbbb): undefined reference to `set_module_sig_enforced'

So only declare set_module_sig_enforced when CONFIG_MODULE_SIG is enabled.

Note this issue hasn't caused a real problem because all current callers of set_module_sig_enforced e.g. security/integrity/ima/ima_efi.c depend on CONFIG_MODULE_SIG=y.

---
 include/linux/module.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
include/linux/module.h +6 -6
index e135cc79acee..fa251958b138 100644
@@ -769,8 +769,6 @@ static inline bool is_livepatch_module(struct module *mod)
 #endif
 }
 
-void set_module_sig_enforced(void);
-
 void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data);
 
 #else /* !CONFIG_MODULES... */
@@ -865,10 +863,6 @@ static inline bool module_requested_async_probing(struct module *module)
 }
 
 
-static inline void set_module_sig_enforced(void)
-{
-}
-
 /* Dereference module function descriptor */
 static inline
 void *dereference_module_function_descriptor(struct module *mod, void *ptr)
@@ -924,6 +918,8 @@ static inline bool retpoline_module_ok(bool has_retpoline)
 #ifdef CONFIG_MODULE_SIG
 bool is_module_sig_enforced(void);
 
+void set_module_sig_enforced(void);
+
 static inline bool module_sig_ok(struct module *module)
 {
 	return module->sig_ok;
@@ -934,6 +930,10 @@ static inline bool is_module_sig_enforced(void)
 	return false;
 }
 
+static inline void set_module_sig_enforced(void)
+{
+}
+
 static inline bool module_sig_ok(struct module *module)
 {
 	return true;
Quoted 5 lines

base-commit: e53642b87a4f4b03a8d7e5f8507fc3cd0c595ea6 --
2.51.0

Looks good to me.

Quoted 1 line

Hi Aaron,

Thanks for reviewing the patch!

Quoted 4 lines
Signature · 2 lines
-- 
Aaron Tomlin
Signature · 2 lines
Best regards,
Coiby
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Coiby Xu
Quoted 6 lines · Coiby Xu

Currently, set_module_sig_enforced is declared as long as CONFIG_MODULES is enabled. This can lead to a linking error if set_module_sig_enforced is called with CONFIG_MODULE_SIG=n,

ld: security/integrity/ima/ima_appraise.o: in function `ima_appraise_measurement':
security/integrity/ima/ima_appraise.c:587:(.text+0xbbb): undefined reference to `set_module_sig_enforced'

It's a bit unclear whether you're referring to a current upstream issue (which I couldn't find as of -rc3), or if this is just a hypothetical scenario.

Quoted 3 lines

So only declare set_module_sig_enforced when CONFIG_MODULE_SIG is enabled.

I only see cases where code has a safeguard like in security/integrity/ima/ima_efi.c:71

		if (IS_ENABLED(CONFIG_MODULE_SIG))
			set_module_sig_enforced();
Quoted 4 lines

Note this issue hasn't caused a real problem because all current callers of set_module_sig_enforced e.g. security/integrity/ima/ima_efi.c depend on CONFIG_MODULE_SIG=y.

I think the correct term we should use here is runtime safeguard. The code does not actually depend on that config, nor is there any dep in Kconfig.

Quoted 4 lines

Just minor nits regarding the commit message structure. This change should allow us to remove the safeguard from users of set_module_sig_enforced().

Other than that, LGTM,

author
#4 lore raw
Quoted 10 lines · Daniel Gomez
Quoted 6 lines · Coiby Xu

Currently, set_module_sig_enforced is declared as long as CONFIG_MODULES is enabled. This can lead to a linking error if set_module_sig_enforced is called with CONFIG_MODULE_SIG=n,

ld: security/integrity/ima/ima_appraise.o: in function `ima_appraise_measurement':
security/integrity/ima/ima_appraise.c:587:(.text+0xbbb): undefined reference to `set_module_sig_enforced'

It's a bit unclear whether you're referring to a current upstream issue (which I couldn't find as of -rc3), or if this is just a hypothetical scenario.

Hi Daniel,

Yes, this issue is hypothetical and currently doesn't cause any real trouble. lkp found this issue in one of my proposed patches
https://lore.kernel.org/lkml/[email protected]/
But I'll use a different solution so the above patch will be abandoned and will not be applied.

Quoted 12 lines
Quoted 4 lines

So only declare set_module_sig_enforced when CONFIG_MODULE_SIG is enabled.

I only see cases where code has a safeguard like in security/integrity/ima/ima_efi.c:71

		if (IS_ENABLED(CONFIG_MODULE_SIG))
			set_module_sig_enforced();
Quoted 1 line
Quoted 6 lines
Quoted 3 lines

Note this issue hasn't caused a real problem because all current callers of set_module_sig_enforced e.g. security/integrity/ima/ima_efi.c depend on CONFIG_MODULE_SIG=y.

I think the correct term we should use here is runtime safeguard. The code does not actually depend on that config, nor is there any dep in Kconfig.

Thanks for correcting me! Sorry I didn't realize the constant folding compiler optimization and made a false claim while forgetting the fact security/integrity/ima/ima_efi.c also explicitly use
"#if !IS_ENABLED(CONFIG_MODULE_SIG)".

Quoted 9 lines
Quoted 5 lines

Just minor nits regarding the commit message structure. This change should allow us to remove the safeguard from users of set_module_sig_enforced().

Thanks for the suggestion! Does the following commit address address you concern?

module: Only declare set_module_sig_enforced when CONFIG_MODULE_SIG=y

Currently if set_module_sig_enforced is called with CONFIG_MODULE_SIG=n e.g. [1], it can lead to a linking error,

ld: security/integrity/ima/ima_appraise.o: in function `ima_appraise_measurement':
security/integrity/ima/ima_appraise.c:587:(.text+0xbbb): undefined reference to `set_module_sig_enforced'

This happens because the actual implementation of set_module_sig_enforced comes from CONFIG_MODULE_SIG but both the function declaration and the empty stub definition are tied to CONFIG_MODULES.

So bind set_module_sig_enforced to CONFIG_MODULE_SIG instead. This allows (future) users to call set_module_sig_enforced directly without the "if IS_ENABLED(CONFIG_MODULE_SIG)" safeguard.

Note this issue hasn't caused a real problem because all current callers of set_module_sig_enforced e.g. security/integrity/ima/ima_efi.c use "if IS_ENABLED(CONFIG_MODULE_SIG)" safeguard.

[1] https://lore.kernel.org/lkml/[email protected]/

Quoted 5 lines

Other than that, LGTM,

Thanks for reviewing the patch!

Quoted 1 line
Signature · 2 lines
Best regards,
Coiby
author
#5 lore raw

PATCH v2 1/1 module: Only declare set_module_sig_enforced when CONFIG_MODULE_SIG=y

In reply to Coiby Xu

Currently if set_module_sig_enforced is called with CONFIG_MODULE_SIG=n e.g. [1], it can lead to a linking error,

ld: security/integrity/ima/ima_appraise.o: in function `ima_appraise_measurement':
security/integrity/ima/ima_appraise.c:587:(.text+0xbbb): undefined reference to `set_module_sig_enforced'

This happens because the actual implementation of set_module_sig_enforced comes from CONFIG_MODULE_SIG but both the function declaration and the empty stub definition are tied to CONFIG_MODULES.

So bind set_module_sig_enforced to CONFIG_MODULE_SIG instead. This allows (future) users to call set_module_sig_enforced directly without the "if IS_ENABLED(CONFIG_MODULE_SIG)" safeguard.

Note this issue hasn't caused a real problem because all current callers of set_module_sig_enforced e.g. security/integrity/ima/ima_efi.c use "if IS_ENABLED(CONFIG_MODULE_SIG)" safeguard.

[1] https://lore.kernel.org/lkml/[email protected]/

---
v2
- improve commit message as suggested by Daniel
- add Reviewed-by tags from Aaron and Daniel

 include/linux/module.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
include/linux/module.h +6 -6
index e135cc79acee..fa251958b138 100644
@@ -769,8 +769,6 @@ static inline bool is_livepatch_module(struct module *mod)
 #endif
 }
 
-void set_module_sig_enforced(void);
-
 void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data);
 
 #else /* !CONFIG_MODULES... */
@@ -865,10 +863,6 @@ static inline bool module_requested_async_probing(struct module *module)
 }
 
 
-static inline void set_module_sig_enforced(void)
-{
-}
-
 /* Dereference module function descriptor */
 static inline
 void *dereference_module_function_descriptor(struct module *mod, void *ptr)
@@ -924,6 +918,8 @@ static inline bool retpoline_module_ok(bool has_retpoline)
 #ifdef CONFIG_MODULE_SIG
 bool is_module_sig_enforced(void);
 
+void set_module_sig_enforced(void);
+
 static inline bool module_sig_ok(struct module *module)
 {
 	return module->sig_ok;
@@ -934,6 +930,10 @@ static inline bool is_module_sig_enforced(void)
 	return false;
 }
 
+static inline void set_module_sig_enforced(void)
+{
+}
+
 static inline bool module_sig_ok(struct module *module)
 {
 	return true;

base-commit: ac3fd01e4c1efce8f2c054cdeb2ddd2fc0fb150d

Signature · 1 line
2.52.0
maintainer Applied
#6 lore raw
Quoted 6 lines · Coiby Xu

Currently if set_module_sig_enforced is called with CONFIG_MODULE_SIG=n e.g. [1], it can lead to a linking error,

ld: security/integrity/ima/ima_appraise.o: in function `ima_appraise_measurement':
security/integrity/ima/ima_appraise.c:587:(.text+0xbbb): undefined reference to `set_module_sig_enforced'

Quoted 6 lines

This happens because the actual implementation of set_module_sig_enforced comes from CONFIG_MODULE_SIG but both the function declaration and the empty stub definition are tied to CONFIG_MODULES.

[...]

Applied to modules-next, thanks!

[1/1] module: Only declare set_module_sig_enforced when CONFIG_MODULE_SIG=y

      commit: 1ae719a43b0336678172b3eb55c5187816f9a130

Best regards,

Sami