Skip to contentSkip to conversation

Open vSwitch

GIT net New Jesse Gross 2 participants 5 messages May 8, 2012 1 message not in the archive

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

A few patches for net/3.4.

The following changes since commit dd775ae2549217d3ae09363e3edb305d0fa19928:

Linux 3.4-rc1 (2012-03-31 16:24:09 -0700)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/jesse/openvswitch.git fixes

for you to fetch changes up to 072ae6314a191e3a9fc309b1e4e539ac7abc48ad:

openvswitch: Validation of IPv6 set port action uses IPv4 header (2012-05-07 17:23:10 -0700)

----------------------------------------------------------------
Ansis Atteka (1):
openvswitch: Release rtnl_lock if ovs_vport_cmd_build_info() failed.

Jesse Gross (1):
openvswitch: Add length check when retrieving TCP flags.

Pravin B Shelar (1):
openvswitch: Validation of IPv6 set port action uses IPv4 header

 net/openvswitch/datapath.c |   27 +++++++++++++++++----------
 net/openvswitch/flow.c     |    3 ++-
 2 files changed, 19 insertions(+), 11 deletions(-)
#2 lore raw

PATCH 1/3 openvswitch: Add length check when retrieving TCP flags.

In reply to a message not in the archive

When collecting TCP flags we check that the IP header indicates that a TCP header is present but not that the packet is actually long enough to contain the header. This adds a check to prevent reading off the end of the packet.

In practice, this is only likely to result in reading of bad data and not a crash due to the presence of struct skb_shared_info at the end of the packet.

---
 net/openvswitch/flow.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/openvswitch/flow.c +2 -1
index 1252c30..2a11ec2 100644
@@ -183,7 +183,8 @@ void ovs_flow_used(struct sw_flow *flow, struct sk_buff *skb)
 	u8 tcp_flags = 0;
 
 	if (flow->key.eth.type == htons(ETH_P_IP) &&
-	    flow->key.ip.proto == IPPROTO_TCP) {
+	    flow->key.ip.proto == IPPROTO_TCP &&
+	    likely(skb->len >= skb_transport_offset(skb) + sizeof(struct tcphdr))) {
 		u8 *tcp = (u8 *)tcp_hdr(skb);
 		tcp_flags = *(tcp + TCP_FLAGS_OFFSET) & TCP_FLAG_MASK;
 	}
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 2/3 openvswitch: Release rtnl_lock if ovs_vport_cmd_build_info() failed.

In reply to a message not in the archive

From: Ansis Atteka <[email protected]>

This patch fixes a possible lock-up bug where rtnl_lock might not get released.

---
 net/openvswitch/datapath.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
net/openvswitch/datapath.c +2 -3
index e44e631..4cb615d 100644
@@ -1641,10 +1641,9 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info)
 	reply = ovs_vport_cmd_build_info(vport, info->snd_pid, info->snd_seq,
 					 OVS_VPORT_CMD_NEW);
 	if (IS_ERR(reply)) {
-		err = PTR_ERR(reply);
 		netlink_set_err(init_net.genl_sock, 0,
-				ovs_dp_vport_multicast_group.id, err);
-		return 0;
+				ovs_dp_vport_multicast_group.id, PTR_ERR(reply));
+		goto exit_unlock;
 	}
 
 	genl_notify(reply, genl_info_net(info), info->snd_pid,
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 3/3 openvswitch: Validation of IPv6 set port action uses IPv4 header

In reply to a message not in the archive

From: Pravin B Shelar <[email protected]>

When the kernel validates set TCP/UDP port actions, it looks at the ports in the existing flow to make sure that the L4 header exists. However, these actions always use the IPv4 version of the struct. Following patch fixes this by checking for flow ip protocol first.

---
 net/openvswitch/datapath.c |   22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
net/openvswitch/datapath.c +15 -7
index 4cb615d..777716b 100644
@@ -421,6 +421,19 @@ static int validate_sample(const struct nlattr *attr,
 	return validate_actions(actions, key, depth + 1);
 }
 
+static int validate_tp_port(const struct sw_flow_key *flow_key)
+{
+	if (flow_key->eth.type == htons(ETH_P_IP)) {
+		if (flow_key->ipv4.tp.src && flow_key->ipv4.tp.dst)
+			return 0;
+	} else if (flow_key->eth.type == htons(ETH_P_IPV6)) {
+		if (flow_key->ipv6.tp.src && flow_key->ipv6.tp.dst)
+			return 0;
+	}
+
+	return -EINVAL;
+}
+
 static int validate_set(const struct nlattr *a,
 			const struct sw_flow_key *flow_key)
 {
@@ -462,18 +475,13 @@ static int validate_set(const struct nlattr *a,
 		if (flow_key->ip.proto != IPPROTO_TCP)
 			return -EINVAL;
 
-		if (!flow_key->ipv4.tp.src || !flow_key->ipv4.tp.dst)
-			return -EINVAL;
-
-		break;
+		return validate_tp_port(flow_key);
 
 	case OVS_KEY_ATTR_UDP:
 		if (flow_key->ip.proto != IPPROTO_UDP)
 			return -EINVAL;
 
-		if (!flow_key->ipv4.tp.src || !flow_key->ipv4.tp.dst)
-			return -EINVAL;
-		break;
+		return validate_tp_port(flow_key);
 
 	default:
 		return -EINVAL;
Signature · 1 line
1.7.9.5
#5 lore raw
In reply to a message not in the archive

From: Jesse Gross <[email protected]>
Date: Mon, 7 May 2012 18:51:22 -0700

Quoted 9 lines

A few patches for net/3.4.

The following changes since commit dd775ae2549217d3ae09363e3edb305d0fa19928:

Linux 3.4-rc1 (2012-03-31 16:24:09 -0700)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/jesse/openvswitch.git fixes

Pulled, thanks Jesse.