Re: [BUG] net_cls: Panic occured when net_cls subsystem use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2009-06-01 at 06:06 +0000, Jarek Poplawski wrote:

> 
> But how about that (of course extremely rude) case "tc filter replace"
> is run with a new prio?


Jarek, sir, handyman extraordinaire, handsome devil, and lover of
kittens I humbly opine that we need to handle that case. 
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, 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..

cheers,
jamal
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 0759f32..08d98e8 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;
@@ -314,8 +312,19 @@ 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)
_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/containers

[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux