aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/keys.txt
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-10-28 12:17:52 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-10-28 12:17:52 -0400
commit90890687859ea658759e653c4e70ed7e9e1a6217 (patch)
tree9065b30bb189e16ef99b8b5a0d444558f8dc579f /Documentation/keys.txt
parent2995bfb7855aabd493f840af361f3dd7d221caea (diff)
parent5fadd053d9bb4345ec6f405d24db4e7eb49cf81e (diff)
Merge branch 'master'
Diffstat (limited to 'Documentation/keys.txt')
-rw-r--r--Documentation/keys.txt92
1 files changed, 66 insertions, 26 deletions
diff --git a/Documentation/keys.txt b/Documentation/keys.txt
index 0321ded4b9ae..4afe03a58c5b 100644
--- a/Documentation/keys.txt
+++ b/Documentation/keys.txt
@@ -195,8 +195,8 @@ KEY ACCESS PERMISSIONS
195====================== 195======================
196 196
197Keys have an owner user ID, a group access ID, and a permissions mask. The mask 197Keys have an owner user ID, a group access ID, and a permissions mask. The mask
198has up to eight bits each for user, group and other access. Only five of each 198has up to eight bits each for possessor, user, group and other access. Only
199set of eight bits are defined. These permissions granted are: 199five of each set of eight bits are defined. These permissions granted are:
200 200
201 (*) View 201 (*) View
202 202
@@ -241,16 +241,16 @@ about the status of the key service:
241 type, description and permissions. The payload of the key is not available 241 type, description and permissions. The payload of the key is not available
242 this way: 242 this way:
243 243
244 SERIAL FLAGS USAGE EXPY PERM UID GID TYPE DESCRIPTION: SUMMARY 244 SERIAL FLAGS USAGE EXPY PERM UID GID TYPE DESCRIPTION: SUMMARY
245 00000001 I----- 39 perm 1f0000 0 0 keyring _uid_ses.0: 1/4 245 00000001 I----- 39 perm 1f1f0000 0 0 keyring _uid_ses.0: 1/4
246 00000002 I----- 2 perm 1f0000 0 0 keyring _uid.0: empty 246 00000002 I----- 2 perm 1f1f0000 0 0 keyring _uid.0: empty
247 00000007 I----- 1 perm 1f0000 0 0 keyring _pid.1: empty 247 00000007 I----- 1 perm 1f1f0000 0 0 keyring _pid.1: empty
248 0000018d I----- 1 perm 1f0000 0 0 keyring _pid.412: empty 248 0000018d I----- 1 perm 1f1f0000 0 0 keyring _pid.412: empty
249 000004d2 I--Q-- 1 perm 1f0000 32 -1 keyring _uid.32: 1/4 249 000004d2 I--Q-- 1 perm 1f1f0000 32 -1 keyring _uid.32: 1/4
250 000004d3 I--Q-- 3 perm 1f0000 32 -1 keyring _uid_ses.32: empty 250 000004d3 I--Q-- 3 perm 1f1f0000 32 -1 keyring _uid_ses.32: empty
251 00000892 I--QU- 1 perm 1f0000 0 0 user metal:copper: 0 251 00000892 I--QU- 1 perm 1f000000 0 0 user metal:copper: 0
252 00000893 I--Q-N 1 35s 1f0000 0 0 user metal:silver: 0 252 00000893 I--Q-N 1 35s 1f1f0000 0 0 user metal:silver: 0
253 00000894 I--Q-- 1 10h 1f0000 0 0 user metal:gold: 0 253 00000894 I--Q-- 1 10h 001f0000 0 0 user metal:gold: 0
254 254
255 The flags are: 255 The flags are:
256 256
@@ -361,6 +361,8 @@ The main syscalls are:
361 /sbin/request-key will be invoked in an attempt to obtain a key. The 361 /sbin/request-key will be invoked in an attempt to obtain a key. The
362 callout_info string will be passed as an argument to the program. 362 callout_info string will be passed as an argument to the program.
363 363
364 See also Documentation/keys-request-key.txt.
365
364 366
365The keyctl syscall functions are: 367The keyctl syscall functions are:
366 368
@@ -533,8 +535,8 @@ The keyctl syscall functions are:
533 535
534 (*) Read the payload data from a key: 536 (*) Read the payload data from a key:
535 537
536 key_serial_t keyctl(KEYCTL_READ, key_serial_t keyring, char *buffer, 538 long keyctl(KEYCTL_READ, key_serial_t keyring, char *buffer,
537 size_t buflen); 539 size_t buflen);
538 540
539 This function attempts to read the payload data from the specified key 541 This function attempts to read the payload data from the specified key
540 into the buffer. The process must have read permission on the key to 542 into the buffer. The process must have read permission on the key to
@@ -555,9 +557,9 @@ The keyctl syscall functions are:
555 557
556 (*) Instantiate a partially constructed key. 558 (*) Instantiate a partially constructed key.
557 559
558 key_serial_t keyctl(KEYCTL_INSTANTIATE, key_serial_t key, 560 long keyctl(KEYCTL_INSTANTIATE, key_serial_t key,
559 const void *payload, size_t plen, 561 const void *payload, size_t plen,
560 key_serial_t keyring); 562 key_serial_t keyring);
561 563
562 If the kernel calls back to userspace to complete the instantiation of a 564 If the kernel calls back to userspace to complete the instantiation of a
563 key, userspace should use this call to supply data for the key before the 565 key, userspace should use this call to supply data for the key before the
@@ -576,8 +578,8 @@ The keyctl syscall functions are:
576 578
577 (*) Negatively instantiate a partially constructed key. 579 (*) Negatively instantiate a partially constructed key.
578 580
579 key_serial_t keyctl(KEYCTL_NEGATE, key_serial_t key, 581 long keyctl(KEYCTL_NEGATE, key_serial_t key,
580 unsigned timeout, key_serial_t keyring); 582 unsigned timeout, key_serial_t keyring);
581 583
582 If the kernel calls back to userspace to complete the instantiation of a 584 If the kernel calls back to userspace to complete the instantiation of a
583 key, userspace should use this call mark the key as negative before the 585 key, userspace should use this call mark the key as negative before the
@@ -637,6 +639,34 @@ call, and the key released upon close. How to deal with conflicting keys due to
637two different users opening the same file is left to the filesystem author to 639two different users opening the same file is left to the filesystem author to
638solve. 640solve.
639 641
642Note that there are two different types of pointers to keys that may be
643encountered:
644
645 (*) struct key *
646
647 This simply points to the key structure itself. Key structures will be at
648 least four-byte aligned.
649
650 (*) key_ref_t
651
652 This is equivalent to a struct key *, but the least significant bit is set
653 if the caller "possesses" the key. By "possession" it is meant that the
654 calling processes has a searchable link to the key from one of its
655 keyrings. There are three functions for dealing with these:
656
657 key_ref_t make_key_ref(const struct key *key,
658 unsigned long possession);
659
660 struct key *key_ref_to_ptr(const key_ref_t key_ref);
661
662 unsigned long is_key_possessed(const key_ref_t key_ref);
663
664 The first function constructs a key reference from a key pointer and
665 possession information (which must be 0 or 1 and not any other value).
666
667 The second function retrieves the key pointer from a reference and the
668 third retrieves the possession flag.
669
640When accessing a key's payload contents, certain precautions must be taken to 670When accessing a key's payload contents, certain precautions must be taken to
641prevent access vs modification races. See the section "Notes on accessing 671prevent access vs modification races. See the section "Notes on accessing
642payload contents" for more information. 672payload contents" for more information.
@@ -660,12 +690,18 @@ payload contents" for more information.
660 If successful, the key will have been attached to the default keyring for 690 If successful, the key will have been attached to the default keyring for
661 implicitly obtained request-key keys, as set by KEYCTL_SET_REQKEY_KEYRING. 691 implicitly obtained request-key keys, as set by KEYCTL_SET_REQKEY_KEYRING.
662 692
693 See also Documentation/keys-request-key.txt.
694
663 695
664(*) When it is no longer required, the key should be released using: 696(*) When it is no longer required, the key should be released using:
665 697
666 void key_put(struct key *key); 698 void key_put(struct key *key);
667 699
668 This can be called from interrupt context. If CONFIG_KEYS is not set then 700 Or:
701
702 void key_ref_put(key_ref_t key_ref);
703
704 These can be called from interrupt context. If CONFIG_KEYS is not set then
669 the argument will not be parsed. 705 the argument will not be parsed.
670 706
671 707
@@ -689,13 +725,17 @@ payload contents" for more information.
689 725
690(*) If a keyring was found in the search, this can be further searched by: 726(*) If a keyring was found in the search, this can be further searched by:
691 727
692 struct key *keyring_search(struct key *keyring, 728 key_ref_t keyring_search(key_ref_t keyring_ref,
693 const struct key_type *type, 729 const struct key_type *type,
694 const char *description) 730 const char *description)
695 731
696 This searches the keyring tree specified for a matching key. Error ENOKEY 732 This searches the keyring tree specified for a matching key. Error ENOKEY
697 is returned upon failure. If successful, the returned key will need to be 733 is returned upon failure (use IS_ERR/PTR_ERR to determine). If successful,
698 released. 734 the returned key will need to be released.
735
736 The possession attribute from the keyring reference is used to control
737 access through the permissions mask and is propagated to the returned key
738 reference pointer if successful.
699 739
700 740
701(*) To check the validity of a key, this function can be called: 741(*) To check the validity of a key, this function can be called:
@@ -732,7 +772,7 @@ More complex payload contents must be allocated and a pointer to them set in
732key->payload.data. One of the following ways must be selected to access the 772key->payload.data. One of the following ways must be selected to access the
733data: 773data:
734 774
735 (1) Unmodifyable key type. 775 (1) Unmodifiable key type.
736 776
737 If the key type does not have a modify method, then the key's payload can 777 If the key type does not have a modify method, then the key's payload can
738 be accessed without any form of locking, provided that it's known to be 778 be accessed without any form of locking, provided that it's known to be