summaryrefslogtreecommitdiffstats
path: root/patches/ima-evm-utils-1.0/0006-evmctl-Do-not-account-.-and-.-for-directory-hash-gen.patch
blob: 734994a31aec51107f3bff4f1c0b921a9ae4a8ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Mon, 1 Dec 2014 15:22:19 +0100
Subject: [PATCH] evmctl: Do not account '.' and '..' for directory hash
 generation

The '.' and '..' directories are in different order depending on the
filesystem, so the calculated hash for the directories differ aswell.
This means an image generated from an ext4 host filesystem won't be
usable on the target if it uses another order for the special directories.
Ignore the entries since they do not add to the security anyway.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 src/libimaevm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/libimaevm.c b/src/libimaevm.c
index 6b81e7e2d7aa..4eb37e2bf167 100644
--- a/src/libimaevm.c
+++ b/src/libimaevm.c
@@ -224,6 +224,9 @@ static int add_dir_hash(const char *file, EVP_MD_CTX *ctx)
 	}
 
 	while ((de = readdir(dir))) {
+		if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
+			continue;
+
 		if (params.image_mode) {
 			char *name;
 			char buf[128] = { };