Skip to contentSkip to conversation

firmware_loader: revert removal of the fw_fallback_config export

PATCH In review Luis R. Rodriguez 2 participants 3 messages Apr 24, 2020 – Apr 25, 2020

Subsystems (3)
lore
Share & tools
lore

Luis R. Rodriguez

author maintainer
#0 lore raw

PATCH v2 1/2 firmware_loader: revert removal of the fw_fallback_config export

From: Luis Chamberlain <[email protected]>

Christoph's patch removed two unsused exported symbols, however, one symbol is used by the firmware_loader itself. If CONFIG_FW_LOADER=m so the firmware_loader is modular but CONFIG_FW_LOADER_USER_HELPER=y we fail the build at mostpost.

ERROR: modpost: "fw_fallback_config" [drivers/base/firmware_loader/firmware_class.ko] undefined!

This happens because the variable fw_fallback_config is built into the kernel if CONFIG_FW_LOADER_USER_HELPER=y always, so we need to grant access to the firmware loader module by exporting it.

Revert only one hunk from his patch.

Fixes 739604734bd8e4ad71 ("firmware_loader: remove unused exports")
---
 drivers/base/firmware_loader/fallback_table.c | 1 +
 1 file changed, 1 insertion(+)
drivers/base/firmware_loader/fallback_table.c +1 -0
index 0a737349f78f..a182e318bd09 100644
@@ -21,6 +21,7 @@ struct firmware_fallback_config fw_fallback_config = {
 	.loading_timeout = 60,
 	.old_timeout = 60,
 };
+EXPORT_SYMBOL_GPL(fw_fallback_config);
 
 #ifdef CONFIG_SYSCTL
 struct ctl_table firmware_config_table[] = {
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH v2 2/2 firmware_loader: move fw_fallback_config to a private kernel symbol namespace

From: Luis Chamberlain <[email protected]>

Take advantage of the new kernel symbol namespacing functionality, and export the fw_fallback_config symbol only to a new private firmware loader namespace. This would prevent misuses from other drivers and makes it clear the goal is to keep this private to the firmware loader only.

It should also make it clearer for folks git grep'ing for users of the symbol that this exported symbol is private, and prevent future accidental removals of the exported symbol.

---
 drivers/base/firmware_loader/fallback.c       | 3 +++
 drivers/base/firmware_loader/fallback_table.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/base/firmware_loader/fallback.c +3 -0
index 1e9c96e3ed63..d9ac7296205e 100644
@@ -9,6 +9,7 @@
 #include <linux/umh.h>
 #include <linux/sysctl.h>
 #include <linux/vmalloc.h>
+#include <linux/module.h>
 
 #include "fallback.h"
 #include "firmware.h"
@@ -17,6 +18,8 @@
  * firmware fallback mechanism
  */
 
+MODULE_IMPORT_NS(FIRMWARE_LOADER_PRIVATE);
+
 extern struct firmware_fallback_config fw_fallback_config;
 
 /* These getters are vetted to use int properly */
drivers/base/firmware_loader/fallback_table.c +1 -1
index a182e318bd09..46a731dede6f 100644
@@ -21,7 +21,7 @@ struct firmware_fallback_config fw_fallback_config = {
 	.loading_timeout = 60,
 	.old_timeout = 60,
 };
-EXPORT_SYMBOL_GPL(fw_fallback_config);
+EXPORT_SYMBOL_NS_GPL(fw_fallback_config, FIRMWARE_LOADER_PRIVATE);
 
 #ifdef CONFIG_SYSCTL
 struct ctl_table firmware_config_table[] = {
Signature · 1 line
2.25.1
maintainer
#2 lore raw
In reply to Luis R. Rodriguez
Quoted 9 lines · Luis R. Rodriguez

From: Luis Chamberlain <[email protected]>

Christoph's patch removed two unsused exported symbols, however, one symbol is used by the firmware_loader itself. If CONFIG_FW_LOADER=m so the firmware_loader is modular but CONFIG_FW_LOADER_USER_HELPER=y we fail the build at mostpost.

ERROR: modpost: "fw_fallback_config" [drivers/base/firmware_loader/firmware_class.ko] undefined!

Quoted 7 lines

This happens because the variable fw_fallback_config is built into the kernel if CONFIG_FW_LOADER_USER_HELPER=y always, so we need to grant access to the firmware loader module by exporting it.

Revert only one hunk from his patch.

Fixes 739604734bd8e4ad71 ("firmware_loader: remove unused exports")
Fixes 739604734bd8 ("firmware_loader: remove unused exports")

No need to be over-eager with the number of digits...

I'll fix this up when I apply it, thanks.

greg k-h