]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/keyctl.2
sched_setattr.2: tfix
[thirdparty/man-pages.git] / man2 / keyctl.2
1 .\" Copyright (C) 2016 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" and Copyright (C) 2016 Eugene Syromyatnikov <evgsyr@gmail.com>
3 .\" A very few fragments remain from an earlier version of this page
4 .\" written by David Howells (dhowells@redhat.com)
5 .\"
6 .\" %%%LICENSE_START(VERBATIM)
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
10 .\"
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
15 .\"
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date. The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein. The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
22 .\" professionally.
23 .\"
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" %%%LICENSE_END
27 .\"
28 .TH KEYCTL 2 2019-03-06 Linux "Linux Key Management Calls"
29 .SH NAME
30 keyctl \- manipulate the kernel's key management facility
31 .SH SYNOPSIS
32 .nf
33 .B #include <sys/types.h>
34 .B #include <keyutils.h>
35 .PP
36 .BI "long keyctl(int " operation ", ...)"
37
38 .B "/* For direct call via syscall(2): */"
39 .B #include <asm/unistd.h>
40 .B #include <linux/keyctl.h>
41 .B #include <unistd.h>
42 .PP
43 .BI "long syscall(__NR_keyctl, int " operation ", __kernel_ulong_t " arg2 ,
44 .BI " __kernel_ulong_t " arg3 ", __kernel_ulong_t " arg4 ,
45 .BI " __kernel_ulong_t " arg5 );
46 .fi
47 .PP
48 No glibc wrapper is provided for this system call; see NOTES.
49 .SH DESCRIPTION
50 .BR keyctl ()
51 allows user-space programs to perform key manipulation.
52 .PP
53 The operation performed by
54 .BR keyctl ()
55 is determined by the value of the
56 .I operation
57 argument.
58 Each of these operations is wrapped by the
59 .I libkeyutils
60 library (provided by the
61 .I keyutils
62 package) into individual functions (noted below)
63 to permit the compiler to check types.
64 .PP
65 The permitted values for
66 .I operation
67 are:
68 .TP
69 .BR KEYCTL_GET_KEYRING_ID " (since Linux 2.6.10)"
70 Map a special key ID to a real key ID for this process.
71 .IP
72 This operation looks up the special key whose ID is provided in
73 .I arg2
74 (cast to
75 .IR key_serial_t ).
76 If the special key is found,
77 the ID of the corresponding real key is returned as the function result.
78 The following values may be specified in
79 .IR arg2 :
80 .RS
81 .TP
82 .B KEY_SPEC_THREAD_KEYRING
83 This specifies the calling thread's thread-specific keyring.
84 See
85 .BR thread-keyring (7).
86 .TP
87 .B KEY_SPEC_PROCESS_KEYRING
88 This specifies the caller's process-specific keyring.
89 See
90 .BR process-keyring (7).
91 .TP
92 .B KEY_SPEC_SESSION_KEYRING
93 This specifies the caller's session-specific keyring.
94 See
95 .BR session-keyring (7).
96 .TP
97 .B KEY_SPEC_USER_KEYRING
98 This specifies the caller's UID-specific keyring.
99 See
100 .BR user-keyring (7).
101 .TP
102 .B KEY_SPEC_USER_SESSION_KEYRING
103 This specifies the caller's UID-session keyring.
104 See
105 .BR user-session-keyring (7).
106 .TP
107 .BR KEY_SPEC_REQKEY_AUTH_KEY " (since Linux 2.6.16)"
108 .\" commit b5f545c880a2a47947ba2118b2509644ab7a2969
109 This specifies the authorization key created by
110 .BR request_key (2)
111 and passed to the process it spawns to generate a key.
112 This key is available only in a
113 .BR request-key (8)-style
114 program that was passed an authorization key by the kernel and
115 ceases to be available once the requested key has been instantiated; see
116 .BR request_key (2).
117 .TP
118 .BR KEY_SPEC_REQUESTOR_KEYRING " (since Linux 2.6.29)"
119 .\" commit 8bbf4976b59fc9fc2861e79cab7beb3f6d647640
120 This specifies the key ID for the
121 .BR request_key (2)
122 destination keyring.
123 This keyring is available only in a
124 .BR request-key (8)-style
125 program that was passed an authorization key by the kernel and
126 ceases to be available once the requested key has been instantiated; see
127 .BR request_key (2).
128 .RE
129 .IP
130 The behavior if the key specified in
131 .I arg2
132 does not exist depends on the value of
133 .I arg3
134 (cast to
135 .IR int ).
136 If
137 .I arg3
138 contains a nonzero value, then\(emif it is appropriate to do so
139 (e.g., when looking up the user, user-session, or session key)\(ema new key
140 is created and its real key ID returned as the function result.
141 .\" The keyctl_get_keyring_ID.3 page says that a new key
142 .\" "will be created *if it is appropriate to do so**. What is the
143 .\" determiner for appropriate?
144 .\" David Howells: Some special keys such as KEY_SPEC_REQKEY_AUTH_KEY
145 .\" wouldn't get created but user/user-session/session keyring would
146 .\" be created.
147 Otherwise, the operation fails with the error
148 .BR ENOKEY .
149 .IP
150 If a valid key ID is specified in
151 .IR arg2 ,
152 and the key exists, then this operation simply returns the key ID.
153 If the key does not exist, the call fails with error
154 .BR ENOKEY .
155 .IP
156 The caller must have
157 .I search
158 permission on a keyring in order for it to be found.
159 .IP
160 The arguments
161 .IR arg4
162 and
163 .IR arg5
164 are ignored.
165 .IP
166 This operation is exposed by
167 .I libkeyutils
168 via the function
169 .BR keyctl_get_keyring_ID (3).
170 .TP
171 .BR KEYCTL_JOIN_SESSION_KEYRING " (since Linux 2.6.10)"
172 Replace the session keyring this process subscribes to with
173 a new session keyring.
174 .\" This may be useful in conjunction with some sort of
175 .\" session management framework that is employed by the application.
176 .IP
177 If
178 .I arg2
179 is NULL,
180 an anonymous keyring with the description "_ses" is created
181 and the process is subscribed to that keyring as its session keyring,
182 displacing the previous session keyring.
183 .IP
184 Otherwise,
185 .I arg2
186 (cast to
187 .IR "char\ *" )
188 is treated as the description (name) of a keyring,
189 and the behavior is as follows:
190 .RS
191 .IP * 3
192 If a keyring with a matching description exists,
193 the process will attempt to subscribe to that keyring
194 as its session keyring if possible;
195 if that is not possible, an error is returned.
196 In order to subscribe to the keyring,
197 the caller must have
198 .I search
199 permission on the keyring.
200 .IP *
201 If a keyring with a matching description does not exist,
202 then a new keyring with the specified description is created,
203 and the process is subscribed to that keyring as its session keyring.
204 .RE
205 .IP
206 The arguments
207 .IR arg3 ,
208 .IR arg4 ,
209 and
210 .IR arg5
211 are ignored.
212 .IP
213 This operation is exposed by
214 .I libkeyutils
215 via the function
216 .BR keyctl_join_session_keyring (3).
217 .TP
218 .BR KEYCTL_UPDATE " (since Linux 2.6.10)"
219 Update a key's data payload.
220 .IP
221 The
222 .I arg2
223 argument (cast to
224 .IR key_serial_t )
225 specifies the ID of the key to be updated.
226 The
227 .I arg3
228 argument (cast to
229 .IR "void\ *" )
230 points to the new payload and
231 .I arg4
232 (cast to
233 .IR size_t )
234 contains the new payload size in bytes.
235 .IP
236 The caller must have
237 .I write
238 permission on the key specified and the key type must support updating.
239 .IP
240 A negatively instantiated key (see the description of
241 .BR KEYCTL_REJECT )
242 can be positively instantiated with this operation.
243 .IP
244 The
245 .I arg5
246 argument is ignored.
247 .IP
248 This operation is exposed by
249 .I libkeyutils
250 via the function
251 .BR keyctl_update (3).
252 .TP
253 .BR KEYCTL_REVOKE " (since Linux 2.6.10)"
254 Revoke the key with the ID provided in
255 .I arg2
256 (cast to
257 .IR key_serial_t ).
258 The key is scheduled for garbage collection;
259 it will no longer be findable,
260 and will be unavailable for further operations.
261 Further attempts to use the key will fail with the error
262 .BR EKEYREVOKED .
263 .IP
264 The caller must have
265 .IR write
266 or
267 .IR setattr
268 permission on the key.
269 .\" Keys with the KEY_FLAG_KEEP bit set cause an EPERM
270 .\" error for KEYCTL_REVOKE. Does this need to be documented?
271 .\" David Howells: No significance for user space.
272 .IP
273 The arguments
274 .IR arg3 ,
275 .IR arg4 ,
276 and
277 .IR arg5
278 are ignored.
279 .IP
280 This operation is exposed by
281 .I libkeyutils
282 via the function
283 .BR keyctl_revoke (3).
284 .TP
285 .BR KEYCTL_CHOWN " (since Linux 2.6.10)"
286 Change the ownership (user and group ID) of a key.
287 .IP
288 The
289 .I arg2
290 argument (cast to
291 .IR key_serial_t )
292 contains the key ID.
293 The
294 .I arg3
295 argument (cast to
296 .IR uid_t )
297 contains the new user ID (or \-1 in case the user ID shouldn't be changed).
298 The
299 .I arg4
300 argument (cast to
301 .IR gid_t )
302 contains the new group ID (or \-1 in case the group ID shouldn't be changed).
303 .IP
304 The key must grant the caller
305 .I setattr
306 permission.
307 .IP
308 For the UID to be changed, or for the GID to be changed to a group
309 the caller is not a member of, the caller must have the
310 .B CAP_SYS_ADMIN
311 capability (see
312 .BR capabilities (7)).
313 .IP
314 If the UID is to be changed, the new user must have sufficient
315 quota to accept the key.
316 The quota deduction will be removed from the old user
317 to the new user should the UID be changed.
318 .IP
319 The
320 .I arg5
321 argument is ignored.
322 .IP
323 This operation is exposed by
324 .I libkeyutils
325 via the function
326 .BR keyctl_chown (3).
327 .TP
328 .BR KEYCTL_SETPERM " (since Linux 2.6.10)"
329 Change the permissions of the key with the ID provided in the
330 .I arg2
331 argument (cast to
332 .IR key_serial_t )
333 to the permissions provided in the
334 .I arg3
335 argument (cast to
336 .IR key_perm_t ).
337 .IP
338 If the caller doesn't have the
339 .B CAP_SYS_ADMIN
340 capability, it can change permissions only for the keys it owns.
341 (More precisely: the caller's filesystem UID must match the UID of the key.)
342 .IP
343 The key must grant
344 .I setattr
345 permission to the caller
346 .IR regardless
347 of the caller's capabilities.
348 .\" FIXME Above, is it really intended that a privileged process can't
349 .\" override the lack of the 'setattr' permission?
350 .IP
351 The permissions in
352 .IR arg3
353 specify masks of available operations
354 for each of the following user categories:
355 .RS
356 .TP
357 .IR possessor " (since Linux 2.6.14)"
358 .\" commit 664cceb0093b755739e56572b836a99104ee8a75
359 This is the permission granted to a process that possesses the key
360 (has it attached searchably to one of the process's keyrings);
361 see
362 .BR keyrings (7).
363 .TP
364 .IR user
365 This is the permission granted to a process
366 whose filesystem UID matches the UID of the key.
367 .TP
368 .IR group
369 This is the permission granted to a process
370 whose filesystem GID or any of its supplementary GIDs
371 matches the GID of the key.
372 .TP
373 .IR other
374 This is the permission granted to other processes
375 that do not match the
376 .IR user
377 and
378 .IR group
379 categories.
380 .RE
381 .IP
382 The
383 .IR user ,
384 .IR group ,
385 and
386 .IR other
387 categories are exclusive: if a process matches the
388 .IR user
389 category, it will not receive permissions granted in the
390 .IR group
391 category; if a process matches the
392 .I user
393 or
394 .IR group
395 category, then it will not receive permissions granted in the
396 .IR other
397 category.
398 .IP
399 The
400 .I possessor
401 category grants permissions that are cumulative with the grants from the
402 .IR user ,
403 .IR group ,
404 or
405 .IR other
406 category.
407 .IP
408 Each permission mask is eight bits in size,
409 with only six bits currently used.
410 The available permissions are:
411 .RS
412 .TP
413 .IR view
414 This permission allows reading attributes of a key.
415 .IP
416 This permission is required for the
417 .BR KEYCTL_DESCRIBE
418 operation.
419 .IP
420 The permission bits for each category are
421 .BR KEY_POS_VIEW ,
422 .BR KEY_USR_VIEW ,
423 .BR KEY_GRP_VIEW ,
424 and
425 .BR KEY_OTH_VIEW .
426 .TP
427 .IR read
428 This permission allows reading a key's payload.
429 .IP
430 This permission is required for the
431 .BR KEYCTL_READ
432 operation.
433 .IP
434 The permission bits for each category are
435 .BR KEY_POS_READ ,
436 .BR KEY_USR_READ ,
437 .BR KEY_GRP_READ ,
438 and
439 .BR KEY_OTH_READ .
440 .TP
441 .IR write
442 This permission allows update or instantiation of a key's payload.
443 For a keyring, it allows keys to be linked and unlinked from the keyring,
444 .IP
445 This permission is required for the
446 .BR KEYCTL_UPDATE ,
447 .BR KEYCTL_REVOKE ,
448 .BR KEYCTL_CLEAR ,
449 .BR KEYCTL_LINK ,
450 and
451 .BR KEYCTL_UNLINK
452 operations.
453 .IP
454 The permission bits for each category are
455 .BR KEY_POS_WRITE ,
456 .BR KEY_USR_WRITE ,
457 .BR KEY_GRP_WRITE ,
458 and
459 .BR KEY_OTH_WRITE .
460 .TP
461 .IR search
462 This permission allows keyrings to be searched and keys to be found.
463 Searches can recurse only into nested keyrings that have
464 .I search
465 permission set.
466 .IP
467 This permission is required for the
468 .BR KEYCTL_GET_KEYRING_ID ,
469 .BR KEYCTL_JOIN_SESSION_KEYRING ,
470 .BR KEYCTL_SEARCH ,
471 and
472 .BR KEYCTL_INVALIDATE
473 operations.
474 .IP
475 The permission bits for each category are
476 .BR KEY_POS_SEARCH ,
477 .BR KEY_USR_SEARCH ,
478 .BR KEY_GRP_SEARCH ,
479 and
480 .BR KEY_OTH_SEARCH .
481 .TP
482 .IR link
483 This permission allows a key or keyring to be linked to.
484 .IP
485 This permission is required for the
486 .BR KEYCTL_LINK
487 and
488 .BR KEYCTL_SESSION_TO_PARENT
489 operations.
490 .IP
491 The permission bits for each category are
492 .BR KEY_POS_LINK ,
493 .BR KEY_USR_LINK ,
494 .BR KEY_GRP_LINK ,
495 and
496 .BR KEY_OTH_LINK .
497 .TP
498 .IR setattr " (since Linux 2.6.15)."
499 This permission allows a key's UID, GID, and permissions mask to be changed.
500 .IP
501 This permission is required for the
502 .BR KEYCTL_REVOKE ,
503 .BR KEYCTL_CHOWN ,
504 and
505 .BR KEYCTL_SETPERM
506 operations.
507 .IP
508 The permission bits for each category are
509 .BR KEY_POS_SETATTR ,
510 .BR KEY_USR_SETATTR ,
511 .BR KEY_GRP_SETATTR ,
512 and
513 .BR KEY_OTH_SETATTR .
514 .RE
515 .IP
516 As a convenience, the following macros are defined as masks for
517 all of the permission bits in each of the user categories:
518 .BR KEY_POS_ALL ,
519 .BR KEY_USR_ALL ,
520 .BR KEY_GRP_ALL ,
521 and
522 .BR KEY_OTH_ALL .
523 .IP
524 The
525 .IR arg4 " and " arg5
526 arguments are ignored.
527 .IP
528 This operation is exposed by
529 .I libkeyutils
530 via the function
531 .BR keyctl_setperm (3).
532 .TP
533 .BR KEYCTL_DESCRIBE " (since Linux 2.6.10)"
534 Obtain a string describing the attributes of a specified key.
535 .IP
536 The ID of the key to be described is specified in
537 .I arg2
538 (cast to
539 .IR key_serial_t ).
540 The descriptive string is returned in the buffer pointed to by
541 .I arg3
542 (cast to
543 .IR "char\ *" );
544 .I arg4
545 (cast to
546 .IR size_t )
547 specifies the size of that buffer in bytes.
548 .IP
549 The key must grant the caller
550 .I view
551 permission.
552 .IP
553 The returned string is null-terminated and
554 contains the following information about the key:
555 .IP
556 .in +4n
557 .IR type ; uid ; gid ; perm ; description
558 .in
559 .IP
560 In the above,
561 .IR type
562 and
563 .IR description
564 are strings,
565 .IR uid
566 and
567 .IR gid
568 are decimal strings, and
569 .I perm
570 is a hexadecimal permissions mask.
571 The descriptive string is written with the following format:
572 .IP
573 %s;%d;%d;%08x;%s
574 .IP
575 .BR "Note: the intention is that the descriptive string should"
576 .BR "be extensible in future kernel versions".
577 In particular, the
578 .IR description
579 field will not contain semicolons;
580 .\" FIXME But, the kernel does not enforce the requirement
581 .\" that the key description contains no semicolons!
582 .\" So, user space has no guarantee here??
583 .\" Either something more needs to be said here,
584 .\" or a kernel fix is required.
585 it should be parsed by working backwards from the end of the string
586 to find the last semicolon.
587 This allows future semicolon-delimited fields to be inserted
588 in the descriptive string in the future.
589 .IP
590 Writing to the buffer is attempted only when
591 .IR arg3
592 is non-NULL and the specified buffer size
593 is large enough to accept the descriptive string
594 (including the terminating null byte).
595 '\" Function commentary says it copies up to buflen bytes, but see the
596 '\" (buffer && buflen >= ret) condition in keyctl_describe_key() in
597 '\" security/keyctl.c
598 In order to determine whether the buffer size was too small,
599 check to see if the return value of the operation is greater than
600 .IR arg4 .
601 .IP
602 The
603 .I arg5
604 argument is ignored.
605 .IP
606 This operation is exposed by
607 .I libkeyutils
608 via the function
609 .BR keyctl_describe (3).
610 .TP
611 .B KEYCTL_CLEAR
612 Clear the contents of (i.e., unlink all keys from) a keyring.
613 .IP
614 The ID of the key
615 (which must be of keyring type)
616 .\" or the error ENOTDIR results
617 is provided in
618 .I arg2
619 (cast to
620 .IR key_serial_t ).
621 .\" According to Documentation/security/keys.txt:
622 .\" This function can also be used to clear special kernel keyrings if they
623 .\" are appropriately marked if the user has CAP_SYS_ADMIN capability. The
624 .\" DNS resolver cache keyring is an example of this.
625 .IP
626 The caller must have
627 .I write
628 permission on the keyring.
629 .IP
630 The arguments
631 .IR arg3 ,
632 .IR arg4 ,
633 and
634 .IR arg5
635 are ignored.
636 .IP
637 This operation is exposed by
638 .I libkeyutils
639 via the function
640 .BR keyctl_clear (3).
641 .TP
642 .BR KEYCTL_LINK " (since Linux 2.6.10)"
643 Create a link from a keyring to a key.
644 .IP
645 The key to be linked is specified in
646 .IR arg2
647 (cast to
648 .IR key_serial_t );
649 the keyring is specified in
650 .IR arg3
651 (cast to
652 .IR key_serial_t ).
653 .IP
654 If a key with the same type and description is already linked in the keyring,
655 then that key is displaced from the keyring.
656 .IP
657 Before creating the link,
658 the kernel checks the nesting of the keyrings and returns appropriate errors
659 if the link would produce a cycle
660 or if the nesting of keyrings would be too deep
661 (The limit on the nesting of keyrings is determined by the kernel constant
662 .BR KEYRING_SEARCH_MAX_DEPTH ,
663 defined with the value 6, and is necessary to prevent overflows
664 on the kernel stack when recursively searching keyrings).
665 .IP
666 The caller must have
667 .I link
668 permission on the key being added and
669 .I write
670 permission on the keyring.
671 .IP
672 The arguments
673 .IR arg4
674 and
675 .IR arg5
676 are ignored.
677 .IP
678 This operation is exposed by
679 .I libkeyutils
680 via the function
681 .BR keyctl_link (3).
682 .TP
683 .BR KEYCTL_UNLINK " (since Linux 2.6.10)"
684 Unlink a key from a keyring.
685 .IP
686 The ID of the key to be unlinked is specified in
687 .I arg2
688 (cast to
689 .IR key_serial_t );
690 the ID of the keyring from which it is to be unlinked is specified in
691 .I arg3
692 (cast to
693 .IR key_serial_t ).
694 .IP
695 If the key is not currently linked into the keyring, an error results.
696 .IP
697 The caller must have
698 .I write
699 permission on the keyring from which the key is being removed.
700 .IP
701 If the last link to a key is removed,
702 then that key will be scheduled for destruction.
703 .IP
704 The arguments
705 .IR arg4
706 and
707 .IR arg5
708 are ignored.
709 .IP
710 This operation is exposed by
711 .I libkeyutils
712 via the function
713 .BR keyctl_unlink (3).
714 .TP
715 .BR KEYCTL_SEARCH " (since Linux 2.6.10)"
716 Search for a key in a keyring tree,
717 returning its ID and optionally linking it to a specified keyring.
718 .IP
719 The tree to be searched is specified by passing
720 the ID of the head keyring in
721 .IR arg2
722 (cast to
723 .IR key_serial_t ).
724 The search is performed breadth-first and recursively.
725 .IP
726 The
727 .I arg3
728 and
729 .I arg4
730 arguments specify the key to be searched for:
731 .I arg3
732 (cast as
733 .IR "char\ *" )
734 contains the key type
735 (a null-terminated character string up to 32 bytes in size,
736 including the terminating null byte), and
737 .I arg4
738 (cast as
739 .IR "char\ *" )
740 contains the description of the key
741 (a null-terminated character string up to 4096 bytes in size,
742 including the terminating null byte).
743 .IP
744 The source keyring must grant
745 .I search
746 permission to the caller.
747 When performing the recursive search, only keyrings that grant the caller
748 .I search
749 permission will be searched.
750 Only keys with for which the caller has
751 .I search
752 permission can be found.
753 .IP
754 If the key is found, its ID is returned as the function result.
755 .IP
756 If the key is found and
757 .I arg5
758 (cast to
759 .IR key_serial_t )
760 is nonzero, then, subject to the same constraints and rules as
761 .BR KEYCTL_LINK ,
762 the key is linked into the keyring whose ID is specified in
763 .IR arg5 .
764 If the destination keyring specified in
765 .I arg5
766 already contains a link to a key that has the same type and description,
767 then that link will be displaced by a link to
768 the key found by this operation.
769 .IP
770 Instead of valid existing keyring IDs, the source
771 .RI ( arg2 )
772 and destination
773 .RI ( arg5 )
774 keyrings can be one of the special keyring IDs listed under
775 .BR KEYCTL_GET_KEYRING_ID .
776 .IP
777 This operation is exposed by
778 .I libkeyutils
779 via the function
780 .BR keyctl_search (3).
781 .TP
782 .BR KEYCTL_READ " (since Linux 2.6.10)"
783 Read the payload data of a key.
784 .IP
785 The ID of the key whose payload is to be read is specified in
786 .I arg2
787 (cast to
788 .IR key_serial_t ).
789 This can be the ID of an existing key,
790 or any of the special key IDs listed for
791 .BR KEYCTL_GET_KEYRING_ID .
792 .\" including KEY_SPEC_REQKEY_AUTH_KEY
793 .IP
794 The payload is placed in the buffer pointed by
795 .I arg3
796 (cast to
797 .IR "char\ *" );
798 the size of that buffer must be specified in
799 .I arg4
800 (cast to
801 .IR size_t ).
802 .IP
803 The returned data will be processed for presentation
804 according to the key type.
805 For example, a keyring will return an array of
806 .I key_serial_t
807 entries representing the IDs of all the keys that are linked to it.
808 The
809 .IR "user"
810 key type will return its data as is.
811 If a key type does not implement this function,
812 the operation fails with the error
813 .BR EOPNOTSUPP .
814 .IP
815 If
816 .I arg3
817 is not NULL,
818 as much of the payload data as will fit is copied into the buffer.
819 On a successful return,
820 the return value is always the total size of the payload data.
821 To determine whether the buffer was of sufficient size,
822 check to see that the return value is less than or equal to
823 the value supplied in
824 .IR arg4 .
825 .IP
826 The key must either grant the caller
827 .I read
828 permission, or grant the caller
829 .I search
830 permission when searched for from the process keyrings
831 (i.e., the key is possessed).
832 .IP
833 The
834 .I arg5
835 argument is ignored.
836 .IP
837 This operation is exposed by
838 .I libkeyutils
839 via the function
840 .BR keyctl_read (3).
841 .TP
842 .BR KEYCTL_INSTANTIATE " (since Linux 2.6.10)"
843 (Positively) instantiate an uninstantiated key with a specified payload.
844 .IP
845 The ID of the key to be instantiated is provided in
846 .I arg2
847 (cast to
848 .IR key_serial_t ).
849 .IP
850 The key payload is specified in the buffer pointed to by
851 .I arg3
852 (cast to
853 .IR "void\ *");
854 the size of that buffer is specified in
855 .I arg4
856 (cast to
857 .IR size_t ).
858 .IP
859 The payload may be a NULL pointer and the buffer size may be 0
860 if this is supported by the key type (e.g., it is a keyring).
861 .IP
862 The operation may be fail if the payload data is in the wrong format
863 or is otherwise invalid.
864 .IP
865 If
866 .I arg5
867 (cast to
868 .IR key_serial_t )
869 is nonzero, then, subject to the same constraints and rules as
870 .BR KEYCTL_LINK ,
871 the instantiated key is linked into the keyring whose ID specified in
872 .IR arg5 .
873 .IP
874 The caller must have the appropriate authorization key,
875 and once the uninstantiated key has been instantiated,
876 the authorization key is revoked.
877 In other words, this operation is available only from a
878 .BR request-key (8)-style
879 program.
880 See
881 .BR request_key (2)
882 for an explanation of uninstantiated keys and key instantiation.
883 .IP
884 This operation is exposed by
885 .I libkeyutils
886 via the function
887 .BR keyctl_instantiate (3).
888 .TP
889 .BR KEYCTL_NEGATE " (since Linux 2.6.10)"
890 Negatively instantiate an uninstantiated key.
891 .IP
892 This operation is equivalent to the call:
893 .IP
894 keyctl(KEYCTL_REJECT, arg2, arg3, ENOKEY, arg4);
895 .IP
896 The
897 .I arg5
898 argument is ignored.
899 .IP
900 This operation is exposed by
901 .I libkeyutils
902 via the function
903 .BR keyctl_negate (3).
904 .TP
905 .BR KEYCTL_SET_REQKEY_KEYRING " (since Linux 2.6.13)"
906 Set the default keyring to which implicitly requested keys
907 will be linked for this thread, and return the previous setting.
908 Implicit key requests are those made by internal kernel components,
909 .\" I.e., calls to the kernel's internal request_key() interface,
910 .\" which is distinct from the request_key(2) system call (which
911 .\" ultimately employs the kernel-internal interface).
912 such as can occur when, for example, opening files
913 on an AFS or NFS filesystem.
914 Setting the default keyring also has an effect when requesting
915 a key from user space; see
916 .BR request_key (2)
917 for details.
918 .IP
919 The
920 .I arg2
921 argument (cast to
922 .IR int )
923 should contain one of the following values,
924 to specify the new default keyring:
925 .RS
926 .TP
927 .BR KEY_REQKEY_DEFL_NO_CHANGE
928 Don't change the default keyring.
929 This can be used to discover the current default keyring
930 (without changing it).
931 .TP
932 .BR KEY_REQKEY_DEFL_DEFAULT
933 This selects the default behaviour,
934 which is to use the thread-specific keyring if there is one,
935 otherwise the process-specific keyring if there is one,
936 otherwise the session keyring if there is one,
937 otherwise the UID-specific session keyring,
938 otherwise the user-specific keyring.
939 .TP
940 .BR KEY_REQKEY_DEFL_THREAD_KEYRING
941 Use the thread-specific keyring
942 .RB ( thread-keyring (7))
943 as the new default keyring.
944 .TP
945 .BR KEY_REQKEY_DEFL_PROCESS_KEYRING
946 Use the process-specific keyring
947 .RB ( process-keyring (7))
948 as the new default keyring.
949 .TP
950 .BR KEY_REQKEY_DEFL_SESSION_KEYRING
951 Use the session-specific keyring
952 .RB ( session-keyring (7))
953 as the new default keyring.
954 .TP
955 .BR KEY_REQKEY_DEFL_USER_KEYRING
956 Use the UID-specific keyring
957 .RB ( user-keyring (7))
958 as the new default keyring.
959 .TP
960 .BR KEY_REQKEY_DEFL_USER_SESSION_KEYRING
961 Use the UID-specific session keyring
962 .RB ( user-session-keyring (7))
963 as the new default keyring.
964 .TP
965 .BR KEY_REQKEY_DEFL_REQUESTOR_KEYRING " (since Linux 2.6.29)"
966 '\" 8bbf4976b59fc9fc2861e79cab7beb3f6d647640
967 Use the requestor keyring.
968 .\" FIXME The preceding explanation needs to be expanded.
969 .\" Is the following correct:
970 .\"
971 .\" The requestor keyring is the dest_keyring that
972 .\" was supplied to a call to request_key(2)?
973 .\"
974 .\" David Howells said: to be checked
975 .RE
976 .IP
977 All other values are invalid.
978 .\" (including the still-unsupported KEY_REQKEY_DEFL_GROUP_KEYRING)
979 .IP
980 The arguments
981 .IR arg3 ,
982 .IR arg4 ,
983 and
984 .IR arg5
985 are ignored.
986 .IP
987 The setting controlled by this operation is inherited by the child of
988 .BR fork (2)
989 and preserved across
990 .BR execve (2).
991 .IP
992 This operation is exposed by
993 .I libkeyutils
994 via the function
995 .BR keyctl_set_reqkey_keyring (3).
996 .TP
997 .BR KEYCTL_SET_TIMEOUT " (since Linux 2.6.16)"
998 Set a timeout on a key.
999 .IP
1000 The ID of the key is specified in
1001 .I arg2
1002 (cast to
1003 .IR key_serial_t ).
1004 The timeout value, in seconds from the current time,
1005 is specified in
1006 .I arg3
1007 (cast to
1008 .IR "unsigned int" ).
1009 The timeout is measured against the realtime clock.
1010 .IP
1011 Specifying the timeout value as 0 clears any existing timeout on the key.
1012 .IP
1013 The
1014 .I /proc/keys
1015 file displays the remaining time until each key will expire.
1016 (This is the only method of discovering the timeout on a key.)
1017 .IP
1018 The caller must either have the
1019 .I setattr
1020 permission on the key
1021 or hold an instantiation authorization token for the key (see
1022 .BR request_key (2)).
1023 .IP
1024 The key and any links to the key will be
1025 automatically garbage collected after the timeout expires.
1026 Subsequent attempts to access the key will then fail with the error
1027 .BR EKEYEXPIRED .
1028 .IP
1029 This operation cannot be used to set timeouts on revoked, expired,
1030 or negatively instantiated keys.
1031 .IP
1032 The arguments
1033 .IR arg4
1034 and
1035 .IR arg5
1036 are ignored.
1037 .IP
1038 This operation is exposed by
1039 .I libkeyutils
1040 via the function
1041 .BR keyctl_set_timeout (3).
1042 .TP
1043 .BR KEYCTL_ASSUME_AUTHORITY " (since Linux 2.6.16)"
1044 Assume (or divest) the authority for the calling thread
1045 to instantiate a key.
1046 .IP
1047 The
1048 .I arg2
1049 argument (cast to
1050 .IR key_serial_t )
1051 specifies either a nonzero key ID to assume authority,
1052 or the value 0 to divest authority.
1053 .IP
1054 If
1055 .I arg2
1056 is nonzero, then it specifies the ID of an uninstantiated key for which
1057 authority is to be assumed.
1058 That key can then be instantiated using one of
1059 .BR KEYCTL_INSTANTIATE ,
1060 .BR KEYCTL_INSTANTIATE_IOV ,
1061 .BR KEYCTL_REJECT ,
1062 or
1063 .BR KEYCTL_NEGATE .
1064 Once the key has been instantiated,
1065 the thread is automatically divested of authority to instantiate the key.
1066 .IP
1067 Authority over a key can be assumed only if the calling thread has present
1068 in its keyrings the authorization key that is
1069 associated with the specified key.
1070 (In other words, the
1071 .BR KEYCTL_ASSUME_AUTHORITY
1072 operation is available only from a
1073 .BR request-key (8)-style
1074 program; see
1075 .BR request_key (2)
1076 for an explanation of how this operation is used.)
1077 The caller must have
1078 .I search
1079 permission on the authorization key.
1080 .IP
1081 If the specified key has a matching authorization key,
1082 then the ID of that key is returned.
1083 The authorization key can be read
1084 .RB ( KEYCTL_READ )
1085 to obtain the callout information passed to
1086 .BR request_key (2).
1087 .IP
1088 If the ID given in
1089 .I arg2
1090 is 0, then the currently assumed authority is cleared (divested),
1091 and the value 0 is returned.
1092 .IP
1093 The
1094 .BR KEYCTL_ASSUME_AUTHORITY
1095 mechanism allows a program such as
1096 .BR request-key (8)
1097 to assume the necessary authority to instantiate a new uninstantiated key
1098 that was created as a consequence of a call to
1099 .BR request_key (2).
1100 For further information, see
1101 .BR request_key (2)
1102 and the kernel source file
1103 .IR Documentation/security/keys-request-key.txt .
1104 .IP
1105 The arguments
1106 .IR arg3 ,
1107 .IR arg4 ,
1108 and
1109 .IR arg5
1110 are ignored.
1111 .IP
1112 This operation is exposed by
1113 .I libkeyutils
1114 via the function
1115 .BR keyctl_assume_authority (3).
1116 .TP
1117 .BR KEYCTL_GET_SECURITY " (since Linux 2.6.26)"
1118 .\" commit 70a5bb72b55e82fbfbf1e22cae6975fac58a1e2d
1119 Get the LSM (Linux Security Module) security label of the specified key.
1120 .IP
1121 The ID of the key whose security label is to be fetched is specified in
1122 .I arg2
1123 (cast to
1124 .IR key_serial_t ).
1125 The security label (terminated by a null byte)
1126 will be placed in the buffer pointed to by
1127 .I arg3
1128 argument (cast to
1129 .IR "char\ *" );
1130 the size of the buffer must be provided in
1131 .I arg4
1132 (cast to
1133 .IR size_t ).
1134 .IP
1135 If
1136 .I arg3
1137 is specified as NULL or the buffer size specified in
1138 .IR arg4
1139 is too small, the full size of the security label string
1140 (including the terminating null byte)
1141 is returned as the function result,
1142 and nothing is copied to the buffer.
1143 .IP
1144 The caller must have
1145 .I view
1146 permission on the specified key.
1147 .IP
1148 The returned security label string will be rendered in a form appropriate
1149 to the LSM in force.
1150 For example, with SELinux, it may look like:
1151 .IP
1152 unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
1153 .IP
1154 If no LSM is currently in force,
1155 then an empty string is placed in the buffer.
1156 .IP
1157 The
1158 .I arg5
1159 argument is ignored.
1160 .IP
1161 This operation is exposed by
1162 .I libkeyutils
1163 via the functions
1164 .BR keyctl_get_security (3)
1165 and
1166 .BR keyctl_get_security_alloc (3).
1167 .TP
1168 .BR KEYCTL_SESSION_TO_PARENT " (since Linux 2.6.32)"
1169 .\" commit ee18d64c1f632043a02e6f5ba5e045bb26a5465f
1170 Replace the session keyring to which the
1171 .I parent
1172 of the calling process
1173 subscribes with the session keyring of the calling process.
1174 .\" What is the use case for KEYCTL_SESSION_TO_PARENT?
1175 .\" David Howells: the Process Authentication Groups people requested this,
1176 .\" but then didn't use it; maybe there are no users.
1177 .IP
1178 The keyring will be replaced in the parent process at the point
1179 where the parent next transitions from kernel space to user space.
1180 .IP
1181 The keyring must exist and must grant the caller
1182 .I link
1183 permission.
1184 The parent process must be single-threaded and have
1185 the same effective ownership as this process
1186 and must not be set-user-ID or set-group-ID.
1187 The UID of the parent process's existing session keyring (f it has one),
1188 as well as the UID of the caller's session keyring
1189 much match the caller's effective UID.
1190 .IP
1191 The fact that it is the parent process that is affected by this operation
1192 allows a program such as the shell to start a child process that
1193 uses this operation to change the shell's session keyring.
1194 (This is what the
1195 .BR keyctl (1)
1196 .B new_session
1197 command does.)
1198 .IP
1199 The arguments
1200 .IR arg2 ,
1201 .IR arg3 ,
1202 .IR arg4 ,
1203 and
1204 .IR arg5
1205 are ignored.
1206 .IP
1207 This operation is exposed by
1208 .I libkeyutils
1209 via the function
1210 .BR keyctl_session_to_parent (3).
1211 .TP
1212 .BR KEYCTL_REJECT " (since Linux 2.6.39)"
1213 .\" commit fdd1b94581782a2ddf9124414e5b7a5f48ce2f9c
1214 Mark a key as negatively instantiated and set an expiration timer
1215 on the key.
1216 This operation provides a superset of the functionality of the earlier
1217 .BR KEYCTL_NEGATE
1218 operation.
1219 .IP
1220 The ID of the key that is to be negatively instantiated is specified in
1221 .I arg2
1222 (cast to
1223 .IR key_serial_t ).
1224 The
1225 .I arg3
1226 (cast to
1227 .IR "unsigned int" )
1228 argument specifies the lifetime of the key, in seconds.
1229 The
1230 .I arg4
1231 argument (cast to
1232 .IR "unsigned int" )
1233 specifies the error to be returned when a search hits this key;
1234 typically, this is one of
1235 .BR EKEYREJECTED ,
1236 .BR EKEYREVOKED ,
1237 or
1238 .BR EKEYEXPIRED .
1239 .IP
1240 If
1241 .I arg5
1242 (cast to
1243 .IR key_serial_t )
1244 is nonzero, then, subject to the same constraints and rules as
1245 .BR KEYCTL_LINK ,
1246 the negatively instantiated key is linked into the keyring
1247 whose ID is specified in
1248 .IR arg5 .
1249 .IP
1250 The caller must have the appropriate authorization key.
1251 In other words, this operation is available only from a
1252 .BR request-key (8)-style
1253 program.
1254 See
1255 .BR request_key (2).
1256 .IP
1257 The caller must have the appropriate authorization key,
1258 and once the uninstantiated key has been instantiated,
1259 the authorization key is revoked.
1260 In other words, this operation is available only from a
1261 .BR request-key (8)-style
1262 program.
1263 See
1264 .BR request_key (2)
1265 for an explanation of uninstantiated keys and key instantiation.
1266 .IP
1267 This operation is exposed by
1268 .I libkeyutils
1269 via the function
1270 .BR keyctl_reject (3).
1271 .TP
1272 .BR KEYCTL_INSTANTIATE_IOV " (since Linux 2.6.39)"
1273 .\" commit ee009e4a0d4555ed522a631bae9896399674f063
1274 Instantiate an uninstantiated key with a payload specified
1275 via a vector of buffers.
1276 .IP
1277 This operation is the same as
1278 .BR KEYCTL_INSTANTIATE ,
1279 but the payload data is specified as an array of
1280 .IR iovec
1281 structures:
1282 .IP
1283 .in +4n
1284 .EX
1285 struct iovec {
1286 void *iov_base; /* Starting address of buffer */
1287 size_t iov_len; /* Size of buffer (in bytes) */
1288 };
1289 .EE
1290 .in
1291 .IP
1292 The pointer to the payload vector is specified in
1293 .IR arg3
1294 (cast as
1295 .IR "const struct iovec\ *" ).
1296 The number of items in the vector is specified in
1297 .IR arg4
1298 (cast as
1299 .IR "unsigned int" ).
1300 .IP
1301 The
1302 .I arg2
1303 (key ID)
1304 and
1305 .I arg5
1306 (keyring ID)
1307 are interpreted as for
1308 .BR KEYCTL_INSTANTIATE .
1309 .IP
1310 This operation is exposed by
1311 .I libkeyutils
1312 via the function
1313 .BR keyctl_instantiate_iov (3).
1314 .TP
1315 .BR KEYCTL_INVALIDATE " (since Linux 3.5)"
1316 .\" commit fd75815f727f157a05f4c96b5294a4617c0557da
1317 Mark a key as invalid.
1318 .IP
1319 The ID of the key to be invalidated is specified in
1320 .I arg2
1321 (cast to
1322 .IR key_serial_t ).
1323 .IP
1324 To invalidate a key,
1325 the caller must have
1326 .I search
1327 permission on the key.
1328 .\" CAP_SYS_ADMIN is permitted to invalidate certain special keys
1329 .IP
1330 This operation marks the key as invalid
1331 and schedules immediate garbage collection.
1332 The garbage collector removes the invalidated key from all keyrings and
1333 deletes the key when its reference count reaches zero.
1334 After this operation,
1335 the key will be ignored by all searches,
1336 even if it is not yet deleted.
1337 .IP
1338 Keys that are marked invalid become invisible to normal key operations
1339 immediately, though they are still visible in
1340 .I /proc/keys
1341 (marked with an 'i' flag)
1342 until they are actually removed.
1343 .IP
1344 The arguments
1345 .IR arg3 ,
1346 .IR arg4 ,
1347 and
1348 .IR arg5
1349 are ignored.
1350 .IP
1351 This operation is exposed by
1352 .I libkeyutils
1353 via the function
1354 .BR keyctl_invalidate (3).
1355 .TP
1356 .BR KEYCTL_GET_PERSISTENT " (since Linux 3.13)"
1357 .\" commit f36f8c75ae2e7d4da34f4c908cebdb4aa42c977e
1358 Get the persistent keyring
1359 .RB ( persistent-keyring (7))
1360 for a specified user and link it to a specified keyring.
1361 .IP
1362 The user ID is specified in
1363 .I arg2
1364 (cast to
1365 .IR uid_t ).
1366 If the value \-1 is specified, the caller's real user ID is used.
1367 The ID of the destination keyring is specified in
1368 .I arg3
1369 (cast to
1370 .IR key_serial_t ).
1371 .IP
1372 The caller must have the
1373 .BR CAP_SETUID
1374 capability in its user namespace in order to fetch the persistent keyring
1375 for a user ID that does not match either the real or effective user ID
1376 of the caller.
1377 .IP
1378 If the call is successful,
1379 a link to the persistent keyring is added to the keyring
1380 whose ID was specified in
1381 .IR arg3 .
1382 .IP
1383 The caller must have
1384 .I write
1385 permission on the keyring.
1386 .IP
1387 The persistent keyring will be created by the kernel
1388 if it does not yet exist.
1389 .IP
1390 Each time the
1391 .B KEYCTL_GET_PERSISTENT
1392 operation is performed, the persistent keyring will
1393 have its expiration timeout reset to the value in:
1394 .IP
1395 .in +4n
1396 .EX
1397 /proc/sys/kernel/keys/persistent_keyring_expiry
1398 .EE
1399 .in
1400 .IP
1401 Should the timeout be reached,
1402 the persistent keyring will be removed and
1403 everything it pins can then be garbage collected.
1404 .IP
1405 Persistent keyrings were added to Linux in kernel version 3.13.
1406 .IP
1407 The arguments
1408 .IR arg4
1409 and
1410 .IR arg5
1411 are ignored.
1412 .IP
1413 This operation is exposed by
1414 .I libkeyutils
1415 via the function
1416 .BR keyctl_get_persistent (3).
1417 .TP
1418 .BR KEYCTL_DH_COMPUTE " (since Linux 4.7)"
1419 .\" commit ddbb41148724367394d0880c516bfaeed127b52e
1420 Compute a Diffie-Hellman shared secret or public key,
1421 optionally applying key derivation function (KDF) to the result.
1422 .IP
1423 The
1424 .I arg2
1425 argument is a pointer to a set of parameters containing
1426 serial numbers for three
1427 .IR """user"""
1428 keys used in the Diffie-Hellman calculation,
1429 packaged in a structure of the following form:
1430 .IP
1431 .in +4n
1432 .EX
1433 struct keyctl_dh_params {
1434 int32_t private; /* The local private key */
1435 int32_t prime; /* The prime, known to both parties */
1436 int32_t base; /* The base integer: either a shared
1437 generator or the remote public key */
1438 };
1439 .EE
1440 .in
1441 .IP
1442 Each of the three keys specified in this structure must grant the caller
1443 .I read
1444 permission.
1445 The payloads of these keys are used to calculate the Diffie-Hellman
1446 result as:
1447 .IP
1448 base ^ private mod prime
1449 .IP
1450 If the base is the shared generator, the result is the local public key.
1451 If the base is the remote public key, the result is the shared secret.
1452 .IP
1453 The
1454 .I arg3
1455 argument (cast to
1456 .IR "char\ *" )
1457 points to a buffer where the result of the calculation is placed.
1458 The size of that buffer is specified in
1459 .I arg4
1460 (cast to
1461 .IR size_t ).
1462 .IP
1463 The buffer must be large enough to accommodate the output data,
1464 otherwise an error is returned.
1465 If
1466 .I arg4
1467 is specified zero,
1468 in which case the buffer is not used and
1469 the operation returns the minimum required buffer size
1470 (i.e., the length of the prime).
1471 .IP
1472 Diffie-Hellman computations can be performed in user space,
1473 but require a multiple-precision integer (MPI) library.
1474 Moving the implementation into the kernel gives access to
1475 the kernel MPI implementation,
1476 and allows access to secure or acceleration hardware.
1477 .IP
1478 Adding support for DH computation to the
1479 .BR keyctl ()
1480 system call was considered a good fit due to the DH algorithm's use
1481 for deriving shared keys;
1482 it also allows the type of the key to determine
1483 which DH implementation (software or hardware) is appropriate.
1484 .\" commit f1c316a3ab9d24df6022682422fe897492f2c0c8
1485 .IP
1486 If the
1487 .I arg5
1488 argument is
1489 .BR NULL ,
1490 then the DH result itself is returned.
1491 Otherwise (since Linux 4.12), it is a pointer to a structure which specifies
1492 parameters of the KDF operation to be applied:
1493 .IP
1494 .in +4n
1495 .EX
1496 struct keyctl_kdf_params {
1497 char *hashname; /* Hash algorithm name */
1498 char *otherinfo; /* SP800-56A OtherInfo */
1499 __u32 otherinfolen; /* Length of otherinfo data */
1500 __u32 __spare[8]; /* Reserved */
1501 };
1502 .EE
1503 .in
1504 .IP
1505 The
1506 .I hashname
1507 field is a null-terminated string which specifies a hash name
1508 (available in the kernel's crypto API; the list of the hashes available
1509 is rather tricky to observe; please refer to the
1510 .UR https://www.kernel.org\:/doc\:/html\:/latest\:/crypto\:/architecture.html
1511 "Kernel Crypto API Architecture"
1512 .UE
1513 documentation for the information regarding how hash names are constructed and
1514 your kernel's source and configuration regarding what ciphers
1515 and templates with type
1516 .B CRYPTO_ALG_TYPE_SHASH
1517 are available)
1518 to be applied to DH result in KDF operation.
1519 .IP
1520 The
1521 .I otherinfo
1522 field is an
1523 .I OtherInfo
1524 data as described in SP800-56A section 5.8.1.2 and is algorithm-specific.
1525 This data is concatenated with the result of DH operation and is provided as
1526 an input to the KDF operation.
1527 Its size is provided in the
1528 .I otherinfolen
1529 field and is limited by
1530 .B KEYCTL_KDF_MAX_OI_LEN
1531 constant that defined in
1532 .I security/keys/internal.h
1533 to a value of 64.
1534 .IP
1535 The
1536 .B __spare
1537 field is currently unused.
1538 .\" commit 4f9dabfaf8df971f8a3b6aa324f8f817be38d538
1539 It was ignored until Linux 4.13 (but still should be
1540 user-addressable since it is copied to the kernel),
1541 and should contain zeros since Linux 4.13.
1542 .IP
1543 The KDF implementation complies with SP800-56A as well
1544 as with SP800-108 (the counter KDF).
1545 .IP
1546 .\" keyutils commit 742c9d7b94051d3b21f9f61a73ed6b5f3544cb82
1547 .\" keyutils commit d68a981e5db41d059ac782071c35d1e8f3aaf61c
1548 This operation is exposed by
1549 .I libkeyutils
1550 (from version 1.5.10 onwards) via the functions
1551 .BR keyctl_dh_compute (3)
1552 and
1553 .BR keyctl_dh_compute_alloc (3).
1554 .TP
1555 .BR KEYCTL_RESTRICT_KEYRING " (since Linux 4.12)"
1556 .\" commit 6563c91fd645556c7801748f15bc727c77fcd311
1557 .\" commit 7228b66aaf723a623e578aa4db7d083bb39546c9
1558 Apply a key-linking restriction to the keyring with the ID provided in
1559 .IR arg2
1560 (cast to
1561 .IR key_serial_t ).
1562 The caller must have
1563 .IR setattr
1564 permission on the key.
1565 If
1566 .I arg3
1567 is NULL, any attempt to add a key to the keyring is blocked;
1568 otherwise it contains a pointer to a string with a key type name and
1569 .I arg4
1570 contains a pointer to string that describes the type-specific restriction.
1571 As of Linux 4.12, only the type "asymmetric" has restrictions defined:
1572 .RS
1573 .TP
1574 .B builtin_trusted
1575 Allows only keys that are signed by a key linked to the built-in keyring
1576 (".builtin_trusted_keys").
1577 .TP
1578 .B builtin_and_secondary_trusted
1579 Allows only keys that are signed by a key linked to the secondary keyring
1580 (".secondary_trusted_keys") or, by extension, a key in a built-in keyring,
1581 as the latter is linked to the former.
1582 .TP
1583 .BI key_or_keyring: key
1584 .TQ
1585 .BI key_or_keyring: key :chain
1586 If
1587 .I key
1588 specifies the ID of a key of type "asymmetric",
1589 then only keys that are signed by this key are allowed.
1590 .IP
1591 If
1592 .I key
1593 specifies the ID of a keyring,
1594 then only keys that are signed by a key linked
1595 to this keyring are allowed.
1596 .IP
1597 If ":chain" is specified, keys that are signed by a keys linked to the
1598 destination keyring (that is, the keyring with the ID specified in the
1599 .I arg2
1600 argument) are also allowed.
1601 .RE
1602 .IP
1603 Note that a restriction can be configured only once for the specified keyring;
1604 once a restriction is set, it can't be overridden.
1605 .IP
1606 The argument
1607 .I arg5
1608 is ignored.
1609 .\" FIXME Document KEYCTL_RESTRICT_KEYRING, added in Linux 4.12
1610 .\" commit 6563c91fd645556c7801748f15bc727c77fcd311
1611 .\" Author: Mat Martineau <mathew.j.martineau@linux.intel.com>
1612 .\" See Documentation/security/keys.txt
1613 .SH RETURN VALUE
1614 For a successful call, the return value depends on the operation:
1615 .TP
1616 .B KEYCTL_GET_KEYRING_ID
1617 The ID of the requested keyring.
1618 .TP
1619 .B KEYCTL_JOIN_SESSION_KEYRING
1620 The ID of the joined session keyring.
1621 .TP
1622 .B KEYCTL_DESCRIBE
1623 The size of the description (including the terminating null byte),
1624 irrespective of the provided buffer size.
1625 .TP
1626 .B KEYCTL_SEARCH
1627 The ID of the key that was found.
1628 .TP
1629 .B KEYCTL_READ
1630 The amount of data that is available in the key,
1631 irrespective of the provided buffer size.
1632 .TP
1633 .B KEYCTL_SET_REQKEY_KEYRING
1634 The ID of the previous default keyring
1635 to which implicitly requested keys were linked
1636 (one of
1637 .BR KEY_REQKEY_DEFL_USER_* ).
1638 .TP
1639 .B KEYCTL_ASSUME_AUTHORITY
1640 Either 0, if the ID given was 0,
1641 or the ID of the authorization key matching the specified key,
1642 if a nonzero key ID was provided.
1643 .TP
1644 .B KEYCTL_GET_SECURITY
1645 The size of the LSM security label string
1646 (including the terminating null byte),
1647 irrespective of the provided buffer size.
1648 .TP
1649 .B KEYCTL_GET_PERSISTENT
1650 The ID of the persistent keyring.
1651 .TP
1652 .B KEYCTL_DH_COMPUTE
1653 The number of bytes copied to the buffer, or, if
1654 .I arg4
1655 is 0, the required buffer size.
1656 .TP
1657 All other operations
1658 Zero.
1659 .PP
1660 On error, \-1 is returned, and
1661 .I errno
1662 is set appropriately to indicate the error.
1663 .SH ERRORS
1664 .TP
1665 .B EACCES
1666 The requested operation wasn't permitted.
1667 .TP
1668 .B EAGAIN
1669 .I operation
1670 was
1671 .B KEYCTL_DH_COMPUTE
1672 and there was an error during crypto module initialization.
1673 .TP
1674 .B EDEADLK
1675 .I operation
1676 was
1677 .BR KEYCTL_LINK
1678 and the requested link would result in a cycle.
1679 .TP
1680 .B EDEADLK
1681 .I operation
1682 was
1683 .BR KEYCTL_RESTRICT_KEYRING
1684 and the requested keyring restriction would result in a cycle.
1685 .TP
1686 .B EDQUOT
1687 The key quota for the caller's user would be exceeded by creating a key or
1688 linking it to the keyring.
1689 .TP
1690 .B EEXIST
1691 .I operation
1692 was
1693 .BR KEYCTL_RESTRICT_KEYRING
1694 and keyring provided in
1695 .I arg2
1696 argument already has a restriction set.
1697 .TP
1698 .B EFAULT
1699 .I operation
1700 was
1701 .B KEYCTL_DH_COMPUTE
1702 and one of the following has failed:
1703 .RS
1704 .IP \(bu 3
1705 copying of the
1706 .IR "struct keyctl_dh_params" ,
1707 provided in the
1708 .I arg2
1709 argument, from user space;
1710 .IP \(bu
1711 copying of the
1712 .IR "struct keyctl_kdf_params" ,
1713 provided in the non-NULL
1714 .I arg5
1715 argument, from user space
1716 (in case kernel supports performing KDF operation on DH operation result);
1717 .IP \(bu
1718 copying of data pointed by the
1719 .I hashname
1720 field of the
1721 .I "struct keyctl_kdf_params"
1722 from user space;
1723 .IP \(bu
1724 copying of data pointed by the
1725 .I otherinfo
1726 field of the
1727 .I struct keyctl_kdf_params
1728 from user space if the
1729 .I otherinfolen
1730 field was nonzero;
1731 .IP \(bu
1732 copying of the result to user space.
1733 .RE
1734 .TP
1735 .B EINVAL
1736 .I operation
1737 was
1738 .B KEYCTL_SETPERM
1739 and an invalid permission bit was specified in
1740 .IR arg3 .
1741 .TP
1742 .B EINVAL
1743 .I operation
1744 was
1745 .BR KEYCTL_SEARCH
1746 and the size of the description in
1747 .IR arg4
1748 (including the terminating null byte) exceeded 4096 bytes.
1749 size of the string (including the terminating null byte) specified in
1750 .I arg3
1751 (the key type)
1752 or
1753 .I arg4
1754 (the key description)
1755 exceeded the limit (32 bytes and 4096 bytes respectively).
1756 .TP
1757 .BR EINVAL " (Linux kernels before 4.12)"
1758 .I operation
1759 was
1760 .BR KEYCTL_DH_COMPUTE ,
1761 argument
1762 .I arg5
1763 was non-NULL.
1764 .TP
1765 .B EINVAL
1766 .I operation
1767 was
1768 .B KEYCTL_DH_COMPUTE
1769 And the digest size of the hashing algorithm supplied is zero.
1770 .TP
1771 .B EINVAL
1772 .I operation
1773 was
1774 .B KEYCTL_DH_COMPUTE
1775 and the buffer size provided is not enough to hold the result.
1776 Provide 0 as a buffer size in order to obtain the minimum buffer size.
1777 .TP
1778 .B EINVAL
1779 .I operation
1780 was
1781 .B KEYCTL_DH_COMPUTE
1782 and the hash name provided in the
1783 .I hashname
1784 field of the
1785 .I struct keyctl_kdf_params
1786 pointed by
1787 .I arg5
1788 argument is too big (the limit is implementation-specific and varies between
1789 kernel versions, but it is deemed big enough for all valid algorithm names).
1790 .TP
1791 .B EINVAL
1792 .\" commit 4f9dabfaf8df971f8a3b6aa324f8f817be38d538
1793 .I operation
1794 was
1795 .B KEYCTL_DH_COMPUTE
1796 and the
1797 .I __spare
1798 field of the
1799 .I struct keyctl_kdf_params
1800 provided in the
1801 .I arg5
1802 argument contains nonzero values.
1803 .TP
1804 .B EKEYEXPIRED
1805 An expired key was found or specified.
1806 .TP
1807 .B EKEYREJECTED
1808 A rejected key was found or specified.
1809 .TP
1810 .B EKEYREVOKED
1811 A revoked key was found or specified.
1812 .TP
1813 .B ELOOP
1814 .I operation
1815 was
1816 .BR KEYCTL_LINK
1817 and the requested link would cause the maximum nesting depth
1818 for keyrings to be exceeded.
1819 .TP
1820 .B EMSGSIZE
1821 .I operation
1822 was
1823 .B KEYCTL_DH_COMPUTE
1824 and the buffer length exceeds
1825 .B KEYCTL_KDF_MAX_OUTPUT_LEN
1826 (which is 1024 currently)
1827 or the
1828 .I otherinfolen
1829 field of the
1830 .I struct keyctl_kdf_parms
1831 passed in
1832 .I arg5
1833 exceeds
1834 .B KEYCTL_KDF_MAX_OI_LEN
1835 (which is 64 currently).
1836 .TP
1837 .BR ENFILE " (Linux kernels before 3.13)"
1838 .IR operation
1839 was
1840 .BR KEYCTL_LINK
1841 and the keyring is full.
1842 (Before Linux 3.13,
1843 .\" commit b2a4df200d570b2c33a57e1ebfa5896e4bc81b69
1844 the available space for storing keyring links was limited to
1845 a single page of memory; since Linux 3.13, there is no fixed limit.)
1846 .TP
1847 .B ENOENT
1848 .I operation
1849 was
1850 .B KEYCTL_UNLINK
1851 and the key to be unlinked isn't linked to the keyring.
1852 .TP
1853 .B ENOENT
1854 .I operation
1855 was
1856 .B KEYCTL_DH_COMPUTE
1857 and the hashing algorithm specified in the
1858 .I hashname
1859 field of the
1860 .I struct keyctl_kdf_params
1861 pointed by
1862 .I arg5
1863 argument hasn't been found.
1864 .TP
1865 .B ENOENT
1866 .I operation
1867 was
1868 .B KEYCTL_RESTRICT_KEYRING
1869 and the type provided in
1870 .I arg3
1871 argument doesn't support setting key linking restrictions.
1872 .TP
1873 .B ENOKEY
1874 No matching key was found or an invalid key was specified.
1875 .TP
1876 .B ENOKEY
1877 The value
1878 .B KEYCTL_GET_KEYRING_ID
1879 was specified in
1880 .IR operation ,
1881 the key specified in
1882 .I arg2
1883 did not exist, and
1884 .I arg3
1885 was zero (meaning don't create the key if it didn't exist).
1886 .TP
1887 .B ENOMEM
1888 One of kernel memory allocation routines failed during the execution of the
1889 syscall.
1890 .TP
1891 .B ENOTDIR
1892 A key of keyring type was expected but the ID of a key with
1893 a different type was provided.
1894 .TP
1895 .B EOPNOTSUPP
1896 .I operation
1897 was
1898 .B KEYCTL_READ
1899 and the key type does not support reading
1900 (e.g., the type is
1901 .IR """login""" ).
1902 .TP
1903 .B EOPNOTSUPP
1904 .I operation
1905 was
1906 .B KEYCTL_UPDATE
1907 and the key type does not support updating.
1908 .TP
1909 .B EOPNOTSUPP
1910 .I operation
1911 was
1912 .BR KEYCTL_RESTRICT_KEYRING ,
1913 the type provided in
1914 .I arg3
1915 argument was "asymmetric", and the key specified in the restriction specification
1916 provided in
1917 .I arg4
1918 has type other than "asymmetric" or "keyring".
1919 .TP
1920 .B EPERM
1921 .I operation
1922 was
1923 .BR KEYCTL_GET_PERSISTENT ,
1924 .I arg2
1925 specified a UID other than the calling thread's real or effective UID,
1926 and the caller did not have the
1927 .B CAP_SETUID
1928 capability.
1929 .TP
1930 .B EPERM
1931 .I operation
1932 was
1933 .BR KEYCTL_SESSION_TO_PARENT
1934 and either:
1935 all of the UIDs (GIDs) of the parent process do not match
1936 the effective UID (GID) of the calling process;
1937 the UID of the parent's existing session keyring or
1938 the UID of the caller's session keyring did not match
1939 the effective UID of the caller;
1940 the parent process is not single-thread;
1941 or the parent process is
1942 .BR init (1)
1943 or a kernel thread.
1944 .TP
1945 .B ETIMEDOUT
1946 .I operation
1947 was
1948 .B KEYCTL_DH_COMPUTE
1949 and the initialization of crypto modules has timed out.
1950 .SH VERSIONS
1951 This system call first appeared in Linux 2.6.10.
1952 .SH CONFORMING TO
1953 This system call is a nonstandard Linux extension.
1954 .SH NOTES
1955 No wrapper for this system call is provided in glibc.
1956 A wrapper is provided in the
1957 .IR libkeyutils
1958 library.
1959 When employing the wrapper in that library, link with
1960 .IR \-lkeyutils .
1961 However, rather than using this system call directly,
1962 you probably want to use the various library functions
1963 mentioned in the descriptions of individual operations above.
1964 .SH EXAMPLE
1965 The program below provide subset of the functionality of the
1966 .BR request-key (8)
1967 program provided by the
1968 .I keyutils
1969 package.
1970 For informational purposes,
1971 the program records various information in a log file.
1972 .PP
1973 As described in
1974 .BR request_key (2),
1975 the
1976 .BR request-key (8)
1977 program is invoked with command-line arguments that
1978 describe a key that is to be instantiated.
1979 The example program fetches and logs these arguments.
1980 The program assumes authority to instantiate the requested key,
1981 and then instantiates that key.
1982 .PP
1983 The following shell session demonstrates the use of this program.
1984 In the session,
1985 we compile the program and then use it to temporarily replace the standard
1986 .BR request-key (8)
1987 program.
1988 (Note that temporarily disabling the standard
1989 .BR request-key (8)
1990 program may not be safe on some systems.)
1991 While our example program is installed,
1992 we use the example program shown in
1993 .BR request_key (2)
1994 to request a key.
1995 .PP
1996 .in +4n
1997 .EX
1998 $ \fBcc \-o key_instantiate key_instantiate.c \-lkeyutils\fP
1999 $ \fBsudo mv /sbin/request\-key /sbin/request\-key.backup\fP
2000 $ \fBsudo cp key_instantiate /sbin/request\-key\fP
2001 $ \fB./t_request_key user mykey somepayloaddata\fP
2002 Key ID is 20d035bf
2003 $ \fBsudo mv /sbin/request\-key.backup /sbin/request\-key\fP
2004 .EE
2005 .in
2006 .PP
2007 Looking at the log file created by this program,
2008 we can see the command-line arguments supplied to our example program:
2009 .PP
2010 .in +4n
2011 .EX
2012 $ \fBcat /tmp/key_instantiate.log \fP
2013 Time: Mon Nov 7 13:06:47 2016
2014
2015 Command line arguments:
2016 argv[0]: /sbin/request-key
2017 operation: create
2018 key_to_instantiate: 20d035bf
2019 UID: 1000
2020 GID: 1000
2021 thread_keyring: 0
2022 process_keyring: 0
2023 session_keyring: 256e6a6
2024
2025 Key description: user;1000;1000;3f010000;mykey
2026 Auth key payload: somepayloaddata
2027 Destination keyring: 256e6a6
2028 Auth key description: .request_key_auth;1000;1000;0b010000;20d035bf
2029 .EE
2030 .in
2031 .PP
2032 The last few lines of the above output show that the example program
2033 was able to fetch:
2034 .IP * 3
2035 the description of the key to be instantiated,
2036 which included the name of the key
2037 .RI ( mykey );
2038 .IP *
2039 the payload of the authorization key, which consisted of the data
2040 .RI ( somepayloaddata )
2041 passed to
2042 .BR request_key (2);
2043 .IP *
2044 the destination keyring that was specified in the call to
2045 .BR request_key (2);
2046 and
2047 .IP *
2048 the description of the authorization key,
2049 where we can see that the name of the authorization key matches
2050 the ID of the key that is to be instantiated
2051 .RI ( 20d035bf ).
2052 .PP
2053 The example program in
2054 .BR request_key (2)
2055 specified the destination keyring as
2056 .BR KEY_SPEC_SESSION_KEYRING .
2057 By examining the contents of
2058 .IR /proc/keys ,
2059 we can see that this was translated to the ID of the destination keyring
2060 .RI ( 0256e6a6 )
2061 shown in the log output above;
2062 we can also see the newly created key with the name
2063 .IR mykey
2064 and ID
2065 .IR 20d035bf .
2066 .PP
2067 .in +4n
2068 .EX
2069 $ \fBcat /proc/keys | egrep \(aqmykey|256e6a6\(aq\fP
2070 0256e6a6 I\-\-Q\-\-\- 194 perm 3f030000 1000 1000 keyring _ses: 3
2071 20d035bf I\-\-Q\-\-\- 1 perm 3f010000 1000 1000 user mykey: 16
2072 .EE
2073 .in
2074 .SS Program source
2075 \&
2076 .EX
2077 /* key_instantiate.c */
2078
2079 #include <sys/types.h>
2080 #include <keyutils.h>
2081 #include <time.h>
2082 #include <fcntl.h>
2083 #include <stdio.h>
2084 #include <stdlib.h>
2085 #include <unistd.h>
2086 #include <string.h>
2087 #include <errno.h>
2088
2089 #ifndef KEY_SPEC_REQUESTOR_KEYRING
2090 #define KEY_SPEC_REQUESTOR_KEYRING \-8
2091 #endif
2092
2093 int
2094 main(int argc, char *argv[])
2095 {
2096 FILE *fp;
2097 time_t t;
2098 char *operation;
2099 key_serial_t key_to_instantiate, dest_keyring;
2100 key_serial_t thread_keyring, process_keyring, session_keyring;
2101 uid_t uid;
2102 gid_t gid;
2103 char dbuf[256];
2104 char auth_key_payload[256];
2105 int akp_size; /* Size of auth_key_payload */
2106
2107 fp = fopen("/tmp/key_instantiate.log", "w");
2108 if (fp == NULL)
2109 exit(EXIT_FAILURE);
2110
2111 setbuf(fp, NULL);
2112
2113 t = time(NULL);
2114 fprintf(fp, "Time: %s\en", ctime(&t));
2115
2116 /*
2117 * The kernel passes a fixed set of arguments to the program
2118 * that it execs; fetch them.
2119 */
2120 operation = argv[1];
2121 key_to_instantiate = atoi(argv[2]);
2122 uid = atoi(argv[3]);
2123 gid = atoi(argv[4]);
2124 thread_keyring = atoi(argv[5]);
2125 process_keyring = atoi(argv[6]);
2126 session_keyring = atoi(argv[7]);
2127
2128 fprintf(fp, "Command line arguments:\en");
2129 fprintf(fp, " argv[0]: %s\en", argv[0]);
2130 fprintf(fp, " operation: %s\en", operation);
2131 fprintf(fp, " key_to_instantiate: %lx\en",
2132 (long) key_to_instantiate);
2133 fprintf(fp, " UID: %ld\en", (long) uid);
2134 fprintf(fp, " GID: %ld\en", (long) gid);
2135 fprintf(fp, " thread_keyring: %lx\en", (long) thread_keyring);
2136 fprintf(fp, " process_keyring: %lx\en", (long) process_keyring);
2137 fprintf(fp, " session_keyring: %lx\en", (long) session_keyring);
2138 fprintf(fp, "\en");
2139
2140 /*
2141 * Assume the authority to instantiate the key named in argv[2]
2142 */
2143 if (keyctl(KEYCTL_ASSUME_AUTHORITY, key_to_instantiate) == \-1) {
2144 fprintf(fp, "KEYCTL_ASSUME_AUTHORITY failed: %s\en",
2145 strerror(errno));
2146 exit(EXIT_FAILURE);
2147 }
2148
2149 /*
2150 * Fetch the description of the key that is to be instantiated
2151 */
2152 if (keyctl(KEYCTL_DESCRIBE, key_to_instantiate,
2153 dbuf, sizeof(dbuf)) == \-1) {
2154 fprintf(fp, "KEYCTL_DESCRIBE failed: %s\en", strerror(errno));
2155 exit(EXIT_FAILURE);
2156 }
2157
2158 fprintf(fp, "Key description: %s\en", dbuf);
2159
2160 /*
2161 * Fetch the payload of the authorization key, which is
2162 * actually the callout data given to request_key()
2163 */
2164 akp_size = keyctl(KEYCTL_READ, KEY_SPEC_REQKEY_AUTH_KEY,
2165 auth_key_payload, sizeof(auth_key_payload));
2166 if (akp_size == \-1) {
2167 fprintf(fp, "KEYCTL_READ failed: %s\en", strerror(errno));
2168 exit(EXIT_FAILURE);
2169 }
2170
2171 auth_key_payload[akp_size] = \(aq\e0\(aq;
2172 fprintf(fp, "Auth key payload: %s\en", auth_key_payload);
2173
2174 /*
2175 * For interest, get the ID of the authorization key and
2176 * display it.
2177 */
2178 auth_key = keyctl(KEYCTL_GET_KEYRING_ID,
2179 KEY_SPEC_REQKEY_AUTH_KEY);
2180 if (auth_key == \-1) {
2181 fprintf(fp, "KEYCTL_GET_KEYRING_ID failed: %s\en",
2182 strerror(errno));
2183 exit(EXIT_FAILURE);
2184 }
2185
2186 fprintf(fp, "Auth key ID: %lx\en", (long) auth_key);
2187
2188 /*
2189 * Fetch key ID for the request_key(2) destination keyring.
2190 */
2191 dest_keyring = keyctl(KEYCTL_GET_KEYRING_ID,
2192 KEY_SPEC_REQUESTOR_KEYRING);
2193 if (dest_keyring == \-1) {
2194 fprintf(fp, "KEYCTL_GET_KEYRING_ID failed: %s\en",
2195 strerror(errno));
2196 exit(EXIT_FAILURE);
2197 }
2198
2199 fprintf(fp, "Destination keyring: %lx\en", (long) dest_keyring);
2200
2201 /*
2202 * Fetch the description of the authorization key. This
2203 * allows us to see the key type, UID, GID, permissions,
2204 * and description (name) of the key. Among other things,
2205 * we will see that the name of the key is a hexadecimal
2206 * string representing the ID of the key to be instantiated.
2207 */
2208 if (keyctl(KEYCTL_DESCRIBE, KEY_SPEC_REQKEY_AUTH_KEY,
2209 dbuf, sizeof(dbuf)) == \-1) {
2210 fprintf(fp, "KEYCTL_DESCRIBE failed: %s\en", strerror(errno));
2211 exit(EXIT_FAILURE);
2212 }
2213
2214 fprintf(fp, "Auth key description: %s\en", dbuf);
2215
2216 /*
2217 * Instantiate the key using the callout data that was supplied
2218 * in the payload of the authorization key.
2219 */
2220 if (keyctl(KEYCTL_INSTANTIATE, key_to_instantiate,
2221 auth_key_payload, akp_size + 1, dest_keyring) == \-1) {
2222 fprintf(fp, "KEYCTL_INSTANTIATE failed: %s\en",
2223 strerror(errno));
2224 exit(EXIT_FAILURE);
2225 }
2226
2227 exit(EXIT_SUCCESS);
2228 }
2229 .EE
2230 .SH SEE ALSO
2231 .ad l
2232 .nh
2233 .BR keyctl (1),
2234 .BR add_key (2),
2235 .BR request_key (2),
2236 .\" .BR find_key_by_type_and_name (3)
2237 .\" There is a man page, but this function seems not to exist
2238 .BR keyctl (3),
2239 .BR keyctl_assume_authority (3),
2240 .BR keyctl_chown (3),
2241 .BR keyctl_clear (3),
2242 .BR keyctl_describe (3),
2243 .BR keyctl_describe_alloc (3),
2244 .BR keyctl_dh_compute (3),
2245 .BR keyctl_dh_compute_alloc (3),
2246 .BR keyctl_get_keyring_ID (3),
2247 .BR keyctl_get_persistent (3),
2248 .BR keyctl_get_security (3),
2249 .BR keyctl_get_security_alloc (3),
2250 .BR keyctl_instantiate (3),
2251 .BR keyctl_instantiate_iov (3),
2252 .BR keyctl_invalidate (3),
2253 .BR keyctl_join_session_keyring (3),
2254 .BR keyctl_link (3),
2255 .BR keyctl_negate (3),
2256 .BR keyctl_read (3),
2257 .BR keyctl_read_alloc (3),
2258 .BR keyctl_reject (3),
2259 .BR keyctl_revoke (3),
2260 .BR keyctl_search (3),
2261 .BR keyctl_session_to_parent (3),
2262 .BR keyctl_set_reqkey_keyring (3),
2263 .BR keyctl_set_timeout (3),
2264 .BR keyctl_setperm (3),
2265 .BR keyctl_unlink (3),
2266 .BR keyctl_update (3),
2267 .BR recursive_key_scan (3),
2268 .BR recursive_session_key_scan (3),
2269 .BR capabilities (7),
2270 .BR credentials (7),
2271 .BR keyrings (7),
2272 .BR keyutils (7),
2273 .BR persistent\-keyring (7),
2274 .BR process\-keyring (7),
2275 .BR session\-keyring (7),
2276 .BR thread\-keyring (7),
2277 .BR user\-keyring (7),
2278 .BR user_namespaces (7),
2279 .BR user\-session\-keyring (7),
2280 .BR request\-key (8)
2281 .PP
2282 The kernel source files under
2283 .IR Documentation/security/keys/
2284 (or, before Linux 4.13, in the file
2285 .IR Documentation/security/keys.txt ).