From patchwork Wed Feb 7 15:49:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 870454 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FtuuzFfa"; 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 3zc5Vb3F6nz9s71 for ; Thu, 8 Feb 2018 02:54:31 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0BE111231; Wed, 7 Feb 2018 15:50:21 +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 F17211234 for ; Wed, 7 Feb 2018 15:50:19 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7B4883CC for ; Wed, 7 Feb 2018 15:50:19 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id f6so428004pgs.10 for ; Wed, 07 Feb 2018 07:50:19 -0800 (PST) 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=41cCc0GXSXiUinBF8S9H1Q8BVZKOntriBhT0OOWa2eY=; b=FtuuzFfaBKgW/KGdM+7kF+kcS/YI6HUEIcu3JPX7ljDonfpdx4/DtO8L8uGw82IMFH LVxFZ1qSng9puyE94/ey3G3ib6joAu53WYc4wUXvrd/QVPeo96KQr8/Qa9PX4nsuWGwb z0ilhIGF8T5bkiO8lkW4zan3AQKRwFavC5+kIssEM7+LRCxd6KDxnRRmIhH3vL5Da2U9 R7Jyag6xeHMWhXWO9hc+u7NaMIAV1XZVM/nOil0fezfcRg2P3l8O+0NtcmiD/XnOsNuM 88870du1VOWXAgVdw5dAumzSoZigd4Xn6Rm+WowK50eOS0Cp+PNJ1ZgQm3pNCMggtIfh 16+w== 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=41cCc0GXSXiUinBF8S9H1Q8BVZKOntriBhT0OOWa2eY=; b=Aqverhq6LMYbLpnV4cDQPeeEbkSt0YxK30puU99II7UQFHUbNpABdmlUNLMqZwGlMk E9VUJQt/K3KkFEKHXrEzbfZYHiZW2hhrYo6CZ31xFMYoHrxAveUBz3hZWcvlLcb0Yuby UC1c+6b4hIAvbufMnGEq4fSUJSRZKXo2nhYyN4CPpoUgau/K6LfDmv0q8UjcTWxAlpi/ Aa8flT35wRQ+EVkLVusbE43bWBDeU82xvoAzdhz25N7Pq9PR11CQbJStW4W95FLPQrAM qAif/Y1f7TG4QlfB56kAPOHxrBEG/qfvZF+eDx6Gx1JAAk4NPNZy+7IJJnUwKi6hUnkb 5Lkg== X-Gm-Message-State: APf1xPAzBfTg+M3KwFXJdoBMFSkklS8UI5RHw7Qvqbq0k8fCAyrk/Or1 7v1uX/jY/rrHqjAXYlYu1wINQg== X-Google-Smtp-Source: AH8x2266mRX+gdFT4dXInElHnGiF0g9ddfbgKGmk+nRqbvQY/4UNx9ETmrMlOOiV8ioSUFP+iDXlag== X-Received: by 10.99.52.203 with SMTP id b194mr5517937pga.40.1518018618466; Wed, 07 Feb 2018 07:50:18 -0800 (PST) Received: from gizo.domain (184-100-240-187.ptld.qwest.net. [184.100.240.187]) by smtp.gmail.com with ESMTPSA id x15sm4924096pff.55.2018.02.07.07.50.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Feb 2018 07:50:17 -0800 (PST) From: Greg Rose To: dev@openvswitch.org Date: Wed, 7 Feb 2018 07:49:57 -0800 Message-Id: <1518018601-31980-8-git-send-email-gvrose8192@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1518018601-31980-1-git-send-email-gvrose8192@gmail.com> References: <1518018601-31980-1-git-send-email-gvrose8192@gmail.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: "Gustavo A. R. Silva" Subject: [ovs-dev] [PATCH v2 07/11] datapath: meter: fix NULL pointer dereference in ovs_meter_cmd_reply_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 From: "Gustavo A. R. Silva" Upstream commit: commit b74912a2fdae9aadd20da502644aa8848c861954 Author: Gustavo A. R. Silva Date: Tue Nov 14 14:26:16 2017 -0600 openvswitch: meter: fix NULL pointer dereference in ovs_meter_cmd_reply_star It seems that the intention of the code is to null check the value returned by function genlmsg_put. But the current code is null checking the address of the pointer that holds the value returned by genlmsg_put. Fix this by properly null checking the value returned by function genlmsg_put in order to avoid a pontential null pointer dereference. Addresses-Coverity-ID: 1461561 ("Dereference before null check") Addresses-Coverity-ID: 1461562 ("Dereference null return value") Fixes: 96fbc13d7e77 ("openvswitch: Add meter infrastructure") Signed-off-by: Gustavo A. R. Silva Signed-off-by: David S. Miller Cc: Gustavo A. R. Silva Signed-off-by: Greg Rose --- datapath/meter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datapath/meter.c b/datapath/meter.c index 7b9391d..d36870b 100644 --- a/datapath/meter.c +++ b/datapath/meter.c @@ -99,7 +99,7 @@ ovs_meter_cmd_reply_start(struct genl_info *info, u8 cmd, *ovs_reply_header = genlmsg_put(skb, info->snd_portid, info->snd_seq, &dp_meter_genl_family, 0, cmd); - if (!ovs_reply_header) { + if (!*ovs_reply_header) { nlmsg_free(skb); return ERR_PTR(-EMSGSIZE); }