From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH net] net/sched: cls_api: add missing validation of netlink attributes Date: Tue, 9 Oct 2018 11:45:34 -0600 Message-ID: <9ed4e6b0-9eb9-9fff-e5e4-a21e5815605d@gmail.com> References: <05f98d2d220d443c157fc797fecc22692eeaa0da.1539090183.git.dcaratti@redhat.com> <72e8eeea-a4e7-e80d-217d-7ccf4cd71e0d@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: Davide Caratti , "David S. Miller" , Jamal Hadi Salim Return-path: Received: from mail-pl1-f195.google.com ([209.85.214.195]:41234 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726418AbeJJBDo (ORCPT ); Tue, 9 Oct 2018 21:03:44 -0400 Received: by mail-pl1-f195.google.com with SMTP id q17-v6so1183150plr.8 for ; Tue, 09 Oct 2018 10:45:38 -0700 (PDT) In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 10/9/18 10:12 AM, Davide Caratti wrote: >>> --- a/net/sched/cls_api.c >>> +++ b/net/sched/cls_api.c >>> @@ -37,6 +37,11 @@ static LIST_HEAD(tcf_proto_base); >>> /* Protects list of registered TC modules. It is pure SMP lock. */ >>> static DEFINE_RWLOCK(cls_mod_lock); >>> >>> +const struct nla_policy cls_tca_policy[TCA_MAX + 1] = { >>> + [TCA_KIND] = { .type = NLA_STRING }, >>> + [TCA_CHAIN] = { .type = NLA_U32 }, >>> +}; >>> + >> > >> it be nice to have a tc_common module so this stuff does not have to be >> defined multiple times. > > it makes sense to avoid duplicating the declaration of that array. But I > don't think we can put it in a module, because CONFIG_NET_SCHED is 'bool' > and > > obj-$(CONFIG_NET_SCHED) += sch_api.o > > I can try a v2 where 'rtm_tca_policy' symbol in sch_api is exported and > used by cls_api.c code. WDYT? since NET_SCHED is a bool, that should work.