Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1948287ybv; Fri, 14 Feb 2020 08:42:42 -0800 (PST) X-Google-Smtp-Source: APXvYqzyqD5M4L0nKF7JI5mLD70x3f1higd79oRO03SjQkVLymL1xl/EtJQNOGVoZTa5fzqalddz X-Received: by 2002:a9d:170a:: with SMTP id i10mr3001583ota.284.1581698562842; Fri, 14 Feb 2020 08:42:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581698562; cv=none; d=google.com; s=arc-20160816; b=z3/gt4GWmTh/0PuX8CNjwZXsNIdhlIZcyAy81YgKj3cid8w2wBVw2uHWNwQHP6FCsB +mhush1XONWGqZ38tzT6DWgRCgxyP3nyj2OGvQtxPq2moVrCruyREeEk83xsWK7cLS0C Es2sDwbzG/EBrizr0ZD9hnMw5BBWBtinzMqI6XnHIehCa2+MyTi3MKaXt3TlcxFnvowH 4PsOV7QKxnyhisEHfi8F+HxbfC77tj51K6DHYJAZ1FLeu9LhlLemqIn+bA0T9t/twOcN +/+ORuWdbS44a7sSSEoSrr6oubZrJ65YSuDKmqB198HS7R+VAe1QmydlqVtza1BaIk/n ROzg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uPSKKGe4t0oV8QPVoFNNWr2o1F0wfdi05UnwZx0WeaI=; b=tFUrUKOVvs93tiu6cVmMsdPBenbCtTN37p66MSVF5xC/UibRsgpZXfafdoyp+qNH+Y 0Qv/IwQVG7uC9AX+ZM9aIu+mQrDs3bZKf05a82tip2wwJ1V/mUsyklL6Vs/NvKvlJ76i 6yyun+x2/GvtVr1i0Ilyj7bJqoQE313yb/lDi/xHpm875vPC6Dyga4AwyM6JMFoS7INA JH9CbTvLKBZbWoi3Q6fb7iZ6lEmCIdrWTm9dL++l+el6B3KhyQfdXDCO+YLqLLxiPo9T tzx7WbBnquqJUoPGLDDi4JLIe1RkiAz3aclVAmrBDi1iyumyZV7STGmrKlj0WjXyzY/d RjpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y5h4oDPL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si3225295otn.140.2020.02.14.08.42.30; Fri, 14 Feb 2020 08:42:42 -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=y5h4oDPL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405705AbgBNQlr (ORCPT + 99 others); Fri, 14 Feb 2020 11:41:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:58096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405464AbgBNQWc (ORCPT ); Fri, 14 Feb 2020 11:22:32 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4C664246B0; Fri, 14 Feb 2020 16:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697351; bh=HDPTk9KMWGfmBO57K4dZYCHvm0cyIMknNFBja08viRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y5h4oDPLiwuz2HesGqh8uHIeS/Yc/OZpWWagFixiAcybiAFi8ExzslHs2E2abyItb Hi3pxZJtuOLy8SiGHnBA+zAzL0zsLt/jR1rQtjowVVikoY9qk078jt3tmZCQQQItoI Vs8Z8C5ONS/HlCuIJecwj821V6GZJKz07r3ZgCbY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Daniel Jordan , Eric Biggers , Herbert Xu , Steffen Klassert , linux-crypto@vger.kernel.org, Sasha Levin Subject: [PATCH AUTOSEL 4.9 054/141] padata: always acquire cpu_hotplug_lock before pinst->lock Date: Fri, 14 Feb 2020 11:19:54 -0500 Message-Id: <20200214162122.19794-54-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 63449fc584daf..ee5da2394cf57 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -635,8 +635,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: @@ -654,8 +654,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