From: Stefan Berger <stefanb@linux.ibm.com>
To: linux-integrity@vger.kernel.org
Cc: zohar@linux.ibm.com, Stefan Berger <stefanb@linux.ibm.com>
Subject: [PATCH ima-evm-utils v2 3/4] libimaevm: Remove calculation of a digest over a directory
Date: Thu, 8 Jul 2021 12:04:07 -0400 [thread overview]
Message-ID: <20210708160408.2779849-4-stefanb@linux.ibm.com> (raw)
In-Reply-To: <20210708160408.2779849-1-stefanb@linux.ibm.com>
Signature verification on directories is not supported by IMA in the
kernel, so remove the calculation of digests over directories.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
---
src/libimaevm.c | 37 -------------------------------------
1 file changed, 37 deletions(-)
diff --git a/src/libimaevm.c b/src/libimaevm.c
index 4d51901..07a25c9 100644
--- a/src/libimaevm.c
+++ b/src/libimaevm.c
@@ -177,40 +177,6 @@ out:
return err;
}
-static int add_dir_hash(const char *file, EVP_MD_CTX *ctx)
-{
- struct dirent *de;
- DIR *dir;
- unsigned long long ino;
- unsigned int type;
- int result = 0;
-
- dir = opendir(file);
- if (!dir) {
- log_err("Failed to open: %s\n", file);
- return -1;
- }
-
- while ((de = readdir(dir))) {
- ino = de->d_ino;
- type = de->d_type;
- log_debug("entry: %s, ino: %llu, type: %u, reclen: %hu\n",
- de->d_name, ino, type, de->d_reclen);
- if (EVP_DigestUpdate(ctx, de->d_name, strlen(de->d_name)) != 1 ||
- EVP_DigestUpdate(ctx, &ino, sizeof(ino)) != 1||
- EVP_DigestUpdate(ctx, &type, sizeof(type)) != 1) {
- log_err("EVP_DigestUpdate() failed\n");
- output_openssl_errors();
- result = 1;
- break;
- }
- }
-
- closedir(dir);
-
- return result;
-}
-
static int add_link_hash(const char *path, EVP_MD_CTX *ctx)
{
int len;
@@ -265,9 +231,6 @@ int ima_calc_hash(const char *file, uint8_t *hash)
case S_IFREG:
err = add_file_hash(file, pctx);
break;
- case S_IFDIR:
- err = add_dir_hash(file, pctx);
- break;
case S_IFLNK:
err = add_link_hash(file, pctx);
break;
--
2.31.1
next prev parent reply other threads:[~2021-07-08 16:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-08 16:04 [PATCH ima-evm-utils v2 0/4] libimaevm: Remove digest calculations not supported by IMA Stefan Berger
2021-07-08 16:04 ` [PATCH ima-evm-utils v2 1/4] evmctl: Remove filtering support for file types unsupported " Stefan Berger
2021-07-08 16:04 ` [PATCH ima-evm-utils v2 2/4] libimaevm: Remove calculation of a digest over a device file Stefan Berger
2021-07-08 16:04 ` Stefan Berger [this message]
2021-07-08 16:04 ` [PATCH ima-evm-utils v2 4/4] libimaevm: Remove calculation of a digest over a symbolic link Stefan Berger
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=20210708160408.2779849-4-stefanb@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=linux-integrity@vger.kernel.org \
--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).