All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: scompress - initialize per-CPU variables on each CPU
@ 2019-04-12 15:14 Sebastian Andrzej Siewior
  2019-04-12 18:10 ` Guenter Roeck
  2019-04-18 14:27 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-04-12 15:14 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: linux-crypto, Herbert Xu, tglx

In commit 71052dcf4be70 ("crypto: scompress - Use per-CPU struct instead
multiple variables") I accidentally initialized multiple times the memory on a
random CPU. I should have initialize the memory on every CPU like it has
been done earlier. I didn't notice this because the scheduler didn't
move the task to another CPU.
Guenter managed to do that and the code crashed as expected.

Allocate / free per-CPU memory on each CPU.

Fixes: 71052dcf4be70 ("crypto: scompress - Use per-CPU struct instead multiple variables")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
Guenter, this should cure that.

 crypto/scompress.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/crypto/scompress.c b/crypto/scompress.c
index da31f6fe1f833..712b4c2ea021f 100644
--- a/crypto/scompress.c
+++ b/crypto/scompress.c
@@ -76,7 +76,7 @@ static void crypto_scomp_free_scratches(void)
 	int i;
 
 	for_each_possible_cpu(i) {
-		scratch = raw_cpu_ptr(&scomp_scratch);
+		scratch = per_cpu_ptr(&scomp_scratch, i);
 
 		vfree(scratch->src);
 		vfree(scratch->dst);
@@ -93,7 +93,7 @@ static int crypto_scomp_alloc_scratches(void)
 	for_each_possible_cpu(i) {
 		void *mem;
 
-		scratch = raw_cpu_ptr(&scomp_scratch);
+		scratch = per_cpu_ptr(&scomp_scratch, i);
 
 		mem = vmalloc_node(SCOMP_SCRATCH_SIZE, cpu_to_node(i));
 		if (!mem)
-- 
2.20.1


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

* Re: [PATCH] crypto: scompress - initialize per-CPU variables on each CPU
  2019-04-12 15:14 [PATCH] crypto: scompress - initialize per-CPU variables on each CPU Sebastian Andrzej Siewior
@ 2019-04-12 18:10 ` Guenter Roeck
  2019-04-18 14:27 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2019-04-12 18:10 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: linux-crypto, Herbert Xu, tglx

On 4/12/19 8:14 AM, Sebastian Andrzej Siewior wrote:
> In commit 71052dcf4be70 ("crypto: scompress - Use per-CPU struct instead
> multiple variables") I accidentally initialized multiple times the memory on a
> random CPU. I should have initialize the memory on every CPU like it has
> been done earlier. I didn't notice this because the scheduler didn't
> move the task to another CPU.
> Guenter managed to do that and the code crashed as expected.
> 
> Allocate / free per-CPU memory on each CPU.
> 
> Fixes: 71052dcf4be70 ("crypto: scompress - Use per-CPU struct instead multiple variables")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> Guenter, this should cure that.

Yes, it does.

Tested-by: Guenter Roeck <linux@roeck-us.net>

Tested with the patch applied on top of next-20190412, running all
345 qemu boot tests. No boot failures or new warnings observed.
To be sure, I ran the arm64 boot tests twice.

Guenter

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

* Re: [PATCH] crypto: scompress - initialize per-CPU variables on each CPU
  2019-04-12 15:14 [PATCH] crypto: scompress - initialize per-CPU variables on each CPU Sebastian Andrzej Siewior
  2019-04-12 18:10 ` Guenter Roeck
@ 2019-04-18 14:27 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2019-04-18 14:27 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: Guenter Roeck, linux-crypto, tglx

On Fri, Apr 12, 2019 at 05:14:15PM +0200, Sebastian Andrzej Siewior wrote:
> In commit 71052dcf4be70 ("crypto: scompress - Use per-CPU struct instead
> multiple variables") I accidentally initialized multiple times the memory on a
> random CPU. I should have initialize the memory on every CPU like it has
> been done earlier. I didn't notice this because the scheduler didn't
> move the task to another CPU.
> Guenter managed to do that and the code crashed as expected.
> 
> Allocate / free per-CPU memory on each CPU.
> 
> Fixes: 71052dcf4be70 ("crypto: scompress - Use per-CPU struct instead multiple variables")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> Guenter, this should cure that.
> 
>  crypto/scompress.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2019-04-18 14:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12 15:14 [PATCH] crypto: scompress - initialize per-CPU variables on each CPU Sebastian Andrzej Siewior
2019-04-12 18:10 ` Guenter Roeck
2019-04-18 14:27 ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.