1 /* keyctl.c: userspace keyctl operations
3 * Copyright (C) 2004-5 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/sched.h>
15 #include <linux/slab.h>
16 #include <linux/syscalls.h>
17 #include <linux/keyctl.h>
19 #include <linux/capability.h>
20 #include <linux/string.h>
21 #include <linux/err.h>
22 #include <linux/vmalloc.h>
23 #include <linux/security.h>
24 #include <asm/uaccess.h>
27 static int key_get_type_from_user(char *type,
28 const char __user *_type,
33 ret = strncpy_from_user(type, _type, len);
38 if (ret == 0 || ret >= len)
49 /*****************************************************************************/
51 * extract the description of a new key from userspace and either add it as a
52 * new key to the specified keyring or update a matching key in that keyring
53 * - the keyring must be writable
54 * - returns the new key's serial number
55 * - implements add_key()
57 asmlinkage long sys_add_key(const char __user *_type,
58 const char __user *_description,
59 const void __user *_payload,
63 key_ref_t keyring_ref, key_ref;
64 char type[32], *description;
70 if (plen > 1024 * 1024 - 1)
73 /* draw all the data into kernel space */
74 ret = key_get_type_from_user(type, _type, sizeof(type));
78 description = strndup_user(_description, PAGE_SIZE);
79 if (IS_ERR(description)) {
80 ret = PTR_ERR(description);
84 /* pull the payload in if one was supplied */
90 payload = kmalloc(plen, GFP_KERNEL);
92 if (plen <= PAGE_SIZE)
95 payload = vmalloc(plen);
101 if (copy_from_user(payload, _payload, plen) != 0)
105 /* find the target keyring (which must be writable) */
106 keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE);
107 if (IS_ERR(keyring_ref)) {
108 ret = PTR_ERR(keyring_ref);
112 /* create or update the requested key and add it to the target
114 key_ref = key_create_or_update(keyring_ref, type, description,
115 payload, plen, KEY_ALLOC_IN_QUOTA);
116 if (!IS_ERR(key_ref)) {
117 ret = key_ref_to_ptr(key_ref)->serial;
118 key_ref_put(key_ref);
121 ret = PTR_ERR(key_ref);
124 key_ref_put(keyring_ref);
135 } /* end sys_add_key() */
137 /*****************************************************************************/
139 * search the process keyrings for a matching key
140 * - nested keyrings may also be searched if they have Search permission
141 * - if a key is found, it will be attached to the destination keyring if
142 * there's one specified
143 * - /sbin/request-key will be invoked if _callout_info is non-NULL
144 * - the _callout_info string will be passed to /sbin/request-key
145 * - if the _callout_info string is empty, it will be rendered as "-"
146 * - implements request_key()
148 asmlinkage long sys_request_key(const char __user *_type,
149 const char __user *_description,
150 const char __user *_callout_info,
151 key_serial_t destringid)
153 struct key_type *ktype;
157 char type[32], *description, *callout_info;
160 /* pull the type into kernel space */
161 ret = key_get_type_from_user(type, _type, sizeof(type));
165 /* pull the description into kernel space */
166 description = strndup_user(_description, PAGE_SIZE);
167 if (IS_ERR(description)) {
168 ret = PTR_ERR(description);
172 /* pull the callout info into kernel space */
176 callout_info = strndup_user(_callout_info, PAGE_SIZE);
177 if (IS_ERR(callout_info)) {
178 ret = PTR_ERR(callout_info);
181 callout_len = strlen(callout_info);
184 /* get the destination keyring if specified */
187 dest_ref = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE);
188 if (IS_ERR(dest_ref)) {
189 ret = PTR_ERR(dest_ref);
194 /* find the key type */
195 ktype = key_type_lookup(type);
197 ret = PTR_ERR(ktype);
202 key = request_key_and_link(ktype, description, callout_info,
203 callout_len, NULL, key_ref_to_ptr(dest_ref),
216 key_ref_put(dest_ref);
224 } /* end sys_request_key() */
226 /*****************************************************************************/
228 * get the ID of the specified process keyring
229 * - the keyring must have search permission to be found
230 * - implements keyctl(KEYCTL_GET_KEYRING_ID)
232 long keyctl_get_keyring_ID(key_serial_t id, int create)
237 key_ref = lookup_user_key(NULL, id, create, 0, KEY_SEARCH);
238 if (IS_ERR(key_ref)) {
239 ret = PTR_ERR(key_ref);
243 ret = key_ref_to_ptr(key_ref)->serial;
244 key_ref_put(key_ref);
248 } /* end keyctl_get_keyring_ID() */
250 /*****************************************************************************/
252 * join the session keyring
253 * - implements keyctl(KEYCTL_JOIN_SESSION_KEYRING)
255 long keyctl_join_session_keyring(const char __user *_name)
260 /* fetch the name from userspace */
263 name = strndup_user(_name, PAGE_SIZE);
270 /* join the session */
271 ret = join_session_keyring(name);
276 } /* end keyctl_join_session_keyring() */
278 /*****************************************************************************/
280 * update a key's data payload
281 * - the key must be writable
282 * - implements keyctl(KEYCTL_UPDATE)
284 long keyctl_update_key(key_serial_t id,
285 const void __user *_payload,
293 if (plen > PAGE_SIZE)
296 /* pull the payload in if one was supplied */
300 payload = kmalloc(plen, GFP_KERNEL);
305 if (copy_from_user(payload, _payload, plen) != 0)
309 /* find the target key (which must be writable) */
310 key_ref = lookup_user_key(NULL, id, 0, 0, KEY_WRITE);
311 if (IS_ERR(key_ref)) {
312 ret = PTR_ERR(key_ref);
317 ret = key_update(key_ref, payload, plen);
319 key_ref_put(key_ref);
325 } /* end keyctl_update_key() */
327 /*****************************************************************************/
330 * - the key must be writable
331 * - implements keyctl(KEYCTL_REVOKE)
333 long keyctl_revoke_key(key_serial_t id)
338 key_ref = lookup_user_key(NULL, id, 0, 0, KEY_WRITE);
339 if (IS_ERR(key_ref)) {
340 ret = PTR_ERR(key_ref);
344 key_revoke(key_ref_to_ptr(key_ref));
347 key_ref_put(key_ref);
351 } /* end keyctl_revoke_key() */
353 /*****************************************************************************/
355 * clear the specified process keyring
356 * - the keyring must be writable
357 * - implements keyctl(KEYCTL_CLEAR)
359 long keyctl_keyring_clear(key_serial_t ringid)
361 key_ref_t keyring_ref;
364 keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE);
365 if (IS_ERR(keyring_ref)) {
366 ret = PTR_ERR(keyring_ref);
370 ret = keyring_clear(key_ref_to_ptr(keyring_ref));
372 key_ref_put(keyring_ref);
376 } /* end keyctl_keyring_clear() */
378 /*****************************************************************************/
380 * link a key into a keyring
381 * - the keyring must be writable
382 * - the key must be linkable
383 * - implements keyctl(KEYCTL_LINK)
385 long keyctl_keyring_link(key_serial_t id, key_serial_t ringid)
387 key_ref_t keyring_ref, key_ref;
390 keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE);
391 if (IS_ERR(keyring_ref)) {
392 ret = PTR_ERR(keyring_ref);
396 key_ref = lookup_user_key(NULL, id, 1, 0, KEY_LINK);
397 if (IS_ERR(key_ref)) {
398 ret = PTR_ERR(key_ref);
402 ret = key_link(key_ref_to_ptr(keyring_ref), key_ref_to_ptr(key_ref));
404 key_ref_put(key_ref);
406 key_ref_put(keyring_ref);
410 } /* end keyctl_keyring_link() */
412 /*****************************************************************************/
414 * unlink the first attachment of a key from a keyring
415 * - the keyring must be writable
416 * - we don't need any permissions on the key
417 * - implements keyctl(KEYCTL_UNLINK)
419 long keyctl_keyring_unlink(key_serial_t id, key_serial_t ringid)
421 key_ref_t keyring_ref, key_ref;
424 keyring_ref = lookup_user_key(NULL, ringid, 0, 0, KEY_WRITE);
425 if (IS_ERR(keyring_ref)) {
426 ret = PTR_ERR(keyring_ref);
430 key_ref = lookup_user_key(NULL, id, 0, 0, 0);
431 if (IS_ERR(key_ref)) {
432 ret = PTR_ERR(key_ref);
436 ret = key_unlink(key_ref_to_ptr(keyring_ref), key_ref_to_ptr(key_ref));
438 key_ref_put(key_ref);
440 key_ref_put(keyring_ref);
444 } /* end keyctl_keyring_unlink() */
446 /*****************************************************************************/
448 * describe a user key
449 * - the key must have view permission
450 * - if there's a buffer, we place up to buflen bytes of data into it
451 * - unless there's an error, we return the amount of description available,
452 * irrespective of how much we may have copied
453 * - the description is formatted thus:
454 * type;uid;gid;perm;description<NUL>
455 * - implements keyctl(KEYCTL_DESCRIBE)
457 long keyctl_describe_key(key_serial_t keyid,
461 struct key *key, *instkey;
466 key_ref = lookup_user_key(NULL, keyid, 0, 1, KEY_VIEW);
467 if (IS_ERR(key_ref)) {
468 /* viewing a key under construction is permitted if we have the
469 * authorisation token handy */
470 if (PTR_ERR(key_ref) == -EACCES) {
471 instkey = key_get_instantiation_authkey(keyid);
472 if (!IS_ERR(instkey)) {
474 key_ref = lookup_user_key(NULL, keyid,
476 if (!IS_ERR(key_ref))
481 ret = PTR_ERR(key_ref);
486 /* calculate how much description we're going to return */
488 tmpbuf = kmalloc(PAGE_SIZE, GFP_KERNEL);
492 key = key_ref_to_ptr(key_ref);
494 ret = snprintf(tmpbuf, PAGE_SIZE - 1,
496 key_ref_to_ptr(key_ref)->type->name,
497 key_ref_to_ptr(key_ref)->uid,
498 key_ref_to_ptr(key_ref)->gid,
499 key_ref_to_ptr(key_ref)->perm,
500 key_ref_to_ptr(key_ref)->description ?
501 key_ref_to_ptr(key_ref)->description : ""
504 /* include a NUL char at the end of the data */
505 if (ret > PAGE_SIZE - 1)
510 /* consider returning the data */
511 if (buffer && buflen > 0) {
515 if (copy_to_user(buffer, tmpbuf, buflen) != 0)
521 key_ref_put(key_ref);
525 } /* end keyctl_describe_key() */
527 /*****************************************************************************/
529 * search the specified keyring for a matching key
530 * - the start keyring must be searchable
531 * - nested keyrings may also be searched if they are searchable
532 * - only keys with search permission may be found
533 * - if a key is found, it will be attached to the destination keyring if
534 * there's one specified
535 * - implements keyctl(KEYCTL_SEARCH)
537 long keyctl_keyring_search(key_serial_t ringid,
538 const char __user *_type,
539 const char __user *_description,
540 key_serial_t destringid)
542 struct key_type *ktype;
543 key_ref_t keyring_ref, key_ref, dest_ref;
544 char type[32], *description;
547 /* pull the type and description into kernel space */
548 ret = key_get_type_from_user(type, _type, sizeof(type));
552 description = strndup_user(_description, PAGE_SIZE);
553 if (IS_ERR(description)) {
554 ret = PTR_ERR(description);
558 /* get the keyring at which to begin the search */
559 keyring_ref = lookup_user_key(NULL, ringid, 0, 0, KEY_SEARCH);
560 if (IS_ERR(keyring_ref)) {
561 ret = PTR_ERR(keyring_ref);
565 /* get the destination keyring if specified */
568 dest_ref = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE);
569 if (IS_ERR(dest_ref)) {
570 ret = PTR_ERR(dest_ref);
575 /* find the key type */
576 ktype = key_type_lookup(type);
578 ret = PTR_ERR(ktype);
583 key_ref = keyring_search(keyring_ref, ktype, description);
584 if (IS_ERR(key_ref)) {
585 ret = PTR_ERR(key_ref);
587 /* treat lack or presence of a negative key the same */
593 /* link the resulting key to the destination keyring if we can */
595 ret = key_permission(key_ref, KEY_LINK);
599 ret = key_link(key_ref_to_ptr(dest_ref), key_ref_to_ptr(key_ref));
604 ret = key_ref_to_ptr(key_ref)->serial;
607 key_ref_put(key_ref);
611 key_ref_put(dest_ref);
613 key_ref_put(keyring_ref);
619 } /* end keyctl_keyring_search() */
621 /*****************************************************************************/
623 * read a user key's payload
624 * - the keyring must be readable or the key must be searchable from the
626 * - if there's a buffer, we place up to buflen bytes of data into it
627 * - unless there's an error, we return the amount of data in the key,
628 * irrespective of how much we may have copied
629 * - implements keyctl(KEYCTL_READ)
631 long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
637 /* find the key first */
638 key_ref = lookup_user_key(NULL, keyid, 0, 0, 0);
639 if (IS_ERR(key_ref)) {
644 key = key_ref_to_ptr(key_ref);
646 /* see if we can read it directly */
647 ret = key_permission(key_ref, KEY_READ);
653 /* we can't; see if it's searchable from this process's keyrings
654 * - we automatically take account of the fact that it may be
655 * dangling off an instantiation key
657 if (!is_key_possessed(key_ref)) {
662 /* the key is probably readable - now try to read it */
664 ret = key_validate(key);
667 if (key->type->read) {
668 /* read the data with the semaphore held (since we
670 down_read(&key->sem);
671 ret = key->type->read(key, buffer, buflen);
681 } /* end keyctl_read_key() */
683 /*****************************************************************************/
685 * change the ownership of a key
686 * - the keyring owned by the changer
687 * - if the uid or gid is -1, then that parameter is not changed
688 * - implements keyctl(KEYCTL_CHOWN)
690 long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid)
692 struct key_user *newowner, *zapowner = NULL;
698 if (uid == (uid_t) -1 && gid == (gid_t) -1)
701 key_ref = lookup_user_key(NULL, id, 1, 1, KEY_SETATTR);
702 if (IS_ERR(key_ref)) {
703 ret = PTR_ERR(key_ref);
707 key = key_ref_to_ptr(key_ref);
709 /* make the changes with the locks held to prevent chown/chown races */
711 down_write(&key->sem);
713 if (!capable(CAP_SYS_ADMIN)) {
714 /* only the sysadmin can chown a key to some other UID */
715 if (uid != (uid_t) -1 && key->uid != uid)
718 /* only the sysadmin can set the key's GID to a group other
719 * than one of those that the current process subscribes to */
720 if (gid != (gid_t) -1 && gid != key->gid && !in_group_p(gid))
725 if (uid != (uid_t) -1 && uid != key->uid) {
727 newowner = key_user_lookup(uid);
731 /* transfer the quota burden to the new user */
732 if (test_bit(KEY_FLAG_IN_QUOTA, &key->flags)) {
733 spin_lock(&newowner->lock);
734 if (newowner->qnkeys + 1 >= KEYQUOTA_MAX_KEYS ||
735 newowner->qnbytes + key->quotalen >=
740 newowner->qnbytes += key->quotalen;
741 spin_unlock(&newowner->lock);
743 spin_lock(&key->user->lock);
745 key->user->qnbytes -= key->quotalen;
746 spin_unlock(&key->user->lock);
749 atomic_dec(&key->user->nkeys);
750 atomic_inc(&newowner->nkeys);
752 if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) {
753 atomic_dec(&key->user->nikeys);
754 atomic_inc(&newowner->nikeys);
757 zapowner = key->user;
758 key->user = newowner;
763 if (gid != (gid_t) -1)
772 key_user_put(zapowner);
777 spin_unlock(&newowner->lock);
782 } /* end keyctl_chown_key() */
784 /*****************************************************************************/
786 * change the permission mask on a key
787 * - the keyring owned by the changer
788 * - implements keyctl(KEYCTL_SETPERM)
790 long keyctl_setperm_key(key_serial_t id, key_perm_t perm)
797 if (perm & ~(KEY_POS_ALL | KEY_USR_ALL | KEY_GRP_ALL | KEY_OTH_ALL))
800 key_ref = lookup_user_key(NULL, id, 1, 1, KEY_SETATTR);
801 if (IS_ERR(key_ref)) {
802 ret = PTR_ERR(key_ref);
806 key = key_ref_to_ptr(key_ref);
808 /* make the changes with the locks held to prevent chown/chmod races */
810 down_write(&key->sem);
812 /* if we're not the sysadmin, we can only change a key that we own */
813 if (capable(CAP_SYS_ADMIN) || key->uid == current->fsuid) {
823 } /* end keyctl_setperm_key() */
825 /*****************************************************************************/
827 * instantiate the key with the specified payload, and, if one is given, link
828 * the key into the keyring
830 long keyctl_instantiate_key(key_serial_t id,
831 const void __user *_payload,
835 struct request_key_auth *rka;
837 key_ref_t keyring_ref;
843 if (plen > 1024 * 1024 - 1)
846 /* the appropriate instantiation authorisation key must have been
847 * assumed before calling this */
849 instkey = current->request_key_auth;
853 rka = instkey->payload.data;
854 if (rka->target_key->serial != id)
857 /* pull the payload in if one was supplied */
862 payload = kmalloc(plen, GFP_KERNEL);
864 if (plen <= PAGE_SIZE)
867 payload = vmalloc(plen);
873 if (copy_from_user(payload, _payload, plen) != 0)
877 /* find the destination keyring amongst those belonging to the
881 keyring_ref = lookup_user_key(rka->context, ringid, 1, 0,
883 if (IS_ERR(keyring_ref)) {
884 ret = PTR_ERR(keyring_ref);
889 /* instantiate the key and link it into a keyring */
890 ret = key_instantiate_and_link(rka->target_key, payload, plen,
891 key_ref_to_ptr(keyring_ref), instkey);
893 key_ref_put(keyring_ref);
895 /* discard the assumed authority if it's just been disabled by
896 * instantiation of the key */
898 key_put(current->request_key_auth);
899 current->request_key_auth = NULL;
910 } /* end keyctl_instantiate_key() */
912 /*****************************************************************************/
914 * negatively instantiate the key with the given timeout (in seconds), and, if
915 * one is given, link the key into the keyring
917 long keyctl_negate_key(key_serial_t id, unsigned timeout, key_serial_t ringid)
919 struct request_key_auth *rka;
921 key_ref_t keyring_ref;
924 /* the appropriate instantiation authorisation key must have been
925 * assumed before calling this */
927 instkey = current->request_key_auth;
931 rka = instkey->payload.data;
932 if (rka->target_key->serial != id)
935 /* find the destination keyring if present (which must also be
939 keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE);
940 if (IS_ERR(keyring_ref)) {
941 ret = PTR_ERR(keyring_ref);
946 /* instantiate the key and link it into a keyring */
947 ret = key_negate_and_link(rka->target_key, timeout,
948 key_ref_to_ptr(keyring_ref), instkey);
950 key_ref_put(keyring_ref);
952 /* discard the assumed authority if it's just been disabled by
953 * instantiation of the key */
955 key_put(current->request_key_auth);
956 current->request_key_auth = NULL;
962 } /* end keyctl_negate_key() */
964 /*****************************************************************************/
966 * set the default keyring in which request_key() will cache keys
967 * - return the old setting
969 long keyctl_set_reqkey_keyring(int reqkey_defl)
973 switch (reqkey_defl) {
974 case KEY_REQKEY_DEFL_THREAD_KEYRING:
975 ret = install_thread_keyring(current);
980 case KEY_REQKEY_DEFL_PROCESS_KEYRING:
981 ret = install_process_keyring(current);
985 case KEY_REQKEY_DEFL_DEFAULT:
986 case KEY_REQKEY_DEFL_SESSION_KEYRING:
987 case KEY_REQKEY_DEFL_USER_KEYRING:
988 case KEY_REQKEY_DEFL_USER_SESSION_KEYRING:
990 current->jit_keyring = reqkey_defl;
992 case KEY_REQKEY_DEFL_NO_CHANGE:
993 return current->jit_keyring;
995 case KEY_REQKEY_DEFL_GROUP_KEYRING:
1000 } /* end keyctl_set_reqkey_keyring() */
1002 /*****************************************************************************/
1004 * set or clear the timeout for a key
1006 long keyctl_set_timeout(key_serial_t id, unsigned timeout)
1008 struct timespec now;
1014 key_ref = lookup_user_key(NULL, id, 1, 1, KEY_SETATTR);
1015 if (IS_ERR(key_ref)) {
1016 ret = PTR_ERR(key_ref);
1020 key = key_ref_to_ptr(key_ref);
1022 /* make the changes with the locks held to prevent races */
1023 down_write(&key->sem);
1027 now = current_kernel_time();
1028 expiry = now.tv_sec + timeout;
1031 key->expiry = expiry;
1033 up_write(&key->sem);
1040 } /* end keyctl_set_timeout() */
1042 /*****************************************************************************/
1044 * assume the authority to instantiate the specified key
1046 long keyctl_assume_authority(key_serial_t id)
1048 struct key *authkey;
1051 /* special key IDs aren't permitted */
1056 /* we divest ourselves of authority if given an ID of 0 */
1058 key_put(current->request_key_auth);
1059 current->request_key_auth = NULL;
1064 /* attempt to assume the authority temporarily granted to us whilst we
1065 * instantiate the specified key
1066 * - the authorisation key must be in the current task's keyrings
1069 authkey = key_get_instantiation_authkey(id);
1070 if (IS_ERR(authkey)) {
1071 ret = PTR_ERR(authkey);
1075 key_put(current->request_key_auth);
1076 current->request_key_auth = authkey;
1077 ret = authkey->serial;
1082 } /* end keyctl_assume_authority() */
1085 * get the security label of a key
1086 * - the key must grant us view permission
1087 * - if there's a buffer, we place up to buflen bytes of data into it
1088 * - unless there's an error, we return the amount of information available,
1089 * irrespective of how much we may have copied (including the terminal NUL)
1090 * - implements keyctl(KEYCTL_GET_SECURITY)
1092 long keyctl_get_security(key_serial_t keyid,
1093 char __user *buffer,
1096 struct key *key, *instkey;
1101 key_ref = lookup_user_key(NULL, keyid, 0, 1, KEY_VIEW);
1102 if (IS_ERR(key_ref)) {
1103 if (PTR_ERR(key_ref) != -EACCES)
1104 return PTR_ERR(key_ref);
1106 /* viewing a key under construction is also permitted if we
1107 * have the authorisation token handy */
1108 instkey = key_get_instantiation_authkey(keyid);
1109 if (IS_ERR(instkey))
1110 return PTR_ERR(key_ref);
1113 key_ref = lookup_user_key(NULL, keyid, 0, 1, 0);
1114 if (IS_ERR(key_ref))
1115 return PTR_ERR(key_ref);
1118 key = key_ref_to_ptr(key_ref);
1119 ret = security_key_getsecurity(key, &context);
1121 /* if no information was returned, give userspace an empty
1124 if (buffer && buflen > 0 &&
1125 copy_to_user(buffer, "", 1) != 0)
1127 } else if (ret > 0) {
1128 /* return as much data as there's room for */
1129 if (buffer && buflen > 0) {
1133 if (copy_to_user(buffer, context, buflen) != 0)
1140 key_ref_put(key_ref);
1144 /*****************************************************************************/
1146 * the key control system call
1148 asmlinkage long sys_keyctl(int option, unsigned long arg2, unsigned long arg3,
1149 unsigned long arg4, unsigned long arg5)
1152 case KEYCTL_GET_KEYRING_ID:
1153 return keyctl_get_keyring_ID((key_serial_t) arg2,
1156 case KEYCTL_JOIN_SESSION_KEYRING:
1157 return keyctl_join_session_keyring((const char __user *) arg2);
1160 return keyctl_update_key((key_serial_t) arg2,
1161 (const void __user *) arg3,
1165 return keyctl_revoke_key((key_serial_t) arg2);
1167 case KEYCTL_DESCRIBE:
1168 return keyctl_describe_key((key_serial_t) arg2,
1169 (char __user *) arg3,
1173 return keyctl_keyring_clear((key_serial_t) arg2);
1176 return keyctl_keyring_link((key_serial_t) arg2,
1177 (key_serial_t) arg3);
1180 return keyctl_keyring_unlink((key_serial_t) arg2,
1181 (key_serial_t) arg3);
1184 return keyctl_keyring_search((key_serial_t) arg2,
1185 (const char __user *) arg3,
1186 (const char __user *) arg4,
1187 (key_serial_t) arg5);
1190 return keyctl_read_key((key_serial_t) arg2,
1191 (char __user *) arg3,
1195 return keyctl_chown_key((key_serial_t) arg2,
1199 case KEYCTL_SETPERM:
1200 return keyctl_setperm_key((key_serial_t) arg2,
1203 case KEYCTL_INSTANTIATE:
1204 return keyctl_instantiate_key((key_serial_t) arg2,
1205 (const void __user *) arg3,
1207 (key_serial_t) arg5);
1210 return keyctl_negate_key((key_serial_t) arg2,
1212 (key_serial_t) arg4);
1214 case KEYCTL_SET_REQKEY_KEYRING:
1215 return keyctl_set_reqkey_keyring(arg2);
1217 case KEYCTL_SET_TIMEOUT:
1218 return keyctl_set_timeout((key_serial_t) arg2,
1221 case KEYCTL_ASSUME_AUTHORITY:
1222 return keyctl_assume_authority((key_serial_t) arg2);
1224 case KEYCTL_GET_SECURITY:
1225 return keyctl_get_security((key_serial_t) arg2,
1233 } /* end sys_keyctl() */