Skip to content

Commit 0e83a78

Browse files
Asbjørn Sloth Tønnesenkuba-moo
authored andcommitted
net/sched: cls_flower: add policy for TCA_FLOWER_KEY_FLAGS
This policy guards fl_set_key_flags() from seeing flags not used in the context of TCA_FLOWER_KEY_FLAGS. In order For the policy check to be performed with the correct endianness, then we also needs to change the attribute type to NLA_BE32 (Thanks Davide). TCA_FLOWER_KEY_FLAGS{,_MASK} already has a be32 comment in include/uapi/linux/pkt_cls.h. Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]> Tested-by: Davide Caratti <[email protected]> Reviewed-by: Davide Caratti <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fcb4bb0 commit 0e83a78

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

net/sched/cls_flower.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
#define TCA_FLOWER_KEY_CT_FLAGS_MASK \
4242
(TCA_FLOWER_KEY_CT_FLAGS_MAX - 1)
4343

44+
#define TCA_FLOWER_KEY_FLAGS_POLICY_MASK \
45+
(TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT | \
46+
TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST)
47+
4448
#define TUNNEL_FLAGS_PRESENT (\
4549
_BITUL(IP_TUNNEL_CSUM_BIT) | \
4650
_BITUL(IP_TUNNEL_DONT_FRAGMENT_BIT) | \
@@ -676,8 +680,10 @@ static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = {
676680
[TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK] = { .type = NLA_U16 },
677681
[TCA_FLOWER_KEY_ENC_UDP_DST_PORT] = { .type = NLA_U16 },
678682
[TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK] = { .type = NLA_U16 },
679-
[TCA_FLOWER_KEY_FLAGS] = { .type = NLA_U32 },
680-
[TCA_FLOWER_KEY_FLAGS_MASK] = { .type = NLA_U32 },
683+
[TCA_FLOWER_KEY_FLAGS] = NLA_POLICY_MASK(NLA_BE32,
684+
TCA_FLOWER_KEY_FLAGS_POLICY_MASK),
685+
[TCA_FLOWER_KEY_FLAGS_MASK] = NLA_POLICY_MASK(NLA_BE32,
686+
TCA_FLOWER_KEY_FLAGS_POLICY_MASK),
681687
[TCA_FLOWER_KEY_ICMPV4_TYPE] = { .type = NLA_U8 },
682688
[TCA_FLOWER_KEY_ICMPV4_TYPE_MASK] = { .type = NLA_U8 },
683689
[TCA_FLOWER_KEY_ICMPV4_CODE] = { .type = NLA_U8 },

0 commit comments

Comments
 (0)