diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2019-10-07 16:26:29 -0400 |
---|---|---|
committer | Jakub Kicinski <jakub.kicinski@netronome.com> | 2019-10-08 19:29:35 -0400 |
commit | 4b793feccae3b06764268377a4030eb774ed924e (patch) | |
tree | 06e59399c389a2151fb56b0c937315e95393f51e /net | |
parent | 6f96c3c6904c26cea9ca2726d5d8a9b0b8205b3c (diff) |
net_sched: fix backward compatibility for TCA_ACT_KIND
For TCA_ACT_KIND, we have to keep the backward compatibility too,
and rely on nla_strlcpy() to check and terminate the string with
a NUL.
Note for TC actions, nla_strcmp() is already used to compare kind
strings, so we don't need to fix other places.
Fixes: 199ce850ce11 ("net_sched: add policy validation for action attributes")
Reported-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/sched/act_api.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 2558f00f6b3e..4e7429c6f864 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -832,8 +832,7 @@ static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb) | |||
832 | } | 832 | } |
833 | 833 | ||
834 | static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = { | 834 | static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = { |
835 | [TCA_ACT_KIND] = { .type = NLA_NUL_STRING, | 835 | [TCA_ACT_KIND] = { .type = NLA_STRING }, |
836 | .len = IFNAMSIZ - 1 }, | ||
837 | [TCA_ACT_INDEX] = { .type = NLA_U32 }, | 836 | [TCA_ACT_INDEX] = { .type = NLA_U32 }, |
838 | [TCA_ACT_COOKIE] = { .type = NLA_BINARY, | 837 | [TCA_ACT_COOKIE] = { .type = NLA_BINARY, |
839 | .len = TC_COOKIE_MAX_SIZE }, | 838 | .len = TC_COOKIE_MAX_SIZE }, |
@@ -865,8 +864,10 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, | |||
865 | NL_SET_ERR_MSG(extack, "TC action kind must be specified"); | 864 | NL_SET_ERR_MSG(extack, "TC action kind must be specified"); |
866 | goto err_out; | 865 | goto err_out; |
867 | } | 866 | } |
868 | nla_strlcpy(act_name, kind, IFNAMSIZ); | 867 | if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ) { |
869 | 868 | NL_SET_ERR_MSG(extack, "TC action name too long"); | |
869 | goto err_out; | ||
870 | } | ||
870 | if (tb[TCA_ACT_COOKIE]) { | 871 | if (tb[TCA_ACT_COOKIE]) { |
871 | cookie = nla_memdup_cookie(tb); | 872 | cookie = nla_memdup_cookie(tb); |
872 | if (!cookie) { | 873 | if (!cookie) { |