net/rds: fix init failures leaving built-in transports on a dead core
Status from this message: This series was applied to netdev/net.git (main)
Get series with b4
b4 am [email protected]Versions newest first
Patches in v1 All 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | net/rds: do not fail init when CONFIG_SYSCTL=nnet/ net/ net/ | +3 | 2 replies | Applied |
| 2/2 | net/rds: do not initialize transports after rds_init() failednet/ net/ net/ +1 more | +21 | 0 replies | Applied |
Reviews trailers per patch
1 of 2 patches has a Reviewed-by or Acked-by.
| Patch | Joel Granados | Oleg Nesterov |
|---|---|---|
| 1/2 | R-b | A-b |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH net 0/2] net/rds: fix init failures leaving built-in transports on a dead core
The kernel test robot hit a slab-use-after-free on rds_wq at boot with CONFIG_SYSCTL=n and RDS, RDS_RDMA and RDS_TCP built in [1]. Two separate bugs are involved.
With CONFIG_SYSCTL=n, register_net_sysctl() is a stub that returns NULL, and RDS treats that as -ENOMEM, so rds_init() fails even though every tunable has a usable default. Patch 1 only treats NULL as a failure when sysctl support is built in.
Second, when RDS is built in, a failed rds_init() does not stop the rds_rdma and rds_tcp initcalls. They run against a core that has already been torn down and queue onto or flush the freed rds_wq. The error path of rds_ib_init() did this in the robot's report. The rds_tcp listen socket can also do it when an incoming connection arrives. Patch 2 makes both transports bail out with -ENODEV unless rds_init() succeeded. Modular builds can't hit this, because the transports need symbols from rds.ko.
Thanks to Oleg Nesterov and Joel Granados for the analysis in [2].
Testing: x86_64 under virtme-ng, built in RDS/RDS_RDMA/RDS_TCP, CONFIG_SYSCTL=n, KASAN, booted with initcall_debug:
- net/main: rds_init() returns -ENOMEM, then rds_rdma_init() hits KASAN slab-use-after-free in __flush_workqueue() from rds_ib_init(), reproducing [1].
- patch 2 only: rds_init() still returns -ENOMEM; rds_rdma_init() and rds_tcp_init() return -ENODEV and the boot completes cleanly.
- both patches: rds_init(), rds_rdma_init() and rds_tcp_init() all return 0, no KASAN reports.
[1] https://lore.kernel.org/oe-lkp/[email protected]
[2] https://lore.kernel.org/all/[email protected]/
Allison Henderson (2):
net/rds: do not fail init when CONFIG_SYSCTL=n net/rds: do not initialize transports after rds_init() failed
net/rds/af_rds.c | 14 ++++++++++++++ net/rds/ib_sysctl.c | 2 +- net/rds/rdma_transport.c | 3 +++ net/rds/rds.h | 1 + net/rds/sysctl.c | 2 +- net/rds/tcp.c | 5 ++++- 6 files changed, 24 insertions(+), 3 deletions(-)
Signature · 1 line
2.50.1