diff options
| author | Lucas De Marchi <demarchi@kernel.org> | 2026-03-30 08:13:51 -0500 |
|---|---|---|
| committer | Sami Tolvanen <samitolvanen@google.com> | 2026-04-04 00:04:42 +0000 |
| commit | 743f8cae549affe8eafb021b8c0e78a9f3bc23fa (patch) | |
| tree | 32b7961f7377f1ec1dc6eb8bc37c4465f71a7f14 /kernel/module | |
| parent | 3b1299f25b07ef83e020d049dfc62ced9c09450d (diff) | |
| download | linux-743f8cae549affe8eafb021b8c0e78a9f3bc23fa.tar.gz linux-743f8cae549affe8eafb021b8c0e78a9f3bc23fa.zip | |
module: Override -EEXIST module return
The -EEXIST errno is reserved by the module loading functionality. When
userspace calls [f]init_module(), it expects a -EEXIST to mean that the
module is already loaded in the kernel. If module_init() returns it,
that is not true anymore.
Override the error when returning to userspace: it doesn't make sense to
change potentially long error propagation call chains just because it's
will end up as the return of module_init().
Closes: https://lore.kernel.org/all/aKLzsAX14ybEjHfJ@orbyte.nwl.cc/
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Aaron Tomlin <atomlin@atomlin.com>
Cc: Petr Pavlu <petr.pavlu@suse.com>
Cc: Daniel Gomez <da.gomez@samsung.com>
Cc: Phil Sutter <phil@nwl.cc>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
[Sami: Fixed a typo.]
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Diffstat (limited to 'kernel/module')
| -rw-r--r-- | kernel/module/main.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/module/main.c b/kernel/module/main.c index c4f768953516..ef6742536700 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -3105,6 +3105,14 @@ static noinline int do_init_module(struct module *mod) if (mod->init != NULL) ret = do_one_initcall(mod->init); if (ret < 0) { + /* + * -EEXIST is reserved by [f]init_module() to signal to userspace that + * a module with this name is already loaded. Use something else if the + * module itself is returning that. + */ + if (ret == -EEXIST) + ret = -EBUSY; + goto fail_free_freeinit; } if (ret > 0) { |
