linux/include
Sebastian Andrzej Siewior e81cff1ced crypto: mcryptd - protect the per-CPU queue with a lock
commit 9abffc6f2e upstream.

mcryptd_enqueue_request() grabs the per-CPU queue struct and protects
access to it with disabled preemption. Then it schedules a worker on the
same CPU. The worker in mcryptd_queue_worker() guards access to the same
per-CPU variable with disabled preemption.

If we take CPU-hotplug into account then it is possible that between
queue_work_on() and the actual invocation of the worker the CPU goes
down and the worker will be scheduled on _another_ CPU. And here the
preempt_disable() protection does not work anymore. The easiest thing is
to add a spin_lock() to guard access to the list.

Another detail: mcryptd_queue_worker() is not processing more than
MCRYPTD_BATCH invocation in a row. If there are still items left, then
it will invoke queue_work() to proceed with more later. *I* would
suggest to simply drop that check because it does not use a system
workqueue and the workqueue is already marked as "CPU_INTENSIVE". And if
preemption is required then the scheduler should do it.
However if queue_work() is used then the work item is marked as CPU
unbound. That means it will try to run on the local CPU but it may run
on another CPU as well. Especially with CONFIG_DEBUG_WQ_FORCE_RR_CPU=y.
Again, the preempt_disable() won't work here but lock which was
introduced will help.
In order to keep work-item on the local CPU (and avoid RR) I changed it
to queue_work_on().

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2017-12-29 17:42:58 +01:00
..
acpi ACPICA: Linuxize: Restore and fix Intel compiler build 2017-02-26 11:10:52 +01:00
asm-generic percpu: make this_cpu_generic_read() atomic w.r.t. interrupts 2017-10-12 11:51:23 +02:00
clocksource clocksource/drivers/sp804: Convert init function to return error 2016-06-28 10:19:30 +02:00
crypto crypto: mcryptd - protect the per-CPU queue with a lock 2017-12-29 17:42:58 +01:00
drm drm: Don't race connector registration 2017-06-17 06:41:53 +02:00
dt-bindings ARM: dts: Fix omap3 off mode pull defines 2017-11-21 09:23:22 +01:00
keys KEYS: Strip trailing spaces 2016-06-14 10:29:44 +01:00
kvm ARM: KVM: Support vgic-v3 2016-09-22 13:22:21 +02:00
linux bpf: fix branch pruning logic 2017-12-25 14:23:47 +01:00
math-emu math-emu: fix floating-point to integer overflow detection 2014-01-07 18:36:24 -06:00
media Linux 4.8 2016-10-05 16:43:53 -03:00
memory ddr: add LPDDR2 data from JESD209-2 2012-05-02 00:04:06 -07:00
misc cxl: Add cxl_check_and_switch_mode() API to switch bi-modal cards 2016-07-14 20:28:11 +10:00
net vhost-vsock: add pkt cancel capability 2017-12-25 14:23:37 +01:00
pcmcia pcmcia/ds.h: introduce helper for pcmcia_driver module boilerplate 2013-03-15 12:26:03 -07:00
ras tracing, RAS: Cleanup on __get_str() usage 2016-07-15 15:51:16 -04:00
rdma IB/core: Fix calculation of maximum RoCE MTU 2017-12-20 10:07:32 +01:00
rxrpc rxrpc: Add tracepoint for ACK proposal 2016-09-23 15:49:19 +01:00
scsi scsi: libsas: align sata_device's rps_resp on a cacheline 2017-12-14 09:28:11 +01:00
soc ARM: at91: define LPDDR types 2017-03-12 06:41:41 +01:00
sound ALSA: seq: Avoid invalid lockdep class warning 2017-11-15 15:53:18 +01:00
target target: fix ALUA transition timeout handling 2017-12-20 10:07:26 +01:00
trace SUNRPC: Fix tracepoint storage issues with svc_recv and svc_rqst_status 2017-11-30 08:39:07 +00:00
uapi usb: add helper to extract bits 12:11 of wMaxPacketSize 2017-12-20 10:07:16 +01:00
video fbdev changes for 4.9 2016-10-12 11:01:37 -07:00
xen swiotlb-xen: implement xen_swiotlb_dma_mmap callback 2017-10-05 09:44:05 +02:00
Kbuild UAPI: remove empty Kbuild files 2013-04-30 17:04:09 -07:00