3 typedef int32_t key_serial_t;
5 #include "xlat/key_spec.h"
8 print_keyring_serial_number(key_serial_t id)
10 const char *str = xlookup(key_spec, id);
19 sys_add_key(struct tcb *tcp)
23 printstr(tcp, tcp->u_arg[0], -1);
26 printstr(tcp, tcp->u_arg[1], -1);
29 printstr(tcp, tcp->u_arg[2], tcp->u_arg[3]);
31 tprintf(", %lu, ", tcp->u_arg[3]);
32 /* keyring serial number */
33 print_keyring_serial_number(tcp->u_arg[4]);
39 sys_request_key(struct tcb *tcp)
43 printstr(tcp, tcp->u_arg[0], -1);
46 printstr(tcp, tcp->u_arg[1], -1);
49 printstr(tcp, tcp->u_arg[2], -1);
50 /* keyring serial number */
52 print_keyring_serial_number(tcp->u_arg[3]);
58 keyctl_get_keyring_id(struct tcb *tcp, key_serial_t id, int create)
62 print_keyring_serial_number(id);
63 tprintf(", %d", create);
69 keyctl_join_session_keyring(struct tcb *tcp, long addr)
73 printstr(tcp, addr, -1);
79 keyctl_update_key(struct tcb *tcp, key_serial_t id, long addr, long len)
83 print_keyring_serial_number(id);
85 printstr(tcp, addr, len);
86 tprintf(", %lu", len);
92 keyctl_handle_key(struct tcb *tcp, key_serial_t id)
96 print_keyring_serial_number(id);
102 keyctl_handle_key_key(struct tcb *tcp, key_serial_t id1, key_serial_t id2)
106 print_keyring_serial_number(id1);
108 print_keyring_serial_number(id2);
114 keyctl_read_key(struct tcb *tcp, key_serial_t id, long addr, long len)
118 print_keyring_serial_number(id);
121 if (addr && syserror(tcp))
122 tprintf("%#lx", addr);
124 long rval = tcp->u_rval > len ?
125 len : (tcp->u_rval ? -1 : 0);
126 printstr(tcp, addr, rval);
128 tprintf(", %lu", len);
134 keyctl_keyring_search(struct tcb *tcp, key_serial_t id1, long addr1,
135 long addr2, key_serial_t id2)
139 print_keyring_serial_number(id1);
141 printstr(tcp, addr1, -1);
143 printstr(tcp, addr2, -1);
145 print_keyring_serial_number(id2);
151 keyctl_chown_key(struct tcb *tcp, key_serial_t id, int user, int group)
155 print_keyring_serial_number(id);
156 tprintf(", %d, %d", user, group);
162 keyctl_instantiate_key(struct tcb *tcp, key_serial_t id1, long addr,
163 long len, key_serial_t id2)
167 print_keyring_serial_number(id1);
169 printstr(tcp, addr, len);
170 tprintf(", %lu, ", len);
171 print_keyring_serial_number(id2);
177 keyctl_instantiate_key_iov(struct tcb *tcp, key_serial_t id1,
178 long addr, long len, key_serial_t id2)
182 print_keyring_serial_number(id1);
184 tprint_iov(tcp, len, addr, 1);
185 tprintf(", %lu, ", len);
186 print_keyring_serial_number(id2);
192 keyctl_negate_key(struct tcb *tcp, key_serial_t id1, unsigned timeout,
197 print_keyring_serial_number(id1);
198 tprintf(", %u, ", timeout);
199 print_keyring_serial_number(id2);
205 keyctl_reject_key(struct tcb *tcp, key_serial_t id1, unsigned timeout,
206 unsigned error, key_serial_t id2)
210 print_keyring_serial_number(id1);
211 tprintf(", %u, %u, ", timeout, error);
212 print_keyring_serial_number(id2);
218 keyctl_set_timeout(struct tcb *tcp, key_serial_t id, unsigned timeout)
222 print_keyring_serial_number(id);
223 tprintf(", %u", timeout);
229 keyctl_get_persistent(struct tcb *tcp, int uid, key_serial_t id)
232 tprintf(", %d, ", uid);
233 print_keyring_serial_number(id);
238 #include "xlat/key_perms.h"
241 keyctl_setperm_key(struct tcb *tcp, key_serial_t id, uint32_t perm)
245 print_keyring_serial_number(id);
247 printflags(key_perms, perm, "KEY_???");
252 #include "xlat/key_reqkeys.h"
255 keyctl_set_reqkey_keyring(struct tcb *tcp, int reqkey)
259 printxval(key_reqkeys, reqkey, "KEY_REQKEY_DEFL_???");
264 #include "xlat/keyctl_commands.h"
267 sys_keyctl(struct tcb *tcp)
269 int cmd = tcp->u_arg[0];
272 printxval(keyctl_commands, cmd, "KEYCTL_???");
275 case KEYCTL_GET_KEYRING_ID:
276 return keyctl_get_keyring_id(tcp, tcp->u_arg[1], tcp->u_arg[2]);
278 case KEYCTL_JOIN_SESSION_KEYRING:
279 return keyctl_join_session_keyring(tcp, tcp->u_arg[1]);
282 return keyctl_update_key(tcp, tcp->u_arg[1],
283 tcp->u_arg[2], tcp->u_arg[3]);
287 case KEYCTL_INVALIDATE:
288 case KEYCTL_ASSUME_AUTHORITY:
289 return keyctl_handle_key(tcp, tcp->u_arg[1]);
293 return keyctl_handle_key_key(tcp, tcp->u_arg[1], tcp->u_arg[2]);
295 case KEYCTL_DESCRIBE:
297 case KEYCTL_GET_SECURITY:
298 return keyctl_read_key(tcp, tcp->u_arg[1],
299 tcp->u_arg[2], tcp->u_arg[3]);
302 return keyctl_keyring_search(tcp, tcp->u_arg[1], tcp->u_arg[2],
303 tcp->u_arg[3], tcp->u_arg[4]);
306 return keyctl_chown_key(tcp, tcp->u_arg[1],
307 tcp->u_arg[2], tcp->u_arg[3]);
310 return keyctl_setperm_key(tcp, tcp->u_arg[1], tcp->u_arg[2]);
312 case KEYCTL_INSTANTIATE:
313 return keyctl_instantiate_key(tcp, tcp->u_arg[1], tcp->u_arg[2],
314 tcp->u_arg[3], tcp->u_arg[4]);
317 return keyctl_negate_key(tcp, tcp->u_arg[1],
318 tcp->u_arg[2], tcp->u_arg[3]);
320 case KEYCTL_SET_REQKEY_KEYRING:
321 return keyctl_set_reqkey_keyring(tcp, tcp->u_arg[1]);
323 case KEYCTL_SET_TIMEOUT:
324 return keyctl_set_timeout(tcp, tcp->u_arg[1], tcp->u_arg[2]);
326 case KEYCTL_SESSION_TO_PARENT:
330 return keyctl_reject_key(tcp, tcp->u_arg[1], tcp->u_arg[2],
331 tcp->u_arg[3], tcp->u_arg[4]);
333 case KEYCTL_INSTANTIATE_IOV:
334 return keyctl_instantiate_key_iov(tcp, tcp->u_arg[1],
335 tcp->u_arg[2], tcp->u_arg[3],
338 case KEYCTL_GET_PERSISTENT:
339 return keyctl_get_persistent(tcp, tcp->u_arg[1], tcp->u_arg[2]);
343 tprintf(", %#lx, %#lx, %#lx, %#lx",
344 tcp->u_arg[1], tcp->u_arg[2],
345 tcp->u_arg[3], tcp->u_arg[4]);