mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
modpost: check forbidden MODULE_IMPORT_NS("module:") at compile time
Explicitly adding MODULE_IMPORT_NS("module:...") is not allowed. Currently, this is only checked at run time. That is, when such a module is loaded, an error message like the following is shown: foo: module tries to import module namespace: module:bar Obviously, checking this at compile time improves usability. In such a case, modpost will report the following error at compile time: ERROR: modpost: foo: explicitly importing namespace "module:bar" is not allowed. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
parent
8f81d8529e
commit
9c036cfbb7
1 changed files with 8 additions and 1 deletions
|
@ -28,6 +28,8 @@
|
|||
#include "modpost.h"
|
||||
#include "../../include/linux/license.h"
|
||||
|
||||
#define MODULE_NS_PREFIX "module:"
|
||||
|
||||
static bool module_enabled;
|
||||
/* Are we using CONFIG_MODVERSIONS? */
|
||||
static bool modversions;
|
||||
|
@ -1597,8 +1599,13 @@ static void read_symbols(const char *modname)
|
|||
|
||||
for (namespace = get_modinfo(&info, "import_ns");
|
||||
namespace;
|
||||
namespace = get_next_modinfo(&info, "import_ns", namespace))
|
||||
namespace = get_next_modinfo(&info, "import_ns", namespace)) {
|
||||
if (strstarts(namespace, MODULE_NS_PREFIX))
|
||||
error("%s: explicitly importing namespace \"%s\" is not allowed.\n",
|
||||
mod->name, namespace);
|
||||
|
||||
add_namespace(&mod->imported_namespaces, namespace);
|
||||
}
|
||||
|
||||
if (!get_modinfo(&info, "description"))
|
||||
warn("missing MODULE_DESCRIPTION() in %s\n", modname);
|
||||
|
|
Loading…
Add table
Reference in a new issue