Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 1 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The commit message says that above RDS_IB_MAX_PROBE_PENDING the check 'fails with -ENOMEM rather than returning a value that would… - [Low] The new comment above struct rds_ib_probe_work in net/rds/ib.c says the probe runs 'while rds_trans_get_preferred() holds… -- net/rds: defer the probe cm_id destroy to rds_wq This patch moves the rdma_destroy_id() of the probe cm_id in rds_ib_laddr_check_cm() onto rds_wq. This avoids a recursive handler_mutex lockdep report on the passive connection path. A global counter caps pending destroys at RDS_IB_MAX_PROBE_PENDING (64), and rds_ib_exit() flushes rds_wq before the module goes away.
> diff --git a/net/rds/ib.c b/net/rds/ib.c > index 4ea9838d090c3..624374ecf4fad 100644 > --- a/net/rds/ib.c > +++ b/net/rds/ib.c > @@ -391,6 +391,31 @@ static void rds6_ib_ic_info(struct socket *sock, unsigned int len, > } > #endif > > +/* > + * The probe cm_id must not be destroyed from the caller's context: > + * rds_ib_laddr_check() runs it while rdma_cm's handler_mutex is held > + * (the passive connection path) or while rds_trans_get_preferred() holds > + * rds_trans_sem, and rdma_destroy_id() takes handler_mutex again. Queue > + * the destruction on rds_wq, which runs without either lock. > + */
[Severity: Low] Is the rds_trans_sem part of this comment accurate? In this tree, rds_trans_get_preferred() drops the semaphore before it calls ->laddr_check(): net/rds/transport.c:rds_trans_get_preferred() { ... /* * ->laddr_check() may create and destroy an rdma_cm id, which * takes rdma_cm's handler_mutex. Don't hold rds_trans_sem * across it: the module reference keeps trans alive. */ up_read(&rds_trans_sem); if (trans->laddr_check(net, addr, scope_id) == 0) return trans; ... } The SO_RDS_TRANSPORT path in rds_bind() doesn't take rds_trans_sem either. The transport.c comment has the opposite problem. It says ->laddr_check() destroys the rdma_cm id and takes handler_mutex, but with this patch the destroy runs later on rds_wq. Could both comments be updated so they describe the same locking rules for ->laddr_check()?
> +struct rds_ib_probe_work { > + struct work_struct work; > + struct rdma_cm_id *cm_id; > +}; > + > +static atomic_t rds_ib_probe_pending = ATOMIC_INIT(0); > +#define RDS_IB_MAX_PROBE_PENDING 64 > + > +static void rds_ib_probe_work_fn(struct work_struct *work) > +{ > + struct rds_ib_probe_work *pw = > + container_of(work, struct rds_ib_probe_work, work); > + > + rdma_destroy_id(pw->cm_id); > + kfree(pw); > + atomic_dec(&rds_ib_probe_pending); > +}
[ ... ]
> @@ -414,11 +440,25 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr, > bool isv4; > > isv4 = ipv6_addr_v4mapped(addr); > + > + pw = kzalloc_obj(*pw); > + if (!pw) > + return -ENOMEM; > + > + if (atomic_inc_return(&rds_ib_probe_pending) > RDS_IB_MAX_PROBE_PENDING) { > + atomic_dec(&rds_ib_probe_pending); > + kfree(pw); > + return -ENOMEM; > + }
[Severity: Medium] The commit message says: above the bound the check fails with -ENOMEM rather than returning a value that would make rds_trans_get_preferred() fall back to another transport. Does -ENOMEM actually prevent the fallback? rds_trans_get_preferred() only checks for zero: if (trans->laddr_check(net, addr, scope_id) == 0) return trans; rds_trans_put(trans); down_read(&rds_trans_sem); Any non-zero return, including -ENOMEM, moves on to the next registered transport. RDS_TRANS_TCP comes after RDS_TRANS_IB, and rds_tcp_laddr_check() returns 0 for any local address, IPoIB addresses included. rds_ib_probe_pending is also a single global counter that every caller shares. Every call that reaches the cm path takes a slot. That covers every IPv6 address and every IPv4 address that rds_ib_get_device() doesn't find, including addresses that don't exist. A slot is freed only when rds_ib_probe_work_fn() runs. rds_wq comes from create_singlethread_workqueue("krdsd"), so those destroys wait behind all other RDS work queued there. Nothing in net/rds/ requires a capability to create AF_RDS sockets. While more than 64 destroys are pending, an unrelated bind() seems to end up like this: - Without SO_RDS_TRANSPORT, an IB address is silently bound to RDS/TCP, and rs->rs_transport keeps that value for the life of the socket. If rds_tcp isn't loaded, the bind fails with -EADDRNOTAVAIL. - With SO_RDS_TRANSPORT set to IB, rds_bind() returns -ENOPROTOOPT. In both cases userspace never sees the -ENOMEM. The loopback check in __rds_conn_create() also goes through this path: loop_trans = rds_trans_get_preferred(net, faddr, conn->c_dev_if); Could that check give the wrong answer during the same window? I wasn't able to confirm how easily more than 64 destroys can be kept pending in practice. Still, before this patch the destroy was synchronous and there was no shared budget. Is it intended that one user can use up this cap and affect everyone else? Should the commit message's explanation for returning -ENOMEM be corrected? [ ... ]
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40cmss.chinamobile.com