/*
* Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2014-2017 The strace developers.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include "defs.h"
+#include "keyctl_kdf_params.h"
+#include "print_fields.h"
+
typedef int32_t key_serial_t;
#include "xlat/key_spec.h"
static void
print_keyring_serial_number(key_serial_t id)
{
- const char *str = xlookup(key_spec, (unsigned int) id);
-
- if (str)
- tprints(str);
- else
- tprintf("%d", id);
+ printxval_d(key_spec, id, NULL);
}
SYS_FUNC(add_key)
tprints(", ");
printstrn(tcp, tcp->u_arg[2], tcp->u_arg[3]);
/* payload length */
- tprintf(", %lu, ", tcp->u_arg[3]);
+ tprintf(", %" PRI_klu ", ", tcp->u_arg[3]);
/* keyring serial number */
print_keyring_serial_number(tcp->u_arg[4]);
print_keyring_serial_number(id1);
tprintf(", %u, ", timeout);
-
- if (err_str)
- tprintf("%s, ", err_str);
- else
- tprintf("%u, ", error);
-
+ print_xlat_ex(error, err_str, XLAT_STYLE_FMT_U);
+ tprints(", ");
print_keyring_serial_number(id2);
}
static void
keyctl_dh_compute(struct tcb *tcp, kernel_ulong_t params, kernel_ulong_t buf,
- kernel_ulong_t len)
+ kernel_ulong_t len, kernel_ulong_t kdf_addr)
{
if (entering(tcp)) {
print_dh_params(tcp, params);
tprints(", ");
} else {
+ struct strace_keyctl_kdf_params kdf;
+
if (syserror(tcp)) {
printaddr(buf);
} else {
(kernel_ulong_t) tcp->u_rval;
printstrn(tcp, buf, rval);
}
- tprintf(", %llu", zero_extend_signed_to_ull(len));
+ tprintf(", %llu, ", zero_extend_signed_to_ull(len));
+
+ if (fetch_keyctl_kdf_params(tcp, kdf_addr, &kdf)) {
+ printaddr(kdf_addr);
+ } else {
+ size_t i;
+
+ PRINT_FIELD_STR("{", kdf, hashname, tcp);
+
+ /*
+ * Kernel doesn't touch otherinfo
+ * if otherinfolen is zero.
+ */
+ if (kdf.otherinfolen)
+ PRINT_FIELD_STRN(", ", kdf, otherinfo,
+ kdf.otherinfolen, tcp);
+ else
+ PRINT_FIELD_PTR(", ", kdf, otherinfo);
+
+ PRINT_FIELD_U(", ", kdf, otherinfolen);
+
+ /* Some future-proofing */
+ for (i = 0; i < ARRAY_SIZE(kdf.__spare); i++) {
+ if (kdf.__spare[i])
+ break;
+ }
+
+ if (i < ARRAY_SIZE(kdf.__spare)) {
+ tprints(", __spare=[");
+
+ for (i = 0; i < ARRAY_SIZE(kdf.__spare); i++) {
+ if (i)
+ tprints(", ");
+
+ tprintf("%#x", kdf.__spare[i]);
+ }
+
+ tprints("]");
+ }
+
+ tprints("}");
+ }
}
}
+static void
+keyctl_restrict_keyring(struct tcb *const tcp,
+ const key_serial_t id,
+ const kernel_ulong_t addr1,
+ const kernel_ulong_t addr2)
+{
+ print_keyring_serial_number(id);
+ tprints(", ");
+ printstr(tcp, addr1);
+ tprints(", ");
+ printstr(tcp, addr2);
+}
+
#include "xlat/key_reqkeys.h"
#include "xlat/keyctl_commands.h"
SYS_FUNC(keyctl)
{
int cmd = tcp->u_arg[0];
- kernel_ulong_t arg2 = getarg_klu(tcp, 1);
- kernel_ulong_t arg3 = getarg_klu(tcp, 2);
- kernel_ulong_t arg4 = getarg_klu(tcp, 3);
- kernel_ulong_t arg5 = getarg_klu(tcp, 4);
+ kernel_ulong_t arg2 = tcp->u_arg[1];
+ kernel_ulong_t arg3 = tcp->u_arg[2];
+ kernel_ulong_t arg4 = tcp->u_arg[3];
+ kernel_ulong_t arg5 = tcp->u_arg[4];
if (entering(tcp)) {
printxval(keyctl_commands, cmd, "KEYCTL_???");
break;
case KEYCTL_SET_REQKEY_KEYRING:
- printxval(key_reqkeys, arg2, "KEY_REQKEY_DEFL_???");
+ printxvals_ex((int) arg2, "KEY_REQKEY_DEFL_???",
+ XLAT_STYLE_FMT_D, key_reqkeys, NULL);
break;
case KEYCTL_SET_TIMEOUT:
break;
case KEYCTL_DH_COMPUTE:
- keyctl_dh_compute(tcp, arg2, arg3, arg4);
+ keyctl_dh_compute(tcp, arg2, arg3, arg4, arg5);
return 0;
+ case KEYCTL_RESTRICT_KEYRING:
+ keyctl_restrict_keyring(tcp, arg2, arg3, arg4);
+ break;
+
default:
tprintf("%#" PRI_klx ", %#" PRI_klx
", %#" PRI_klx ", %#" PRI_klx,