CVE-2026-98360: RDMA/rxe: insert mcg into mcg_tree only after rxe_mcast_add() succeeds
In the Linux kernel, the following vulnerability has been resolved:
RDMA/rxe: insert mcg into mcgtree only after rxemcastadd() succeeds
rxegetmcg() publishes a newly allocated multicast group in rxe->mcgtree before programming the backing Ethernet multicast address with rxemcastadd(), which runs outside mcglock. A local userspace RDMA client reaches this path with ATTACHMCAST on a UD QP; if rxemcastadd() then returns an error (for example -ENODEV when the backing netdev has been removed, or a propagated devmcadd() error), the unwind frees the published group without removing it from the tree. A later lookup of the same MGID dereferences the freed struct rxemcg from rxelookupmcg().
Fix this by keeping the new mcg private until rxemcastadd() succeeds. Split the tree publication into rxepublishmcg(), call rxemcastadd() before taking the tree reference, and free the still-private mcg on failure. Because the group is never visible in mcgtree until the multicast address is programmed, no concurrent caller can look it up or attach a QP to a group that is about to be torn down, so the error path needs no conditional unwind. If another caller publishes the same MGID while the address is being programmed, the post-add re-check under mcglock finds the winner; this caller then drops its private object and balances its own rxemcastadd() with rxemcastdel() before returning the winner.
Reproduced by forcing the rxemcastadd() error return under KASAN: without the change the next attach to the same MGID reports a slab-use-after-free in rxelookupmcg(); with it the forced failure returns cleanly. A no-injection attach/detach regression, including a two-QP shared join/leave and re-attach, stays KASAN- and leak-clean.
Affected Software
Event History
Frequently Asked Questions
Who can trigger the vulnerable path?
A local userspace RDMA client can reach it by issuing ATTACH_MCAST on a UD queue pair. The issue is specific to the RXE RDMA path handling multicast groups.
What conditions are required for the use-after-free to occur?
Programming the backing Ethernet multicast address must fail after a new multicast group has been published in the multicast-group tree. Examples given include the backing network device having been removed, causing -ENODEV, or a dev_mc_add() error; a later lookup of the same MGID can then dereference the freed group.