netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: netdev@vger.kernel.org
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	"David S. Miller" <davem@davemloft.net>,
	Cong Wang <cwang@twopensource.com>
Subject: [Patch net-next] net_sched: hold tcf_lock in netdevice notifier
Date: Wed, 16 Jul 2014 14:25:31 -0700	[thread overview]
Message-ID: <1405545931-13832-2-git-send-email-xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <1405545931-13832-1-git-send-email-xiyou.wangcong@gmail.com>

From: Cong Wang <cwang@twopensource.com>

We modify mirred action (m->tcfm_dev) in netdev event, we need to
prevent on-going mirred actions from reading freed m->tcfm_dev.
So we need to acquire this spin lock.

Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <cwang@twopensource.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 net/sched/act_mirred.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 4f912c0..eb48306 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -218,10 +218,12 @@ static int mirred_device_event(struct notifier_block *unused,
 
 	if (event == NETDEV_UNREGISTER)
 		list_for_each_entry(m, &mirred_list, tcfm_list) {
+			spin_lock_bh(&m->tcf_lock);
 			if (m->tcfm_dev == dev) {
 				dev_put(dev);
 				m->tcfm_dev = NULL;
 			}
+			spin_unlock_bh(&m->tcf_lock);
 		}
 
 	return NOTIFY_DONE;
-- 
1.8.3.1

  reply	other threads:[~2014-07-16 21:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-16 21:25 [Patch net-next] net_sched: cancel nest attribute on failure in tcf_exts_dump() Cong Wang
2014-07-16 21:25 ` Cong Wang [this message]
2014-07-17 12:49   ` [Patch net-next] net_sched: hold tcf_lock in netdevice notifier Jamal Hadi Salim
2014-07-17 16:45     ` Cong Wang
2014-07-17 18:17       ` Eric Dumazet
2014-07-17 21:25         ` Cong Wang
2014-07-18  5:37           ` Eric Dumazet
2014-07-18  5:51             ` Cong Wang
2014-07-18  7:08               ` Eric Dumazet
2014-07-19 22:02                 ` Jamal Hadi Salim
2014-07-17 23:01   ` David Miller
2014-07-21  3:31   ` David Miller
2014-07-17  6:51 ` [Patch net-next] net_sched: cancel nest attribute on failure in tcf_exts_dump() David Miller
2014-07-17 12:39 ` Jamal Hadi Salim
2014-07-17 21:59 ` David Miller

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=1405545931-13832-2-git-send-email-xiyou.wangcong@gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=cwang@twopensource.com \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=netdev@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;
as well as URLs for NNTP newsgroup(s).