All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@gmail.com>
To: jamal <hadi@cyberus.ca>
Cc: Minoru Usui <usui@mxm.nes.nec.co.jp>,
	netdev@vger.kernel.org, containers@lists.linux-foundation.org
Subject: Re: [BUG] net_cls: Panic occured when net_cls subsystem use
Date: Mon, 1 Jun 2009 22:49:58 +0200	[thread overview]
Message-ID: <20090601204957.GA2760@ami.dom.local> (raw)
In-Reply-To: <1243861410.3966.268.camel@dogo.mojatatu.com>

On Mon, Jun 01, 2009 at 09:03:30AM -0400, jamal wrote:
...
> How about going back to your original idea of defining tp_created? With
> apologies to Minoru (he must be thinking we are lunatics by now), how
> does the attached changed patch look to you?
> 
> Before you throw another rock,

Actually, I'd insist with the old rock and handling that other rude
u32 case, at least until it's fixed in place. So I attach my version
of your patch (additionally I removed a pair of braces because of
checkpatch warning).

Alas, I still think we don't need to change so much in -stable to
fix the cls_cgroup oops, so I attach a patch which I think is
enough for -stable and probably -net too. It could be "reverted"
in -net-next just after applying cls_api patch. Of course, treat
it only as my humble proposal, and feel free to recommend to David
your version, no problem (really).

> there is another issue which will be
> caused by this rude misconfig:
> "replace" really means "get rid of the old and add this new one".
> But for the last 50 years we do not "get rid of the old". I cant think
> of a clean way to do it sans shaving one of the kittens. One simple
> thing to do is to printk a warning when detecting this error. I think
> one needs to draw a line where bad config affects your life - in this
> case i dont think it is worth big changes..

Of course I'm against any printk on shaving the kitten...

Cheers,
Jarek P.
-----------------------> patch #1

 net/sched/cls_api.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 0759f32..09cdcdf 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -135,6 +135,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 	unsigned long cl;
 	unsigned long fh;
 	int err;
+	int tp_created = 0;
 
 	if (net != &init_net)
 		return -EINVAL;
@@ -266,10 +267,7 @@ replay:
 			goto errout;
 		}
 
-		spin_lock_bh(root_lock);
-		tp->next = *back;
-		*back = tp;
-		spin_unlock_bh(root_lock);
+		tp_created = 1;
 
 	} else if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], tp->ops->kind))
 		goto errout;
@@ -296,8 +294,11 @@ replay:
 		switch (n->nlmsg_type) {
 		case RTM_NEWTFILTER:
 			err = -EEXIST;
-			if (n->nlmsg_flags & NLM_F_EXCL)
+			if (n->nlmsg_flags & NLM_F_EXCL) {
+				if (tp_created)
+					tcf_destroy(tp);
 				goto errout;
+			}
 			break;
 		case RTM_DELTFILTER:
 			err = tp->ops->delete(tp, fh);
@@ -314,8 +315,18 @@ replay:
 	}
 
 	err = tp->ops->change(tp, cl, t->tcm_handle, tca, &fh);
-	if (err == 0)
+	if (err == 0) {
+		if (tp_created) {
+			spin_lock_bh(root_lock);
+			tp->next = *back;
+			*back = tp;
+			spin_unlock_bh(root_lock);
+		}
 		tfilter_notify(skb, n, tp, fh, RTM_NEWTFILTER);
+	} else {
+		if (tp_created)
+			tcf_destroy(tp);
+	}
 
 errout:
 	if (cl)

--------------------------> patch #2

 net/sched/cls_cgroup.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
