Skip to content

Commit 23f787c

Browse files
Liping Zhanggregkh
authored andcommitted
openvswitch: fix potential out of bound access in parse_ct
[ Upstream commit 69ec932e364b1ba9c3a2085fe96b76c8a3f71e7c ] 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: 7f8a436 ("openvswitch: Add conntrack action") Signed-off-by: Liping Zhang <zlpnobody@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6d1e34e commit 23f787c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

net/openvswitch/conntrack.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,15 +577,18 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
577577

578578
nla_for_each_nested(a, attr, rem) {
579579
int type = nla_type(a);
580-
int maxlen = ovs_ct_attr_lens[type].maxlen;
581-
int minlen = ovs_ct_attr_lens[type].minlen;
580+
int maxlen;
581+
int minlen;
582582

583583
if (type > OVS_CT_ATTR_MAX) {
584584
OVS_NLERR(log,
585585
"Unknown conntrack attr (type=%d, max=%d)",
586586
type, OVS_CT_ATTR_MAX);
587587
return -EINVAL;
588588
}
589+
590+
maxlen = ovs_ct_attr_lens[type].maxlen;
591+
minlen = ovs_ct_attr_lens[type].minlen;
589592
if (nla_len(a) < minlen || nla_len(a) > maxlen) {
590593
OVS_NLERR(log,
591594
"Conntrack attr type has unexpected length (type=%d, length=%d, expected=%d)",

0 commit comments

Comments
 (0)