ipv6: mcast: fix data race in mld_process_v1
Subsystems (2)
PATCH 1/1 ipv6: mcast: fix data race in mld_process_v1
idev->mc_ifc_count can be overwritten without proper locking in mld_process_v1.
This issue is similar to the one found in ipv6_mc_down / mld_ifc_work (CVE-2024-26631), where mld_ifc_stop_work() modifies shared state without holding idev->mc_lock.
mld_process_v1() invokes mld_gq_stop_work() and mld_ifc_stop_work() to cancel MLDv2 report work and interface change work. However, unlike other paths, it performs these calls without acquiring the mc_lock, leading to potential data races if the work queue is running concurrently.
Fix this by wrapping the calls to mld_gq_stop_work() and mld_ifc_stop_work() with mutex_lock() and mutex_unlock() accordingly.
Signed-off-by Kery Qi <[email protected]>
--- net/ipv6/mcast.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/mcast.c +2 -0
@@ -1377,10 +1377,12 @@ static int mld_process_v1(struct inet6_dev *idev, struct mld_msg *mld,if (v1_query)mld_set_v1_mode (idev); +mutex_lock (&idev->mc_lock);/* cancel MLDv2 report work */ mld_gq_stop_work (idev);/* cancel the interface change work */ mld_ifc_stop_work (idev); +mutex_unlock (&idev->mc_lock);/* clear deleted report items */ mld_clear_delrec (idev);
Signature · 1 line
2.34.1