From patchwork Fri Mar 15 06:11:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 1056860 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=umn.edu Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=umn.edu header.i=@umn.edu header.b="aMybzQA/"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44LFZz3tc3z9s6w for ; Fri, 15 Mar 2019 17:11:38 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CB768CDD; Fri, 15 Mar 2019 06:11:33 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 28976CC4 for ; Fri, 15 Mar 2019 06:11:33 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mta-p6.oit.umn.edu (mta-p6.oit.umn.edu [134.84.196.206]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C297512E for ; Fri, 15 Mar 2019 06:11:32 +0000 (UTC) Received: from localhost (unknown [127.0.0.1]) by mta-p6.oit.umn.edu (Postfix) with ESMTP id 30D72D52 for ; Fri, 15 Mar 2019 06:11:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p6.oit.umn.edu ([127.0.0.1]) by localhost (mta-p6.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3FPALUG29AH2 for ; Fri, 15 Mar 2019 01:11:32 -0500 (CDT) Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p6.oit.umn.edu (Postfix) with ESMTPS id 07873D43 for ; Fri, 15 Mar 2019 01:11:31 -0500 (CDT) Received: by mail-io1-f72.google.com with SMTP id e1so6135975iod.23 for ; Thu, 14 Mar 2019 23:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=glKVrF76DqYG8OwLc+rWqwZpUefQ0RPQdTYZl6DR47A=; b=aMybzQA/MOMJBJlh9J78iiM02qZgDQCclqKM/TTG9K9HzBP0i7IkT26UtVvgbImcJE RaIDm1ipvzgqcWSX0xdbeL+PzhV5WP9V/iyQS4qDHUUnYQVinWVKvXnDF/UzKQBezDB/ oxg0mJ960Vd7bV9ZQVzsCLj29bhtB4jbPmTV/Pb7Tl4iVW+rAlacMC+nnAzUJHZnn6U9 mZx0wdIV3cioE7lKIUkEz3UAUkxayybiybN0B6p9NQIEYLp2k2vOUgwWlf1NtnAEEDwI WxLeKHAtsQekwJ3Y0ea03d5buLf5z2m9zwe9hgqjUs95pJNwlgYwBuD2p1iq2koFigI/ Q1sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=glKVrF76DqYG8OwLc+rWqwZpUefQ0RPQdTYZl6DR47A=; b=WlHAudY2z+g2LSzt5bsKK0/3q+MzyS/+u5fMD51eqiyo41WEqtjORQ0xnYTOL3kXJD k04c2a00gSi1NeM1sIxkiTkh7Z61cZP+/fsXeuKx+b5s7zpmk26U0GlwCMaEx7ba0H/p 74qP9E+HPZL4Xw1KBGHrjICiFe6BWJX9y1dsajYcDYkDwL1+Tg1m6yVlLVJhAqWUOdd2 yIolTxac6ANraJqaoVcawc5viX/sPrtKjGoMw9p+9n2rpG+V/J9bRp1e12dqdxo+Bmd2 EQfQJcErAVXw9/IOocRypbZleVa8FQ6Kp3Bj6lyiLMfKq3auME1kXRxF14ABOS2FBgXD 4oTg== X-Gm-Message-State: APjAAAX2ieUAZIUPQz0yllp5Ljh/F3vXIS1ENFtl7gYqK0lGY9knJ/Ou 9fmcSe1tbwpjNgnOpFkwneT38FVjFvJXwLVSA2sJyWZjIuDXQBW6vLkmYF43uT49O09Makthvc8 NhpzJbui4NvHXVxeu X-Received: by 2002:a24:7d94:: with SMTP id b142mr944979itc.136.1552630291502; Thu, 14 Mar 2019 23:11:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbby7QsMsLC1zjVYbBuBwXb1+XwLhmSLSax1o6hC4nUHSQ+xPUU+GJ+menSwRVbIjLd7FpHg== X-Received: by 2002:a24:7d94:: with SMTP id b142mr944968itc.136.1552630291265; Thu, 14 Mar 2019 23:11:31 -0700 (PDT) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id o9sm612087itb.23.2019.03.14.23.11.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 23:11:30 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Date: Fri, 15 Mar 2019 01:11:22 -0500 Message-Id: <20190315061122.14794-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: dev@openvswitch.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, pakki001@umn.edu, "David S. Miller" Subject: [ovs-dev] [PATCH] net: openvswitch: fix missing checks for nla_nest_start X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org nla_nest_start may fail and thus deserves a check. The fix returns -EMSGSIZE when it fails. Signed-off-by: Kangjie Lu --- net/openvswitch/datapath.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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);