From patchwork Mon Jan 18 16:12:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1428223 Return-Path: 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.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DKGyr4Bm8z9sRf for ; Tue, 19 Jan 2021 03:12:36 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E243B85754; Mon, 18 Jan 2021 16:12:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L4pNQ3j4VJS8; Mon, 18 Jan 2021 16:12:32 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8F7338577C; Mon, 18 Jan 2021 16:12:32 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7272AC088B; Mon, 18 Jan 2021 16:12:32 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 61C04C013A for ; Mon, 18 Jan 2021 16:12:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 1EEC4866B9 for ; Mon, 18 Jan 2021 16:12:31 +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 SBy4BQ143wqY for ; Mon, 18 Jan 2021 16:12:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by whitealder.osuosl.org (Postfix) with ESMTPS id D225686673 for ; Mon, 18 Jan 2021 16:12:29 +0000 (UTC) X-Originating-IP: 78.45.89.65 Received: from im-t490s.redhat.com (ip-78-45-89-65.net.upcbroadband.cz [78.45.89.65]) (Authenticated sender: i.maximets@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 0B51D4001A; Mon, 18 Jan 2021 16:12:24 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Mon, 18 Jan 2021 17:12:23 +0100 Message-Id: <20210118161223.1049714-1-i.maximets@ovn.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Cc: Dumitru Ceara , Ilya Maximets Subject: [ovs-dev] [PATCH] ofproto-dpif-upcall: Fix ukey leak on udpif destroy. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Since commit 79eadafeb1b4 udpif_stop_threads() doesn't delete datapath flows while called from udpif_destroy(). This means that ukeys are not cleaned up either. So, hash maps in udpif->ukeys[] might still contain valid pointers to ukeys that should be destroyed before destroying the hash map itself: ==2783089==ERROR: LeakSanitizer: detected memory leaks Direct leak of 1560 byte(s) in 1 object(s) allocated from: # 0 0x7f8a57eae667 in __interceptor_malloc (/lib64/libasan.so.6+0xb0667) # 1 0x8411f6 in xmalloc lib/util.c:138 # 2 0x4d8a52 in ukey_create__ ofproto/ofproto-dpif-upcall.c:1682 # 3 0x4d99e3 in ukey_create_from_upcall ofproto/ofproto-dpif-upcall.c:1751 # 4 0x4d517d in upcall_xlate ofproto/ofproto-dpif-upcall.c:1242 # 5 0x4d63d2 in process_upcall ofproto/ofproto-dpif-upcall.c:1414 # 6 0x4d29f3 in recv_upcalls ofproto/ofproto-dpif-upcall.c:833 # 7 0x4d1ee1 in udpif_upcall_handler ofproto/ofproto-dpif-upcall.c:750 # 8 0x795aa2 in ovsthread_wrapper lib/ovs-thread.c:383 # 9 0x7f8a57a59431 in start_thread (/lib64/libpthread.so.0+0x9431) Fixes: 79eadafeb1b4 ("ofproto: Do not delete datapath flows on exit by default.") Reported-by: Dumitru Ceara Signed-off-by: Ilya Maximets Acked-by: William Tu --- ofproto/ofproto-dpif-upcall.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 5fae46adf..ccf97266c 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -491,6 +491,11 @@ udpif_destroy(struct udpif *udpif) dpif_register_upcall_cb(udpif->dpif, NULL, udpif); for (int i = 0; i < N_UMAPS; i++) { + struct udpif_key *ukey; + + CMAP_FOR_EACH (ukey, cmap_node, &udpif->ukeys[i].cmap) { + ukey_delete__(ukey); + } cmap_destroy(&udpif->ukeys[i].cmap); ovs_mutex_destroy(&udpif->ukeys[i].mutex); }