On 21/12/2025 05.02, James Bottomley wrote: > On Sun, 2025-12-21 at 04:30 +0100, Daniel Gomez wrote: >> On 20/12/2025 05.27, James Bottomley wrote: >>> On Sat, 2025-12-20 at 04:37 +0100, Daniel Gomez wrote: > None of that answers the why question: Given that EEXIST is used all > over the kernel, for what appear to be fairly legitimate cases, why > would we suddenly want it to become only for modules? I get that we > can, as you propose patches above, but why should we bother? It seems > to be a useful error code outside the module use case, so why the need > to restrict it to being only for modules?
Because both the module loader and module_init() return through the same (f)init_module() syscall path, we need to ensure consistency in what we report back to userspace. The init_module(2) man page documents EEXIST as "a module with this name is already loaded." When module_init() returns EEXIST for a different reason, userspace tools following the documented behavior will misinterpret it. We can't use the same error code for different meanings and expect the caller to differentiate.

