Skip to content

Commit 7337adb

Browse files
danieljordan10gregkh
authored andcommitted
padata: Always leave BHs disabled when running ->parallel()
[ Upstream commit 34c3a47 ] A deadlock can happen when an overloaded system runs ->parallel() in the context of the current task: padata_do_parallel ->parallel() pcrypt_aead_enc/dec padata_do_serial spin_lock(&reorder->lock) // BHs still enabled <interrupt> ... __do_softirq ... padata_do_serial spin_lock(&reorder->lock) It's a bug for BHs to be on in _do_serial as Steffen points out, so ensure they're off in the "current task" case like they are in padata_parallel_worker to avoid this situation. Reported-by: [email protected] Fixes: 4611ce2 ("padata: allocate work structures for parallel jobs from a pool") Signed-off-by: Daniel Jordan <[email protected]> Acked-by: Steffen Klassert <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 4751b10 commit 7337adb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

kernel/padata.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,16 @@ int padata_do_parallel(struct padata_shell *ps,
207207
pw = padata_work_alloc();
208208
spin_unlock(&padata_works_lock);
209209

210+
if (!pw) {
211+
/* Maximum works limit exceeded, run in the current task. */
212+
padata->parallel(padata);
213+
}
214+
210215
rcu_read_unlock_bh();
211216

212217
if (pw) {
213218
padata_work_init(pw, padata_parallel_worker, padata, 0);
214219
queue_work(pinst->parallel_wq, &pw->pw_work);
215-
} else {
216-
/* Maximum works limit exceeded, run in the current task. */
217-
padata->parallel(padata);
218220
}
219221

220222
return 0;

0 commit comments

Comments
 (0)