Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1936817pxb; Fri, 29 Jan 2021 08:49:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRJdBaoBX5L91JKCrztrfFO407k0joOsfxbKUPnp48YHy7WzaS8YHgcScBw8w4RGfAJB9W X-Received: by 2002:aa7:dd4b:: with SMTP id o11mr6098067edw.303.1611938967759; Fri, 29 Jan 2021 08:49:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611938967; cv=none; d=google.com; s=arc-20160816; b=sXzYJDV+as8LVeQNx4ZglgErSxeZesK2g/lPsFky9Jfd7H5iGh8Buv+4RcTzW7dFUf jpqYIE4eGdHceN73+SYRBFtUZcjqTEdM+5CXjvAJ9tboiFggEIvgklpdacuNPoIWpEgr ua0H9cMr7sa6kjuP3YNHCe7TLxojxjYA5KiZjnjVoWQrx7wFodIvQC03hfLAB1nEQdn7 qctIscmhZbZJTzYL7IrmXEGTaiFIOe9K+IVUhjcG0/V/Se3NVB0W6qNpPn3tubbZulDg 1raQa0Q8EKX8Vo6ql/4ShTHX+1XMpj5nIO4LEwVxWD4//q66+rlIA3C8ZyajEf93yEoz ASMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:from:subject:organization :dkim-signature; bh=lncyBnRSwCr+gp+0N2c2Im6LydS91xklb476PalMYnA=; b=pe1hNZtMnPI3duMnfnKZ4yqHYkguYUaUQXGZEdLYa3JCHpqDycOkPObp3tqxYWFjQ7 A42rE+HDsD/VlKmbA8hfUipC498Y8IPz2JorXxjiF4zyKNAMe960eTpj/EYdYjud98fs 7z2eiJQjoAT6e777lg60f7MMJqeWdBOyJKjeTyhxlMpwyy6nQkGTeCq3KQrq5CXlpUJw WaRpuvsNR2kWIEKm4moWB11gbGo9EykzNe8HAAZTh7bWfIm9U4ofny0cNvN9wqj8anX+ ZJcxbWy/T/3rBamWJB2x3XV7jOYtKlVUz7dSwo255nHGqD66OTyDGk/7+org2gBppdX4 Zxcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ARwyoVGo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f10si5749465edc.491.2021.01.29.08.49.02; Fri, 29 Jan 2021 08:49:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ARwyoVGo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231960AbhA2QqP (ORCPT + 99 others); Fri, 29 Jan 2021 11:46:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56030 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231814AbhA2Qpe (ORCPT ); Fri, 29 Jan 2021 11:45:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611938648; 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=lncyBnRSwCr+gp+0N2c2Im6LydS91xklb476PalMYnA=; b=ARwyoVGoZlAh3/6sbLW1s6tzE/n+RyIK+K8yUVs5SfYg4TEnncwSSEu+xyd1jW1bwdP5Vq Zm6PNf1KUZvZC5yaCeIpKq4PHaC9bPuCjQsz/f656H81WME7EKxZaaor9hZh+qxboPAvPj Gl9XDEXhihbXr9TV0VouDUdRJzqX4zA= 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-586-aADtCFqwMhicv0DohJL8bg-1; Fri, 29 Jan 2021 11:44:04 -0500 X-MC-Unique: aADtCFqwMhicv0DohJL8bg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D87098030A2; Fri, 29 Jan 2021 16:44:02 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-115-23.rdu2.redhat.com [10.10.115.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id E91561971B; Fri, 29 Jan 2021 16:44:00 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH net] rxrpc: Fix deadlock around release of dst cached on udp tunnel From: David Howells To: vfedorenko@novek.ru Cc: syzbot+df400f2f24a1677cd7e0@syzkaller.appspotmail.com, netdev@vger.kernel.org, dhowells@redhat.com, linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Date: Fri, 29 Jan 2021 16:44:00 +0000 Message-ID: <161193864000.3781058.7593105791689441003.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org AF_RXRPC sockets use UDP ports in encap mode. This causes socket and dst from an incoming packet to get stolen and attached to the UDP socket from whence it is leaked when that socket is closed. When a network namespace is removed, the wait for dst records to be cleaned up happens before the cleanup of the rxrpc and UDP socket, meaning that the wait never finishes. Fix this by moving the rxrpc (and, by dependence, the afs) private per-network namespace registrations to the device group rather than subsys group. This allows cached rxrpc local endpoints to be cleared and their UDP sockets closed before we try waiting for the dst records. The symptom is that lines looking like the following: unregister_netdevice: waiting for lo to become free get emitted at regular intervals after running something like the referenced syzbot test. Thanks to Vadim for tracking this down and work out the fix. Reported-by: syzbot+df400f2f24a1677cd7e0@syzkaller.appspotmail.com Reported-by: Vadim Fedorenko Fixes: 5271953cad31 ("rxrpc: Use the UDP encap_rcv hook") Signed-off-by: David Howells --- fs/afs/main.c | 6 +++--- net/rxrpc/af_rxrpc.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/afs/main.c b/fs/afs/main.c index accdd8970e7c..b2975256dadb 100644 --- a/fs/afs/main.c +++ b/fs/afs/main.c @@ -193,7 +193,7 @@ static int __init afs_init(void) goto error_cache; #endif - ret = register_pernet_subsys(&afs_net_ops); + ret = register_pernet_device(&afs_net_ops); if (ret < 0) goto error_net; @@ -213,7 +213,7 @@ static int __init afs_init(void) error_proc: afs_fs_exit(); error_fs: - unregister_pernet_subsys(&afs_net_ops); + unregister_pernet_device(&afs_net_ops); error_net: #ifdef CONFIG_AFS_FSCACHE fscache_unregister_netfs(&afs_cache_netfs); @@ -244,7 +244,7 @@ static void __exit afs_exit(void) proc_remove(afs_proc_symlink); afs_fs_exit(); - unregister_pernet_subsys(&afs_net_ops); + unregister_pernet_device(&afs_net_ops); #ifdef CONFIG_AFS_FSCACHE fscache_unregister_netfs(&afs_cache_netfs); #endif diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c index 0a2f4817ec6c..41671af6b33f 100644 --- a/net/rxrpc/af_rxrpc.c +++ b/net/rxrpc/af_rxrpc.c @@ -990,7 +990,7 @@ static int __init af_rxrpc_init(void) goto error_security; } - ret = register_pernet_subsys(&rxrpc_net_ops); + ret = register_pernet_device(&rxrpc_net_ops); if (ret) goto error_pernet; @@ -1035,7 +1035,7 @@ static int __init af_rxrpc_init(void) error_sock: proto_unregister(&rxrpc_proto); error_proto: - unregister_pernet_subsys(&rxrpc_net_ops); + unregister_pernet_device(&rxrpc_net_ops); error_pernet: rxrpc_exit_security(); error_security: @@ -1057,7 +1057,7 @@ static void __exit af_rxrpc_exit(void) unregister_key_type(&key_type_rxrpc); sock_unregister(PF_RXRPC); proto_unregister(&rxrpc_proto); - unregister_pernet_subsys(&rxrpc_net_ops); + unregister_pernet_device(&rxrpc_net_ops); ASSERTCMP(atomic_read(&rxrpc_n_tx_skbs), ==, 0); ASSERTCMP(atomic_read(&rxrpc_n_rx_skbs), ==, 0);