diff mbox series

[ovs-dev] net: openvswitch: fix missing checks for nla_nest_start

Message ID 20190315061122.14794-1-kjlu@umn.edu
State Accepted
Headers show
Series [ovs-dev] net: openvswitch: fix missing checks for nla_nest_start | expand

Commit Message

Kangjie Lu March 15, 2019, 6:11 a.m. UTC
nla_nest_start may fail and thus deserves a check.
The fix returns -EMSGSIZE when it fails.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 net/openvswitch/datapath.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

David Miller March 16, 2019, 6:43 p.m. UTC | #1
From: Kangjie Lu <kjlu@umn.edu>
Date: Fri, 15 Mar 2019 01:11:22 -0500

> nla_nest_start may fail and thus deserves a check.
> The fix returns -EMSGSIZE when it fails.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>

Applied.
diff mbox series

Patch

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 45d1469308b0..9dd158ab51b3 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -464,6 +464,10 @@  static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
 
 	if (upcall_info->egress_tun_info) {
 		nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_EGRESS_TUN_KEY);
+		if (!nla) {
+			err = -EMSGSIZE;
+			goto out;
+		}
 		err = ovs_nla_put_tunnel_info(user_skb,
 					      upcall_info->egress_tun_info);
 		BUG_ON(err);
@@ -472,6 +476,10 @@  static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
 
 	if (upcall_info->actions_len) {
 		nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_ACTIONS);
+		if (!nla) {
+			err = -EMSGSIZE;
+			goto out;
+		}
 		err = ovs_nla_put_actions(upcall_info->actions,
 					  upcall_info->actions_len,
 					  user_skb);