1
0
Fork 0
alistair23-linux/include
Herbert Xu bbefa1dd6a crypto: pcrypt - Avoid deadlock by using per-instance padata queues
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>
2019-12-11 16:36:45 +08:00
..
acpi Merge branches 'acpi-utils', 'acpi-platform', 'acpi-video' and 'acpi-doc' 2019-11-26 10:30:49 +01:00
asm-generic powerpc updates for 5.5 #2 2019-12-06 13:36:31 -08:00
clocksource x86/hyperv: Initialize clockevents earlier in CPU onlining 2019-11-15 10:33:49 +01:00
crypto crypto: ablkcipher - remove deprecated and unused ablkcipher support 2019-11-17 09:02:49 +08:00
drm mm + drm coherent memory support for vmwgfx 2019-11-30 09:38:11 -08:00
dt-bindings ARM: Device-tree updates 2019-12-05 12:09:47 -08:00
keys powerpc updates for 5.5 2019-11-30 14:35:43 -08:00
kunit
kvm
linux crypto: pcrypt - Avoid deadlock by using per-instance padata queues 2019-12-11 16:36:45 +08:00
math-emu
media drm main pull for 5.5-rc1 2019-11-27 17:45:48 -08:00
misc
net inet: protect against too small mtu values. 2019-12-07 11:55:11 -08:00
pcmcia
ras
rdma hmm related patches for 5.5 2019-11-30 10:33:14 -08:00
scsi scsi: target: iscsi: Wait for all commands to finish before freeing a session 2019-11-19 21:37:35 -05:00
soc drm msm + fixes for 5.5-rc1 2019-12-06 10:28:09 -08:00
sound ALSA: hda: Modify stream stripe mask only when needed 2019-12-03 07:46:30 +01:00
target
trace This is a relatively quiet cycle for nfsd, mainly various bugfixes. 2019-12-07 16:56:00 -08:00
uapi Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2019-12-07 18:33:01 -08:00
vdso
video
xen dma-mapping updates for 5.5-rc1 2019-11-28 11:16:43 -08:00