* [PATCH net] net: sched: cls_flower: validate nested enc_opts_policy to avoid build warning
@ 2018-11-09 22:41 Jakub Kicinski
2018-11-10 4:40 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2018-11-09 22:41 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. 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.
Fixes: 0a6e77784f49 ("net/sched: allow flower to match tunnel options")
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] net: sched: cls_flower: validate nested enc_opts_policy to avoid build warning
2018-11-09 22:41 [PATCH net] net: sched: cls_flower: validate nested enc_opts_policy to avoid build warning Jakub Kicinski
@ 2018-11-10 4:40 ` David Miller
2018-11-10 4:58 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2018-11-10 4:40 UTC (permalink / raw)
To: jakub.kicinski; +Cc: oss-drivers, netdev
From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Fri, 9 Nov 2018 14:41:22 -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. 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.
>
> Fixes: 0a6e77784f49 ("net/sched: allow flower to match tunnel options")
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Acked-by: Simon Horman <simon.horman@netronome.com>
If this fixes a build warning, please include the build warning
message in your commit log.
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] net: sched: cls_flower: validate nested enc_opts_policy to avoid build warning
2018-11-10 4:40 ` David Miller
@ 2018-11-10 4:58 ` Jakub Kicinski
0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2018-11-10 4:58 UTC (permalink / raw)
To: David Miller; +Cc: oss-drivers, netdev
On Fri, 09 Nov 2018 20:40:25 -0800 (PST), David Miller wrote:
> From: Jakub Kicinski <jakub.kicinski@netronome.com>
> Date: Fri, 9 Nov 2018 14:41:22 -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. 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.
> >
> > Fixes: 0a6e77784f49 ("net/sched: allow flower to match tunnel options")
> > Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> > Acked-by: Simon Horman <simon.horman@netronome.com>
>
> If this fixes a build warning, please include the build warning
> message in your commit log.
>
> Thanks!
Ah, sorry, it's a W=1 warning, which should have been mentioned, too.
I'll repost shortly!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-10 15:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-09 22:41 [PATCH net] net: sched: cls_flower: validate nested enc_opts_policy to avoid build warning Jakub Kicinski
2018-11-10 4:40 ` David Miller
2018-11-10 4:58 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox