Skip to content

Commit b1d47d7

Browse files
danieljordan10gregkh
authored andcommitted
padata: always acquire cpu_hotplug_lock before pinst->lock
commit 38228e8 upstream. 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: 6751fb3 ("padata: Use get_online_cpus/put_online_cpus") Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com> Cc: Eric Biggers <ebiggers@kernel.org> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Steffen Klassert <steffen.klassert@secunet.com> Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 02c0b89 commit b1d47d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/padata.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,8 @@ int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type,
614614
struct cpumask *serial_mask, *parallel_mask;
615615
int err = -EINVAL;
616616

617-
mutex_lock(&pinst->lock);
618617
get_online_cpus();
618+
mutex_lock(&pinst->lock);
619619

620620
switch (cpumask_type) {
621621
case PADATA_CPU_PARALLEL:
@@ -633,8 +633,8 @@ int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type,
633633
err = __padata_set_cpumasks(pinst, parallel_mask, serial_mask);
634634

635635
out:
636-
put_online_cpus();
637636
mutex_unlock(&pinst->lock);
637+
put_online_cpus();
638638

639639
return err;
640640
}

0 commit comments

Comments
 (0)