index 1ab4542..3b2026f 100644
--- a/net/sched/cls_cgroup.c
+++ b/net/sched/cls_cgroup.c
@@ -101,6 +101,8 @@ static int cls_cgroup_classify(struct sk_buff *skb, struct tcf_proto *tp,
 	struct cgroup_cls_state *cs;
 	int ret = 0;
 
+	if (!head)
+		return -1;
 	/*
 	 * Due to the nature of the classifier it is required to ignore all
 	 * packets originating from softirq context as accessing `current'

  parent reply	other threads:[~2009-06-01 20:50 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-21  0:22 [BUG] net_cls: Panic occured when net_cls subsystem use Minoru Usui
2009-05-29  5:18 ` Minoru Usui
2009-05-29  7:48   ` Jarek Poplawski
2009-05-29  8:03     ` Jarek Poplawski
     [not found]       ` <20090529080330.GB5483-8HppEYmqbBCE+EvaaNYduQ@public.gmane.org>
2009-05-29 10:22         ` Jarek Poplawski
2009-05-29 10:22       ` Jarek Poplawski
     [not found]         ` <20090529102232.GA6279-8HppEYmqbBCE+EvaaNYduQ@public.gmane.org>
2009-05-29 13:15           ` jamal
     [not found]     ` <20090529074812.GA5483-8HppEYmqbBCE+EvaaNYduQ@public.gmane.org>
2009-05-29  8:03       ` Jarek Poplawski
2009-05-29 13:46   ` jamal
2009-05-29 13:54     ` jamal
     [not found]       ` <1243605269.3966.28.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-29 22:59         ` Jarek Poplawski
2009-05-29 22:59       ` Jarek Poplawski
     [not found]         ` <20090529225929.GD2753-dUp/P3zyUuaNj9Bq2fkWzw@public.gmane.org>
2009-05-30 11:17           ` Minoru Usui
2009-05-30 11:45             ` Jarek Poplawski
     [not found]               ` <20090530114506.GA3166-dUp/P3zyUuaNj9Bq2fkWzw@public.gmane.org>
2009-05-30 11:56                 ` jamal
2009-05-30 11:56               ` jamal
     [not found]                 ` <1243684594.3966.89.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-30 12:07                   ` Jarek Poplawski
     [not found]                     ` <20090530120750.GB3166-dUp/P3zyUuaNj9Bq2fkWzw@public.gmane.org>
2009-05-30 12:31                       ` jamal
2009-05-30 12:45                         ` Jarek Poplawski
2009-05-30 13:03                           ` jamal
2009-05-30 13:20                             ` Jarek Poplawski
2009-05-30 13:31                               ` jamal
2009-05-30 14:00                                 ` Jarek Poplawski
     [not found]                                   ` <20090530140006.GE3166-dUp/P3zyUuaNj9Bq2fkWzw@public.gmane.org>
2009-05-30 22:38                                     ` Minoru Usui
     [not found]                                       ` <b10243b50905301538o2716855ag21fbc95b37c8da22-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-05-30 23:34                                         ` jamal
2009-05-31  8:15                                         ` Jarek Poplawski
2009-05-30 23:34                                       ` jamal
2009-05-31  1:45                                         ` Minoru Usui
     [not found]                                         ` <1243726492.3966.178.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-31  1:45                                           ` Minoru Usui
2009-05-31  8:15                                       ` Jarek Poplawski
2009-05-30 23:08                                     ` jamal
2009-05-30 23:08                                   ` jamal
     [not found]                                     ` <1243724933.3966.158.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-31  7:55                                       ` Jarek Poplawski
     [not found]                                         ` <20090531075528.GA2756-dUp/P3zyUuaNj9Bq2fkWzw@public.gmane.org>
2009-05-31 13:17                                           ` jamal
2009-05-31 13:17                                         ` jamal
2009-05-31 20:33                                           ` Jarek Poplawski
     [not found]                                           ` <1243775830.3966.231.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-31 20:33                                             ` Jarek Poplawski
     [not found]                                 ` <1243690297.3966.135.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-30 14:00                                   ` Jarek Poplawski
     [not found]                               ` <20090530132047.GD3166-dUp/P3zyUuaNj9Bq2fkWzw@public.gmane.org>
2009-05-30 13:31                                 ` jamal
2009-05-30 22:22                             ` Minoru Usui
     [not found]                               ` <b10243b50905301522t42aafaffxbf5934388af3df93-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-05-30 23:13                                 ` jamal
2009-05-30 23:13                               ` jamal
     [not found]                                 ` <1243725194.3966.162.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-31  8:07                                   ` Jarek Poplawski
2009-05-31  8:07                                 ` Jarek Poplawski
     [not found]                             ` <1243688628.3966.126.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-30 13:20                               ` Jarek Poplawski
2009-05-30 22:22                               ` Minoru Usui
     [not found]                           ` <20090530124554.GC3166-dUp/P3zyUuaNj9Bq2fkWzw@public.gmane.org>
2009-05-30 13:03                             ` jamal
     [not found]                         ` <1243686683.3966.117.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-30 12:45                           ` Jarek Poplawski
     [not found]             ` <b10243b50905300417v3e208ad8s78936f106175e51-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-05-30 11:45               ` Jarek Poplawski
2009-05-30 11:50           ` jamal
     [not found]             ` <1243684218.3966.83.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-31  8:12               ` Jarek Poplawski
2009-05-31  8:12             ` Jarek Poplawski
2009-05-31 13:24               ` jamal
     [not found]                 ` <1243776293.3966.241.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-31 13:43                   ` jamal
2009-05-31 19:55                   ` Jarek Poplawski
2009-05-31 13:43                 ` jamal
     [not found]                   ` <1243777427.3966.243.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-31 21:12                     ` Jarek Poplawski
2009-05-31 19:55                 ` Jarek Poplawski
     [not found]                   ` <20090531195557.GA2777-dUp/P3zyUuaNj9Bq2fkWzw@public.gmane.org>
2009-05-31 23:40                     ` jamal
     [not found]                       ` <1243813216.3966.254.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-06-01  6:06                         ` Jarek Poplawski
2009-06-01  6:06                       ` Jarek Poplawski
     [not found]                         ` <20090601060638.GA4256-8HppEYmqbBCE+EvaaNYduQ@public.gmane.org>
2009-06-01 13:03                           ` jamal
2009-06-01 13:03                         ` jamal
     [not found]                           ` <1243861410.3966.268.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-06-01 13:34                             ` Minoru Usui
2009-06-01 20:49                             ` Jarek Poplawski
2009-06-01 13:34                           ` Minoru Usui
2009-06-01 20:49                           ` Jarek Poplawski [this message]
2009-06-01 21:55                             ` Jarek Poplawski
2009-06-01 22:06                             ` jamal
2009-06-02  6:59                               ` Minoru Usui
2009-06-02  7:24                                 ` Jarek Poplawski
2009-06-02  8:29                                   ` Minoru Usui
     [not found]                                   ` <20090602072436.GB4239-8HppEYmqbBCE+EvaaNYduQ@public.gmane.org>
2009-06-02  8:29                                     ` Minoru Usui
     [not found]                                 ` <20090602155919.da89c08e.usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil@public.gmane.org>
2009-06-02  7:24                                   ` Jarek Poplawski
2009-06-02 13:19                                   ` jamal
     [not found]                                     ` <1243948765.3966.397.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-06-04  4:41                                       ` Minoru Usui
2009-06-04  4:41                                     ` Minoru Usui
     [not found]                                       ` <20090604134133.dde9ddc6.usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil@public.gmane.org>
2009-06-04  6:34                                         ` Jarek Poplawski
2009-06-04  6:34                                       ` Jarek Poplawski
     [not found]                                         ` <20090604063445.GA2683-8HppEYmqbBCE+EvaaNYduQ@public.gmane.org>
2009-06-04  8:37                                           ` Jarek Poplawski
2009-06-04  8:37                                         ` Jarek Poplawski
     [not found]                               ` <1243893963.3966.325.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-06-02  6:26                                 ` Jarek Poplawski
2009-06-02 13:16                                   ` jamal
2009-06-02 21:10                                     ` Jarek Poplawski
2009-06-03 11:27                                       ` Jarek Poplawski
2009-06-10 11:58                                         ` jamal
     [not found]                                         ` <20090603112746.GA7000-8HppEYmqbBCE+EvaaNYduQ@public.gmane.org>
2009-06-10 11:58                                           ` jamal
     [not found]                                       ` <20090602211031.GA2850-dUp/P3zyUuaNj9Bq2fkWzw@public.gmane.org>
2009-06-03 11:27                                         ` Jarek Poplawski
     [not found]                                     ` <1243948587.3966.393.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-06-02 21:10                                       ` Jarek Poplawski
     [not found]                                   ` <20090602062623.GA4239-8HppEYmqbBCE+EvaaNYduQ@public.gmane.org>
2009-06-02 13:16                                     ` jamal
2009-06-02  6:59                                 ` Minoru Usui
     [not found]                             ` <20090601204957.GA2760-dUp/P3zyUuaNj9Bq2fkWzw@public.gmane.org>
2009-06-01 21:55                               ` Jarek Poplawski
2009-06-01 22:06                               ` jamal
     [not found]               ` <20090531081213.GC2756-dUp/P3zyUuaNj9Bq2fkWzw@public.gmane.org>
2009-05-31 13:24                 ` jamal
     [not found]     ` <1243604796.3966.21.camel-A00voryUPPswpNmlq7E/ZAC/G2K4zDHf@public.gmane.org>
2009-05-29 13:54       ` jamal
2009-06-01  5:25       ` Minoru Usui
2009-06-01  5:25     ` Minoru Usui
     [not found]   ` <20090529141830.8ba30a24.usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil@public.gmane.org>
2009-05-29  7:48     ` Jarek Poplawski
2009-05-29 13:46     ` jamal
     [not found] ` <20090521092256.d33717b9.usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil@public.gmane.org>
2009-05-29  5:18   ` Minoru Usui
2009-06-01  9:12   ` Minoru Usui
2009-06-01  9:12 ` Minoru Usui
2009-06-08  6:39   ` Minoru Usui
     [not found]     ` <20090608153951.dfa4b162.usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil@public.gmane.org>
2009-06-08  7:48       ` Jarek Poplawski
2009-06-08  7:48     ` Jarek Poplawski
2009-06-09  0:02       ` Minoru Usui
     [not found]       ` <20090608074814.GA4972-8HppEYmqbBCE+EvaaNYduQ@public.gmane.org>
2009-06-09  0:02         ` Minoru Usui
     [not found]   ` <20090601181201.ca1c2832.usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil@public.gmane.org>
2009-06-08  6:39     ` Minoru Usui
  -- strict thread matches above, loose matches on Subject: below --
2009-05-21  0:22 Minoru Usui

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=20090601204957.GA2760@ami.dom.local \
    --to=jarkao2@gmail.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=hadi@cyberus.ca \
    --cc=netdev@vger.kernel.org \
    --cc=usui@mxm.nes.nec.co.jp \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.