Message ID | 20191122161303.4719.78753.stgit@dceara.remote.csb |
---|---|
Headers | show
Return-Path: <ovs-dev-bounces@openvswitch.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN>) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="Vb4TT1d+"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47KM173jMMz9sPK for <incoming@patchwork.ozlabs.org>; Sat, 23 Nov 2019 03:13:31 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 57F78882F9; Fri, 22 Nov 2019 16:13:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n-FedAmhrWp0; Fri, 22 Nov 2019 16:13:25 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 2964C882C7; Fri, 22 Nov 2019 16:13:25 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D30E0C1D74; Fri, 22 Nov 2019 16:13:24 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 839B1C18DA for <dev@openvswitch.org>; Fri, 22 Nov 2019 16:13:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 728EB2632A for <dev@openvswitch.org>; Fri, 22 Nov 2019 16:13:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yBtDsYA1-776 for <dev@openvswitch.org>; Fri, 22 Nov 2019 16:13:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by silver.osuosl.org (Postfix) with ESMTPS id 28D472631D for <dev@openvswitch.org>; Fri, 22 Nov 2019 16:13:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574439200; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8p7K3hKh8uIYyOsILarItFl8iDOx8AGprM/68FQbdPg=; b=Vb4TT1d+ftn7QIsv7XbeIThLT88Dt26bk4jy7JFpDGceSk5OYf08VBcT0UsFzDQOhFV9fA BqBcG2wRqApEidXF3I/9LDDYlWlUBPBfdlVScp7gvojaVNpadISN0IPdcmhXu+xXUU9H50 cp+WCDch2Yr4GVlU4DLBDEZpu0YxnWw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-281-_S2LXoh8Oiefy_dHrBc9Rw-1; Fri, 22 Nov 2019 11:13:14 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2600B801E58; Fri, 22 Nov 2019 16:13:13 +0000 (UTC) Received: from dceara.remote.csb (ovpn-117-130.ams2.redhat.com [10.36.117.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AEDA60141; Fri, 22 Nov 2019 16:13:11 +0000 (UTC) From: Dumitru Ceara <dceara@redhat.com> To: dev@openvswitch.org Date: Fri, 22 Nov 2019 17:13:06 +0100 Message-Id: <20191122161303.4719.78753.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: _S2LXoh8Oiefy_dHrBc9Rw-1 X-Mimecast-Spam-Score: 0 Cc: hzhou@ovn.org Subject: [ovs-dev] [PATCH v6 ovn 0/4] Refactor I-P engine and fix use after free. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: <ovs-dev.openvswitch.org> List-Unsubscribe: <https://mail.openvswitch.org/mailman/options/ovs-dev>, <mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe> List-Archive: <http://mail.openvswitch.org/pipermail/ovs-dev/> List-Post: <mailto:ovs-dev@openvswitch.org> List-Help: <mailto:ovs-dev-request@openvswitch.org?subject=help> List-Subscribe: <https://mail.openvswitch.org/mailman/listinfo/ovs-dev>, <mailto:ovs-dev-request@openvswitch.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" <ovs-dev-bounces@openvswitch.org> |
Series |
Refactor I-P engine and fix use after free.
|
expand
|
The incremental processing engine might stop a run before the en_runtime_data node is processed. In such cases the ed_runtime_data fields might contain pointers to already deleted SB records. For example, if a port binding corresponding to a patch port is removed from the SB database and the incremental processing engine aborts before the en_runtime_data node is processed then the corresponding local_datapath hashtable entry in ed_runtime_data is stale and will store a pointer to the already freed sbrec_port_binding record. This will cause invalid memory accesses in various places (e.g., pinctrl_run() -> prepare_ipv6_ras()). This series fixes the issue (patch4) but to make the fix generic and easier to debug it first refactors the incremental processing engine in the following way: - patch1: split engine_run() in smaller functional parts and simplify the logic of calling engine_run and engine_need_run in the main loop. - patch2: remove recursion from the I-P engine code. Introduce node states to track validity of node data. - patch3: move ct-zones to its own engine node in order to remove dependencies on other runtime data. CC: Han Zhou <hzhou@ovn.org> Fixes: ca278d98a4f5 ("ovn-controller: Initial use of incremental engine - quiet mode.") Signed-off-by: Dumitru Ceara <dceara@redhat.com> Dumitru Ceara (4): ovn-controller: Refactor I-P engine_run() tracking. ovn-controller: Add per node states to I-P engine. ovn-controller: Add separate I-P engine node for processing ct-zones. ovn-controller: Fix use of dangling pointers in I-P runtime_data. controller/ovn-controller.c | 414 ++++++++++++++++++++++++------------------- lib/inc-proc-eng.c | 338 +++++++++++++++++++++++++++-------- lib/inc-proc-eng.h | 103 ++++++++--- 3 files changed, 570 insertions(+), 285 deletions(-) --- v6: - Address Han's comments: - Call engine_recompute only once for a node if at least one of its input nodes' change handler returns false. - Simplify the incremental engine API and internally store the topologically sorted engine nodes. - Change 'engine_abort_recompute' from global variable to argument to be passed to engine_run(). It's only relevant in one run context anyway as we used to reset it before every call to engine_run(). - engine_init_run() and engine_has_run() now check all the nodes in the engine instead of a single one. - Change 'engine_node_valid()' to call the node's 'is_valid' method only if the node is not in state EN_UPDATED or EN_VALID. v5: - Rebase. v4: - Address Numan's comments: - Fix engine_need_run(). v3: - split the change in series. - Address Han's comments: - fix the data encapsulation issue. - add is_valid method to nodes. - add internal_data/data fields to nodes as it makes it easier to write the code instead of adding an "engine_get_data()" API. v2: Address Han's comments: - call engine_node_valid() in all the places where node local data is used. - move out "global" data outside the engine nodes. Make a clear separation between data that can be safely used at any time and data that can be used only when the engine run was successful. - add a debug log for iterations when the engine didn't run. - refactor a bit more the incremental engine code.