Linux-Crypto Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] padata: initialize pd->cpu with effective cpumask
@ 2019-08-08 16:05 Daniel Jordan
  2019-08-08 16:54 ` Daniel Jordan
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jordan @ 2019-08-08 16:05 UTC (permalink / raw)
  To: Herbert Xu, Steffen Klassert; +Cc: Daniel Jordan, linux-crypto, linux-kernel

Exercising CPU hotplug on a 5.2 kernel with recent padata fixes from
cryptodev-2.6.git in an 8-CPU kvm guest...

    # modprobe tcrypt alg="pcrypt(rfc4106(gcm(aes)))" type=3
    # echo 0 > /sys/devices/system/cpu/cpu1/online
    # echo c > /sys/kernel/pcrypt/pencrypt/parallel_cpumask
    # modprobe tcrypt mode=215

...caused the following crash:

    BUG: kernel NULL pointer dereference, address: 0000000000000000
    #PF: supervisor read access in kernel mode
    #PF: error_code(0x0000) - not-present page
    PGD 0 P4D 0
    Oops: 0000 [#1] SMP PTI
    CPU: 2 PID: 134 Comm: kworker/2:2 Not tainted 5.2.0-padata-base+ #7
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-<snip>
    Workqueue: pencrypt padata_parallel_worker
    RIP: 0010:padata_reorder+0xcb/0x180
    ...
    Call Trace:
     padata_do_serial+0x57/0x60
     pcrypt_aead_enc+0x3a/0x50 [pcrypt]
     padata_parallel_worker+0x9b/0xe0
     process_one_work+0x1b5/0x3f0
     worker_thread+0x4a/0x3c0
     ...

In padata_alloc_pd, pd->cpu is set using the user-supplied cpumask
instead of the effective cpumask, and in this case cpumask_first picked
an offline CPU.

The offline CPU's reorder->list.next is NULL in padata_reorder because
the list wasn't initialized in padata_init_pqueues, which only operates
on CPUs in the effective mask.

Fix by using the effective mask in padata_alloc_pd.

Fixes: 726e431130f3 ("padata: Replace delayed timer with immediate workqueue in padata_reorder")
Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>
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
---

Hi, not sure what the normal process is for fixing patches in cryptodev
that haven't reached mainline yet.  Feel free to fold this in with the
Fixes patch if preferred.

Thanks,
Daniel

 kernel/padata.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/padata.c b/kernel/padata.c
index 7372fb45eeeb..b60cc3dcee58 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -426,7 +426,7 @@ static struct parallel_data *padata_alloc_pd(struct padata_instance *pinst,
 	atomic_set(&pd->refcnt, 0);
 	pd->pinst = pinst;
 	spin_lock_init(&pd->lock);
-	pd->cpu = cpumask_first(pcpumask);
+	pd->cpu = cpumask_first(pd->cpumask.pcpu);
 	INIT_WORK(&pd->reorder_work, invoke_padata_reorder);
 
 	return pd;
-- 
2.22.0


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

* Re: [PATCH] padata: initialize pd->cpu with effective cpumask
  2019-08-08 16:05 [PATCH] padata: initialize pd->cpu with effective cpumask Daniel Jordan
@ 2019-08-08 16:54 ` Daniel Jordan
  2019-08-09  6:20   ` Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jordan @ 2019-08-08 16:54 UTC (permalink / raw)
  To: Herbert Xu, Steffen Klassert; +Cc: linux-crypto, linux-kernel

On 8/8/19 12:05 PM, Daniel Jordan wrote:
> Fixes: 726e431130f3 ("padata: Replace delayed timer with immediate workqueue in padata_reorder")

Should be

	 6fc4dbcf0276 ("padata: Replace delayed timer with immediate workqueue in padata_reorder")


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

* Re: [PATCH] padata: initialize pd->cpu with effective cpumask
  2019-08-08 16:54 ` Daniel Jordan
@ 2019-08-09  6:20   ` Herbert Xu
  0 siblings, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2019-08-09  6:20 UTC (permalink / raw)
  To: Daniel Jordan; +Cc: Steffen Klassert, linux-crypto, linux-kernel

On Thu, Aug 08, 2019 at 12:54:16PM -0400, Daniel Jordan wrote:
> On 8/8/19 12:05 PM, Daniel Jordan wrote:
> >Fixes: 726e431130f3 ("padata: Replace delayed timer with immediate workqueue in padata_reorder")
> 
> Should be
> 
> 	 6fc4dbcf0276 ("padata: Replace delayed timer with immediate workqueue in padata_reorder")

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, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-08 16:05 [PATCH] padata: initialize pd->cpu with effective cpumask Daniel Jordan
2019-08-08 16:54 ` Daniel Jordan
2019-08-09  6:20   ` Herbert Xu

Linux-Crypto Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-crypto/0 linux-crypto/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-crypto linux-crypto/ https://lore.kernel.org/linux-crypto \
		linux-crypto@vger.kernel.org linux-crypto@archiver.kernel.org
	public-inbox-index linux-crypto

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-crypto


AGPL code for this site: git clone https://public-inbox.org/ public-inbox