svc: check for allocation overflow in crypto calls part 2
svc: check for allocation overflow in crypto calls part 2

Without checking for overflow there is a risk of allocating a buffer
with size smaller than anticipated and as a consequence of that it might
lead to a heap based overflow with attacker controlled data written
outside the boundaries of the buffer.

Fixes: OP-TEE-2018-0011: "Integer overflow in crypto system calls (x2)"

Signed-off-by: Joakim Bech <741f90e2a7f4d9afbad8bd50be20560f4cf38962@linaro.org>
Tested-by: Joakim Bech <741f90e2a7f4d9afbad8bd50be20560f4cf38962@linaro.org> (QEMU v7, v8)
Reviewed-by: Jens Wiklander <7706914404370d7502c27a0eff493dcf491feb51@linaro.org>
Reported-by: Riscure <b5f9fc9e60751b217b3b089dcbd74cd514b67618@riscure.com>
Reported-by: Alyssa Milburn <a5c5029f43bc9836f7af03c99377ded51f71ff9b@vu.nl>
Acked-by: Etienne Carriere <f21bc5b8f3ea1962eb45af359f1abea6578cab94@linaro.org>

pascal-brand-st-dev/optee_os,pascal-brand-st-dev/optee_os,pascal-brand-st-dev/optee_os,pascal-brand-st-dev/optee_os,pascal-brand-st-dev/optee_os