Message ID | 20231228064358.3042747-1-linma@zju.edu.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-12466-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1838658dyb; Wed, 27 Dec 2023 22:44:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJuH2b1/am7XLdhyoSR9epEdnKAHEqzmWUeYV+ziL3weuQOeI9SOyVZn/leajHq8diKrmL X-Received: by 2002:a05:6512:1116:b0:50e:84a5:f793 with SMTP id l22-20020a056512111600b0050e84a5f793mr702117lfg.75.1703745889067; Wed, 27 Dec 2023 22:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703745889; cv=none; d=google.com; s=arc-20160816; b=C58Edn283JAAwpNdurM+T5NvU/Hk8KkH8vtEcy0jbGenmqQ4VE5jtN7tjgaO+H4Ffe +sWk6j6YzthD1KfmTQtDXiKmjujAxczA7u+YH7Q0i7+O5KJhqv+vXqFBxVyKd/V8hL1Z zCGG4iNbrDhFNhotseVUnYtuVbUDQ0YUhjkcZsaVPU16R2E037biUjz0HrHjfuGAfHPc khCsp5u80tInGNV0H3F34jEQkKcMHo3qus0SrqpeG1kOVVkbY5+n7noGZPz9mt7fuIXH pM84w8NOqDZ+AeCyV1TGLmCZlzNdJ9cuqI065UOFHtKP+8u0y0dd7vIQ1K199czXXJ52 RO6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=NMzIrQHaQTgDtnrvcXV9vDgOv3mWiwYr/I3HYbVm160=; fh=KYovjcnz99Uc/wxgCfEKehITcqlb+4FKQ/03gJzLrs4=; b=gP/ZseSaQSInU9ETbPK6uTcBuibL3ayIZoqIXy9sijV+/XiEEdPuzDCgWMv0/ZmZqU ED4bjYoyn487dWFGWSiHGiP6WtX7t4xMxpdePtkJs/uQG+LqEOqLpvKvw5JTsKZ4m3eT 4Lu0iAvOi+g3a28Z0FQZb3KCbf0rl5Q1ss23cFnuzWPCpAjrNujEaJxnJW2eiRSa76Ur R11yPZHQq7VaqzbGRbhNVuLmW/t2c94+ieO65qSFG4XDDtXwxwmxqpJ1KS38hYmJga1i hxvvOdaxdQNm2K6n3fnNIlt+7h2x4flqOR3DlxNGfjAbC6BD9yS6mp0YsCGOUmTe0aGk XAQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12466-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12466-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id pj17-20020a170906d79100b00a23414e0462si6924671ejb.678.2023.12.27.22.44.48 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 22:44:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12466-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12466-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12466-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A731D1F22603 for <ouuuleilei@gmail.com>; Thu, 28 Dec 2023 06:44:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 057B953BD; Thu, 28 Dec 2023 06:44:31 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [207.46.229.174]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF7962909; Thu, 28 Dec 2023 06:44:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zju.edu.cn Received: from localhost.localdomain (unknown [125.119.253.75]) by mail-app3 (Coremail) with SMTP id cC_KCgAXjo0vGY1ljQGVAQ--.6801S4; Thu, 28 Dec 2023 14:44:00 +0800 (CST) From: Lin Ma <linma@zju.edu.cn> To: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lin Ma <linma@zju.edu.cn> Subject: [PATCH net-next v2] net/sched: cls_api: complement tcf_tfilter_dump_policy Date: Thu, 28 Dec 2023 14:43:58 +0800 Message-Id: <20231228064358.3042747-1-linma@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cC_KCgAXjo0vGY1ljQGVAQ--.6801S4 X-Coremail-Antispam: 1UD129KBjvJXoW7CFW7Aw1fAr43CFyfXw4DCFg_yoW8GrykpF ZrW348Cr1DXry8Jws7G3Z7uF1agrZxZw47GrWvk34xZ3sxJrn3GFWftFWak3W2kF48Arsr tF15t3yUua1q9F7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkE14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4U JVW0owA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFyl IxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxV AFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j 6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUdHU DUUUUU= X-CM-SenderInfo: qtrwiiyqvtljo62m3hxhgxhubq/ Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786183057052507654 X-GMAIL-MSGID: 1786507049486827393 |
Series |
[net-next,v2] net/sched: cls_api: complement tcf_tfilter_dump_policy
|
|
Commit Message
Lin Ma
Dec. 28, 2023, 6:43 a.m. UTC
In function `tc_dump_tfilter`, the attributes array is parsed via
tcf_tfilter_dump_policy which only describes TCA_DUMP_FLAGS. However,
the NLA TCA_CHAIN is also accessed with `nla_get_u32`.
The access to TCA_CHAIN is introduced in commit 5bc1701881e3 ("net:
sched: introduce multichain support for filters") and no nla_policy is
provided for parsing at that point. Later on, tcf_tfilter_dump_policy is
introduced in commit f8ab1807a9c9 ("net: sched: introduce terse dump
flag") while still ignoring the fact that TCA_CHAIN needs a check. This
patch does that by complementing the policy to allow the access
discussed here can be safe as other cases just choose rtm_tca_policy as
the parsing policy.
Signed-off-by: Lin Ma <linma@zju.edu.cn>
---
V1 -> V2: send to net-next as told by Jamal <jhs@mojatatu.com>
net/sched/cls_api.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Thu, Dec 28, 2023 at 1:44 AM Lin Ma <linma@zju.edu.cn> wrote: > > In function `tc_dump_tfilter`, the attributes array is parsed via > tcf_tfilter_dump_policy which only describes TCA_DUMP_FLAGS. However, > the NLA TCA_CHAIN is also accessed with `nla_get_u32`. > > The access to TCA_CHAIN is introduced in commit 5bc1701881e3 ("net: > sched: introduce multichain support for filters") and no nla_policy is > provided for parsing at that point. Later on, tcf_tfilter_dump_policy is > introduced in commit f8ab1807a9c9 ("net: sched: introduce terse dump > flag") while still ignoring the fact that TCA_CHAIN needs a check. This > patch does that by complementing the policy to allow the access > discussed here can be safe as other cases just choose rtm_tca_policy as > the parsing policy. > > Signed-off-by: Lin Ma <linma@zju.edu.cn> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> cheers, jamal > --- > V1 -> V2: send to net-next as told by Jamal <jhs@mojatatu.com> > > net/sched/cls_api.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c > index 1976bd163986..2b5b8eca2ee3 100644 > --- a/net/sched/cls_api.c > +++ b/net/sched/cls_api.c > @@ -2732,6 +2732,7 @@ static bool tcf_chain_dump(struct tcf_chain *chain, struct Qdisc *q, u32 parent, > } > > static const struct nla_policy tcf_tfilter_dump_policy[TCA_MAX + 1] = { > + [TCA_CHAIN] = { .type = NLA_U32 }, > [TCA_DUMP_FLAGS] = NLA_POLICY_BITFIELD32(TCA_DUMP_FLAGS_TERSE), > }; > > -- > 2.17.1 >
On Thu, Dec 28, 2023 at 02:43:58PM +0800, Lin Ma wrote: > In function `tc_dump_tfilter`, the attributes array is parsed via > tcf_tfilter_dump_policy which only describes TCA_DUMP_FLAGS. However, > the NLA TCA_CHAIN is also accessed with `nla_get_u32`. > > The access to TCA_CHAIN is introduced in commit 5bc1701881e3 ("net: > sched: introduce multichain support for filters") and no nla_policy is > provided for parsing at that point. Later on, tcf_tfilter_dump_policy is > introduced in commit f8ab1807a9c9 ("net: sched: introduce terse dump > flag") while still ignoring the fact that TCA_CHAIN needs a check. This > patch does that by complementing the policy to allow the access > discussed here can be safe as other cases just choose rtm_tca_policy as > the parsing policy. > This patch looks good but you could use NLA_POLICY_MAX() to validate TCA_CHAIN while you are on it. Thanks.
Hello: This patch was applied to netdev/net-next.git (main) by David S. Miller <davem@davemloft.net>: On Thu, 28 Dec 2023 14:43:58 +0800 you wrote: > In function `tc_dump_tfilter`, the attributes array is parsed via > tcf_tfilter_dump_policy which only describes TCA_DUMP_FLAGS. However, > the NLA TCA_CHAIN is also accessed with `nla_get_u32`. > > The access to TCA_CHAIN is introduced in commit 5bc1701881e3 ("net: > sched: introduce multichain support for filters") and no nla_policy is > provided for parsing at that point. Later on, tcf_tfilter_dump_policy is > introduced in commit f8ab1807a9c9 ("net: sched: introduce terse dump > flag") while still ignoring the fact that TCA_CHAIN needs a check. This > patch does that by complementing the policy to allow the access > discussed here can be safe as other cases just choose rtm_tca_policy as > the parsing policy. > > [...] Here is the summary with links: - [net-next,v2] net/sched: cls_api: complement tcf_tfilter_dump_policy https://git.kernel.org/netdev/net-next/c/2ab1efad60ad You are awesome, thank you!
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 1976bd163986..2b5b8eca2ee3 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -2732,6 +2732,7 @@ static bool tcf_chain_dump(struct tcf_chain *chain, struct Qdisc *q, u32 parent, } static const struct nla_policy tcf_tfilter_dump_policy[TCA_MAX + 1] = { + [TCA_CHAIN] = { .type = NLA_U32 }, [TCA_DUMP_FLAGS] = NLA_POLICY_BITFIELD32(TCA_DUMP_FLAGS_TERSE), };