From: Allison Henderson <achender@kernel.org>
To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
pabeni@redhat.com, edumazet@google.com, kuba@kernel.org,
horms@kernel.org
Cc: achender@kernel.org, oleg@redhat.com, joel.granados@kernel.org
Subject: [PATCH net 1/2] net/rds: do not fail init when CONFIG_SYSCTL=n
Date: Wed, 21 Oct 2026 12:58:36 -0700 [thread overview]
Message-ID: <20261021195837.142802-2-achender@kernel.org> (raw)
In-Reply-To: <20261021195837.142802-1-achender@kernel.org>
With CONFIG_SYSCTL=n, register_net_sysctl() and register_net_sysctl_sz()
are inline stubs that return NULL. rds_sysctl_init(),
rds_ib_sysctl_init() and rds_tcp_init_net() all treat that NULL as
-ENOMEM, so RDS refuses to initialize at all even though every tunable
has a sane compiled-in default.
When RDS is built in, that is worse than a missing feature: the failed
rds_init() destroys rds_wq, but the rds_rdma initcall still runs, and
when rds_ib_sysctl_init() fails the same way, the error path in
rds_ib_init() flushes the already freed workqueue:
BUG: KASAN: slab-use-after-free in touch_wq_lockdep_map
...
__flush_workqueue
rds_ib_init
rds_rdma_init
...
Allocated by task 1:
alloc_workqueue_noprof
rds_threads_init
rds_init
...
Freed by task 0:
kfree
rcu_do_batch
Only treat the NULL return as a failure when sysctl support is actually
compiled in. The exit paths need no change: unregister_net_sysctl_table()
is an empty stub with CONFIG_SYSCTL=n and already tolerates a NULL header
otherwise.
The underlying problem of built-in transports initializing after
rds_init() has failed is independent of sysctl and is addressed
separately.
Reported-by: kernel test robot <yi1.lai@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202610190310.9737b2e3-lkp@intel.com
Fixes: 3e5048495c85 ("RDS: sysctls")
Fixes: e6babe4cc4ce ("RDS/IB: Stats and sysctls")
Fixes: c6a58ffed536 ("RDS: TCP: Add sysctl tunables for sndbuf/rcvbuf on rds-tcp socket")
Suggested-by: Joel Granados <joel.granados@kernel.org>
Assisted-by: LLM
Signed-off-by: Allison Henderson <achender@kernel.org>
---
net/rds/ib_sysctl.c | 2 +-
net/rds/sysctl.c | 2 +-
net/rds/tcp.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/rds/ib_sysctl.c b/net/rds/ib_sysctl.c
index 2af678e71e3c..bc97a3eecad6 100644
--- a/net/rds/ib_sysctl.c
+++ b/net/rds/ib_sysctl.c
@@ -114,7 +114,7 @@ void rds_ib_sysctl_exit(void)
int rds_ib_sysctl_init(void)
{
rds_ib_sysctl_hdr = register_net_sysctl(&init_net, "net/rds/ib", rds_ib_sysctl_table);
- if (!rds_ib_sysctl_hdr)
+ if (!rds_ib_sysctl_hdr && IS_ENABLED(CONFIG_SYSCTL))
return -ENOMEM;
return 0;
}
diff --git a/net/rds/sysctl.c b/net/rds/sysctl.c
index 025f518a4349..968d6279bbd3 100644
--- a/net/rds/sysctl.c
+++ b/net/rds/sysctl.c
@@ -103,7 +103,7 @@ int rds_sysctl_init(void)
rds_sysctl_reg_table =
register_net_sysctl(&init_net, "net/rds", rds_sysctl_rds_table);
- if (!rds_sysctl_reg_table)
+ if (!rds_sysctl_reg_table && IS_ENABLED(CONFIG_SYSCTL))
return -ENOMEM;
return 0;
}
diff --git a/net/rds/tcp.c b/net/rds/tcp.c
index 774a71f88d37..34815b4f658b 100644
--- a/net/rds/tcp.c
+++ b/net/rds/tcp.c
@@ -637,7 +637,7 @@ static __net_init int rds_tcp_init_net(struct net *net)
tbl[RDS_TCP_RCVBUF].data = &rtn->rcvbuf_size;
rtn->rds_tcp_sysctl = register_net_sysctl_sz(net, "net/rds/tcp", tbl,
ARRAY_SIZE(rds_tcp_sysctl_table));
- if (!rtn->rds_tcp_sysctl) {
+ if (!rtn->rds_tcp_sysctl && IS_ENABLED(CONFIG_SYSCTL)) {
pr_warn("could not register sysctl\n");
err = -ENOMEM;
goto fail;
--
2.50.1
next prev parent reply other threads:[~2026-10-21 19:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 19:58 [PATCH net 0/2] net/rds: fix init failures leaving built-in transports on a dead core Allison Henderson
2026-10-21 19:58 ` Allison Henderson [this message]
2026-10-21 20:03 ` [PATCH net 1/2] net/rds: do not fail init when CONFIG_SYSCTL=n sashiko-bot
2026-10-22 7:22 ` Joel Granados
2026-10-22 12:33 ` Oleg Nesterov
2026-10-21 19:58 ` [PATCH net 2/2] net/rds: do not initialize transports after rds_init() failed Allison Henderson
2026-10-21 20:03 ` sashiko-bot
2026-10-27 10:40 ` [PATCH net 0/2] net/rds: fix init failures leaving built-in transports on a dead core patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261021195837.142802-2-achender@kernel.org \
--to=achender@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=joel.granados@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.