lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210213175148.28375-1-ap420073@gmail.com>
Date:   Sat, 13 Feb 2021 17:51:48 +0000
From:   Taehee Yoo <ap420073@...il.com>
To:     davem@...emloft.net, kuba@...nel.org, xiyou.wangcong@...il.com,
        netdev@...r.kernel.org, jwi@...ux.ibm.com, kgraul@...ux.ibm.com,
        hca@...ux.ibm.com, gor@...ux.ibm.com, borntraeger@...ibm.com,
        mareklindner@...mailbox.ch, sw@...onwunderlich.de, a@...table.cc,
        sven@...fation.org, yoshfuji@...ux-ipv6.org, dsahern@...nel.org
Cc:     Taehee Yoo <ap420073@...il.com>
Subject: [PATCH net-next v2 3/7] mld: add a new delayed_work, mc_delrec_work

The goal of mc_delrec_work delayed work is to call mld_clear_delrec().
The mld_clear_delrec() is called under both data path and control path.
So, the context of mld_clear_delrec() can be atomic.
But this function accesses struct ifmcaddr6 and struct ip6_sf_list.
These structures are going to be protected by RTNL.
So, this function should be called in a sleepable context.

Suggested-by: Cong Wang <xiyou.wangcong@...il.com>
Signed-off-by: Taehee Yoo <ap420073@...il.com>
---
v1 -> v2:
 - Separated from previous big one patch.

 include/net/if_inet6.h |  1 +
 net/ipv6/mcast.c       | 32 +++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
index bec372283ac0..5946b5d76f7b 100644
--- a/include/net/if_inet6.h
+++ b/include/net/if_inet6.h
@@ -182,6 +182,7 @@ struct inet6_dev {
 	struct delayed_work	mc_gq_work;	/* general query work */
 	struct delayed_work	mc_ifc_work;	/* interface change work */
 	struct delayed_work	mc_dad_work;	/* dad complete mc work */
+	struct delayed_work     mc_delrec_work; /* delete records work */
 
 	struct ifacaddr6	*ac_list;
 	rwlock_t		lock;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 1f7fd3fbb4b6..ca8ca6faca4e 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1067,6 +1067,22 @@ static void mld_dad_stop_work(struct inet6_dev *idev)
 		__in6_dev_put(idev);
 }
 
+static void mld_clear_delrec_start_work(struct inet6_dev *idev)
+{
+	write_lock_bh(&idev->lock);
+	if (!mod_delayed_work(mld_wq, &idev->mc_delrec_work, 0))
+		in6_dev_hold(idev);
+	write_unlock_bh(&idev->lock);
+}
+
+static void mld_clear_delrec_stop_work(struct inet6_dev *idev)
+{
+	write_lock_bh(&idev->lock);
+	if (cancel_delayed_work(&idev->mc_delrec_work))
+		__in6_dev_put(idev);
+	write_unlock_bh(&idev->lock);
+}
+
 /*
  *	IGMP handling (alias multicast ICMPv6 messages)
  */
@@ -1304,7 +1320,7 @@ static int mld_process_v1(struct inet6_dev *idev, struct mld_msg *mld,
 	/* cancel the interface change work */
 	mld_ifc_stop_work(idev);
 	/* clear deleted report items */
-	mld_clear_delrec(idev);
+	mld_clear_delrec_start_work(idev);
 
 	return 0;
 }
@@ -2120,6 +2136,18 @@ static void mld_dad_work(struct work_struct *work)
 	in6_dev_put(idev);
 }
 
+static void mld_clear_delrec_work(struct work_struct *work)
+{
+	struct inet6_dev *idev = container_of(to_delayed_work(work),
+			struct inet6_dev,
+			mc_delrec_work);
+
+	rtnl_lock();
+	mld_clear_delrec(idev);
+	rtnl_unlock();
+	in6_dev_put(idev);
+}
+
 static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode,
 	const struct in6_addr *psfsrc)
 {
@@ -2553,6 +2581,7 @@ void ipv6_mc_down(struct inet6_dev *idev)
 	mld_gq_stop_work(idev);
 	mld_dad_stop_work(idev);
 	read_unlock_bh(&idev->lock);
+	mld_clear_delrec_stop_work(idev);
 }
 
 static void ipv6_mc_reset(struct inet6_dev *idev)
@@ -2593,6 +2622,7 @@ void ipv6_mc_init_dev(struct inet6_dev *idev)
 	idev->mc_ifc_count = 0;
 	INIT_DELAYED_WORK(&idev->mc_ifc_work, mld_ifc_work);
 	INIT_DELAYED_WORK(&idev->mc_dad_work, mld_dad_work);
+	INIT_DELAYED_WORK(&idev->mc_delrec_work, mld_clear_delrec_work);
 	ipv6_mc_reset(idev);
 	write_unlock_bh(&idev->lock);
 }
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