mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kery Qi <qikeyu2017@gmail.com>
To: davem@davemloft.net
Cc: linux-kernel@vger.kernel.org, Kery Qi <qikeyu2017@gmail.com>
Subject: [PATCH] ipv6: mcast: fix data race in mld_process_v1
Date: Sun,  4 Jan 2026 22:41:24 +0800	[thread overview]
Message-ID: <20260104144125.1190-1-qikeyu2017@gmail.com> (raw)

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 <qikeyu2017@gmail.com>
---
 net/ipv6/mcast.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 016b572e7d6f..6708eb693f9d 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -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);
 
-- 
2.34.1


                 reply	other threads:[~2026-01-04 14:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260104144125.1190-1-qikeyu2017@gmail.com \
    --to=qikeyu2017@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®