From patchwork Mon Oct 14 17:37:48 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: 1176568 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="hXoHjIiO"; 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 46sR5X1R0Rz9sP4 for ; Tue, 15 Oct 2019 04:54:24 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E6F2D2777; Mon, 14 Oct 2019 17:50:01 +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 BF101276C for ; Mon, 14 Oct 2019 17:50:00 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id F044C8A0 for ; Mon, 14 Oct 2019 17:49:58 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id t10so8320708plr.8 for ; Mon, 14 Oct 2019 10:49:58 -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=I2MIjbcFG3rAaxzcOC/Cmzsa5gWJoWN2gJt2A//XVC4=; b=hXoHjIiOvp2meRTQxzsBG1MJemsTbT7vS35bESIyxECikkdgvRJr5wMG1zSCg1C+DZ tun6nlkML5a9OYZmVMKxHcpClQM3xo98x7IWVcWpL8Btdjazi/JhNigC+WYTeoygWD9Q i34fJUG2XPXGWvPt09wwsX0hPvy7cWCArYmpz7HNC0U8sVNl16eVd2mox3mVWRrxt4Io 9lkseCEewjkalz/Hr0mCK0ATc6xHUndJ/d9D5fwDDaWxEak8fwCXUlH1HMWdLR6+VpSF loIRy9cQ1140HynzxBFZaxDa8FZfxvlJAHe/bnLKCuXDyWaTnUyNGgrpB87CNY6vfV+h aGYA== 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=I2MIjbcFG3rAaxzcOC/Cmzsa5gWJoWN2gJt2A//XVC4=; b=Q8t864IkP5yBudXutE7Zk2XWrHVtErlAJG07L9ZQrUIEQ4ligCZ4FfpK3V61eXKdhT XBhnJum+oQe4Gw93y42qpPADprjymnIgslsq9GOVZeXSrozZEuJfQA2hX/qQtps5PJVr aBF0NW+S699xr+qEfBIlKyj1G3Kj1yWkYN5KaaMBUubIVuB8NdgQs8m6w6n8Y1iti1Fk 7961IvvYcGSDcu2vZ7O6vGYBb6jnEIsO4WEvcYS8MYzviw1HaR/LpocRtjhWnwAh5s2e d5rzawumn5lDmid+hRSTLaNIAQF4Aa4uHstfvcnaddtCljmy5Dt4L7vvAQzwwUkh5nXh VUZw== X-Gm-Message-State: APjAAAXxfEwIgCx8GgaAnoa11ewRe4wVcp/S/QT0YK/EBxzaidZJCFe/ cb3Gd2fR31nUm76U5ViwTMlt6s0lrhg= X-Google-Smtp-Source: APXvYqw49ULmDV+6JAaq8qNVn1kdVUB6yqsQjpGM/yAZsym9ZHyUbE1CfKi4a3/LKZoSIAyMMelcAQ== X-Received: by 2002:a17:902:123:: with SMTP id 32mr31758402plb.258.1571075398166; Mon, 14 Oct 2019 10:49:58 -0700 (PDT) Received: from Husky.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id n23sm16849700pff.137.2019.10.14.10.49.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Oct 2019 10:49:55 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Mon, 14 Oct 2019 10:37:48 -0700 Message-Id: <1571074671-31834-9-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571074671-31834-1-git-send-email-yihung.wei@gmail.com> References: <1571074671-31834-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 08/11] 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(