When checking the binary blacklist, traverse every signer content digest
appended to the file. If one digest fails (-EPERM), the content is deemed
blocked.

Signed-off-by: Bruno Meneguele <[email protected]>
---
 security/integrity/ima/ima_appraise.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/security/integrity/ima/ima_appraise.c 
b/security/integrity/ima/ima_appraise.c
index 8aeec2778984..a62dc1aa93b4 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -432,18 +432,23 @@ int ima_check_blacklist(struct ima_iint_cache *iint,
        const char *sig_algo;
        const u8 *digest = NULL;
        u32 digestsize = 0;
+       unsigned int i, count;
        int rc = 0;
 
        if (!(iint->flags & IMA_CHECK_BLACKLIST))
                return 0;
 
        if (iint->flags & IMA_MODSIG_ALLOWED && modsig) {
-               if (ima_get_modsig_signer_count(modsig) == 1 &&
-                   !ima_get_modsig_digest(modsig, 0, &hash_algo, &digest,
-                                          &digestsize, &sig_algo))
-                       rc = is_binary_blacklisted(digest, digestsize);
-       } else if (iint->flags & IMA_DIGSIG_REQUIRED && iint->ima_hash)
+               count = ima_get_modsig_signer_count(modsig);
+               for (i = 0; i < count && rc != -EPERM; i++) {
+                       if (!ima_get_modsig_digest(modsig, i, &hash_algo,
+                                                  &digest, &digestsize,
+                                                  &sig_algo) && digestsize)
+                               rc = is_binary_blacklisted(digest, digestsize);
+               }
+       } else if (iint->flags & IMA_DIGSIG_REQUIRED && iint->ima_hash) {
                rc = is_binary_blacklisted(iint->ima_hash->digest, 
iint->ima_hash->length);
+       }
 
        if ((rc == -EPERM) && (iint->flags & IMA_MEASURE))
                process_buffer_measurement(&nop_mnt_idmap, NULL, digest, 
digestsize,
-- 
2.55.0


Reply via email to