From patchwork Tue Oct 15 17:27:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 1177255 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=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="csLdxofZ"; 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 46t2qP0g1Xz9sP4 for ; Wed, 16 Oct 2019 04:44:17 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B97C0F11; Tue, 15 Oct 2019 17:39:35 +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 CF73BF03 for ; Tue, 15 Oct 2019 17:39:32 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7EE356CE for ; Tue, 15 Oct 2019 17:39:32 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id p12so3233420pgn.6 for ; Tue, 15 Oct 2019 10:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LaiEPuHB/6ynzcnwty2bxImwXeNrZj5BWXcmG9RRzqo=; b=csLdxofZwL+U+rGXO+Tgck9ZthNsfMwJLPNLXp1NHq1o2Lc19wPZkhTZWgq63N9Jfd Mn7N8Kan8oDkA7/JH99/LqfIhfv068h6d7Zpjzz5BF1VSDCUNdlZhD5eWqcBXjHweZAg g25QnACn6t6KFANQmIC8qD69g1K00nAxIk8x9HlkJg+xzOXipgpFeAm3YBJ6vE4ay13D qzuu28aiSYLuX7/jbFHBcsV5IBdc/RNNJPFUoZRWp8HBt3sAOlgmiY4PR8Bf2ifqGOkv GNvMGLOgFdCznJmF4Mde9/hD2m4jUInOeinuMGG/sP27JEgGxTnoXMBUxJKNJLYhyO/O XBMQ== 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:in-reply-to :references; bh=LaiEPuHB/6ynzcnwty2bxImwXeNrZj5BWXcmG9RRzqo=; b=mb0uptpkChmxkC5FbYtRJ2HUpGiUXj8idVkJAA9xs3IiyutCoRPa31cirJdYYhUGwN uBmi2gQLt5BPWY62LAi4NrBYFZr3TeiQnVByEzWQMX2X1E9bTmE5Y5fzC52eSEYswOel JMPt2aX8n008hXJYwFh/jJyQ0naUUIz+b7w0tzN5tKgjSR5R75CW07+C9A7xwQITUs6d Iq4ZibGi9hb5S+rcszG4OJgcJMXvlcSTtE8it+anQtE1XH13TZU89UiY5B6jsfX5jexH lAhxZYnJKyJNLZNqrDjQGpw1hXniiA/wSQQX+vLwEfMo4Bqu0yv4/Pwzn3mIQSO1zbZx pyMg== X-Gm-Message-State: APjAAAXKqH5VbFKJvyJ7OCO3aMbapxNN565bCEG5GrjlJ5scYF30TMIQ VfGae73eBQJvAc2QWX8mXQFZ6fL2kso= X-Google-Smtp-Source: APXvYqwZoN6smRSguLgVzrWDijK8ObLg/UegIb5MI7NniDAW9/ue0TSx75qpP4rVXshiVqPc2kuxwA== X-Received: by 2002:a62:e807:: with SMTP id c7mr39272137pfi.18.1571161171686; Tue, 15 Oct 2019 10:39:31 -0700 (PDT) Received: from Husky.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id q204sm25590311pfc.11.2019.10.15.10.39.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Oct 2019 10:39:30 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Tue, 15 Oct 2019 10:27:50 -0700 Message-Id: <1571160473-46132-10-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571160473-46132-1-git-send-email-yihung.wei@gmail.com> References: <1571160473-46132-1-git-send-email-yihung.wei@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Colin Ian King Subject: [ovs-dev] [PATCH v2 09/12] datapath: Check for null pointer return from nla_nest_start_noflag 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 From: Colin Ian King upstream commit: commit ca96534630e2edfd73121c487c957b17eca3b7d7 Author: Colin Ian King Date: Wed May 1 14:41:58 2019 +0100 openvswitch: check for null pointer return from nla_nest_start_noflag The call to nla_nest_start_noflag can return null in the unlikely event that nla_put returns -EMSGSIZE. Check for this condition to avoid a null pointer dereference on pointer nla_reply. Addresses-Coverity: ("Dereference null return value") Fixes: 11efd5cb04a1 ("openvswitch: Support conntrack zone limit") Signed-off-by: Colin Ian King Acked-by: Yi-Hung Wei Signed-off-by: David S. Miller Signed-off-by: Yi-Hung Wei Reviewed-by: Yifeng Sun --- datapath/conntrack.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/datapath/conntrack.c b/datapath/conntrack.c index 9a7eab655142..86e7dd24bb9b 100644 --- a/datapath/conntrack.c +++ b/datapath/conntrack.c @@ -2273,6 +2273,10 @@ static int ovs_ct_limit_cmd_get(struct sk_buff *skb, struct genl_info *info) return PTR_ERR(reply); nla_reply = nla_nest_start_noflag(reply, OVS_CT_LIMIT_ATTR_ZONE_LIMIT); + if (!nla_reply) { + err = -EMSGSIZE; + goto exit_err; + } if (a[OVS_CT_LIMIT_ATTR_ZONE_LIMIT]) { err = ovs_ct_limit_get_zone_limit(