]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
netfilter: replace -EEXIST with -EBUSY
authorDaniel Gomez <da.gomez@samsung.com>
Fri, 19 Dec 2025 05:13:20 +0000 (06:13 +0100)
committerFlorian Westphal <fw@strlen.de>
Thu, 1 Jan 2026 10:31:48 +0000 (11:31 +0100)
The -EEXIST error code is reserved by the module loading infrastructure
to indicate that a module is already loaded. When a module's init
function returns -EEXIST, userspace tools like kmod interpret this as
"module already loaded" and treat the operation as successful, returning
0 to the user even though the module initialization actually failed.

Replace -EEXIST with -EBUSY to ensure correct error reporting in the module
initialization path.

Affected modules:
  * ebtable_broute ebtable_filter ebtable_nat arptable_filter
  * ip6table_filter ip6table_mangle ip6table_nat ip6table_raw
  * ip6table_security iptable_filter iptable_mangle iptable_nat
  * iptable_raw iptable_security

Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/bridge/netfilter/ebtables.c
net/netfilter/nf_log.c
net/netfilter/x_tables.c

index 5697e3949a36529b6803d14a3aac67ada9db84d6..a04fc1757528979d9c6de1adc6ef8c959db34980 100644 (file)
@@ -1299,7 +1299,7 @@ int ebt_register_template(const struct ebt_table *t, int (*table_init)(struct ne
        list_for_each_entry(tmpl, &template_tables, list) {
                if (WARN_ON_ONCE(strcmp(t->name, tmpl->name) == 0)) {
                        mutex_unlock(&ebt_mutex);
-                       return -EEXIST;
+                       return -EBUSY;
                }
        }
 
index 74cef8bf554c55b52426ccbef0a8f0d22fae0b9d..62cf6a30875e39ac934fb37a45955911475509fe 100644 (file)
@@ -89,7 +89,7 @@ int nf_log_register(u_int8_t pf, struct nf_logger *logger)
        if (pf == NFPROTO_UNSPEC) {
                for (i = NFPROTO_UNSPEC; i < NFPROTO_NUMPROTO; i++) {
                        if (rcu_access_pointer(loggers[i][logger->type])) {
-                               ret = -EEXIST;
+                               ret = -EBUSY;
                                goto unlock;
                        }
                }
@@ -97,7 +97,7 @@ int nf_log_register(u_int8_t pf, struct nf_logger *logger)
                        rcu_assign_pointer(loggers[i][logger->type], logger);
        } else {
                if (rcu_access_pointer(loggers[pf][logger->type])) {
-                       ret = -EEXIST;
+                       ret = -EBUSY;
                        goto unlock;
                }
                rcu_assign_pointer(loggers[pf][logger->type], logger);
index 90b7630421c442398cc95b9329c16652e81c1571..48105ea3df15221d078d3c13f66cd69a60b1d2b8 100644 (file)
@@ -1764,7 +1764,7 @@ EXPORT_SYMBOL_GPL(xt_hook_ops_alloc);
 int xt_register_template(const struct xt_table *table,
                         int (*table_init)(struct net *net))
 {
-       int ret = -EEXIST, af = table->af;
+       int ret = -EBUSY, af = table->af;
        struct xt_template *t;
 
        mutex_lock(&xt[af].mutex);