* [PATCH net v2] net: sched: cls_flower: validate nested enc_opts_policy to avoid warning
@ 2018-11-10 5:06 Jakub Kicinski
2018-11-10 7:18 ` Jiri Pirko
2018-11-10 17:56 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2018-11-10 5:06 UTC (permalink / raw)
To: davem; +Cc: oss-drivers, netdev, Jakub Kicinski
TCA_FLOWER_KEY_ENC_OPTS and TCA_FLOWER_KEY_ENC_OPTS_MASK can only
currently contain further nested attributes, which are parsed by
hand, so the policy is never actually used resulting in a W=1
build warning:
net/sched/cls_flower.c:492:1: warning: ‘enc_opts_policy’ defined but not used [-Wunused-const-variable=]
enc_opts_policy[TCA_FLOWER_KEY_ENC_OPTS_MAX + 1] = {
Add the validation anyway to avoid potential bugs when other
attributes are added and to make the attribute structure slightly
more clear. Validation will also set extact to point to bad
attribute on error.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Simon Horman <simon.horman@netronome.com>
---
net/sched/cls_flower.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 9aada2d0ef06..c6c327874abc 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -709,11 +709,23 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key,
struct netlink_ext_ack *extack)
{
const struct nlattr *nla_enc_key, *nla_opt_key, *nla_opt_msk = NULL;
- int option_len, key_depth, msk_depth = 0;
+ int err, option_len, key_depth, msk_depth = 0;
+
+ err = nla_validate_nested(tb[TCA_FLOWER_KEY_ENC_OPTS],
+ TCA_FLOWER_KEY_ENC_OPTS_MAX,
+ enc_opts_policy, extack);
+ if (err)
+ return err;
nla_enc_key = nla_data(tb[TCA_FLOWER_KEY_ENC_OPTS]);
if (tb[TCA_FLOWER_KEY_ENC_OPTS_MASK]) {
+ err = nla_validate_nested(tb[TCA_FLOWER_KEY_ENC_OPTS_MASK],
+ TCA_FLOWER_KEY_ENC_OPTS_MAX,
+ enc_opts_policy, extack);
+ if (err)
+ return err;
+
nla_opt_msk = nla_data(tb[TCA_FLOWER_KEY_ENC_OPTS_MASK]);
msk_depth = nla_len(tb[TCA_FLOWER_KEY_ENC_OPTS_MASK]);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net v2] net: sched: cls_flower: validate nested enc_opts_policy to avoid warning
2018-11-10 5:06 [PATCH net v2] net: sched: cls_flower: validate nested enc_opts_policy to avoid warning Jakub Kicinski
@ 2018-11-10 7:18 ` Jiri Pirko
2018-11-10 17:56 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2018-11-10 7:18 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: davem, oss-drivers, netdev
Sat, Nov 10, 2018 at 06:06:26AM CET, jakub.kicinski@netronome.com wrote:
>TCA_FLOWER_KEY_ENC_OPTS and TCA_FLOWER_KEY_ENC_OPTS_MASK can only
>currently contain further nested attributes, which are parsed by
>hand, so the policy is never actually used resulting in a W=1
>build warning:
>
>net/sched/cls_flower.c:492:1: warning: ‘enc_opts_policy’ defined but not used [-Wunused-const-variable=]
> enc_opts_policy[TCA_FLOWER_KEY_ENC_OPTS_MAX + 1] = {
>
>Add the validation anyway to avoid potential bugs when other
>attributes are added and to make the attribute structure slightly
>more clear. Validation will also set extact to point to bad
>attribute on error.
>
>Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>Acked-by: Simon Horman <simon.horman@netronome.com>
Fixes: 0a6e77784f49 ("net/sched: allow flower to match tunnel options")
Acked-by: Jiri Pirko <jiri@mellanox.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net v2] net: sched: cls_flower: validate nested enc_opts_policy to avoid warning
2018-11-10 5:06 [PATCH net v2] net: sched: cls_flower: validate nested enc_opts_policy to avoid warning Jakub Kicinski
2018-11-10 7:18 ` Jiri Pirko
@ 2018-11-10 17:56 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-11-10 17:56 UTC (permalink / raw)
To: jakub.kicinski; +Cc: oss-drivers, netdev
From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Fri, 9 Nov 2018 21:06:26 -0800
> TCA_FLOWER_KEY_ENC_OPTS and TCA_FLOWER_KEY_ENC_OPTS_MASK can only
> currently contain further nested attributes, which are parsed by
> hand, so the policy is never actually used resulting in a W=1
> build warning:
>
> net/sched/cls_flower.c:492:1: warning: ‘enc_opts_policy’ defined but not used [-Wunused-const-variable=]
> enc_opts_policy[TCA_FLOWER_KEY_ENC_OPTS_MAX + 1] = {
>
> Add the validation anyway to avoid potential bugs when other
> attributes are added and to make the attribute structure slightly
> more clear. Validation will also set extact to point to bad
> attribute on error.
>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Acked-by: Simon Horman <simon.horman@netronome.com>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-11 3:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-10 5:06 [PATCH net v2] net: sched: cls_flower: validate nested enc_opts_policy to avoid warning Jakub Kicinski
2018-11-10 7:18 ` Jiri Pirko
2018-11-10 17:56 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox