[PATCH v1] net: qualcomm: rmnet: set ep->mux_id before relinking the endpoint
From: Binbin Deng
Date: Mon Nov 30 2026 - 04:08:38 EST
rmnet_changelink() moves the logical endpoint to its new mux bucket
with hlist_del_init_rcu() / hlist_add_head_rcu() and only afterwards
stores ep->mux_id = mux_id.
rmnet_get_endpoint() scans the target bucket with
hlist_for_each_entry_rcu() and filters on ep->mux_id == mux_id from the
receive path (rmnet_rx_handler -> __rmnet_map_ingress_handler) without
rtnl. During the window it observes the endpoint in the new bucket with
the stale id and returns NULL: frames for both the old and the new
mux_id are dropped until the store completes, and the plain 1-byte
store races the lockless load.
BUG: KCSAN: data-race in rmnet_changelink / rmnet_get_endpoint
read to 0xffff88810287c180 of 1 bytes by interrupt on cpu 0:
rmnet_get_endpoint+0x3e/0x80
__rmnet_map_ingress_handler+0x74/0x370
rmnet_rx_handler+0x159/0x200
__netif_receive_skb_core+0x2cc/0x1680
__netif_receive_skb+0x19/0xa0
write to 0xffff88810287c180 of 1 bytes by task 81 on cpu 3:
rmnet_changelink+0x312/0x3e0
rtnl_newlink+0xe27/0x15c0
rtnetlink_rcv_msg+0x504/0x630 ...
Trigger environment: x86_64 QEMU/KVM guest, -smp 4, kernel built with
CONFIG_KCSAN=y. rmnet0 over a veth uplink configured with mux_id 1, an
AF_PACKET sender flooding raw MAP frames that alternate mux_id 1/2,
and a second CPU flipping `ip link set rmnet0 type rmnet mux_id N`
between 1 and 2 in a loop.
Fix by assigning ep->mux_id before the RCU-visible relink, so the
endpoint is only ever visible in the new bucket with the matching id.
Fixes: 23790ef12082 ("net: qualcomm: rmnet: Allow to configure flags for existing devices")
Signed-off-by: Binbin Deng <18983559317@xxxxxxx>
---
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
index bed6f63facf2..0cecc2a80e8a 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
@@ -330,11 +330,11 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
return -EINVAL;
}
+ ep->mux_id = mux_id;
hlist_del_init_rcu(&ep->hlnode);
hlist_add_head_rcu(&ep->hlnode,
&port->muxed_ep[mux_id]);
- ep->mux_id = mux_id;
priv->mux_id = mux_id;
}
}
--
2.43.0