linux/arch/s390
Harald Freudenberger 6f3196b74d s390/crypto: Rework on paes implementation
There have been some findings during Eric Biggers rework of the
paes implementation which this patch tries to address:

A very minor finding within paes ctr where when the cpacf instruction
returns with only partially data en/decrytped the walk_done() was
mistakenly done with the all data counter.  Please note this can only
happen when the kmctr returns because the protected key became invalid
in the middle of the operation. And this is only with suspend and
resume on a system with different effective wrapping key.

Eric Biggers mentioned that the context struct within the tfm struct
may be shared among multiple kernel threads. So here now a rework
which uses a spinlock per context to protect the read and write of the
protected key blob value. The en/decrypt functions copy the protected
key(s) at the beginning into a param struct and do not work with the
protected key within the context any more. If the protected key in the
param struct becomes invalid, the key material is again converted to
protected key(s) and the context gets this update protected by the
spinlock. Race conditions are still possible and may result in writing
the very same protected key value more than once. So the spinlock
needs to make sure the protected key(s) within the context are
consistent updated.

The ctr page is now locked by a mutex instead of a spinlock. A similar
patch went into the aes_s390 code as a result of a complain "sleeping
function called from invalid context at ...algapi.h". See
commit 1c2c7029c0 ("s390/crypto: fix possible sleep during spinlock
aquired")' for more.

During testing with instrumented code another issue with the xts
en/decrypt function revealed. The retry cleared the running iv value
and thus let to wrong en/decrypted data.

Tested and verified with additional testcases via AF_ALG interface and
additional selftests within the kernel (which will be made available
as soon as possible).

Reported-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2020-01-30 13:07:55 +01:00
..
appldata proc/sysctl: add shared variables for range check 2019-07-18 17:08:07 -07:00
boot s390: fix __EMIT_BUG() macro 2020-01-22 13:05:35 +01:00
configs locking/refcount: Consolidate implementations of refcount_t 2019-11-25 09:15:32 +01:00
crypto s390/crypto: Rework on paes implementation 2020-01-30 13:07:55 +01:00
hypfs Merge branch 'work.mount3' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2019-09-24 12:33:34 -07:00
include s390: support KPROBES_ON_FTRACE 2020-01-30 13:07:55 +01:00
kernel s390: support KPROBES_ON_FTRACE 2020-01-30 13:07:55 +01:00
kvm KVM: s390: small fixes and enhancements 2019-11-18 13:16:46 +01:00
lib s390/test_unwind: fix spelling mistake "reqister" -> "register" 2019-12-11 19:53:23 +01:00
mm s390/mm: fix dynamic pagetable upgrade for hugetlbfs 2020-01-30 13:07:54 +01:00
net s390/bpf: Remove JITed image size limitations 2019-11-18 19:51:16 -08:00
numa s390/numa: correct early_param handling 2019-08-26 12:51:17 +02:00
oprofile s390/unwind: introduce stack unwind API 2019-05-02 13:54:11 +02:00
pci s390/pci: Fix possible deadlock in recover_store() 2020-01-22 13:05:34 +01:00
purgatory s390/purgatory: do not build purgatory with kcov, kasan and friends 2019-12-18 23:29:26 +01:00
scripts s390/build: use size command to perform empty .bss check 2019-08-08 14:36:53 +02:00
tools s390: add support for IBM z15 machines 2019-09-13 12:19:14 +02:00
Kbuild s390/kexec_file: Add purgatory 2018-04-16 09:10:22 +02:00
Kconfig s390: support KPROBES_ON_FTRACE 2020-01-30 13:07:55 +01:00
Kconfig.debug Kconfig: consolidate the "Kernel hacking" menu 2018-08-02 08:06:48 +09:00
Makefile s390: adjust -mpacked-stack support check for clang 10 2020-01-22 13:05:35 +01:00