Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3051532ybi; Tue, 2 Jul 2019 01:10:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUdf8DLQaObznrEaZxRHOTtoH53ZAOlmDQHi7llf1CR/bubjqi+P6yE0GzeS7z+BGdbNfc X-Received: by 2002:a63:6c04:: with SMTP id h4mr25797481pgc.94.1562055035906; Tue, 02 Jul 2019 01:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055035; cv=none; d=google.com; s=arc-20160816; b=irUVsB2Nd5AZ+3ElIWcSe2GNkYY1N5uYZtrhceElQe+coyDonMrENIrTyurQOjMmNX wBpTSpwVjNaijgylVfL5a3gdPG7qjnhR24Is6Ock6ELvYjLtW4tyyUFvFNKSacJxjNrR jAfi8Bo88UrT25rGjab49ch0H1D/BY8IinXGPHtHkRYtHU7yBLwrmTk2yhOBkYlZ/fnW Mpf47Zc515z3Booo1EuSjjvwmwuZeygSzS38RboHb8iFXLCAc8pjKysEQTrwhY0cq1v4 XOEfArpAA7ywA8a8NTTyerrOYElbxrfoTBeKkKosUoCk6+lNwnsFlLX/ycWCK/1aoDzk oYGA== 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=iB6G3LtVktg4XJt705c1JyEKsfWZoiuAmV4FIcDrPrc=; b=DOiXw1cmgPFJUc3aNMXpL4tZxv4rQ7+T9MbaT44djccnHBwNimQKPfyE++x7ILV4V0 +j2aKPjjpkni2rseVCesMqkPtF2+BCV5UG7xNZEjeGlJm+b9PnXrv+ibeFip+isHVl1A FlZLFHTf7gvSkOwNjBma2gSgOgUmI6r6zQx07KZZFbFvpckD8j3XnyHUPNPsd+zHiHJq JFifyhJaK6IrSQ0/KB8MytWXfkc8UsJXWZ+gqD9ic/zpkBq2EVoEvMrtP7ICEcPT8ZRD MG5i3T/x7NMWhH8LscC9w9R6EZTAt68YU57Fj0bjuSx8X8QKOlRh1jGdyQvFJSRDdLHq Dd7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DlaoqQX1; 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 k191si5395734pgd.25.2019.07.02.01.10.21; Tue, 02 Jul 2019 01:10:35 -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=DlaoqQX1; 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 S1728340AbfGBIH5 (ORCPT + 99 others); Tue, 2 Jul 2019 04:07:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:55240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727269AbfGBIHw (ORCPT ); Tue, 2 Jul 2019 04:07:52 -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 8E25C2184E; Tue, 2 Jul 2019 08:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054871; bh=7DQGuESCLaUEs01XjT2ZWgglXaxb0cRNK0S7RFfDxiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DlaoqQX1ClFL33yDerOrfSamVyhLul6ldi1TL6wEWP243zksu0H37Pgdg3tMfRSDr bE54Hmw+55kBiOuskDzlKBLCSuUKib9yauA0DcVmzB0s8C8dMtPD5+Q2RrwEC41stF 8VnAjsj5x24b7gTlLUO0uxkul8V2WJ05sNhXLZq8= 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.19 59/72] tipc: change to use register_pernet_device Date: Tue, 2 Jul 2019 10:02:00 +0200 Message-Id: <20190702080127.667772181@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.564652899@linuxfoundation.org> References: <20190702080124.564652899@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 @@ -132,7 +132,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; @@ -140,7 +140,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; @@ -151,11 +151,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: @@ -170,9 +170,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();