blob: 9b9cf3b6fcbb4d5e57e57100055cee2772d1db40 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
David Howells973c9f42011-01-20 16:38:33 +00002/* Authentication token and access key management internal defs
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
David Howells76181c12007-10-16 23:29:46 -07004 * Copyright (C) 2003-5, 2007 Red Hat, Inc. All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Written by David Howells (dhowells@redhat.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7
8#ifndef _INTERNAL_H
9#define _INTERNAL_H
10
David Howellsd84f4f92008-11-14 10:39:23 +110011#include <linux/sched.h>
Ingo Molnar5dd43ce2017-06-20 12:19:09 +020012#include <linux/wait_bit.h>
Ingo Molnar5b825c32017-02-02 17:54:15 +010013#include <linux/cred.h>
David Howells76181c12007-10-16 23:29:46 -070014#include <linux/key-type.h>
Oleg Nesterov413cd3d2012-05-11 10:59:08 +100015#include <linux/task_work.h>
Mat Martineauddbb4112016-04-12 19:54:58 +010016#include <linux/keyctl.h>
Elena Reshetovaddb99e12017-03-31 15:20:49 +030017#include <linux/refcount.h>
David Howellsf7e47672020-01-14 17:07:11 +000018#include <linux/watch_queue.h>
Stephan Muellerf1c316a2016-08-19 20:39:09 +020019#include <linux/compat.h>
Waiman Long4f088242020-03-21 21:11:25 -040020#include <linux/mm.h>
21#include <linux/vmalloc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Kent Overstreeta27bb332013-05-07 16:19:08 -070023struct iovec;
24
David Howells76181c12007-10-16 23:29:46 -070025#ifdef __KDEBUG
26#define kenter(FMT, ...) \
Harvey Harrisondd6f9532008-03-06 10:03:59 +110027 printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)
David Howells76181c12007-10-16 23:29:46 -070028#define kleave(FMT, ...) \
Harvey Harrisondd6f9532008-03-06 10:03:59 +110029 printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
David Howells76181c12007-10-16 23:29:46 -070030#define kdebug(FMT, ...) \
David Howellsd84f4f92008-11-14 10:39:23 +110031 printk(KERN_DEBUG " "FMT"\n", ##__VA_ARGS__)
David Howells3e301482005-06-23 22:00:56 -070032#else
David Howells76181c12007-10-16 23:29:46 -070033#define kenter(FMT, ...) \
Harvey Harrisondd6f9532008-03-06 10:03:59 +110034 no_printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)
David Howells76181c12007-10-16 23:29:46 -070035#define kleave(FMT, ...) \
Harvey Harrisondd6f9532008-03-06 10:03:59 +110036 no_printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
David Howells76181c12007-10-16 23:29:46 -070037#define kdebug(FMT, ...) \
38 no_printk(KERN_DEBUG FMT"\n", ##__VA_ARGS__)
David Howells3e301482005-06-23 22:00:56 -070039#endif
40
David Howells0c061b52011-08-22 14:09:36 +010041extern struct key_type key_type_dead;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042extern struct key_type key_type_user;
Jeff Layton9f6ed2c2012-01-17 16:09:11 -050043extern struct key_type key_type_logon;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45/*****************************************************************************/
46/*
David Howells973c9f42011-01-20 16:38:33 +000047 * Keep track of keys for a user.
48 *
49 * This needs to be separate to user_struct to avoid a refcount-loop
50 * (user_struct pins some keyrings which pin this struct).
51 *
52 * We also keep track of keys under request from userspace for this UID here.
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 */
54struct key_user {
55 struct rb_node node;
David Howells76181c12007-10-16 23:29:46 -070056 struct mutex cons_lock; /* construction initiation lock */
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 spinlock_t lock;
Elena Reshetovaddb99e12017-03-31 15:20:49 +030058 refcount_t usage; /* for accessing qnkeys & qnbytes */
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 atomic_t nkeys; /* number of keys */
60 atomic_t nikeys; /* number of instantiated keys */
Eric W. Biederman9a56c2d2012-02-08 07:53:04 -080061 kuid_t uid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 int qnkeys; /* number of keys allocated to this user */
63 int qnbytes; /* number of bytes allocated to this user */
64};
65
Linus Torvalds1da177e2005-04-16 15:20:36 -070066extern struct rb_root key_user_tree;
67extern spinlock_t key_user_lock;
68extern struct key_user root_key_user;
69
Eric W. Biederman9a56c2d2012-02-08 07:53:04 -080070extern struct key_user *key_user_lookup(kuid_t uid);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071extern void key_user_put(struct key_user *user);
72
David Howells0b77f5b2008-04-29 01:01:32 -070073/*
David Howells973c9f42011-01-20 16:38:33 +000074 * Key quota limits.
David Howells0b77f5b2008-04-29 01:01:32 -070075 * - root has its own separate limits to everyone else
76 */
77extern unsigned key_quota_root_maxkeys;
78extern unsigned key_quota_root_maxbytes;
79extern unsigned key_quota_maxkeys;
80extern unsigned key_quota_maxbytes;
81
82#define KEYQUOTA_LINK_BYTES 4 /* a link in a keyring is worth 4 bytes */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
84
David Howells8bc16de2011-08-22 14:09:11 +010085extern struct kmem_cache *key_jar;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086extern struct rb_root key_serial_tree;
87extern spinlock_t key_serial_lock;
David Howells76181c12007-10-16 23:29:46 -070088extern struct mutex key_construction_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089extern wait_queue_head_t request_key_conswq;
90
David Howells355ef8e2019-06-26 21:02:32 +010091extern void key_set_index_key(struct keyring_index_key *index_key);
David Howellse9e349b2008-11-14 10:39:13 +110092extern struct key_type *key_type_lookup(const char *type);
93extern void key_type_put(struct key_type *ktype);
94
David Howellsdf593ee2019-05-30 11:37:39 +010095extern int __key_link_lock(struct key *keyring,
96 const struct keyring_index_key *index_key);
David Howellsed0ac5c2019-05-20 21:51:50 +010097extern int __key_move_lock(struct key *l_keyring, struct key *u_keyring,
98 const struct keyring_index_key *index_key);
David Howellsf70e2e02010-04-30 14:32:39 +010099extern int __key_link_begin(struct key *keyring,
David Howells16feef42013-09-24 10:35:15 +0100100 const struct keyring_index_key *index_key,
David Howellsb2a4df22013-09-24 10:35:18 +0100101 struct assoc_array_edit **_edit);
David Howellsf70e2e02010-04-30 14:32:39 +0100102extern int __key_link_check_live_key(struct key *keyring, struct key *key);
David Howellsf7e47672020-01-14 17:07:11 +0000103extern void __key_link(struct key *keyring, struct key *key,
104 struct assoc_array_edit **_edit);
David Howellsf70e2e02010-04-30 14:32:39 +0100105extern void __key_link_end(struct key *keyring,
David Howells16feef42013-09-24 10:35:15 +0100106 const struct keyring_index_key *index_key,
David Howellsb2a4df22013-09-24 10:35:18 +0100107 struct assoc_array_edit *edit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
David Howellsb2a4df22013-09-24 10:35:18 +0100109extern key_ref_t find_key_to_update(key_ref_t keyring_ref,
110 const struct keyring_index_key *index_key);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
David Howells3e301482005-06-23 22:00:56 -0700112extern struct key *keyring_search_instkey(struct key *keyring,
113 key_serial_t target_id);
114
David Howellsb2a4df22013-09-24 10:35:18 +0100115extern int iterate_over_keyring(const struct key *keyring,
116 int (*func)(const struct key *key, void *data),
117 void *data);
118
David Howells4bdf0bc2013-09-24 10:35:15 +0100119struct keyring_search_context {
120 struct keyring_index_key index_key;
121 const struct cred *cred;
David Howells46291952014-09-16 17:36:02 +0100122 struct key_match_data match_data;
David Howells4bdf0bc2013-09-24 10:35:15 +0100123 unsigned flags;
David Howells614d8c32014-09-16 17:36:04 +0100124#define KEYRING_SEARCH_NO_STATE_CHECK 0x0001 /* Skip state checks */
125#define KEYRING_SEARCH_DO_STATE_CHECK 0x0002 /* Override NO_STATE_CHECK */
126#define KEYRING_SEARCH_NO_UPDATE_TIME 0x0004 /* Don't update times */
127#define KEYRING_SEARCH_NO_CHECK_PERM 0x0008 /* Don't check permissions */
128#define KEYRING_SEARCH_DETECT_TOO_DEEP 0x0010 /* Give an error on excessive depth */
David Howells0b0a8412014-12-01 22:52:53 +0000129#define KEYRING_SEARCH_SKIP_EXPIRED 0x0020 /* Ignore expired keys (intention to replace) */
David Howellsdcf49db2019-06-26 21:02:32 +0100130#define KEYRING_SEARCH_RECURSE 0x0040 /* Search child keyrings also */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
David Howellsb2a4df22013-09-24 10:35:18 +0100132 int (*iterator)(const void *object, void *iterator_data);
133
David Howells4bdf0bc2013-09-24 10:35:15 +0100134 /* Internal stuff */
135 int skipped_ret;
136 bool possessed;
137 key_ref_t result;
Baolin Wang074d5892017-11-15 16:38:45 +0000138 time64_t now;
David Howells4bdf0bc2013-09-24 10:35:15 +0100139};
140
David Howells0c903ab2014-09-16 17:36:08 +0100141extern bool key_default_cmp(const struct key *key,
142 const struct key_match_data *match_data);
David Howellse59428f2019-06-19 16:10:15 +0100143extern key_ref_t keyring_search_rcu(key_ref_t keyring_ref,
David Howells4bdf0bc2013-09-24 10:35:15 +0100144 struct keyring_search_context *ctx);
145
David Howellse59428f2019-06-19 16:10:15 +0100146extern key_ref_t search_cred_keyrings_rcu(struct keyring_search_context *ctx);
147extern key_ref_t search_process_keyrings_rcu(struct keyring_search_context *ctx);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
Eric Biggers237bbd22017-09-18 11:37:03 -0700149extern struct key *find_keyring_by_name(const char *name, bool uid_keyring);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
David Howells0f44e4d2019-06-26 21:02:32 +0100151extern int look_up_user_keyrings(struct key **, struct key **);
152extern struct key *get_user_session_keyring_rcu(const struct cred *);
David Howellsd84f4f92008-11-14 10:39:23 +1100153extern int install_thread_keyring_to_cred(struct cred *);
154extern int install_process_keyring_to_cred(struct cred *);
Oleg Nesterov685bfd22010-05-26 14:43:00 -0700155extern int install_session_keyring_to_cred(struct cred *, struct key *);
David Howells3e301482005-06-23 22:00:56 -0700156
157extern struct key *request_key_and_link(struct key_type *type,
158 const char *description,
David Howellsa58946c2019-06-26 21:02:33 +0100159 struct key_tag *domain_tag,
David Howells4a38e122008-04-29 01:01:24 -0700160 const void *callout_info,
161 size_t callout_len,
David Howells4e54f082006-06-29 02:24:28 -0700162 void *aux,
David Howells7e047ef2006-06-26 00:24:50 -0700163 struct key *dest_keyring,
164 unsigned long flags);
David Howells3e301482005-06-23 22:00:56 -0700165
David Howells0c903ab2014-09-16 17:36:08 +0100166extern bool lookup_user_key_possessed(const struct key *key,
167 const struct key_match_data *match_data);
David Howells55931222009-09-02 09:13:45 +0100168#define KEY_LOOKUP_CREATE 0x01
169#define KEY_LOOKUP_PARTIAL 0x02
David Howellse9e349b2008-11-14 10:39:13 +1100170
171extern long join_session_keyring(const char *name);
Al Viro67d12142012-06-27 11:07:19 +0400172extern void key_change_session_keyring(struct callback_head *twork);
David Howellse9e349b2008-11-14 10:39:13 +1100173
David Howells0c061b52011-08-22 14:09:36 +0100174extern struct work_struct key_gc_work;
David Howells5d135442009-09-02 09:14:00 +0100175extern unsigned key_gc_delay;
Baolin Wang074d5892017-11-15 16:38:45 +0000176extern void keyring_gc(struct key *keyring, time64_t limit);
Mat Martineau2b6aa412016-08-31 16:05:43 -0700177extern void keyring_restriction_gc(struct key *keyring,
178 struct key_type *dead_type);
Baolin Wang074d5892017-11-15 16:38:45 +0000179extern void key_schedule_gc(time64_t gc_at);
David Howellsfd758152012-05-11 10:56:56 +0100180extern void key_schedule_gc_links(void);
David Howells0c061b52011-08-22 14:09:36 +0100181extern void key_gc_keytype(struct key_type *ktype);
David Howells5d135442009-09-02 09:14:00 +0100182
David Howellse9e349b2008-11-14 10:39:13 +1100183extern int key_task_permission(const key_ref_t key_ref,
David Howellsd84f4f92008-11-14 10:39:23 +1100184 const struct cred *cred,
David Howells8c0637e2020-05-12 15:16:29 +0100185 enum key_need_perm need_perm);
David Howellse9e349b2008-11-14 10:39:13 +1100186
David Howellsf7e47672020-01-14 17:07:11 +0000187static inline void notify_key(struct key *key,
188 enum key_notification_subtype subtype, u32 aux)
189{
190#ifdef CONFIG_KEY_NOTIFICATIONS
191 struct key_notification n = {
192 .watch.type = WATCH_TYPE_KEY_NOTIFY,
193 .watch.subtype = subtype,
194 .watch.info = watch_sizeof(n),
195 .key_id = key_serial(key),
196 .aux = aux,
197 };
198
199 post_watch_notification(key->watchers, &n.watch, current_cred(),
200 n.key_id);
201#endif
202}
David Howellse9e349b2008-11-14 10:39:13 +1100203
David Howells973c9f42011-01-20 16:38:33 +0000204/*
205 * Check to see whether permission is granted to use a key in the desired way.
206 */
David Howells8c0637e2020-05-12 15:16:29 +0100207static inline int key_permission(const key_ref_t key_ref,
208 enum key_need_perm need_perm)
David Howellse9e349b2008-11-14 10:39:13 +1100209{
David Howells8c0637e2020-05-12 15:16:29 +0100210 return key_task_permission(key_ref, current_cred(), need_perm);
David Howellse9e349b2008-11-14 10:39:13 +1100211}
212
David Howells3e301482005-06-23 22:00:56 -0700213extern struct key_type key_type_request_key_auth;
214extern struct key *request_key_auth_new(struct key *target,
David Howells822ad642019-02-14 16:20:25 +0000215 const char *op,
David Howells4a38e122008-04-29 01:01:24 -0700216 const void *callout_info,
David Howells8bbf49762008-11-14 10:39:14 +1100217 size_t callout_len,
218 struct key *dest_keyring);
David Howells3e301482005-06-23 22:00:56 -0700219
220extern struct key *key_get_instantiation_authkey(key_serial_t target_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
222/*
David Howellsfd758152012-05-11 10:56:56 +0100223 * Determine whether a key is dead.
224 */
Baolin Wang074d5892017-11-15 16:38:45 +0000225static inline bool key_is_dead(const struct key *key, time64_t limit)
David Howellsfd758152012-05-11 10:56:56 +0100226{
227 return
228 key->flags & ((1 << KEY_FLAG_DEAD) |
229 (1 << KEY_FLAG_INVALIDATED)) ||
David Howells218e6422019-06-26 21:02:32 +0100230 (key->expiry > 0 && key->expiry <= limit) ||
231 key->domain_tag->removed;
David Howellsfd758152012-05-11 10:56:56 +0100232}
233
234/*
David Howells973c9f42011-01-20 16:38:33 +0000235 * keyctl() functions
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 */
237extern long keyctl_get_keyring_ID(key_serial_t, int);
238extern long keyctl_join_session_keyring(const char __user *);
239extern long keyctl_update_key(key_serial_t, const void __user *, size_t);
240extern long keyctl_revoke_key(key_serial_t);
241extern long keyctl_keyring_clear(key_serial_t);
242extern long keyctl_keyring_link(key_serial_t, key_serial_t);
David Howellsed0ac5c2019-05-20 21:51:50 +0100243extern long keyctl_keyring_move(key_serial_t, key_serial_t, key_serial_t, unsigned int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244extern long keyctl_keyring_unlink(key_serial_t, key_serial_t);
245extern long keyctl_describe_key(key_serial_t, char __user *, size_t);
246extern long keyctl_keyring_search(key_serial_t, const char __user *,
247 const char __user *, key_serial_t);
248extern long keyctl_read_key(key_serial_t, char __user *, size_t);
249extern long keyctl_chown_key(key_serial_t, uid_t, gid_t);
Linus Torvalds028db3e2019-07-10 18:43:43 -0700250extern long keyctl_setperm_key(key_serial_t, key_perm_t);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251extern long keyctl_instantiate_key(key_serial_t, const void __user *,
252 size_t, key_serial_t);
253extern long keyctl_negate_key(key_serial_t, unsigned, key_serial_t);
David Howells3e301482005-06-23 22:00:56 -0700254extern long keyctl_set_reqkey_keyring(int);
David Howells017679c2006-01-08 01:02:43 -0800255extern long keyctl_set_timeout(key_serial_t, unsigned);
David Howellsb5f545c2006-01-08 01:02:47 -0800256extern long keyctl_assume_authority(key_serial_t);
David Howells70a5bb72008-04-29 01:01:26 -0700257extern long keyctl_get_security(key_serial_t keyid, char __user *buffer,
258 size_t buflen);
David Howellsee18d642009-09-02 09:14:21 +0100259extern long keyctl_session_to_parent(void);
David Howellsfdd1b942011-03-07 15:06:09 +0000260extern long keyctl_reject_key(key_serial_t, unsigned, unsigned, key_serial_t);
David Howellsee009e4a02011-03-07 15:06:20 +0000261extern long keyctl_instantiate_key_iov(key_serial_t,
262 const struct iovec __user *,
263 unsigned, key_serial_t);
David Howellsfd758152012-05-11 10:56:56 +0100264extern long keyctl_invalidate_key(key_serial_t);
Mat Martineau6563c912017-03-01 16:44:09 -0800265extern long keyctl_restrict_keyring(key_serial_t id,
266 const char __user *_type,
267 const char __user *_restriction);
David Howellsf36f8c72013-09-24 10:35:19 +0100268#ifdef CONFIG_PERSISTENT_KEYRINGS
269extern long keyctl_get_persistent(uid_t, key_serial_t);
270extern unsigned persistent_keyring_expiry;
271#else
272static inline long keyctl_get_persistent(uid_t uid, key_serial_t destring)
273{
274 return -EOPNOTSUPP;
275}
276#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Mat Martineauddbb4112016-04-12 19:54:58 +0100278#ifdef CONFIG_KEY_DH_OPERATIONS
279extern long keyctl_dh_compute(struct keyctl_dh_params __user *, char __user *,
Stephan Muellerf1c316a2016-08-19 20:39:09 +0200280 size_t, struct keyctl_kdf_params __user *);
281extern long __keyctl_dh_compute(struct keyctl_dh_params __user *, char __user *,
282 size_t, struct keyctl_kdf_params *);
Eric Biggers601f0092019-10-09 16:04:43 -0700283#ifdef CONFIG_COMPAT
Stephan Muellerf1c316a2016-08-19 20:39:09 +0200284extern long compat_keyctl_dh_compute(struct keyctl_dh_params __user *params,
285 char __user *buffer, size_t buflen,
286 struct compat_keyctl_kdf_params __user *kdf);
287#endif
288#define KEYCTL_KDF_MAX_OUTPUT_LEN 1024 /* max length of KDF output */
289#define KEYCTL_KDF_MAX_OI_LEN 64 /* max length of otherinfo */
Mat Martineauddbb4112016-04-12 19:54:58 +0100290#else
291static inline long keyctl_dh_compute(struct keyctl_dh_params __user *params,
Stephan Mueller4693fc72016-05-26 23:38:12 +0200292 char __user *buffer, size_t buflen,
Stephan Muellerf1c316a2016-08-19 20:39:09 +0200293 struct keyctl_kdf_params __user *kdf)
Mat Martineauddbb4112016-04-12 19:54:58 +0100294{
295 return -EOPNOTSUPP;
296}
Stephan Muellerf1c316a2016-08-19 20:39:09 +0200297
Eric Biggers601f0092019-10-09 16:04:43 -0700298#ifdef CONFIG_COMPAT
Stephan Muellerf1c316a2016-08-19 20:39:09 +0200299static inline long compat_keyctl_dh_compute(
300 struct keyctl_dh_params __user *params,
301 char __user *buffer, size_t buflen,
302 struct keyctl_kdf_params __user *kdf)
303{
304 return -EOPNOTSUPP;
305}
306#endif
Mat Martineauddbb4112016-04-12 19:54:58 +0100307#endif
308
David Howells00d60fd2018-10-09 17:46:59 +0100309#ifdef CONFIG_ASYMMETRIC_KEY_TYPE
310extern long keyctl_pkey_query(key_serial_t,
311 const char __user *,
312 struct keyctl_pkey_query __user *);
313
314extern long keyctl_pkey_verify(const struct keyctl_pkey_params __user *,
315 const char __user *,
316 const void __user *, const void __user *);
317
318extern long keyctl_pkey_e_d_s(int,
319 const struct keyctl_pkey_params __user *,
320 const char __user *,
321 const void __user *, void __user *);
322#else
323static inline long keyctl_pkey_query(key_serial_t id,
324 const char __user *_info,
325 struct keyctl_pkey_query __user *_res)
326{
327 return -EOPNOTSUPP;
328}
329
330static inline long keyctl_pkey_verify(const struct keyctl_pkey_params __user *params,
331 const char __user *_info,
332 const void __user *_in,
333 const void __user *_in2)
334{
335 return -EOPNOTSUPP;
336}
337
338static inline long keyctl_pkey_e_d_s(int op,
339 const struct keyctl_pkey_params __user *params,
340 const char __user *_info,
341 const void __user *_in,
342 void __user *_out)
343{
344 return -EOPNOTSUPP;
345}
346#endif
347
David Howells45e0f302019-05-30 14:53:10 +0100348extern long keyctl_capabilities(unsigned char __user *_buffer, size_t buflen);
349
David Howellsf7e47672020-01-14 17:07:11 +0000350#ifdef CONFIG_KEY_NOTIFICATIONS
351extern long keyctl_watch_key(key_serial_t, int, int);
352#else
353static inline long keyctl_watch_key(key_serial_t key_id, int watch_fd, int watch_id)
354{
355 return -EOPNOTSUPP;
356}
357#endif
358
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359/*
David Howells973c9f42011-01-20 16:38:33 +0000360 * Debugging key validation
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 */
362#ifdef KEY_DEBUGGING
363extern void __key_check(const struct key *);
364
365static inline void key_check(const struct key *key)
366{
367 if (key && (IS_ERR(key) || key->magic != KEY_DEBUG_MAGIC))
368 __key_check(key);
369}
370
371#else
372
373#define key_check(key) do {} while(0)
374
375#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376#endif /* _INTERNAL_H */