From: Marcelo Ricardo Leitner <mleitner@redhat.com>
To: wenxu@ucloud.cn
Cc: jhs@mojatatu.com, kuba@kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net v4] net/sched: cls_flower: Reject invalid ct_state flags rules
Date: Mon, 8 Feb 2021 15:57:05 -0300 [thread overview]
Message-ID: <20210208185705.GE2953@horizon.localdomain> (raw)
In-Reply-To: <1612674803-7912-1-git-send-email-wenxu@ucloud.cn>
On Sun, Feb 07, 2021 at 01:13:23PM +0800, wenxu@ucloud.cn wrote:
> --- a/net/sched/cls_flower.c
> +++ b/net/sched/cls_flower.c
> @@ -30,6 +30,11 @@
>
> #include <uapi/linux/netfilter/nf_conntrack_common.h>
>
> +#define TCA_FLOWER_KEY_CT_FLAGS_MASK (TCA_FLOWER_KEY_CT_FLAGS_NEW | \
> + TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED | \
> + TCA_FLOWER_KEY_CT_FLAGS_RELATED | \
> + TCA_FLOWER_KEY_CT_FLAGS_TRACKED)
> +
I know Jakub had said the calculations for _MASK were complicated, but
seeing this, they seem worth, otherwise we have to manually maintain
this duplicated list of entries here.
Maybe add just the __TCA_FLOWER_KEY_CT_FLAGS_MAX to the enum, and do
the calcs here? (to avoid having them in uapi)
> struct fl_flow_key {
> struct flow_dissector_key_meta meta;
> struct flow_dissector_key_control control;
> @@ -687,7 +692,8 @@ static void *fl_get(struct tcf_proto *tp, u32 handle)
> [TCA_FLOWER_KEY_ENC_OPTS] = { .type = NLA_NESTED },
> [TCA_FLOWER_KEY_ENC_OPTS_MASK] = { .type = NLA_NESTED },
> [TCA_FLOWER_KEY_CT_STATE] = { .type = NLA_U16 },
I wonder if this one should be protected by the flags mask as well.
It won't take action on unknown bits because of the mask below, but
still, it is accepting data that it doesn't know its meaning.
> - [TCA_FLOWER_KEY_CT_STATE_MASK] = { .type = NLA_U16 },
> + [TCA_FLOWER_KEY_CT_STATE_MASK] =
> + NLA_POLICY_MASK(NLA_U16, TCA_FLOWER_KEY_CT_FLAGS_MASK),
> [TCA_FLOWER_KEY_CT_ZONE] = { .type = NLA_U16 },
> [TCA_FLOWER_KEY_CT_ZONE_MASK] = { .type = NLA_U16 },
> [TCA_FLOWER_KEY_CT_MARK] = { .type = NLA_U32 },
next prev parent reply other threads:[~2021-02-08 19:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-07 5:13 [PATCH net v4] net/sched: cls_flower: Reject invalid ct_state flags rules wenxu
2021-02-08 18:41 ` Cong Wang
2021-02-08 18:47 ` Jakub Kicinski
2021-02-08 19:03 ` Marcelo Ricardo Leitner
2021-02-09 5:36 ` Cong Wang
2021-02-08 18:57 ` Marcelo Ricardo Leitner [this message]
2021-02-08 19:21 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210208185705.GE2953@horizon.localdomain \
--to=mleitner@redhat.com \
--cc=jhs@mojatatu.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=wenxu@ucloud.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox