[PATCH 09/27] netlink: decode crypto_user_alg attributes of CRYPTOCFGA_REPORT_HASH

JingPiao Chen chenjingpiao at gmail.com
Sat Jul 22 12:43:39 UTC 2017


* configure.ac (AC_CHECK_TYPES): Add struct crypto_report_hash.
* netlink_crypto.c (decode_crypto_report_hash): New function.
(crypto_user_alg_nla_decoders): Add CRYPTOCFGA_REPORT_HASH.
---
 configure.ac     |  1 +
 netlink_crypto.c | 27 ++++++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 99d2c6e..0a0625f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -321,6 +321,7 @@ AC_CHECK_TYPES(m4_normalize([
 #include <linux/fcntl.h>])
 
 AC_CHECK_TYPES(m4_normalize([
+	struct crypto_report_hash,
 	struct crypto_report_larval
 ]),,, [#include <linux/cryptouser.h>])
 
diff --git a/netlink_crypto.c b/netlink_crypto.c
index 9a9635b..9bde8a5 100644
--- a/netlink_crypto.c
+++ b/netlink_crypto.c
@@ -59,9 +59,34 @@ decode_crypto_report_larval(struct tcb *const tcp,
 	return true;
 }
 
+static bool
+decode_crypto_report_hash(struct tcb *const tcp,
+			  const kernel_ulong_t addr,
+			  const unsigned int len,
+			  const void *const opaque_data)
+{
+# ifdef HAVE_STRUCT_CRYPTO_REPORT_HASH
+	struct crypto_report_hash rhash;
+
+	if (len < sizeof(rhash))
+		printstrn(tcp, addr, len);
+	else if (!umove_or_printaddr(tcp, addr, &rhash)) {
+		PRINT_FIELD_CSTRING("{", rhash, type);
+		PRINT_FIELD_U(", ", rhash, blocksize);
+		PRINT_FIELD_U(", ", rhash, digestsize);
+		tprints("}");
+	}
+# else
+	printstrn(tcp, addr, len);
+# endif
+
+	return true;
+}
+
 static const nla_decoder_t crypto_user_alg_nla_decoders[] = {
 	[CRYPTOCFGA_PRIORITY_VAL]	= decode_nla_u32,
-	[CRYPTOCFGA_REPORT_LARVAL]	= decode_crypto_report_larval
+	[CRYPTOCFGA_REPORT_LARVAL]	= decode_crypto_report_larval,
+	[CRYPTOCFGA_REPORT_HASH]	= decode_crypto_report_hash
 };
 
 static void
-- 
2.7.4





More information about the Strace-devel mailing list