From patchwork Sat Oct 7 00:44:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 822843 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=) 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 3y878B3l4cz9t5Y for ; Sat, 7 Oct 2017 11:45:14 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 56BE73EE; Sat, 7 Oct 2017 00:45:12 +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 105133EE for ; Sat, 7 Oct 2017 00:45:11 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7B3303FA for ; Sat, 7 Oct 2017 00:45:10 +0000 (UTC) X-Originating-IP: 173.228.112.34 Received: from sigabrt.gateway.sonic.net (173-228-112-34.dsl.dynamic.fusionbroadband.com [173.228.112.34]) (Authenticated sender: blp@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 28153A80C7; Sat, 7 Oct 2017 02:45:07 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Fri, 6 Oct 2017 17:44:46 -0700 Message-Id: <20171007004458.5788-2-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20171007004458.5788-1-blp@ovn.org> References: <20171007004458.5788-1-blp@ovn.org> X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 01/13] replication: Avoid theoretical use-after-free error in reset_database(). 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 Code that calls ovsdb_txn_row_delete() should avoid referencing the deleted row again, because it might be freed. In practice this shouldn't really happen in this case because of the particular circumstances, but it costs little to be careful. Signed-off-by: Ben Pfaff Acked-by: Russell Bryant --- ovsdb/replication.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ovsdb/replication.c b/ovsdb/replication.c index 304212d9d93a..47b0af19bbf6 100644 --- a/ovsdb/replication.c +++ b/ovsdb/replication.c @@ -529,8 +529,8 @@ reset_database(struct ovsdb *db) /* Delete all rows if the table is not blacklisted. */ if (!blacklist_tables_find(db->schema->name, table_node->name)) { struct ovsdb_table *table = table_node->data; - struct ovsdb_row *row; - HMAP_FOR_EACH (row, hmap_node, &table->rows) { + struct ovsdb_row *row, *next; + HMAP_FOR_EACH_SAFE (row, next, hmap_node, &table->rows) { ovsdb_txn_row_delete(txn, row); } }