Skip to contentSkip to conversation

openvswitch: Avoid OOB read when parsing flow nlattrs

PATCH Applied Ross Lagerwall 3 participants 3 messages Jan 14, 2019 – Jan 16, 2019

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

PATCH 1/1 openvswitch: Avoid OOB read when parsing flow nlattrs

For nested and variable attributes, the expected length of an attribute is not known and marked by a negative number. This results in an OOB read when the expected length is later used to check if the attribute is all zeros. Fix this by using the actual length of the attribute rather than the expected length.

---
 net/openvswitch/flow_netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/openvswitch/flow_netlink.c +1 -1
index 435a4bdf8f89..691da853bef5 100644
@@ -500,7 +500,7 @@ static int __parse_flow_nlattrs(const struct nlattr *attr,
 			return -EINVAL;
 		}
 
-		if (!nz || !is_all_zero(nla_data(nla), expected_len)) {
+		if (!nz || !is_all_zero(nla_data(nla), nla_len(nla))) {
 			attrs |= 1 << type;
 			a[type] = nla;
 		}
Signature · 1 line
2.17.2
Acked-by on v1 1/1
#1 lore raw
Quoted 17 lines · Ross Lagerwall

For nested and variable attributes, the expected length of an attribute is not known and marked by a negative number. This results in an OOB read when the expected length is later used to check if the attribute is all zeros. Fix this by using the actual length of the attribute rather than the expected length.

---
 net/openvswitch/flow_netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/openvswitch/flow_netlink.c +0 -0
index 435a4bdf8f89..691da853bef5 100644

net/openvswitch/flow_netlink.c static int __parse_flow_nlattrs(const struct nlattr *attr, · line 506

Quoted 8 lines
net/openvswitch/flow_netlink.c +1 -1
@@ -500,7 +500,7 @@ static int __parse_flow_nlattrs(const struct nlattr *attr,
                        return -EINVAL;
                }
 
-               if (!nz || !is_all_zero(nla_data(nla), expected_len)) {
+               if (!nz || !is_all_zero(nla_data(nla), nla_len(nla))) {
                        attrs |= 1 << type;
                        a[type] = nla;
                }

Good Catch.

maintainer Applied
#2 lore raw
In reply to Ross Lagerwall

From: Ross Lagerwall <[email protected]>
Date: Mon, 14 Jan 2019 09:16:56 +0000

Quoted 7 lines

For nested and variable attributes, the expected length of an attribute is not known and marked by a negative number. This results in an OOB read when the expected length is later used to check if the attribute is all zeros. Fix this by using the actual length of the attribute rather than the expected length.

Applied.