From patchwork Fri Sep 11 01:41:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 516523 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id BF575140081 for ; Fri, 11 Sep 2015 11:41:54 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 060D810C16; Thu, 10 Sep 2015 18:41:47 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v1.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 9C62510C06 for ; Thu, 10 Sep 2015 18:41:43 -0700 (PDT) Received: from bar3.cudamail.com (bar1 [192.168.15.1]) by mx3v1.cudamail.com (Postfix) with ESMTP id F22626180C7 for ; Thu, 10 Sep 2015 19:41:41 -0600 (MDT) X-ASG-Debug-ID: 1441935701-03dd7b096c0c290001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar3.cudamail.com with ESMTP id ijZO0cVGLHcapSfB (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 10 Sep 2015 19:41:41 -0600 (MDT) X-Barracuda-Envelope-From: joestringer@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mail-pa0-f53.google.com) (209.85.220.53) by mx3-pf3.cudamail.com with ESMTPS (RC4-SHA encrypted); 11 Sep 2015 01:41:41 -0000 Received-SPF: unknown (mx3-pf3.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.53 Received: by padhk3 with SMTP id hk3so58908168pad.3 for ; Thu, 10 Sep 2015 18:41:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fcM+eiQ1asGOL072V3E1qKFZzdQYx/Mg7QY7A25wdR4=; b=LeG2WxP/Hlv2+SAYB0L1U5mT48V1IZ1jgghaIVoZVyZFDgo5AzAsMRlL2+lKZiBatC IqouO58KS8QaZmJBN2CXgT9E3rB+PJIBm+m6RWVVO/3q15Bp5IIGd+MN8Y35AGVp+X6t YZOZO+Mwj0H1/rQCi0WTwn5xbyrYRqUC0HLZBLqg9jYaPjTx/OYVKRsimJWqaPf/mMIm 0WhhMNEN7shog1/VE7OySHvPjsqWksR/fJUDVe9H75gknY/WHlNDMQICzr/zTxhcQYXz 3zgFpeXC39N/YHjCMWOyEme7atbgnOi4g5symiGP4c3bgvYFFtXnOC/e4ckGddcvJzpT HVlQ== X-Gm-Message-State: ALoCoQnLQe6/NPI42A50Sn/3hrMBr9NqGN1PMVUF+FeTqANRF5wNwE9eSYik6CuHuBRyPyis18mr X-Received: by 10.66.186.141 with SMTP id fk13mr80120363pac.7.1441935700952; Thu, 10 Sep 2015 18:41:40 -0700 (PDT) Received: from localhost.localdomain ([208.91.2.4]) by smtp.gmail.com with ESMTPSA id uh10sm14422889pab.41.2015.09.10.18.41.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Sep 2015 18:41:40 -0700 (PDT) X-CudaMail-Envelope-Sender: joestringer@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.2.4 From: Joe Stringer To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V3-909069038 X-CudaMail-DTE: 091015 X-CudaMail-Originating-IP: 209.85.220.53 Date: Thu, 10 Sep 2015 18:41:32 -0700 X-ASG-Orig-Subj: [##CM-V3-909069038##][PATCH 3/3] ipfix: Fix SIGFPE in bridge exporter sampling. Message-Id: <1441935692-6848-4-git-send-email-joestringer@nicira.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441935692-6848-1-git-send-email-joestringer@nicira.com> References: <1441935692-6848-1-git-send-email-joestringer@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1441935701 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH 3/3] ipfix: Fix SIGFPE in bridge exporter sampling. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" A divide-by-zero exception like the below could occur when IPFIX configuration is cleared while handling sampled packets from the datapath. While it's not valid to configure the sampling probability of IPFIX to zero via explicitly setting it in OVSDB, it is possible to clear the configuration, which results in a probability of zero. In this case, there is a window during which it is possible for upcalls to find the cleared IPFIX object and attempt to perform sampling using it. Fix the issue by ensuring that the probability is nonzero before using it. "Program terminated with signal SIGFPE, Arithmetic exception." dpif_ipfix_bridge_sample (...) at ../ofproto/ofproto-dpif-ipfix.c:1701 process_upcall (...) at ../ofproto/ofproto-dpif-upcall.c:1145 recv_upcalls (...) at ../ofproto/ofproto-dpif-upcall.c:705 udpif_upcall_handler (...) at ../ofproto/ofproto-dpif-upcall.c:631 ovsthread_wrapper (...) at ../lib/ovs-thread.c:340 start_thread (...) at pthread_create.c:312 clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 Signed-off-by: Joe Stringer --- Given that there's a couple of other places in the IPFIX code that check the probability before using it, I'm assuming this isn't an invariant and this is a reasonable place to fix the bug. I haven't looked into whether this kind of bug may affect other sampling implementations in OVS. --- ofproto/ofproto-dpif-ipfix.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c index 48ff827..9ad8fa2 100644 --- a/ofproto/ofproto-dpif-ipfix.c +++ b/ofproto/ofproto-dpif-ipfix.c @@ -1692,6 +1692,10 @@ dpif_ipfix_bridge_sample(struct dpif_ipfix *di, const struct dp_packet *packet, struct dpif_ipfix_port * tunnel_port = NULL; ovs_mutex_lock(&mutex); + if (!bridge_exporter_enabled(di)) { + ovs_mutex_unlock(&mutex); + return; + } /* Use the sampling probability as an approximation of the number * of matched packets. */ packet_delta_count = UINT32_MAX / di->bridge_exporter.probability;