aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/cls_api.c
diff options
context:
space:
mode:
authorDavide Caratti <dcaratti@redhat.com>2018-10-10 16:00:58 -0400
committerDavid S. Miller <davem@davemloft.net>2018-10-16 00:48:44 -0400
commite331473fee3d500bb0d2582a1fe598df3326d8cd (patch)
tree5233db75fb1b9795b27e8cca5c5981a076f8427e /net/sched/cls_api.c
parent58f5bbe331c566f49c9559568f982202a278aa78 (diff)
net/sched: cls_api: add missing validation of netlink attributes
Similarly to what has been done in 8b4c3cdd9dd8 ("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: 5bc1701881e39 ("net: sched: introduce multichain support for filters") Signed-off-by: Davide Caratti <dcaratti@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/cls_api.c')
-rw-r--r--net/sched/cls_api.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 0a75cb2e5e7b..70f144ac5e1d 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -31,6 +31,8 @@
31#include <net/pkt_sched.h> 31#include <net/pkt_sched.h>
32#include <net/pkt_cls.h> 32#include <net/pkt_cls.h>
33 33
34extern const struct nla_policy rtm_tca_policy[TCA_MAX + 1];
35
34/* The list of all installed classifier types */ 36/* The list of all installed classifier types */
35static LIST_HEAD(tcf_proto_base); 37static LIST_HEAD(tcf_proto_base);
36 38
@@ -1211,7 +1213,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
1211replay: 1213replay:
1212 tp_created = 0; 1214 tp_created = 0;
1213 1215
1214 err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL, extack); 1216 err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, rtm_tca_policy, extack);
1215 if (err < 0) 1217 if (err < 0)
1216 return err; 1218 return err;
1217 1219
@@ -1360,7 +1362,7 @@ static int tc_del_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
1360 if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) 1362 if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
1361 return -EPERM; 1363 return -EPERM;
1362 1364
1363 err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL, extack); 1365 err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, rtm_tca_policy, extack);
1364 if (err < 0) 1366 if (err < 0)
1365 return err; 1367 return err;
1366 1368
@@ -1475,7 +1477,7 @@ static int tc_get_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
1475 void *fh = NULL; 1477 void *fh = NULL;
1476 int err; 1478 int err;
1477 1479
1478 err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL, extack); 1480 err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, rtm_tca_policy, extack);
1479 if (err < 0) 1481 if (err < 0)
1480 return err; 1482 return err;
1481 1483
@@ -1838,7 +1840,7 @@ static int tc_ctl_chain(struct sk_buff *skb, struct nlmsghdr *n,
1838 return -EPERM; 1840 return -EPERM;
1839 1841
1840replay: 1842replay:
1841 err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL, extack); 1843 err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, rtm_tca_policy, extack);
1842 if (err < 0) 1844 if (err < 0)
1843 return err; 1845 return err;
1844 1846
@@ -1949,7 +1951,8 @@ static int tc_dump_chain(struct sk_buff *skb, struct netlink_callback *cb)
1949 if (nlmsg_len(cb->nlh) < sizeof(*tcm)) 1951 if (nlmsg_len(cb->nlh) < sizeof(*tcm))
1950 return skb->len; 1952 return skb->len;
1951 1953
1952 err = nlmsg_parse(cb->nlh, sizeof(*tcm), tca, TCA_MAX, NULL, NULL); 1954 err = nlmsg_parse(cb->nlh, sizeof(*tcm), tca, TCA_MAX, rtm_tca_policy,
1955 NULL);
1953 if (err) 1956 if (err)
1954 return err; 1957 return err;
1955 1958