Commit 69ec932e authored by Liping Zhang's avatar Liping Zhang Committed by David S. Miller

openvswitch: fix potential out of bound access in parse_ct

Before the 'type' is validated, we shouldn't use it to fetch the
ovs_ct_attr_lens's minlen and maxlen, else, out of bound access
may happen.

Fixes: 7f8a436e ("openvswitch: Add conntrack action")
Signed-off-by: default avatarLiping Zhang <zlpnobody@gmail.com>
Acked-by: default avatarPravin B Shelar <pshelar@ovn.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9476d393
...@@ -1310,8 +1310,8 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info, ...@@ -1310,8 +1310,8 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
nla_for_each_nested(a, attr, rem) { nla_for_each_nested(a, attr, rem) {
int type = nla_type(a); int type = nla_type(a);
int maxlen = ovs_ct_attr_lens[type].maxlen; int maxlen;
int minlen = ovs_ct_attr_lens[type].minlen; int minlen;
if (type > OVS_CT_ATTR_MAX) { if (type > OVS_CT_ATTR_MAX) {
OVS_NLERR(log, OVS_NLERR(log,
...@@ -1319,6 +1319,9 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info, ...@@ -1319,6 +1319,9 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
type, OVS_CT_ATTR_MAX); type, OVS_CT_ATTR_MAX);
return -EINVAL; return -EINVAL;
} }
maxlen = ovs_ct_attr_lens[type].maxlen;
minlen = ovs_ct_attr_lens[type].minlen;
if (nla_len(a) < minlen || nla_len(a) > maxlen) { if (nla_len(a) < minlen || nla_len(a) > maxlen) {
OVS_NLERR(log, OVS_NLERR(log,
"Conntrack attr type has unexpected length (type=%d, length=%d, expected=%d)", "Conntrack attr type has unexpected length (type=%d, length=%d, expected=%d)",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment