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