Skip to contentSkip to conversation

net: ovs: flow: fix potential illegal memory access in __parse_flow_nlattrs

PATCH Applied Daniel Borkmann 3 participants 3 messages Sep 7, 2013 – Sep 11, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ovs: flow: fix potential illegal memory access in __parse_flow_nlattrs

In function __parse_flow_nlattrs(), we check for condition (type > OVS_KEY_ATTR_MAX) and if true, print an error, but we do not return from this function as in other checks. It seems this has been forgotten, as otherwise, we could access beyond the memory of ovs_key_lens, which is of ovs_key_lens[OVS_KEY_ATTR_MAX + 1]. Hence, a maliciously prepared nla_type from user space could access beyond this upper limit.

Introduced by 03f0d916a ("openvswitch: Mega flow implementation").

---
 net/openvswitch/flow.c | 1 +
 1 file changed, 1 insertion(+)
net/openvswitch/flow.c +1 -0
index fb36f85..410db90 100644
@@ -1178,6 +1178,7 @@ static int __parse_flow_nlattrs(const struct nlattr *attr,
 		if (type > OVS_KEY_ATTR_MAX) {
 			OVS_NLERR("Unknown key attribute (type=%d, max=%d).\n",
 				  type, OVS_KEY_ATTR_MAX);
+			return -EINVAL;
 		}
 
 		if (attrs & (1 << type)) {
Signature · 1 line
1.7.11.7
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Daniel Borkmann

In function __parse_flow_nlattrs(), we check for condition (type > OVS_KEY_ATTR_MAX) and if true, print an error, but we do not return from this function as in other checks. It seems this has been forgotten, as otherwise, we could access beyond the memory of ovs_key_lens, which is of ovs_key_lens[OVS_KEY_ATTR_MAX + 1]. Hence, a maliciously prepared nla_type from user space could access beyond this upper limit.

Quoted 4 lines

Introduced by 03f0d916a ("openvswitch: Mega flow implementation").

Yeah, looks like a mistake to me.

maintainer Applied
#2 lore raw

From: Jesse Gross <[email protected]>
Date: Sat, 7 Sep 2013 22:35:33 -0700

Quoted 9 lines · Daniel Borkmann
Quoted 8 lines

In function __parse_flow_nlattrs(), we check for condition (type > OVS_KEY_ATTR_MAX) and if true, print an error, but we do not return from this function as in other checks. It seems this has been forgotten, as otherwise, we could access beyond the memory of ovs_key_lens, which is of ovs_key_lens[OVS_KEY_ATTR_MAX + 1]. Hence, a maliciously prepared nla_type from user space could access beyond this upper limit.

Quoted 8 lines
Quoted 4 lines

Introduced by 03f0d916a ("openvswitch: Mega flow implementation").

Yeah, looks like a mistake to me.

Applied, thanks.