[PATCH 06/27] netlink: decode crypto_user_alg attributes of CRYPTOCFGA_REPORT_LARVAL

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


* configure.ac (AC_CHECK_TYPES): Add struct crypto_report_larval.
* netlink_crypto.c (decode_crypto_report_larval): New function.
(crypto_user_alg_nla_decoders): Add CRYPTOCFGA_REPORT_LARVAL.
---
 configure.ac     |  4 ++++
 netlink_crypto.c | 25 ++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 2c6e254..99d2c6e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -320,6 +320,10 @@ AC_CHECK_TYPES(m4_normalize([
 [#include <sys/types.h>
 #include <linux/fcntl.h>])
 
+AC_CHECK_TYPES(m4_normalize([
+	struct crypto_report_larval
+]),,, [#include <linux/cryptouser.h>])
+
 AC_CHECK_MEMBERS([struct timex.tai],,, [#include <sys/timex.h>])
 
 AC_CHECK_MEMBERS([struct utsname.domainname],,, [#include <sys/utsname.h>])
diff --git a/netlink_crypto.c b/netlink_crypto.c
index e39fdfc..9a9635b 100644
--- a/netlink_crypto.c
+++ b/netlink_crypto.c
@@ -37,8 +37,31 @@
 
 # include "xlat/crypto_nl_attrs.h"
 
+static bool
+decode_crypto_report_larval(struct tcb *const tcp,
+			    const kernel_ulong_t addr,
+			    const unsigned int len,
+			    const void *const opaque_data)
+{
+# ifdef HAVE_STRUCT_CRYPTO_REPORT_LARVAL
+	struct crypto_report_larval rl;
+
+	if (len < sizeof(rl))
+		printstr_ex(tcp, addr, len, QUOTE_0_TERMINATED);
+	else if (!umove_or_printaddr(tcp, addr, &rl)) {
+		PRINT_FIELD_CSTRING("{", rl, type);
+		tprints("}");
+	}
+# else
+	printstr_ex(tcp, addr, len, QUOTE_0_TERMINATED);
+# endif
+
+	return true;
+}
+
 static const nla_decoder_t crypto_user_alg_nla_decoders[] = {
-	[CRYPTOCFGA_PRIORITY_VAL]	= decode_nla_u32
+	[CRYPTOCFGA_PRIORITY_VAL]	= decode_nla_u32,
+	[CRYPTOCFGA_REPORT_LARVAL]	= decode_crypto_report_larval
 };
 
 static void
-- 
2.7.4





More information about the Strace-devel mailing list