1
0
Fork 0
alistair23-linux/include
Herbert Xu b4c8ed0bf9 crypto: pcrypt - Avoid deadlock by using per-instance padata queues
commit bbefa1dd6a upstream.

If the pcrypt template is used multiple times in an algorithm, then a
deadlock occurs because all pcrypt instances share the same
padata_instance, which completes requests in the order submitted.  That
is, the inner pcrypt request waits for the outer pcrypt request while
the outer request is already waiting for the inner.

This patch fixes this by allocating a set of queues for each pcrypt
instance instead of using two global queues.  In order to maintain
the existing user-space interface, the pinst structure remains global
so any sysfs modifications will apply to every pcrypt instance.

Note that when an update occurs we have to allocate memory for
every pcrypt instance.  Should one of the allocations fail we
will abort the update without rolling back changes already made.

The new per-instance data structure is called padata_shell and is
essentially a wrapper around parallel_data.

Reproducer:

	#include <linux/if_alg.h>
	#include <sys/socket.h>
	#include <unistd.h>

	int main()
	{
		struct sockaddr_alg addr = {
			.salg_type = "aead",
			.salg_name = "pcrypt(pcrypt(rfc4106-gcm-aesni))"
		};
		int algfd, reqfd;
		char buf[32] = { 0 };

		algfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
		bind(algfd, (void *)&addr, sizeof(addr));
		setsockopt(algfd, SOL_ALG, ALG_SET_KEY, buf, 20);
		reqfd = accept(algfd, 0, 0);
		write(reqfd, buf, 32);
		read(reqfd, buf, 16);
	}

Reported-by: syzbot+56c7151cad94eec37c521f0e47d2eee53f9361c4@syzkaller.appspotmail.com
Fixes: 5068c7a883 ("crypto: pcrypt - Add pcrypt crypto parallelization wrapper")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Tested-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-02-11 04:35:28 -08:00
..
acpi ACPI / utils: Move acpi_dev_get_first_match_dev() under CONFIG_ACPI 2019-12-17 19:56:29 +01:00
asm-generic asm-generic/nds32: don't redefine cacheflush primitives 2020-01-17 19:48:43 +01:00
clocksource clocksource/drivers/hyperv: Enable TSC page clocksource on 32bit 2019-08-23 16:59:54 +02:00
crypto crypto: algif_skcipher - Use chunksize instead of blocksize 2020-01-17 19:48:46 +01:00
drm drm: mst: Fix query_payload ack reply struct 2019-12-31 16:42:19 +01:00
dt-bindings dt-bindings: reset: meson8b: fix duplicate reset IDs 2020-01-23 08:22:28 +01:00
keys
kvm KVM: arm/arm64: vgic: Use a single IO device per redistributor 2019-08-25 11:02:52 +01:00
linux crypto: pcrypt - Avoid deadlock by using per-instance padata queues 2020-02-11 04:35:28 -08:00
math-emu nds32: Mark expected switch fall-throughs 2019-08-29 11:06:56 -05:00
media media: v4l2-rect.h: fix v4l2_rect_map_inside() top/left adjustments 2020-02-11 04:35:14 -08:00
misc
net cfg80211: Fix radar event during another phy CAC 2020-02-05 21:22:46 +00:00
pcmcia
ras
rdma RDMA/core: Fix ib_dma_max_seg_size() 2019-12-17 19:56:41 +01:00
scsi scsi: target: iscsi: Wait for all commands to finish before freeing a session 2020-01-04 19:18:17 +01:00
soc Char/Misc driver patches for 5.4-rc1 2019-09-18 11:14:31 -07:00
sound ALSA: hda: Apply aligned MMIO access only conditionally 2020-02-11 04:35:15 -08:00
target
trace memcg: fix a crash in wb_workfn when a device disappears 2020-02-11 04:35:11 -08:00
uapi rdma: Remove nes ABI header 2020-01-17 19:48:39 +01:00
vdso
video fbdev: da8xx: remove panel_power_ctrl() callback from platform data 2019-08-26 17:53:58 +05:30
xen xen: fixes and cleanups for 5.4-rc2 2019-10-04 11:13:09 -07:00
Kbuild - New Drivers 2019-09-23 19:37:49 -07:00