Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7152671ybi; Mon, 8 Jul 2019 15:42:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2jZg2h4YcSjEebUlXUV8LdutxmHTAvS5NvUJURTXh2R84cN5eiLDW/Oy8MnsUxc3kAuqK X-Received: by 2002:a17:90b:8d8:: with SMTP id ds24mr28248449pjb.135.1562625759987; Mon, 08 Jul 2019 15:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625759; cv=none; d=google.com; s=arc-20160816; b=xeYBBRKviXwtuOFpduGdOfN9TdZ0GlX1yuDvXE5tBe/DKZZK1SHbxjUbYSOgRqcc2K 0nQCIjJgZ2PPUSymW441glSpJcK7a6SLKQhgyMm+s+exo14+h52nu/r3B//TmeSopxje okZ31gJ5AHiyN9kMOQPztVWLtMmgdynii9nyCC27A0tacxPYe5tQOuzDlkHKmzw+BAwW 4bt/9g66X++0+f4YzvDGdGp23S0lw9M+qiYV1eOlRw+/HVxKGdgznrYT30UhpsbWtfCB odBGoySfxKQAC0O3RsYMM/r6GA8/KdxozZFBkIGKuIPs0Edi7DiEcUQSL1y7XeP+Q8IR MU6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Rt7rKhkMpMDYNTa2jiDnMEA7+hx2nsQjAVQwgNdgf2o=; b=J1mtjZKnNzFFXajNiIFp9lgo6kL500RtHqY9UUSOe7ZzSRWJ+HRZAnuCc7be/xoGk4 jrOOGwQtI4zBf6b0YzQu/SmFflFIEZKolmfZmWPLTE0ERA9KTmjKwAPWNv8ZeD0hYRZw 3qRCvqAOQtETJYLUOPUHOn6VAEUH+nIELrtrrfhR+gFTkwbr45GNIFNkJ6P3LRnXN8ML NFmWuIAsdtX9S+6ZIgUXiEzcyjHvP5fe4KeC/q8BRmfaT/gP/d/3niP/cVw7/FxMy5HC 1v/+67Z4ffkiqa++eHKpuWiwpVpJ9gaEAhQ1EiA9hXGxlOZs1Y8kx9/hxTkM2bPauUO/ m5KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="J1oY5/3r"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si17392215plp.4.2019.07.08.15.42.25; Mon, 08 Jul 2019 15:42:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="J1oY5/3r"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391291AbfGHPqi (ORCPT + 99 others); Mon, 8 Jul 2019 11:46:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:46206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387662AbfGHPUy (ORCPT ); Mon, 8 Jul 2019 11:20:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 31EEF216E3; Mon, 8 Jul 2019 15:20:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599253; bh=YLcbfUXBUozGKSMWDKztSglmTCsQ+7TKQNM5VEuVoY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J1oY5/3r+jZ/INsEHEXhu/G34/buqLxbqcSWIBm/RWm2xVoaSgCAJLBgD+SxEDzc2 j8PT3LDmHaOXIuU0P816Ohyd1HVy/Lx+GDkhAA4Xeppj7jxLx/O5U57qKrumA6x3x5 JciSK7Dkg7nzPt0AOFm6n/f0hGr+lNXtwD6vRxzA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li Shuang , Xin Long , Jon Maloy , "David S. Miller" Subject: [PATCH 4.9 055/102] tipc: change to use register_pernet_device Date: Mon, 8 Jul 2019 17:12:48 +0200 Message-Id: <20190708150529.302275727@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150525.973820964@linuxfoundation.org> References: <20190708150525.973820964@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xin Long [ Upstream commit c492d4c74dd3f87559883ffa0f94a8f1ae3fe5f5 ] This patch is to fix a dst defcnt leak, which can be reproduced by doing: # ip net a c; ip net a s; modprobe tipc # ip net e s ip l a n eth1 type veth peer n eth1 netns c # ip net e c ip l s lo up; ip net e c ip l s eth1 up # ip net e s ip l s lo up; ip net e s ip l s eth1 up # ip net e c ip a a 1.1.1.2/8 dev eth1 # ip net e s ip a a 1.1.1.1/8 dev eth1 # ip net e c tipc b e m udp n u1 localip 1.1.1.2 # ip net e s tipc b e m udp n u1 localip 1.1.1.1 # ip net d c; ip net d s; rmmod tipc and it will get stuck and keep logging the error: unregister_netdevice: waiting for lo to become free. Usage count = 1 The cause is that a dst is held by the udp sock's sk_rx_dst set on udp rx path with udp_early_demux == 1, and this dst (eventually holding lo dev) can't be released as bearer's removal in tipc pernet .exit happens after lo dev's removal, default_device pernet .exit. "There are two distinct types of pernet_operations recognized: subsys and device. At creation all subsys init functions are called before device init functions, and at destruction all device exit functions are called before subsys exit function." So by calling register_pernet_device instead to register tipc_net_ops, the pernet .exit() will be invoked earlier than loopback dev's removal when a netns is being destroyed, as fou/gue does. Note that vxlan and geneve udp tunnels don't have this issue, as the udp sock is released in their device ndo_stop(). This fix is also necessary for tipc dst_cache, which will hold dsts on tx path and I will introduce in my next patch. Reported-by: Li Shuang Signed-off-by: Xin Long Acked-by: Jon Maloy Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tipc/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/net/tipc/core.c +++ b/net/tipc/core.c @@ -128,7 +128,7 @@ static int __init tipc_init(void) if (err) goto out_sysctl; - err = register_pernet_subsys(&tipc_net_ops); + err = register_pernet_device(&tipc_net_ops); if (err) goto out_pernet; @@ -136,7 +136,7 @@ static int __init tipc_init(void) if (err) goto out_socket; - err = register_pernet_subsys(&tipc_topsrv_net_ops); + err = register_pernet_device(&tipc_topsrv_net_ops); if (err) goto out_pernet_topsrv; @@ -147,11 +147,11 @@ static int __init tipc_init(void) pr_info("Started in single node mode\n"); return 0; out_bearer: - unregister_pernet_subsys(&tipc_topsrv_net_ops); + unregister_pernet_device(&tipc_topsrv_net_ops); out_pernet_topsrv: tipc_socket_stop(); out_socket: - unregister_pernet_subsys(&tipc_net_ops); + unregister_pernet_device(&tipc_net_ops); out_pernet: tipc_unregister_sysctl(); out_sysctl: @@ -166,9 +166,9 @@ out_netlink: static void __exit tipc_exit(void) { tipc_bearer_cleanup(); - unregister_pernet_subsys(&tipc_topsrv_net_ops); + unregister_pernet_device(&tipc_topsrv_net_ops); tipc_socket_stop(); - unregister_pernet_subsys(&tipc_net_ops); + unregister_pernet_device(&tipc_net_ops); tipc_netlink_stop(); tipc_netlink_compat_stop(); tipc_unregister_sysctl();