Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1615244ybv; Fri, 21 Feb 2020 00:19:55 -0800 (PST) X-Google-Smtp-Source: APXvYqyd15Y6ztldNo2cdOPg8dNhzfWF/jCIczmGcAhVNordVOvHkmH6nJ8jXzCFzmGV3LqiT2jK X-Received: by 2002:aca:f1c6:: with SMTP id p189mr1000748oih.159.1582273195177; Fri, 21 Feb 2020 00:19:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273195; cv=none; d=google.com; s=arc-20160816; b=x4qO/7JMe33U/YkflRHAKDVchkla4DtI1tkoS+M2QvNDKOaDNICNKJdPdstFfAS1Kv EgHG6U8ZLexjwHEwmYtk+yWL55BvfagTUKhtnzA32ool78Nm4HNHviyyGPg5aBY5EvHb auQxkYivrEpGufeltmt1XOzL6ppqRWiMy+byP415tgnZtX1pG4+Sw3PX1A+UL2PcMAHX B2Btbi9mZ0Qu3rqEHCIN7SeXwxY5C6NfUQPSOQMAyJ1+Njenh4OrUb1HOJWCFlnMqsxw 5EJ7KXeCDIvaPmDNtA1usSJPVbu4qtBlCp+O+/6TmIsQP/c09Nz5q0Ruvj+RF3I9/4OI 7mTw== 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=xE5ojAOjeOJXyFOx/CUChW16YZzXMuM0grNw7dHkahY=; b=QjlBEL8lhgKuE0VjMoOPJkSUYgdqy5qjMgLlCr6WyKcWB7Qi0WAlIaf96QMo7arenM 55IUfzddhVHhIk62mhWf720pK8o187pPfFfppwp2u4yaII0kIfvlujbX61e9dbwYn9iM V54uAP5PauwUUoI8zHN132LwvlV+eNoMe4qj3l8GVlwsh+eBP1+6SZoZvtbD0z3gddzi GbJiHiqoUp2GKXCdkUG5XunTgVeZnvPpiUd7E8D6JefWZz2JdJysXvo5nzaKofi6CUk+ v4i0MoHVD/K3dRChub4+SC8WsCHm6TKWxL7t4XDtMkN48/GTqWKtXKTBBYR3NTvt86PT 4HJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ALwLw8dy; 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 h6si1144330otk.276.2020.02.21.00.19.42; Fri, 21 Feb 2020 00:19:55 -0800 (PST) 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=ALwLw8dy; 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 S2387939AbgBUITA (ORCPT + 99 others); Fri, 21 Feb 2020 03:19:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:57132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387897AbgBUIS7 (ORCPT ); Fri, 21 Feb 2020 03:18:59 -0500 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 1C6CA24689; Fri, 21 Feb 2020 08:18:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273138; bh=fjEoFM/ZI/nczcEXkmdnLMMUAcHJBEZV0uX7k/XZlH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ALwLw8dyteAdQAbKRiBR1K/AVB2ZS9i8YFDnDxlqxKARNIMg5Kh8KNQOXpmcD1hxu BPjcEy/p00Vx7k4racnk71N7+sZhOogsH3+a+XjxSb8YHA1rwRx5Fk/wZysjxfS8cy cIt6SWfNAp8hlaoLhqEDSGom/sGwe0aqBVsk45LU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Jordan , Eric Biggers , Herbert Xu , Steffen Klassert , linux-crypto@vger.kernel.org, Sasha Levin Subject: [PATCH 4.19 061/191] padata: always acquire cpu_hotplug_lock before pinst->lock Date: Fri, 21 Feb 2020 08:40:34 +0100 Message-Id: <20200221072258.745173144@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@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: Daniel Jordan [ Upstream commit 38228e8848cd7dd86ccb90406af32de0cad24be3 ] lockdep complains when padata's paths to update cpumasks via CPU hotplug and sysfs are both taken: # echo 0 > /sys/devices/system/cpu/cpu1/online # echo ff > /sys/kernel/pcrypt/pencrypt/parallel_cpumask ====================================================== WARNING: possible circular locking dependency detected 5.4.0-rc8-padata-cpuhp-v3+ #1 Not tainted ------------------------------------------------------ bash/205 is trying to acquire lock: ffffffff8286bcd0 (cpu_hotplug_lock.rw_sem){++++}, at: padata_set_cpumask+0x2b/0x120 but task is already holding lock: ffff8880001abfa0 (&pinst->lock){+.+.}, at: padata_set_cpumask+0x26/0x120 which lock already depends on the new lock. padata doesn't take cpu_hotplug_lock and pinst->lock in a consistent order. Which should be first? CPU hotplug calls into padata with cpu_hotplug_lock already held, so it should have priority. Fixes: 6751fb3c0e0c ("padata: Use get_online_cpus/put_online_cpus") Signed-off-by: Daniel Jordan Cc: Eric Biggers Cc: Herbert Xu Cc: Steffen Klassert Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- kernel/padata.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/padata.c b/kernel/padata.c index cfab62923c452..c280cb153915f 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -671,8 +671,8 @@ int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type, struct cpumask *serial_mask, *parallel_mask; int err = -EINVAL; - mutex_lock(&pinst->lock); get_online_cpus(); + mutex_lock(&pinst->lock); switch (cpumask_type) { case PADATA_CPU_PARALLEL: @@ -690,8 +690,8 @@ int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type, err = __padata_set_cpumasks(pinst, parallel_mask, serial_mask); out: - put_online_cpus(); mutex_unlock(&pinst->lock); + put_online_cpus(); return err; } -- 2.20.1