linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/5] ima-evm-utils: Fix null dereference from file2bin to memcpy
@ 2019-07-12 21:28 Vitaly Chikunov
  2019-07-12 21:28 ` [PATCH v1 2/5] ima-evm-utils: Fix possible strcpy overflow Vitaly Chikunov
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Vitaly Chikunov @ 2019-07-12 21:28 UTC (permalink / raw)
  To: Mimi Zohar, Dmitry Kasatkin, linux-integrity

file2bin() may return NULL, which is set to tmp, which is passed to
memcpy. Add explicit check for it. CID 229904.
---
 src/evmctl.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/evmctl.c b/src/evmctl.c
index a6d07c9..39bc3d9 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -821,7 +821,15 @@ static int verify_ima(const char *file)
 	if (sigfile) {
 		void *tmp = file2bin(file, "sig", &len);
 
-		assert(len <= sizeof(sig));
+		if (!tmp) {
+			log_err("Failed reading: %s\n", file);
+			return -1;
+		}
+		if (len > sizeof(sig)) {
+			log_err("File is too big: %s\n", file);
+			free(tmp);
+			return -1;
+		}
 		memcpy(sig, tmp, len);
 		free(tmp);
 	} else {
-- 
2.11.0


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

end of thread, other threads:[~2019-07-15 20:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-12 21:28 [PATCH v1 1/5] ima-evm-utils: Fix null dereference from file2bin to memcpy Vitaly Chikunov
2019-07-12 21:28 ` [PATCH v1 2/5] ima-evm-utils: Fix possible strcpy overflow Vitaly Chikunov
2019-07-15 19:08   ` Mimi Zohar
2019-07-15 20:05     ` Vitaly Chikunov
2019-07-12 21:28 ` [PATCH v1 3/5] ima-evm-utils: Fix memory leak in get_password Vitaly Chikunov
2019-07-12 21:28 ` [PATCH v1 4/5] ima-evm-utils: Fix file2bin stat and fopen relations Vitaly Chikunov
2019-07-15 19:09   ` Mimi Zohar
2019-07-15 20:04     ` Vitaly Chikunov
2019-07-12 21:28 ` [PATCH v1 5/5] ima-evm-utils: Add more error checking in add_file_hash Vitaly Chikunov
2019-07-15 19:08 ` [PATCH v1 1/5] ima-evm-utils: Fix null dereference from file2bin to memcpy Mimi Zohar

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).