[PATCH net] openvswitch: fix potential out of bound access in parse_ct

Subsystems: networking [general], openvswitch, the rest

STALE3374d

3 messages, 3 authors, 2017-07-24 · open the first message on its own page

[PATCH net] openvswitch: fix potential out of bound access in parse_ct

From: Liping Zhang <hidden>
Date: 2017-07-23 09:53:18

From: Liping Zhang <redacted>

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: 7f8a436eaa2c ("openvswitch: Add conntrack action")
Signed-off-by: Liping Zhang <redacted>
---
 net/openvswitch/conntrack.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index e3c4c6c..03859e3 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -1310,8 +1310,8 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
 
 	nla_for_each_nested(a, attr, rem) {
 		int type = nla_type(a);
-		int maxlen = ovs_ct_attr_lens[type].maxlen;
-		int minlen = ovs_ct_attr_lens[type].minlen;
+		int maxlen;
+		int minlen;
 
 		if (type > OVS_CT_ATTR_MAX) {
 			OVS_NLERR(log,
@@ -1319,6 +1319,9 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
 				  type, OVS_CT_ATTR_MAX);
 			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) {
 			OVS_NLERR(log,
 				  "Conntrack attr type has unexpected length (type=%d, length=%d, expected=%d)",
-- 
2.5.5

Re: [PATCH net] openvswitch: fix potential out of bound access in parse_ct

From: Pravin Shelar <hidden>
Date: 2017-07-23 16:58:04

On Sun, Jul 23, 2017 at 2:52 AM, Liping Zhang [off-list ref] wrote:
From: Liping Zhang <redacted>

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: 7f8a436eaa2c ("openvswitch: Add conntrack action")
Signed-off-by: Liping Zhang <redacted>
Good catch!
Acked-by: Pravin B Shelar <redacted>

Re: [PATCH net] openvswitch: fix potential out of bound access in parse_ct

From: David Miller <davem@davemloft.net>
Date: 2017-07-24 23:25:40

From: Liping Zhang <redacted>
Date: Sun, 23 Jul 2017 17:52:23 +0800
From: Liping Zhang <redacted>

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: 7f8a436eaa2c ("openvswitch: Add conntrack action")
Signed-off-by: Liping Zhang <redacted>
Applied and queued up for -stable.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help