linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.9 01/22] netfilter: nfnetlink: avoid deadlock due to synchronous request_module
@ 2019-08-02 13:25 Sasha Levin
  2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 02/22] iscsi_ibft: make ISCSI_IBFT dependson ACPI instead of ISCSI_IBFT_FIND Sasha Levin
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: Sasha Levin @ 2019-08-02 13:25 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Florian Westphal, Thomas Jarosch, Juliana Rodrigueiro,
	Pablo Neira Ayuso, Sasha Levin, netfilter-devel, coreteam,
	netdev

From: Florian Westphal <fw@strlen.de>

[ Upstream commit 1b0890cd60829bd51455dc5ad689ed58c4408227 ]

Thomas and Juliana report a deadlock when running:

(rmmod nf_conntrack_netlink/xfrm_user)

  conntrack -e NEW -E &
  modprobe -v xfrm_user

They provided following analysis:

conntrack -e NEW -E
    netlink_bind()
        netlink_lock_table() -> increases "nl_table_users"
            nfnetlink_bind()
            # does not unlock the table as it's locked by netlink_bind()
                __request_module()
                    call_usermodehelper_exec()

This triggers "modprobe nf_conntrack_netlink" from kernel, netlink_bind()
won't return until modprobe process is done.

"modprobe xfrm_user":
    xfrm_user_init()
        register_pernet_subsys()
            -> grab pernet_ops_rwsem
                ..
                netlink_table_grab()
                    calls schedule() as "nl_table_users" is non-zero

so modprobe is blocked because netlink_bind() increased
nl_table_users while also holding pernet_ops_rwsem.

"modprobe nf_conntrack_netlink" runs and inits nf_conntrack_netlink:
    ctnetlink_init()
        register_pernet_subsys()
            -> blocks on "pernet_ops_rwsem" thanks to xfrm_user module

both modprobe processes wait on one another -- neither can make
progress.

Switch netlink_bind() to "nowait" modprobe -- this releases the netlink
table lock, which then allows both modprobe instances to complete.

Reported-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
Reported-by: Juliana Rodrigueiro <juliana.rodrigueiro@intra2net.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/netfilter/nfnetlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 2278d9ab723bf..9837a61cb3e3b 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -490,7 +490,7 @@ static int nfnetlink_bind(struct net *net, int group)
 	ss = nfnetlink_get_subsys(type << 8);
 	rcu_read_unlock();
 	if (!ss)
-		request_module("nfnetlink-subsys-%d", type);
+		request_module_nowait("nfnetlink-subsys-%d", type);
 	return 0;
 }
 #endif
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-08-02 13:30 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-02 13:25 [PATCH AUTOSEL 4.9 01/22] netfilter: nfnetlink: avoid deadlock due to synchronous request_module Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 02/22] iscsi_ibft: make ISCSI_IBFT dependson ACPI instead of ISCSI_IBFT_FIND Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 03/22] mac80211: don't warn about CW params when not using them Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 04/22] hwmon: (nct6775) Fix register address and added missed tolerance for nct6106 Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 05/22] x86/mm: Check for pfn instead of page in vmalloc_sync_one() Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 06/22] x86/mm: Sync also unmappings in vmalloc_sync_all() Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 07/22] drm/msm: stop abusing dma_map/unmap for cache Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 08/22] cpufreq/pasemi: fix use-after-free in pas_cpufreq_cpu_init() Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 09/22] s390/qdio: add sanity checks to the fast-requeue path Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 10/22] ALSA: compress: Fix regression on compressed capture streams Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 11/22] ALSA: compress: Prevent bypasses of set_params Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 12/22] ALSA: compress: Don't allow paritial drain operations on capture streams Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 13/22] ALSA: compress: Be more restrictive about when a drain is allowed Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 14/22] perf probe: Avoid calling freeing routine multiple times for same pointer Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 15/22] drbd: dynamically allocate shash descriptor Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 16/22] ACPI/IORT: Fix off-by-one check in iort_dev_find_its_id() Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 17/22] ARM: davinci: fix sleep.S build error on ARMv4 Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 18/22] scsi: megaraid_sas: fix panic on loading firmware crashdump Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 19/22] scsi: ibmvfc: fix WARN_ON during event pool release Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 20/22] scsi: scsi_dh_alua: always use a 2 second delay before retrying RTPG Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 21/22] tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed sleep loop Sasha Levin
2019-08-02 13:25 ` [PATCH AUTOSEL 4.9 22/22] perf/core: Fix creating kernel counters for PMUs that override event->cpu Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).