From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jamal Hadi Salim Subject: [PATCH net-next 01/11] net: sched: cls_u32: disallow linking to root hnode Date: Sun, 7 Oct 2018 12:38:01 -0400 Message-ID: <20181007163811.18453-2-jhs@emojatatu.com> References: <20181007163811.18453-1-jhs@emojatatu.com> Cc: jiri@resnulli.us, xiyou.wangcong@gmail.com, viro@zeniv.linux.org.uk, netdev@vger.kernel.org, Jamal Hadi Salim To: davem@davemloft.net Return-path: Received: from mail-io1-f65.google.com ([209.85.166.65]:45788 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726803AbeJGXqQ (ORCPT ); Sun, 7 Oct 2018 19:46:16 -0400 Received: by mail-io1-f65.google.com with SMTP id e12-v6so14145124iok.12 for ; Sun, 07 Oct 2018 09:38:27 -0700 (PDT) In-Reply-To: <20181007163811.18453-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Al Viro Operation makes no sense. Nothing will actually break if we do so (depth limit in u32_classify() will prevent infinite loops), but according to maintainers it's best prohibited outright. NOTE: doing so guarantees that u32_destroy() will trigger the call of u32_destroy_hnode(); we might want to make that unconditional. Test: tc qdisc add dev eth0 ingress tc filter add dev eth0 parent ffff: protocol ip prio 100 u32 \ link 800: offset at 0 mask 0f00 shift 6 plus 0 eat match ip protocol 6 ff should fail with Error: cls_u32: Not linking to root node Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- net/sched/cls_u32.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 622f4657da94..3357331a80a2 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -797,6 +797,10 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp, NL_SET_ERR_MSG_MOD(extack, "Link hash table not found"); return -EINVAL; } + if (ht_down->is_root) { + NL_SET_ERR_MSG_MOD(extack, "Not linking to root node"); + return -EINVAL; + } ht_down->refcnt++; } -- 2.11.0