From: Patrick Callaghan <patrickc@linux.ibm.com>
To: linux-integrity@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Sascha Hauer <s.hauer@pengutronix.de>,
Patrick Callaghan <patrickc@linux.ibm.com>,
Mimi Zohar <zohar@linux.ibm.com>
Subject: [PATCH] ima: avoid appraise error for hash calc interrupt
Date: Mon, 11 Nov 2019 14:23:48 -0500 [thread overview]
Message-ID: <20191111192348.30535-1-patrickc@linux.ibm.com> (raw)
The integrity_kernel_read() call in ima_calc_file_hash_tfm() can return
a value of 0 before all bytes of the file are read. A value of 0 would
normally indicate an EOF. This has been observed if a user process is
causing a file appraisal and is terminated with a SIGTERM signal. The
most common occurrence of seeing the problem is if a shutdown or systemd
reload is initiated while files are being appraised.
The problem is similar to commit <f5e1040196db> (ima: always return
negative code for error) that fixed the problem in
ima_calc_file_hash_atfm().
Suggested-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Patrick Callaghan <patrickc@linux.ibm.com>
---
security/integrity/ima/ima_crypto.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c
index 73044fc..7967a69 100644
--- a/security/integrity/ima/ima_crypto.c
+++ b/security/integrity/ima/ima_crypto.c
@@ -362,8 +362,10 @@ static int ima_calc_file_hash_tfm(struct file *file,
rc = rbuf_len;
break;
}
- if (rbuf_len == 0)
+ if (rbuf_len == 0) { /* unexpected EOF */
+ rc = -EINVAL;
break;
+ }
offset += rbuf_len;
rc = crypto_shash_update(shash, rbuf, rbuf_len);
--
2.8.3
next reply other threads:[~2019-11-11 19:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-11 19:23 Patrick Callaghan [this message]
2019-11-11 22:29 ` [PATCH] ima: avoid appraise error for hash calc interrupt Lakshmi Ramasubramanian
2019-11-12 17:14 ` Mimi Zohar
2019-11-12 17:33 ` Lakshmi Ramasubramanian
2019-11-12 18:12 ` Mimi Zohar
2019-11-14 13:55 ` Patrick Callaghan
2019-11-14 18:45 ` Lakshmi Ramasubramanian
2019-11-15 15:25 ` Patrick Callaghan
2019-11-15 20:34 ` Lakshmi Ramasubramanian
2019-11-13 7:52 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191111192348.30535-1-patrickc@linux.ibm.com \
--to=patrickc@linux.ibm.com \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).