From cc08d60a0809528f1bd91ff2d943bd2c1750eeeb Mon Sep 17 00:00:00 2001 From: Kangjie Lu Date: Thu, 16 May 2019 16:46:17 +0000 Subject: [PATCH] net: openvswitch: fix missing checks for nla_nest_start mainline inclusion from mainline-5.1 commit a734d1f4c2fc category: bugfix bugzilla: 15155 CVE: NA ------------------------------------------------- nla_nest_start may fail and thus deserves a check. The fix returns -EMSGSIZE when it fails. Signed-off-by: Kangjie Lu Signed-off-by: David S. Miller Signed-off-by: Zhiqiang Liu Reviewed-by: Wenan Mao Signed-off-by: Yang Yingliang --- net/openvswitch/datapath.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index f9411a049def..2f2d01183d8a 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); -- GitLab