Skip to content

Commit b0ee9bd

Browse files
dcarattigregkh
authored andcommitted
net/sched: cls_api: add missing validation of netlink attributes
[ Upstream commit e331473 ] Similarly to what has been done in 8b4c3cd ("net: sched: Add policy validation for tc attributes"), fix classifier code to add validation of TCA_CHAIN and TCA_KIND netlink attributes. tested with: # ./tdc.py -c filter v2: Let sch_api and cls_api share nla_policy they have in common, thanks to David Ahern. v3: Avoid EXPORT_SYMBOL(), as validation of those attributes is not done by TC modules, thanks to Cong Wang. While at it, restore the 'Delete / get qdisc' comment to its orginal position, just above tc_get_qdisc() function prototype. Fixes: 5bc1701 ("net: sched: introduce multichain support for filters") Signed-off-by: Davide Caratti <dcaratti@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c8c2df1 commit b0ee9bd

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

net/sched/cls_api.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include <net/pkt_sched.h>
3232
#include <net/pkt_cls.h>
3333

34+
extern const struct nla_policy rtm_tca_policy[TCA_MAX + 1];
35+
3436
/* The list of all installed classifier types */
3537
static LIST_HEAD(tcf_proto_base);
3638

@@ -559,7 +561,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
559561
replay:
560562
tp_created = 0;
561563

562-
err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL, extack);
564+
err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, rtm_tca_policy, extack);
563565
if (err < 0)
564566
return err;
565567

@@ -836,7 +838,8 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
836838
if (nlmsg_len(cb->nlh) < sizeof(*tcm))
837839
return skb->len;
838840

839-
err = nlmsg_parse(cb->nlh, sizeof(*tcm), tca, TCA_MAX, NULL, NULL);
841+
err = nlmsg_parse(cb->nlh, sizeof(*tcm), tca, TCA_MAX, rtm_tca_policy,
842+
NULL);
840843
if (err)
841844
return err;
842845

0 commit comments

Comments
 (0)