linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [stable-4.14 1/4] padata: set cpu_index of unused CPUs to -1
@ 2020-05-21 20:46 Daniel Jordan
  2020-05-21 20:46 ` [stable-4.14 2/4] padata: Replace delayed timer with immediate workqueue in padata_reorder Daniel Jordan
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Daniel Jordan @ 2020-05-21 20:46 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Sasha Levin
  Cc: Ben Hutchings, Herbert Xu, Mathias Krause, Steffen Klassert,
	stable, linux-crypto, Daniel Jordan

From: Mathias Krause <minipli@googlemail.com>

[ Upstream commit 1bd845bcb41d5b7f83745e0cb99273eb376f2ec5 ]

The parallel queue per-cpu data structure gets initialized only for CPUs
in the 'pcpu' CPU mask set. This is not sufficient as the reorder timer
may run on a different CPU and might wrongly decide it's the target CPU
for the next reorder item as per-cpu memory gets memset(0) and we might
be waiting for the first CPU in cpumask.pcpu, i.e. cpu_index 0.

Make the '__this_cpu_read(pd->pqueue->cpu_index) == next_queue->cpu_index'
compare in padata_get_next() fail in this case by initializing the
cpu_index member of all per-cpu parallel queues. Use -1 for unused ones.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>
---
 kernel/padata.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/padata.c b/kernel/padata.c
index 40a0ebb8ea51..858e82179744 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -462,8 +462,14 @@ static void padata_init_pqueues(struct parallel_data *pd)
 	struct padata_parallel_queue *pqueue;
 
 	cpu_index = 0;
-	for_each_cpu(cpu, pd->cpumask.pcpu) {
+	for_each_possible_cpu(cpu) {
 		pqueue = per_cpu_ptr(pd->pqueue, cpu);
+
+		if (!cpumask_test_cpu(cpu, pd->cpumask.pcpu)) {
+			pqueue->cpu_index = -1;
+			continue;
+		}
+
 		pqueue->pd = pd;
 		pqueue->cpu_index = cpu_index;
 		cpu_index++;
-- 
2.26.2


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

end of thread, other threads:[~2020-05-21 20:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21 20:46 [stable-4.14 1/4] padata: set cpu_index of unused CPUs to -1 Daniel Jordan
2020-05-21 20:46 ` [stable-4.14 2/4] padata: Replace delayed timer with immediate workqueue in padata_reorder Daniel Jordan
2020-05-21 20:46 ` [stable-4.14 3/4] padata: initialize pd->cpu with effective cpumask Daniel Jordan
2020-05-21 20:46 ` [stable-4.14 4/4] padata: purge get_cpu and reorder_via_wq from padata_do_serial Daniel Jordan

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).