Skip to content

Commit 7b6a70f

Browse files
lxindavem330
authored andcommitted
lwtunnel: be STRICT to validate the new LWTUNNEL_IP(6)_OPTS
LWTUNNEL_IP(6)_OPTS are the new items in ip(6)_tun_policy, which are parsed by nla_parse_nested_deprecated(). We should check it strictly by setting .strict_start_type = LWTUNNEL_IP(6)_OPTS. This patch also adds missing LWTUNNEL_IP6_OPTS in ip6_tun_policy. Fixes: 4ece477 ("lwtunnel: add options setting and dumping for geneve") Signed-off-by: Xin Long <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f3bed7f commit 7b6a70f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/ipv4/ip_tunnel_core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ void ip_tunnel_get_stats64(struct net_device *dev,
215215
EXPORT_SYMBOL_GPL(ip_tunnel_get_stats64);
216216

217217
static const struct nla_policy ip_tun_policy[LWTUNNEL_IP_MAX + 1] = {
218+
[LWTUNNEL_IP_UNSPEC] = { .strict_start_type = LWTUNNEL_IP_OPTS },
218219
[LWTUNNEL_IP_ID] = { .type = NLA_U64 },
219220
[LWTUNNEL_IP_DST] = { .type = NLA_U32 },
220221
[LWTUNNEL_IP_SRC] = { .type = NLA_U32 },
@@ -700,12 +701,14 @@ static const struct lwtunnel_encap_ops ip_tun_lwt_ops = {
700701
};
701702

702703
static const struct nla_policy ip6_tun_policy[LWTUNNEL_IP6_MAX + 1] = {
704+
[LWTUNNEL_IP6_UNSPEC] = { .strict_start_type = LWTUNNEL_IP6_OPTS },
703705
[LWTUNNEL_IP6_ID] = { .type = NLA_U64 },
704706
[LWTUNNEL_IP6_DST] = { .len = sizeof(struct in6_addr) },
705707
[LWTUNNEL_IP6_SRC] = { .len = sizeof(struct in6_addr) },
706708
[LWTUNNEL_IP6_HOPLIMIT] = { .type = NLA_U8 },
707709
[LWTUNNEL_IP6_TC] = { .type = NLA_U8 },
708710
[LWTUNNEL_IP6_FLAGS] = { .type = NLA_U16 },
711+
[LWTUNNEL_IP6_OPTS] = { .type = NLA_NESTED },
709712
};
710713

711714
static int ip6_tun_build_state(struct nlattr *attr,

0 commit comments

Comments
 (0)