]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: cryptd - Protect per-CPU resource by disabling BH.
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Wed, 4 May 2022 15:07:36 +0000 (17:07 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 13 May 2022 09:24:48 +0000 (17:24 +0800)
commit3b3ce7e947eec5e4387d7e4375244083e7be947a
tree6fa3579beb11a36d64b34a178cf992a9c5ef9e6c
parent64677a1b08da29e45f5273bdb69b690ebac14f15
crypto: cryptd - Protect per-CPU resource by disabling BH.

The access to cryptd_queue::cpu_queue is synchronized by disabling
preemption in cryptd_enqueue_request() and disabling BH in
cryptd_queue_worker(). This implies that access is allowed from BH.

If cryptd_enqueue_request() is invoked from preemptible context _and_
soft interrupt then this can lead to list corruption since
cryptd_enqueue_request() is not protected against access from
soft interrupt.

Replace get_cpu() in cryptd_enqueue_request() with local_bh_disable()
to ensure BH is always disabled.
Remove preempt_disable() from cryptd_queue_worker() since it is not
needed because local_bh_disable() ensures synchronisation.

Fixes: a39f9141e2a5 ("crypto: cryptd - Per-CPU thread implementation...")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/cryptd.c