linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.14 01/29] ima: always return negative code for error
@ 2019-10-01 16:43 Sasha Levin
  2019-10-01 16:43 ` [PATCH AUTOSEL 4.14 02/29] fs: nfs: Fix possible null-pointer dereferences in encode_attrs() Sasha Levin
                   ` (27 more replies)
  0 siblings, 28 replies; 29+ messages in thread
From: Sasha Levin @ 2019-10-01 16:43 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Sascha Hauer, Mimi Zohar, Sasha Levin, linux-integrity,
	linux-security-module

From: Sascha Hauer <s.hauer@pengutronix.de>

[ 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 | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c
index af680b5b678a4..06b0ee75f34fb 100644
--- a/security/integrity/ima/ima_crypto.c
+++ b/security/integrity/ima/ima_crypto.c
@@ -293,8 +293,11 @@ static int ima_calc_file_hash_atfm(struct file *file,
 		rbuf_len = min_t(loff_t, i_size - offset, rbuf_size[active]);
 		rc = integrity_kernel_read(file, offset, rbuf[active],
 					   rbuf_len);
-		if (rc != rbuf_len)
+		if (rc != rbuf_len) {
+			if (rc >= 0)
+				rc = -EINVAL;
 			goto out3;
+		}
 
 		if (rbuf[1] && offset) {
 			/* Using two buffers, and it is not the first
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2019-10-01 16:51 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01 16:43 [PATCH AUTOSEL 4.14 01/29] ima: always return negative code for error Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.14 02/29] fs: nfs: Fix possible null-pointer dereferences in encode_attrs() Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.14 03/29] 9p: avoid attaching writeback_fid on mmap with type PRIVATE Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.14 04/29] xen/pci: reserve MCFG areas earlier Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.14 05/29] ceph: fix directories inode i_blkbits initialization Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 06/29] ceph: reconnect connection if session hang in opening state Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 07/29] rbd: fix response length parameter for encoded strings Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 08/29] watchdog: aspeed: Add support for AST2600 Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 09/29] netfilter: nf_tables: allow lookups in dynamic sets Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 10/29] drm/amdgpu: Check for valid number of registers to read Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 11/29] pNFS: Ensure we do clear the return-on-close layout stateid on fatal errors Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 12/29] net/sched: act_sample: don't push mac header on ip6gre ingress Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 13/29] pwm: stm32-lp: Add check in case requested period cannot be achieved Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 14/29] cdc_ncm: fix divide-by-zero caused by invalid wMaxPacketSize Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 15/29] usbnet: ignore endpoints with " Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 16/29] net/phy: fix DP83865 10 Mbps HDX loopback disable function Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 17/29] net_sched: add max len check for TCA_KIND Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 18/29] thermal: Fix use-after-free when unregistering thermal zone device Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 19/29] fuse: fix memleak in cuse_channel_open Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 20/29] arcnet: provide a buffer big enough to actually receive packets Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 21/29] ppp: Fix memory leak in ppp_write Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 22/29] sched/core: Fix migration to invalid CPU in __set_cpus_allowed_ptr() Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 23/29] perf build: Add detection of java-11-openjdk-devel package Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 24/29] kernel/elfcore.c: include proper prototypes Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 25/29] kexec: bail out upon SIGKILL when allocating memory Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 26/29] macsec: drop skb sk before calling gro_cells_receive Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 27/29] perf unwind: Fix libunwind build failure on i386 systems Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 28/29] usbnet: sanity checking of packet sizes and device mtu Sasha Levin
2019-10-01 16:44 ` [PATCH AUTOSEL 4.14 29/29] sch_netem: fix a divide by zero in tabledist() Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).