summaryrefslogtreecommitdiffstats
path: root/include/linux/key.h
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-06-26 16:02:32 -0400
committerDavid Howells <dhowells@redhat.com>2019-06-26 16:02:32 -0400
commit3b6e4de05e9ee2e2f94e4a3fe14d945e2418d9a8 (patch)
treec31a08de17f1607b40358d4351b1f97d78520164 /include/linux/key.h
parent0f44e4d976f96c6439da0d6717238efa4b91196e (diff)
keys: Include target namespace in match criteria
Currently a key has a standard matching criteria of { type, description } and this is used to only allow keys with unique criteria in a keyring. This means, however, that you cannot have keys with the same type and description but a different target namespace in the same keyring. This is a potential problem for a containerised environment where, say, a container is made up of some parts of its mount space involving netfs superblocks from two different network namespaces. This is also a problem for shared system management keyrings such as the DNS records keyring or the NFS idmapper keyring that might contain keys from different network namespaces. Fix this by including a namespace component in a key's matching criteria. Keyring types are marked to indicate which, if any, namespace is relevant to keys of that type, and that namespace is set when the key is created from the current task's namespace set. The capability bit KEYCTL_CAPS1_NS_KEY_TAG is set if the kernel is employing this feature. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'include/linux/key.h')
-rw-r--r--include/linux/key.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/key.h b/include/linux/key.h
index ae1177302d70..abc68555bac3 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -82,9 +82,16 @@ struct cred;
82 82
83struct key_type; 83struct key_type;
84struct key_owner; 84struct key_owner;
85struct key_tag;
85struct keyring_list; 86struct keyring_list;
86struct keyring_name; 87struct keyring_name;
87 88
89struct key_tag {
90 struct rcu_head rcu;
91 refcount_t usage;
92 bool removed; /* T when subject removed */
93};
94
88struct keyring_index_key { 95struct keyring_index_key {
89 /* [!] If this structure is altered, the union in struct key must change too! */ 96 /* [!] If this structure is altered, the union in struct key must change too! */
90 unsigned long hash; /* Hash value */ 97 unsigned long hash; /* Hash value */
@@ -101,6 +108,7 @@ struct keyring_index_key {
101 unsigned long x; 108 unsigned long x;
102 }; 109 };
103 struct key_type *type; 110 struct key_type *type;
111 struct key_tag *domain_tag; /* Domain of operation */
104 const char *description; 112 const char *description;
105}; 113};
106 114
@@ -218,6 +226,7 @@ struct key {
218 unsigned long hash; 226 unsigned long hash;
219 unsigned long len_desc; 227 unsigned long len_desc;
220 struct key_type *type; /* type of key */ 228 struct key_type *type; /* type of key */
229 struct key_tag *domain_tag; /* Domain of operation */
221 char *description; 230 char *description;
222 }; 231 };
223 }; 232 };
@@ -268,6 +277,7 @@ extern struct key *key_alloc(struct key_type *type,
268extern void key_revoke(struct key *key); 277extern void key_revoke(struct key *key);
269extern void key_invalidate(struct key *key); 278extern void key_invalidate(struct key *key);
270extern void key_put(struct key *key); 279extern void key_put(struct key *key);
280extern bool key_put_tag(struct key_tag *tag);
271 281
272static inline struct key *__key_get(struct key *key) 282static inline struct key *__key_get(struct key *key)
273{ 283{