ima: always return negative code for error
authorSascha Hauer <s.hauer@pengutronix.de>
Tue, 2 Jul 2019 08:00:40 +0000 (10:00 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Oct 2019 16:21:10 +0000 (18:21 +0200)
commitb69c3085fcc6839b2c86cab3b7ac9a38495a73ae
tree3dde972fa749cc723b8566485f1f2f9928780ff8
parent6df3c66de09de4e5a4e9564e19d156480caf1050
ima: always return negative code for error

[ Upstream commit f5e1040196dbfe14c77ce3dfe3b7b08d2d961e88 ]

integrity_kernel_read() returns the number of bytes read. If this is
a short read then this positive value is returned from
ima_calc_file_hash_atfm(). Currently this is only indirectly called from
ima_calc_file_hash() and this function only tests for the return value
being zero or nonzero and also doesn't forward the return value.
Nevertheless there's no point in returning a positive value as an error,
so translate a short read into -EINVAL.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
security/integrity/ima/ima_crypto.c