diff options
-rw-r--r-- | net/sched/em_meta.c | 9 | ||||
-rw-r--r-- | net/sched/ematch.c | 11 |
2 files changed, 12 insertions, 8 deletions
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index d9f487d813c4..a1e5619b1876 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c | |||
@@ -745,6 +745,10 @@ static inline int meta_is_supported(struct meta_value *val) | |||
745 | return (!meta_id(val) || meta_ops(val)->get); | 745 | return (!meta_id(val) || meta_ops(val)->get); |
746 | } | 746 | } |
747 | 747 | ||
748 | static const struct nla_policy meta_policy[TCA_EM_META_MAX + 1] = { | ||
749 | [TCA_EM_META_HDR] = { .len = sizeof(struct tcf_meta_hdr) }, | ||
750 | }; | ||
751 | |||
748 | static int em_meta_change(struct tcf_proto *tp, void *data, int len, | 752 | static int em_meta_change(struct tcf_proto *tp, void *data, int len, |
749 | struct tcf_ematch *m) | 753 | struct tcf_ematch *m) |
750 | { | 754 | { |
@@ -753,13 +757,12 @@ static int em_meta_change(struct tcf_proto *tp, void *data, int len, | |||
753 | struct tcf_meta_hdr *hdr; | 757 | struct tcf_meta_hdr *hdr; |
754 | struct meta_match *meta = NULL; | 758 | struct meta_match *meta = NULL; |
755 | 759 | ||
756 | err = nla_parse(tb, TCA_EM_META_MAX, data, len, NULL); | 760 | err = nla_parse(tb, TCA_EM_META_MAX, data, len, meta_policy); |
757 | if (err < 0) | 761 | if (err < 0) |
758 | goto errout; | 762 | goto errout; |
759 | 763 | ||
760 | err = -EINVAL; | 764 | err = -EINVAL; |
761 | if (tb[TCA_EM_META_HDR] == NULL || | 765 | if (tb[TCA_EM_META_HDR] == NULL) |
762 | nla_len(tb[TCA_EM_META_HDR]) < sizeof(*hdr)) | ||
763 | goto errout; | 766 | goto errout; |
764 | hdr = nla_data(tb[TCA_EM_META_HDR]); | 767 | hdr = nla_data(tb[TCA_EM_META_HDR]); |
765 | 768 | ||
diff --git a/net/sched/ematch.c b/net/sched/ematch.c index daa9c4e7e81d..74ff918455a2 100644 --- a/net/sched/ematch.c +++ b/net/sched/ematch.c | |||
@@ -282,6 +282,11 @@ errout: | |||
282 | return err; | 282 | return err; |
283 | } | 283 | } |
284 | 284 | ||
285 | static const struct nla_policy em_policy[TCA_EMATCH_TREE_MAX + 1] = { | ||
286 | [TCA_EMATCH_TREE_HDR] = { .len = sizeof(struct tcf_ematch_tree_hdr) }, | ||
287 | [TCA_EMATCH_TREE_LIST] = { .type = NLA_NESTED }, | ||
288 | }; | ||
289 | |||
285 | /** | 290 | /** |
286 | * tcf_em_tree_validate - validate ematch config TLV and build ematch tree | 291 | * tcf_em_tree_validate - validate ematch config TLV and build ematch tree |
287 | * | 292 | * |
@@ -312,7 +317,7 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla, | |||
312 | return 0; | 317 | return 0; |
313 | } | 318 | } |
314 | 319 | ||
315 | err = nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, NULL); | 320 | err = nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, em_policy); |
316 | if (err < 0) | 321 | if (err < 0) |
317 | goto errout; | 322 | goto errout; |
318 | 323 | ||
@@ -323,10 +328,6 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla, | |||
323 | if (rt_hdr == NULL || rt_list == NULL) | 328 | if (rt_hdr == NULL || rt_list == NULL) |
324 | goto errout; | 329 | goto errout; |
325 | 330 | ||
326 | if (nla_len(rt_hdr) < sizeof(*tree_hdr) || | ||
327 | nla_len(rt_list) < sizeof(*rt_match)) | ||
328 | goto errout; | ||
329 | |||
330 | tree_hdr = nla_data(rt_hdr); | 331 | tree_hdr = nla_data(rt_hdr); |
331 | memcpy(&tree->hdr, tree_hdr, sizeof(*tree_hdr)); | 332 | memcpy(&tree->hdr, tree_hdr, sizeof(*tree_hdr)); |
332 | 333 | ||