aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2014-09-30 19:07:23 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-01 22:00:42 -0400
commit6e0565697a106f2453b636da1ca481d9fe068bac (patch)
treeec253c4d09a7685fac35a6727cb92c9acc826a8f /net/sched
parent25e379c475121c658a344cfd5eeed9affe272d31 (diff)
net_sched: fix another crash in cls_tcindex
This patch fixes the following crash: [ 166.670795] BUG: unable to handle kernel NULL pointer dereference at (null) [ 166.674230] IP: [<ffffffff814b739f>] __list_del_entry+0x5c/0x98 [ 166.674230] PGD d0ea5067 PUD ce7fc067 PMD 0 [ 166.674230] Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC [ 166.674230] CPU: 1 PID: 775 Comm: tc Not tainted 3.17.0-rc6+ #642 [ 166.674230] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 166.674230] task: ffff8800d03c4d20 ti: ffff8800cae7c000 task.ti: ffff8800cae7c000 [ 166.674230] RIP: 0010:[<ffffffff814b739f>] [<ffffffff814b739f>] __list_del_entry+0x5c/0x98 [ 166.674230] RSP: 0018:ffff8800cae7f7d0 EFLAGS: 00010207 [ 166.674230] RAX: 0000000000000000 RBX: ffff8800cba8d700 RCX: ffff8800cba8d700 [ 166.674230] RDX: 0000000000000000 RSI: dead000000200200 RDI: ffff8800cba8d700 [ 166.674230] RBP: ffff8800cae7f7d0 R08: 0000000000000001 R09: 0000000000000001 [ 166.674230] R10: 0000000000000000 R11: 000000000000859a R12: ffffffffffffffe8 [ 166.674230] R13: ffff8800cba8c5b8 R14: 0000000000000001 R15: ffff8800cba8d700 [ 166.674230] FS: 00007fdb5f04a740(0000) GS:ffff88011a800000(0000) knlGS:0000000000000000 [ 166.674230] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 166.674230] CR2: 0000000000000000 CR3: 00000000cf929000 CR4: 00000000000006e0 [ 166.674230] Stack: [ 166.674230] ffff8800cae7f7e8 ffffffff814b73e8 ffff8800cba8d6e8 ffff8800cae7f828 [ 166.674230] ffffffff817caeec 0000000000000046 ffff8800cba8c5b0 ffff8800cba8c5b8 [ 166.674230] 0000000000000000 0000000000000001 ffff8800cf8e33e8 ffff8800cae7f848 [ 166.674230] Call Trace: [ 166.674230] [<ffffffff814b73e8>] list_del+0xd/0x2b [ 166.674230] [<ffffffff817caeec>] tcf_action_destroy+0x4c/0x71 [ 166.674230] [<ffffffff817ca0ce>] tcf_exts_destroy+0x20/0x2d [ 166.674230] [<ffffffff817ec2b5>] tcindex_delete+0x196/0x1b7 struct list_head can not be simply copied and we should always init it. Cc: John Fastabend <john.r.fastabend@intel.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: John Fastabend <john.r.fastabend@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/cls_tcindex.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index 8d0e83d6903e..30f10fb07f4a 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -254,10 +254,15 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
254 cp->tp = tp; 254 cp->tp = tp;
255 255
256 if (p->perfect) { 256 if (p->perfect) {
257 int i;
258
257 cp->perfect = kmemdup(p->perfect, 259 cp->perfect = kmemdup(p->perfect,
258 sizeof(*r) * cp->hash, GFP_KERNEL); 260 sizeof(*r) * cp->hash, GFP_KERNEL);
259 if (!cp->perfect) 261 if (!cp->perfect)
260 goto errout; 262 goto errout;
263 for (i = 0; i < cp->hash; i++)
264 tcf_exts_init(&cp->perfect[i].exts,
265 TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
261 balloc = 1; 266 balloc = 1;
262 } 267 }
263 cp->h = p->h; 268 cp->h = p->h;
@@ -353,6 +358,9 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
353 f = kzalloc(sizeof(*f), GFP_KERNEL); 358 f = kzalloc(sizeof(*f), GFP_KERNEL);
354 if (!f) 359 if (!f)
355 goto errout_alloc; 360 goto errout_alloc;
361 f->key = handle;
362 tcindex_filter_result_init(&f->result);
363 f->next = NULL;
356 } 364 }
357 365
358 if (tb[TCA_TCINDEX_CLASSID]) { 366 if (tb[TCA_TCINDEX_CLASSID]) {
@@ -376,9 +384,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
376 struct tcindex_filter *nfp; 384 struct tcindex_filter *nfp;
377 struct tcindex_filter __rcu **fp; 385 struct tcindex_filter __rcu **fp;
378 386
379 f->key = handle; 387 tcf_exts_change(tp, &f->result.exts, &r->exts);
380 f->result = new_filter_result;
381 f->next = NULL;
382 388
383 fp = cp->h + (handle % cp->hash); 389 fp = cp->h + (handle % cp->hash);
384 for (nfp = rtnl_dereference(*fp); 390 for (nfp = rtnl_dereference(*fp);