*      Using root's kernel master key (kmk), calculate the HMAC
  */
 
+#define pr_fmt(fmt) "EVM: "fmt
+
 #include <linux/export.h>
 #include <linux/crypto.h>
 #include <linux/xattr.h>
            type != EVM_XATTR_PORTABLE_DIGSIG)
                crypto_shash_update(desc, (u8 *)&inode->i_sb->s_uuid, UUID_SIZE);
        crypto_shash_final(desc, digest);
+
+       pr_debug("hmac_misc: (%zu) [%*phN]\n", sizeof(struct h_misc),
+                (int)sizeof(struct h_misc), &hmac_misc);
+}
+
+/*
+ * Dump large security xattr values as a continuous ascii hexademical string.
+ * (pr_debug is limited to 64 bytes.)
+ */
+static void dump_security_xattr(const char *prefix, const void *src,
+                               size_t count)
+{
+#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
+       char *asciihex, *p;
+
+       p = asciihex = kmalloc(count * 2 + 1, GFP_KERNEL);
+       if (!asciihex)
+               return;
+
+       p = bin2hex(p, src, count);
+       *p = 0;
+       pr_debug("%s: (%zu) %.*s\n", prefix, count, (int)count * 2, asciihex);
+       kfree(asciihex);
+#endif
 }
 
 /*
                                             req_xattr_value_len);
                        if (is_ima)
                                ima_present = true;
+
+                       if (req_xattr_value_len < 64)
+                               pr_debug("%s: (%zu) [%*phN]\n", req_xattr_name,
+                                        req_xattr_value_len,
+                                        (int)req_xattr_value_len,
+                                        req_xattr_value);
+                       else
+                               dump_security_xattr(req_xattr_name,
+                                                   req_xattr_value,
+                                                   req_xattr_value_len);
                        continue;
                }
                size = vfs_getxattr_alloc(&init_user_ns, dentry, xattr->name,
                crypto_shash_update(desc, (const u8 *)xattr_value, xattr_size);
                if (is_ima)
                        ima_present = true;
+
+               if (xattr_size < 64)
+                       pr_debug("%s: (%zu) [%*phN]", xattr->name, xattr_size,
+                                (int)xattr_size, xattr_value);
+               else
+                       dump_security_xattr(xattr->name, xattr_value,
+                                           xattr_size);
        }
        hmac_add_misc(desc, inode, type, data->digest);