aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/crypto/zcrypt_ccamisc.h
diff options
context:
space:
mode:
authorHarald Freudenberger <freude@linux.ibm.com>2020-01-22 10:29:33 +0100
committerVasily Gorbik <gor@linux.ibm.com>2020-01-30 13:07:55 +0100
commit6f3196b74d64fe4b0a51cefa6f2f80f7f55bcf49 (patch)
tree185db633166e981805910820ffb6dd51f2981343 /drivers/s390/crypto/zcrypt_ccamisc.h
parents390: support KPROBES_ON_FTRACE (diff)
downloadlinux-dev-6f3196b74d64fe4b0a51cefa6f2f80f7f55bcf49.tar.xz
linux-dev-6f3196b74d64fe4b0a51cefa6f2f80f7f55bcf49.zip
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 1c2c7029c008 ("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>
Diffstat (limited to '')
0 files changed, 0 insertions, 0 deletions