History

keys: Fix dependency loop between construction record and auth key

In the request_key() upcall mechanism there's a dependency loop by which if a key type driver overrides the ->request_key hook and the userspace side manages to lose the authorisation key, the auth key and the internal construction record (struct key_construction) can keep each other pinned. Fix this by the following changes: (1) Killing off the construction record and using the auth key instead. (2) Including the operation name in the auth key payload and making the payload available outside of security/keys/. (3) The ->request_key hook is given the authkey instead of the cons record and operation name. Changes (2) and (3) allow the auth key to naturally be cleaned up if the keyring it is in is destroyed or cleared or the auth key is unlinked.

David Howells committed 7 years ago

Commit 822ad641 parent bb2ba2d8 files · +100 −92Browse files

Showing the changes to include/linux (1 of 8 files). Show all

Unified · Split

include/linux/key-type.h+6−16
@@ -20,15 +20,6 @@ · 19 unmodified lines
2020 struct kernel_pkey_query;
2121 struct kernel_pkey_params;
2222
23−/*
24− * key under-construction record
25− * - passed to the request_key actor if supplied
26− */
27−struct key_construction {
28− struct key *key; /* key being constructed */
29− struct key *authkey;/* authorisation for key being constructed */
30−};
31−
3223 /*
3324 * Pre-parsed payload, used by key add, update and instantiate.
3425 *
@@ -50,8 +41,7 @@ struct key_preparsed_payload { · 15 unmodified lines
5041 time64_t expiry; /* Expiry time of key */
5142 } __randomize_layout;
5243
53−typedef int (*request_key_actor_t)(struct key_construction *key,
54− const char *op, void *aux);
44+typedef int (*request_key_actor_t)(struct key *auth_key, void *aux);
5545
5646 /*
5747 * Preparsed matching criterion.
@@ -181,20 +171,20 @@ extern int key_instantiate_and_link(struct key *key, · 123 unmodified lines
181171 const void *data,
182172 size_t datalen,
183173 struct key *keyring,
184− struct key *instkey);
174+ struct key *authkey);
185175 extern int key_reject_and_link(struct key *key,
186176 unsigned timeout,
187177 unsigned error,
188178 struct key *keyring,
189− struct key *instkey);
190−extern void complete_request_key(struct key_construction *cons, int error);
179+ struct key *authkey);
180+extern void complete_request_key(struct key *authkey, int error);
191181
192182 static inline int key_negate_and_link(struct key *key,
193183 unsigned timeout,
194184 struct key *keyring,
195− struct key *instkey)
185+ struct key *authkey)
196186 {
197− return key_reject_and_link(key, timeout, ENOKEY, keyring, instkey);
187+ return key_reject_and_link(key, timeout, ENOKEY, keyring, authkey);
198188 }
199189
200190 extern int generic_key_instantiate(struct key *key, struct key_preparsed_payload *prep);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t