From patchwork Wed Aug 28 10:24:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Li,Rongqing via dev" X-Patchwork-Id: 1154328 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=none (p=none dis=none) header.from=openvswitch.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=altencalsoftlabs.com header.i=@altencalsoftlabs.com header.b="pYaDu5ZG"; 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 46JMVH2Wylz9sDQ for ; Wed, 28 Aug 2019 20:31:34 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 87CF529B9; Wed, 28 Aug 2019 10:31:31 +0000 (UTC) X-Original-To: ovs-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 6C86A25E9 for ; Wed, 28 Aug 2019 10:31:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.altencalsoftlabs.com (mail.altencalsoftlabs.com [182.73.72.41]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 88F348C2 for ; Wed, 28 Aug 2019 10:31:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.altencalsoftlabs.com (Postfix) with ESMTP id 1565D44201D6; Wed, 28 Aug 2019 16:01:04 +0530 (IST) Received: from mail.altencalsoftlabs.com ([127.0.0.1]) by localhost (mail.altencalsoftlabs.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 3x3Fqo0xdmzU; Wed, 28 Aug 2019 16:01:03 +0530 (IST) Received: from localhost (localhost [127.0.0.1]) by mail.altencalsoftlabs.com (Postfix) with ESMTP id 96D7B44201D2; Wed, 28 Aug 2019 16:01:03 +0530 (IST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.altencalsoftlabs.com 96D7B44201D2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=altencalsoftlabs.com; s=selector; t=1566988263; bh=BdeuQr24tB3Vhg8dHj5zgbDae0rQteHt/fQMrfahRVE=; h=From:To:Date:Message-Id:MIME-Version; b=pYaDu5ZGOodNZEL5NE0MUV3gB9vYYXLRPmm4sMkByl0uGFO0KnwViaeW+fYKiBGHa YjrSfmu8Hz9HLEVk6jruXr0e8CsjCoppOxAjNuofJe2oNjDEPFMgxLg3lYm/CG7yZX uu4FlJ6Ef60X1irjqtuolhx5NDrg0zpArJoOIdVM= X-Virus-Scanned: amavisd-new at altencalsoftlabs.com Received: from mail.altencalsoftlabs.com ([127.0.0.1]) by localhost (mail.altencalsoftlabs.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id owwrsFTEe_g8; Wed, 28 Aug 2019 16:01:03 +0530 (IST) Received: from localhost.localdomain (unknown [10.1.0.4]) by mail.altencalsoftlabs.com (Postfix) with ESMTPSA id 9C71F44201DA; Wed, 28 Aug 2019 16:01:02 +0530 (IST) To: ovs-dev@openvswitch.org Date: Wed, 28 Aug 2019 15:54:58 +0530 Message-Id: <1566987898-344-1-git-send-email-anilkumar.k@altencalsoftlabs.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 Subject: [ovs-dev] [PATCH v1] ofproto: Fix OVS crash when packets hit Openflow rules with certain combinations of nested actions 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: , X-Patchwork-Original-From: Anil Kumar via dev From: "Li,Rongqing via dev" Reply-To: Anil Kumar Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org OVS crashes when a packet sent with action set to OFPP_TABLE hits Openflow rules with conntrack and learn actions. For example: The crash can be triggered by installing the following Open flow rules and sending packet with action set to OFPP_TABLE 1. ovs-ofctl -OOpenflow13 add-flow br-int "table=0, priority=50, \ ct_state=-trk,ip, in_port=10 actions=ct(table=0)" 2. ovs-ofctl -OOpenflow13 add-flow br-int "table=0, priority=50, \ ct_state=+trk,ip, in_port=10 actions=ct(commit),resubmit(,1)" 3. ovs-ofctl -OOpenflow13 add-flow br-int "table=1 \ actions=learn(table=2,NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],load:NXM_OF_IN_PORT[]->NXM_NX_REG0[0..15], \ output:NXM_NX_REG0[0..15]),resubmit(,2)" 4. Send a packet with output as OFPP_TABLE ovs-ofctl -OOpenflow13 packet-out br-int 'in_port=10 \ packet=505400000007101111111111080045000028000000004006f97cc0a80001c0a800020008000a0000000000000000500200002e7d0000, \ actions=TABLE' The processing code path results in the same thread context attempting to acquire a mutex that it already holds. Since the mutex is of error checking type this situation is considered fatal and OVS aborts. The crash isn’t limited to only the above combination of actions Signed-off-by: Anil Kumar --- ofproto/ofproto.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 12758a3..ff7d90b 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -302,7 +302,7 @@ static size_t n_ofproto_classes; static size_t allocated_ofproto_classes; /* Global lock that protects all flow table operations. */ -struct ovs_mutex ofproto_mutex = OVS_MUTEX_INITIALIZER; +struct ovs_mutex ofproto_mutex; unsigned ofproto_flow_limit = OFPROTO_FLOW_LIMIT_DEFAULT; unsigned ofproto_max_idle = OFPROTO_MAX_IDLE_DEFAULT; @@ -337,6 +337,8 @@ ofproto_init(const struct shash *iface_hints) struct shash_node *node; size_t i; + ovs_mutex_init_recursive(&ofproto_mutex); + ofproto_class_register(&ofproto_dpif_class); /* Make a local copy, since we don't own 'iface_hints' elements. */