* [PATCH net] openvswitch: fix potential out of bound access in parse_ct
@ 2017-07-23  9:52 Liping Zhang
  2017-07-23 16:58 ` Pravin Shelar
  2017-07-24 23:25 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Liping Zhang @ 2017-07-23  9:52 UTC (permalink / raw)
  To: davem, pshelar; +Cc: netdev, Liping Zhang
From: Liping Zhang <zlpnobody@gmail.com>
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 <zlpnobody@gmail.com>
---
 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
^ permalink raw reply related	[flat|nested] 3+ messages in thread
* Re: [PATCH net] openvswitch: fix potential out of bound access in parse_ct
  2017-07-23  9:52 [PATCH net] openvswitch: fix potential out of bound access in parse_ct Liping Zhang
@ 2017-07-23 16:58 ` Pravin Shelar
  2017-07-24 23:25 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Pravin Shelar @ 2017-07-23 16:58 UTC (permalink / raw)
  To: Liping Zhang
  Cc: David S. Miller, Pravin Shelar, Linux Kernel Network Developers,
	Liping Zhang
On Sun, Jul 23, 2017 at 2:52 AM, Liping Zhang <zlpnobody@163.com> wrote:
> From: Liping Zhang <zlpnobody@gmail.com>
>
> 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 <zlpnobody@gmail.com>
Good catch!
Acked-by: Pravin B Shelar <pshelar@ovn.org>
^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [PATCH net] openvswitch: fix potential out of bound access in parse_ct
  2017-07-23  9:52 [PATCH net] openvswitch: fix potential out of bound access in parse_ct Liping Zhang
  2017-07-23 16:58 ` Pravin Shelar
@ 2017-07-24 23:25 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-07-24 23:25 UTC (permalink / raw)
  To: zlpnobody; +Cc: pshelar, netdev, zlpnobody
From: Liping Zhang <zlpnobody@163.com>
Date: Sun, 23 Jul 2017 17:52:23 +0800
> From: Liping Zhang <zlpnobody@gmail.com>
> 
> 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 <zlpnobody@gmail.com>
Applied and queued up for -stable.
^ permalink raw reply	[flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-07-24 23:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-23  9:52 [PATCH net] openvswitch: fix potential out of bound access in parse_ct Liping Zhang
2017-07-23 16:58 ` Pravin Shelar
2017-07-24 23:25 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).