Mon, Nov 30, 2026 at 09:52:19AM +0100, AeeS…@126.com wrote:
>In __reconstruct_port_hlist(), when a TX-enabled team port is disabled
>or removed, every subsequent TX-enabled port is unlinked from
>team->tx_en_port_hlist with hlist_del_rcu(&port->tx_hlist) and
>immediately re-inserted into another hash bucket with
>hlist_add_head_rcu(&port->tx_hlist, ...) without waiting for an RCU
>grace period.
>
>Reusing port->tx_hlist immediately after hlist_del_rcu() overwrites
>its next pointer while concurrent TX softirq readers in
>team_get_port_by_tx_index_rcu() may still be traversing the previous
>bucket under rcu_read_lock(). This can cause RCU readers to jump to
>another bucket, miss active ports, or loop indefinitely in TX softirq.
>
>All callers of __reconstruct_port_hlist() run in sleepable process
>context under team->lock. Unlink all affected ports first, wait for a
>single RCU grace period with synchronize_rcu() if any ports are being
>rehashed, and then update their tx_index and re-insert them into the
>hash table.
>
>Found by manual code inspection.
>
>Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device")
>Cc: stab…@vger.kernel.org
>Signed-off-by: Bilal Hashim <AeeS…@126.com>
Reviewed-by: Jiri Pirko <ji…@nvidia.com>