diff options
author | 2025-05-02 16:12:06 +0200 | |
---|---|---|
committer | 2025-05-25 18:11:56 +0900 | |
commit | 520b1a147d918eb07132c847ad5598a17d3ff7ca (patch) | |
tree | ded61b56e8ccc034b54522dd444a114bca3591a2 /scripts | |
parent | modpost: Use for() loop (diff) | |
download | linux-rng-520b1a147d918eb07132c847ad5598a17d3ff7ca.tar.xz linux-rng-520b1a147d918eb07132c847ad5598a17d3ff7ca.zip |
module: Add module specific symbol namespace support
Designate the "module:${modname}" symbol namespace to mean: 'only
export to the named module'.
Notably, explicit imports of anything in the "module:" space is
forbidden.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mod/modpost.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 2d1c059bf6cf..c9ff4db26edb 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1682,6 +1682,14 @@ void buf_write(struct buffer *buf, const char *s, int len) buf->pos += len; } +static bool verify_module_namespace(const char *namespace, const char *modname) +{ + const char *prefix = "module:"; + + return strstarts(namespace, prefix) && + !strcmp(namespace + strlen(prefix), modname); +} + static void check_exports(struct module *mod) { struct symbol *s, *exp; @@ -1709,7 +1717,8 @@ static void check_exports(struct module *mod) basename = get_basename(mod->name); - if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) { + if (!verify_module_namespace(exp->namespace, basename) && + !contains_namespace(&mod->imported_namespaces, exp->namespace)) { modpost_log(!allow_missing_ns_imports, "module %s uses symbol %s from namespace %s, but does not import it.\n", basename, exp->name, exp->namespace); |