module: Only declare set_module_sig_enforced when CONFIG_MODULE_SIG=y
Subsystems (2)
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
@@ -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
Quoted 66 lines · Coiby Xu
Currently,
set_module_sig_enforcedis declared as long asCONFIG_MODULESis enabled. This can lead to a linking error ifset_module_sig_enforcedis called withCONFIG_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_enforcedwhenCONFIG_MODULE_SIGis enabled.Note this issue hasn't caused a real problem because all current callers of
set_module_sig_enforcede.g.security/integrity/ima/ima_efi.cdepend onCONFIG_MODULE_SIG=y.Reported-by kernel test robot <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- include/linux/module.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)include/linux/module.h +6
-6@@ -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:
e53642b87a4f4b03a8d7e5f8507fc3cd0c595ea6Signature · 1 line
2.51.0
Looks good to me.
Signature · 1 line
Aaron Tomlin
Quoted 75 lines · Aaron Tomlin
Quoted 66 lines · Coiby Xu
Currently,
set_module_sig_enforcedis declared as long asCONFIG_MODULESis enabled. This can lead to a linking error ifset_module_sig_enforcedis called withCONFIG_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_enforcedwhenCONFIG_MODULE_SIGis enabled.Note this issue hasn't caused a real problem because all current callers of
set_module_sig_enforcede.g.security/integrity/ima/ima_efi.cdepend onCONFIG_MODULE_SIG=y.Reported-by kernel test robot <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- include/linux/module.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)include/linux/module.h +6
-6@@ -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.0Looks good to me.
Quoted 1 line
Reviewed-by Aaron Tomlin <[email protected]>
Hi Aaron,
Thanks for reviewing the patch!
Quoted 4 lines
Signature · 2 lines
-- Aaron Tomlin
Signature · 2 lines
Best regards, Coiby
Quoted 6 lines · Coiby Xu
Currently,
set_module_sig_enforcedis declared as long asCONFIG_MODULESis enabled. This can lead to a linking error ifset_module_sig_enforcedis called withCONFIG_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_enforcedwhenCONFIG_MODULE_SIGis 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_enforcede.g.security/integrity/ima/ima_efi.cdepend onCONFIG_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
Reported-by kernel test robot <[email protected]>Signed-off-by Coiby Xu <[email protected]>
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,
Quoted 10 lines · Daniel Gomez
Quoted 6 lines · Coiby Xu
Currently,
set_module_sig_enforcedis declared as long asCONFIG_MODULESis enabled. This can lead to a linking error ifset_module_sig_enforcedis called withCONFIG_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_enforcedwhenCONFIG_MODULE_SIGis enabled.I only see cases where code has a safeguard like in
security/integrity/ima/ima_efi.c:71if (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_enforcede.g.security/integrity/ima/ima_efi.cdepend onCONFIG_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
Reported-by kernel test robot <[email protected]>Signed-off-by Coiby Xu <[email protected]>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,
Reviewed-by Daniel Gomez <[email protected]>
Thanks for reviewing the patch!
Quoted 1 line
Signature · 2 lines
Best regards, Coiby
PATCH v2 1/1 module: Only declare set_module_sig_enforced when CONFIG_MODULE_SIG=y
In reply to Coiby XuCurrently 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
@@ -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
Quoted 6 lines · Coiby Xu
Currently if
set_module_sig_enforcedis called withCONFIG_MODULE_SIG=ne.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_enforcedcomes fromCONFIG_MODULE_SIGbut both the function declaration and the empty stub definition are tied toCONFIG_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