Commit 4b793fec authored by Cong Wang's avatar Cong Wang Committed by Jakub Kicinski

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: 199ce850 ("net_sched: add policy validation for action attributes")
Reported-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Reviewed-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
parent 6f96c3c6
...@@ -832,8 +832,7 @@ static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb) ...@@ -832,8 +832,7 @@ static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb)
} }
static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = { static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = {
[TCA_ACT_KIND] = { .type = NLA_NUL_STRING, [TCA_ACT_KIND] = { .type = NLA_STRING },
.len = IFNAMSIZ - 1 },
[TCA_ACT_INDEX] = { .type = NLA_U32 }, [TCA_ACT_INDEX] = { .type = NLA_U32 },
[TCA_ACT_COOKIE] = { .type = NLA_BINARY, [TCA_ACT_COOKIE] = { .type = NLA_BINARY,
.len = TC_COOKIE_MAX_SIZE }, .len = TC_COOKIE_MAX_SIZE },
...@@ -865,8 +864,10 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, ...@@ -865,8 +864,10 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
NL_SET_ERR_MSG(extack, "TC action kind must be specified"); NL_SET_ERR_MSG(extack, "TC action kind must be specified");
goto err_out; goto err_out;
} }
nla_strlcpy(act_name, kind, IFNAMSIZ); if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ) {
NL_SET_ERR_MSG(extack, "TC action name too long");
goto err_out;
}
if (tb[TCA_ACT_COOKIE]) { if (tb[TCA_ACT_COOKIE]) {
cookie = nla_memdup_cookie(tb); cookie = nla_memdup_cookie(tb);
if (!cookie) { if (!cookie) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment