1- ===================
2- KEY REQUEST SERVICE
3- ===================
1+ ===================
2+ Key Request Service
3+ ===================
44
55The key request service is part of the key retention service (refer to
66Documentation/security/keys.txt). This document explains more fully how
77the requesting algorithm works.
88
99The process starts by either the kernel requesting a service by calling
10- request_key*():
10+ `` request_key*() ``: :
1111
1212 struct key *request_key(const struct key_type *type,
1313 const char *description,
1414 const char *callout_info);
1515
16- or:
16+ or::
1717
1818 struct key *request_key_with_auxdata(const struct key_type *type,
1919 const char *description,
2020 const char *callout_info,
2121 size_t callout_len,
2222 void *aux);
2323
24- or:
24+ or::
2525
2626 struct key *request_key_async(const struct key_type *type,
2727 const char *description,
2828 const char *callout_info,
2929 size_t callout_len);
3030
31- or:
31+ or::
3232
3333 struct key *request_key_async_with_auxdata(const struct key_type *type,
3434 const char *description,
3535 const char *callout_info,
3636 size_t callout_len,
3737 void *aux);
3838
39- Or by userspace invoking the request_key system call:
39+ Or by userspace invoking the request_key system call::
4040
4141 key_serial_t request_key(const char *type,
4242 const char *description,
@@ -67,38 +67,37 @@ own upcall mechanisms. If they do, then those should be substituted for the
6767forking and execution of /sbin/request-key.
6868
6969
70- ===========
71- THE PROCESS
70+ The Process
7271===========
7372
7473A request proceeds in the following manner:
7574
76- ( 1) Process A calls request_key() [the userspace syscall calls the kernel
75+ 1) Process A calls request_key() [the userspace syscall calls the kernel
7776 interface].
7877
79- ( 2) request_key() searches the process's subscribed keyrings to see if there's
78+ 2) request_key() searches the process's subscribed keyrings to see if there's
8079 a suitable key there. If there is, it returns the key. If there isn't,
8180 and callout_info is not set, an error is returned. Otherwise the process
8281 proceeds to the next step.
8382
84- ( 3) request_key() sees that A doesn't have the desired key yet, so it creates
83+ 3) request_key() sees that A doesn't have the desired key yet, so it creates
8584 two things:
8685
87- ( a) An uninstantiated key U of requested type and description.
86+ a) An uninstantiated key U of requested type and description.
8887
89- ( b) An authorisation key V that refers to key U and notes that process A
88+ b) An authorisation key V that refers to key U and notes that process A
9089 is the context in which key U should be instantiated and secured, and
9190 from which associated key requests may be satisfied.
9291
93- ( 4) request_key() then forks and executes /sbin/request-key with a new session
92+ 4) request_key() then forks and executes /sbin/request-key with a new session
9493 keyring that contains a link to auth key V.
9594
96- ( 5) /sbin/request-key assumes the authority associated with key U.
95+ 5) /sbin/request-key assumes the authority associated with key U.
9796
98- ( 6) /sbin/request-key execs an appropriate program to perform the actual
97+ 6) /sbin/request-key execs an appropriate program to perform the actual
9998 instantiation.
10099
101- ( 7) The program may want to access another key from A's context (say a
100+ 7) The program may want to access another key from A's context (say a
102101 Kerberos TGT key). It just requests the appropriate key, and the keyring
103102 search notes that the session keyring has auth key V in its bottom level.
104103
@@ -110,10 +109,10 @@ A request proceeds in the following manner:
110109 instantiate key U, using key W as a reference (perhaps it contacts a
111110 Kerberos server using the TGT) and then instantiates key U.
112111
113- ( 9) Upon instantiating key U, auth key V is automatically revoked so that it
112+ 9) Upon instantiating key U, auth key V is automatically revoked so that it
114113 may not be used again.
115114
116- ( 10) The program then exits 0 and request_key() deletes key V and returns key
115+ 10) The program then exits 0 and request_key() deletes key V and returns key
117116 U to the caller.
118117
119118This also extends further. If key W (step 7 above) didn't exist, key W would
@@ -127,8 +126,7 @@ This is because process A's keyrings can't simply be attached to
127126of them, and (b) it requires the same UID/GID/Groups all the way through.
128127
129128
130- ====================================
131- NEGATIVE INSTANTIATION AND REJECTION
129+ Negative Instantiation And Rejection
132130====================================
133131
134132Rather than instantiating a key, it is possible for the possessor of an
@@ -145,23 +143,22 @@ signal, the key under construction will be automatically negatively
145143instantiated for a short amount of time.
146144
147145
148- ====================
149- THE SEARCH ALGORITHM
146+ The Search Algorithm
150147====================
151148
152149A search of any particular keyring proceeds in the following fashion:
153150
154- ( 1) When the key management code searches for a key (keyring_search_aux) it
151+ 1) When the key management code searches for a key (keyring_search_aux) it
155152 firstly calls key_permission(SEARCH) on the keyring it's starting with,
156153 if this denies permission, it doesn't search further.
157154
158- ( 2) It considers all the non-keyring keys within that keyring and, if any key
155+ 2) It considers all the non-keyring keys within that keyring and, if any key
159156 matches the criteria specified, calls key_permission(SEARCH) on it to see
160157 if the key is allowed to be found. If it is, that key is returned; if
161158 not, the search continues, and the error code is retained if of higher
162159 priority than the one currently set.
163160
164- ( 3) It then considers all the keyring-type keys in the keyring it's currently
161+ 3) It then considers all the keyring-type keys in the keyring it's currently
165162 searching. It calls key_permission(SEARCH) on each keyring, and if this
166163 grants permission, it recurses, executing steps (2) and (3) on that
167164 keyring.
@@ -173,28 +170,28 @@ returned.
173170When search_process_keyrings() is invoked, it performs the following searches
174171until one succeeds:
175172
176- ( 1) If extant, the process's thread keyring is searched.
173+ 1) If extant, the process's thread keyring is searched.
177174
178- ( 2) If extant, the process's process keyring is searched.
175+ 2) If extant, the process's process keyring is searched.
179176
180- ( 3) The process's session keyring is searched.
177+ 3) The process's session keyring is searched.
181178
182- ( 4) If the process has assumed the authority associated with a request_key()
179+ 4) If the process has assumed the authority associated with a request_key()
183180 authorisation key then:
184181
185- ( a) If extant, the calling process's thread keyring is searched.
182+ a) If extant, the calling process's thread keyring is searched.
186183
187- ( b) If extant, the calling process's process keyring is searched.
184+ b) If extant, the calling process's process keyring is searched.
188185
189- ( c) The calling process's session keyring is searched.
186+ c) The calling process's session keyring is searched.
190187
191188The moment one succeeds, all pending errors are discarded and the found key is
192189returned.
193190
194191Only if all these fail does the whole thing fail with the highest priority
195192error. Note that several errors may have come from LSM.
196193
197- The error priority is:
194+ The error priority is::
198195
199196 EKEYREVOKED > EKEYEXPIRED > ENOKEY
200197
0 commit comments