Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932825AbcK2Egz (ORCPT ); Mon, 28 Nov 2016 23:36:55 -0500 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:19748 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752250AbcK2Egt (ORCPT ); Mon, 28 Nov 2016 23:36:49 -0500 X-RM-TRANSID: 2ee5583d05d889a-2b9f3 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee7583d05d718c-c3521 From: Haishuang Yan To: Pravin Shelar , "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Haishuang Yan Subject: [PATCH] openvswitch: add sanity check in queue_userspace_packet. Date: Tue, 29 Nov 2016 12:36:36 +0800 Message-Id: <1480394196-73882-1-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 756 Lines: 27 kernel will crash in oops if genlmsg_put return NULL, so add the sanity check. Signed-off-by: Haishuang Yan --- net/openvswitch/datapath.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 2d4c4d3..ceb1b1e 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c @@ -474,6 +474,10 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, upcall = genlmsg_put(user_skb, 0, 0, &dp_packet_genl_family, 0, upcall_info->cmd); + if (!upcall) { + err = -EMSGSIZE; + goto out; + } upcall->dp_ifindex = dp_ifindex; err = ovs_nla_put_key(key, key, OVS_PACKET_ATTR_KEY, false, user_skb); -- 1.8.3.1