xref: /openbmc/linux/security/keys/internal.h (revision 355ef8e1)
1973c9f4fSDavid Howells /* Authentication token and access key management internal defs
21da177e4SLinus Torvalds  *
376181c13SDavid Howells  * Copyright (C) 2003-5, 2007 Red Hat, Inc. All Rights Reserved.
41da177e4SLinus Torvalds  * Written by David Howells (dhowells@redhat.com)
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  * This program is free software; you can redistribute it and/or
71da177e4SLinus Torvalds  * modify it under the terms of the GNU General Public License
81da177e4SLinus Torvalds  * as published by the Free Software Foundation; either version
91da177e4SLinus Torvalds  * 2 of the License, or (at your option) any later version.
101da177e4SLinus Torvalds  */
111da177e4SLinus Torvalds 
121da177e4SLinus Torvalds #ifndef _INTERNAL_H
131da177e4SLinus Torvalds #define _INTERNAL_H
141da177e4SLinus Torvalds 
15d84f4f99SDavid Howells #include <linux/sched.h>
165dd43ce2SIngo Molnar #include <linux/wait_bit.h>
175b825c3aSIngo Molnar #include <linux/cred.h>
1876181c13SDavid Howells #include <linux/key-type.h>
19413cd3d9SOleg Nesterov #include <linux/task_work.h>
20ddbb4114SMat Martineau #include <linux/keyctl.h>
21ddb99e11SElena Reshetova #include <linux/refcount.h>
22f1c316a3SStephan Mueller #include <linux/compat.h>
231da177e4SLinus Torvalds 
24a27bb332SKent Overstreet struct iovec;
25a27bb332SKent Overstreet 
2676181c13SDavid Howells #ifdef __KDEBUG
2776181c13SDavid Howells #define kenter(FMT, ...) \
28dd6f953aSHarvey Harrison 	printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)
2976181c13SDavid Howells #define kleave(FMT, ...) \
30dd6f953aSHarvey Harrison 	printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
3176181c13SDavid Howells #define kdebug(FMT, ...) \
32d84f4f99SDavid Howells 	printk(KERN_DEBUG "   "FMT"\n", ##__VA_ARGS__)
333e30148cSDavid Howells #else
3476181c13SDavid Howells #define kenter(FMT, ...) \
35dd6f953aSHarvey Harrison 	no_printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)
3676181c13SDavid Howells #define kleave(FMT, ...) \
37dd6f953aSHarvey Harrison 	no_printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
3876181c13SDavid Howells #define kdebug(FMT, ...) \
3976181c13SDavid Howells 	no_printk(KERN_DEBUG FMT"\n", ##__VA_ARGS__)
403e30148cSDavid Howells #endif
413e30148cSDavid Howells 
420c061b57SDavid Howells extern struct key_type key_type_dead;
431da177e4SLinus Torvalds extern struct key_type key_type_user;
449f6ed2caSJeff Layton extern struct key_type key_type_logon;
451da177e4SLinus Torvalds 
461da177e4SLinus Torvalds /*****************************************************************************/
471da177e4SLinus Torvalds /*
48973c9f4fSDavid Howells  * Keep track of keys for a user.
49973c9f4fSDavid Howells  *
50973c9f4fSDavid Howells  * This needs to be separate to user_struct to avoid a refcount-loop
51973c9f4fSDavid Howells  * (user_struct pins some keyrings which pin this struct).
52973c9f4fSDavid Howells  *
53973c9f4fSDavid Howells  * We also keep track of keys under request from userspace for this UID here.
541da177e4SLinus Torvalds  */
551da177e4SLinus Torvalds struct key_user {
561da177e4SLinus Torvalds 	struct rb_node		node;
5776181c13SDavid Howells 	struct mutex		cons_lock;	/* construction initiation lock */
581da177e4SLinus Torvalds 	spinlock_t		lock;
59ddb99e11SElena Reshetova 	refcount_t		usage;		/* for accessing qnkeys & qnbytes */
601da177e4SLinus Torvalds 	atomic_t		nkeys;		/* number of keys */
611da177e4SLinus Torvalds 	atomic_t		nikeys;		/* number of instantiated keys */
629a56c2dbSEric W. Biederman 	kuid_t			uid;
631da177e4SLinus Torvalds 	int			qnkeys;		/* number of keys allocated to this user */
641da177e4SLinus Torvalds 	int			qnbytes;	/* number of bytes allocated to this user */
651da177e4SLinus Torvalds };
661da177e4SLinus Torvalds 
671da177e4SLinus Torvalds extern struct rb_root	key_user_tree;
681da177e4SLinus Torvalds extern spinlock_t	key_user_lock;
691da177e4SLinus Torvalds extern struct key_user	root_key_user;
701da177e4SLinus Torvalds 
719a56c2dbSEric W. Biederman extern struct key_user *key_user_lookup(kuid_t uid);
721da177e4SLinus Torvalds extern void key_user_put(struct key_user *user);
731da177e4SLinus Torvalds 
740b77f5bfSDavid Howells /*
75973c9f4fSDavid Howells  * Key quota limits.
760b77f5bfSDavid Howells  * - root has its own separate limits to everyone else
770b77f5bfSDavid Howells  */
780b77f5bfSDavid Howells extern unsigned key_quota_root_maxkeys;
790b77f5bfSDavid Howells extern unsigned key_quota_root_maxbytes;
800b77f5bfSDavid Howells extern unsigned key_quota_maxkeys;
810b77f5bfSDavid Howells extern unsigned key_quota_maxbytes;
820b77f5bfSDavid Howells 
830b77f5bfSDavid Howells #define KEYQUOTA_LINK_BYTES	4		/* a link in a keyring is worth 4 bytes */
841da177e4SLinus Torvalds 
851da177e4SLinus Torvalds 
868bc16deaSDavid Howells extern struct kmem_cache *key_jar;
871da177e4SLinus Torvalds extern struct rb_root key_serial_tree;
881da177e4SLinus Torvalds extern spinlock_t key_serial_lock;
8976181c13SDavid Howells extern struct mutex key_construction_mutex;
901da177e4SLinus Torvalds extern wait_queue_head_t request_key_conswq;
911da177e4SLinus Torvalds 
92355ef8e1SDavid Howells extern void key_set_index_key(struct keyring_index_key *index_key);
93e9e349b0SDavid Howells extern struct key_type *key_type_lookup(const char *type);
94e9e349b0SDavid Howells extern void key_type_put(struct key_type *ktype);
95e9e349b0SDavid Howells 
96df593ee2SDavid Howells extern int __key_link_lock(struct key *keyring,
97df593ee2SDavid Howells 			   const struct keyring_index_key *index_key);
98ed0ac5c7SDavid Howells extern int __key_move_lock(struct key *l_keyring, struct key *u_keyring,
99ed0ac5c7SDavid Howells 			   const struct keyring_index_key *index_key);
100f70e2e06SDavid Howells extern int __key_link_begin(struct key *keyring,
10116feef43SDavid Howells 			    const struct keyring_index_key *index_key,
102b2a4df20SDavid Howells 			    struct assoc_array_edit **_edit);
103f70e2e06SDavid Howells extern int __key_link_check_live_key(struct key *keyring, struct key *key);
104b2a4df20SDavid Howells extern void __key_link(struct key *key, struct assoc_array_edit **_edit);
105f70e2e06SDavid Howells extern void __key_link_end(struct key *keyring,
10616feef43SDavid Howells 			   const struct keyring_index_key *index_key,
107b2a4df20SDavid Howells 			   struct assoc_array_edit *edit);
1081da177e4SLinus Torvalds 
109b2a4df20SDavid Howells extern key_ref_t find_key_to_update(key_ref_t keyring_ref,
110e57e8669SDavid Howells 				    const struct keyring_index_key *index_key);
1111da177e4SLinus Torvalds 
1123e30148cSDavid Howells extern struct key *keyring_search_instkey(struct key *keyring,
1133e30148cSDavid Howells 					  key_serial_t target_id);
1143e30148cSDavid Howells 
115b2a4df20SDavid Howells extern int iterate_over_keyring(const struct key *keyring,
116b2a4df20SDavid Howells 				int (*func)(const struct key *key, void *data),
117b2a4df20SDavid Howells 				void *data);
118b2a4df20SDavid Howells 
1194bdf0bc3SDavid Howells struct keyring_search_context {
1204bdf0bc3SDavid Howells 	struct keyring_index_key index_key;
1214bdf0bc3SDavid Howells 	const struct cred	*cred;
12246291959SDavid Howells 	struct key_match_data	match_data;
1234bdf0bc3SDavid Howells 	unsigned		flags;
124614d8c39SDavid Howells #define KEYRING_SEARCH_NO_STATE_CHECK	0x0001	/* Skip state checks */
125614d8c39SDavid Howells #define KEYRING_SEARCH_DO_STATE_CHECK	0x0002	/* Override NO_STATE_CHECK */
126614d8c39SDavid Howells #define KEYRING_SEARCH_NO_UPDATE_TIME	0x0004	/* Don't update times */
127614d8c39SDavid Howells #define KEYRING_SEARCH_NO_CHECK_PERM	0x0008	/* Don't check permissions */
128614d8c39SDavid Howells #define KEYRING_SEARCH_DETECT_TOO_DEEP	0x0010	/* Give an error on excessive depth */
1290b0a8415SDavid Howells #define KEYRING_SEARCH_SKIP_EXPIRED	0x0020	/* Ignore expired keys (intention to replace) */
1301da177e4SLinus Torvalds 
131b2a4df20SDavid Howells 	int (*iterator)(const void *object, void *iterator_data);
132b2a4df20SDavid Howells 
1334bdf0bc3SDavid Howells 	/* Internal stuff */
1344bdf0bc3SDavid Howells 	int			skipped_ret;
1354bdf0bc3SDavid Howells 	bool			possessed;
1364bdf0bc3SDavid Howells 	key_ref_t		result;
137074d5898SBaolin Wang 	time64_t		now;
1384bdf0bc3SDavid Howells };
1394bdf0bc3SDavid Howells 
1400c903ab6SDavid Howells extern bool key_default_cmp(const struct key *key,
141c06cfb08SDavid Howells 			    const struct key_match_data *match_data);
142e59428f7SDavid Howells extern key_ref_t keyring_search_rcu(key_ref_t keyring_ref,
1434bdf0bc3SDavid Howells 				    struct keyring_search_context *ctx);
1444bdf0bc3SDavid Howells 
145e59428f7SDavid Howells extern key_ref_t search_cred_keyrings_rcu(struct keyring_search_context *ctx);
146e59428f7SDavid Howells extern key_ref_t search_process_keyrings_rcu(struct keyring_search_context *ctx);
1471da177e4SLinus Torvalds 
148237bbd29SEric Biggers extern struct key *find_keyring_by_name(const char *name, bool uid_keyring);
1491da177e4SLinus Torvalds 
1508bbf4976SDavid Howells extern int install_user_keyrings(void);
151d84f4f99SDavid Howells extern int install_thread_keyring_to_cred(struct cred *);
152d84f4f99SDavid Howells extern int install_process_keyring_to_cred(struct cred *);
153685bfd2cSOleg Nesterov extern int install_session_keyring_to_cred(struct cred *, struct key *);
1543e30148cSDavid Howells 
1553e30148cSDavid Howells extern struct key *request_key_and_link(struct key_type *type,
1563e30148cSDavid Howells 					const char *description,
1574a38e122SDavid Howells 					const void *callout_info,
1584a38e122SDavid Howells 					size_t callout_len,
1594e54f085SDavid Howells 					void *aux,
1607e047ef5SDavid Howells 					struct key *dest_keyring,
1617e047ef5SDavid Howells 					unsigned long flags);
1623e30148cSDavid Howells 
1630c903ab6SDavid Howells extern bool lookup_user_key_possessed(const struct key *key,
16446291959SDavid Howells 				      const struct key_match_data *match_data);
1655593122eSDavid Howells #define KEY_LOOKUP_CREATE	0x01
1665593122eSDavid Howells #define KEY_LOOKUP_PARTIAL	0x02
1675593122eSDavid Howells #define KEY_LOOKUP_FOR_UNLINK	0x04
168e9e349b0SDavid Howells 
169e9e349b0SDavid Howells extern long join_session_keyring(const char *name);
17067d12145SAl Viro extern void key_change_session_keyring(struct callback_head *twork);
171e9e349b0SDavid Howells 
1720c061b57SDavid Howells extern struct work_struct key_gc_work;
1735d135440SDavid Howells extern unsigned key_gc_delay;
174074d5898SBaolin Wang extern void keyring_gc(struct key *keyring, time64_t limit);
1752b6aa412SMat Martineau extern void keyring_restriction_gc(struct key *keyring,
1762b6aa412SMat Martineau 				   struct key_type *dead_type);
177074d5898SBaolin Wang extern void key_schedule_gc(time64_t gc_at);
178fd75815fSDavid Howells extern void key_schedule_gc_links(void);
1790c061b57SDavid Howells extern void key_gc_keytype(struct key_type *ktype);
1805d135440SDavid Howells 
181e9e349b0SDavid Howells extern int key_task_permission(const key_ref_t key_ref,
182d84f4f99SDavid Howells 			       const struct cred *cred,
183e9e349b0SDavid Howells 			       key_perm_t perm);
184e9e349b0SDavid Howells 
185973c9f4fSDavid Howells /*
186973c9f4fSDavid Howells  * Check to see whether permission is granted to use a key in the desired way.
187973c9f4fSDavid Howells  */
188f5895943SDavid Howells static inline int key_permission(const key_ref_t key_ref, unsigned perm)
189e9e349b0SDavid Howells {
190d84f4f99SDavid Howells 	return key_task_permission(key_ref, current_cred(), perm);
191e9e349b0SDavid Howells }
192e9e349b0SDavid Howells 
1933e30148cSDavid Howells extern struct key_type key_type_request_key_auth;
1943e30148cSDavid Howells extern struct key *request_key_auth_new(struct key *target,
195822ad64dSDavid Howells 					const char *op,
1964a38e122SDavid Howells 					const void *callout_info,
1978bbf4976SDavid Howells 					size_t callout_len,
1988bbf4976SDavid Howells 					struct key *dest_keyring);
1993e30148cSDavid Howells 
2003e30148cSDavid Howells extern struct key *key_get_instantiation_authkey(key_serial_t target_id);
2011da177e4SLinus Torvalds 
2021da177e4SLinus Torvalds /*
203fd75815fSDavid Howells  * Determine whether a key is dead.
204fd75815fSDavid Howells  */
205074d5898SBaolin Wang static inline bool key_is_dead(const struct key *key, time64_t limit)
206fd75815fSDavid Howells {
207fd75815fSDavid Howells 	return
208fd75815fSDavid Howells 		key->flags & ((1 << KEY_FLAG_DEAD) |
209fd75815fSDavid Howells 			      (1 << KEY_FLAG_INVALIDATED)) ||
210fd75815fSDavid Howells 		(key->expiry > 0 && key->expiry <= limit);
211fd75815fSDavid Howells }
212fd75815fSDavid Howells 
213fd75815fSDavid Howells /*
214973c9f4fSDavid Howells  * keyctl() functions
2151da177e4SLinus Torvalds  */
2161da177e4SLinus Torvalds extern long keyctl_get_keyring_ID(key_serial_t, int);
2171da177e4SLinus Torvalds extern long keyctl_join_session_keyring(const char __user *);
2181da177e4SLinus Torvalds extern long keyctl_update_key(key_serial_t, const void __user *, size_t);
2191da177e4SLinus Torvalds extern long keyctl_revoke_key(key_serial_t);
2201da177e4SLinus Torvalds extern long keyctl_keyring_clear(key_serial_t);
2211da177e4SLinus Torvalds extern long keyctl_keyring_link(key_serial_t, key_serial_t);
222ed0ac5c7SDavid Howells extern long keyctl_keyring_move(key_serial_t, key_serial_t, key_serial_t, unsigned int);
2231da177e4SLinus Torvalds extern long keyctl_keyring_unlink(key_serial_t, key_serial_t);
2241da177e4SLinus Torvalds extern long keyctl_describe_key(key_serial_t, char __user *, size_t);
2251da177e4SLinus Torvalds extern long keyctl_keyring_search(key_serial_t, const char __user *,
2261da177e4SLinus Torvalds 				  const char __user *, key_serial_t);
2271da177e4SLinus Torvalds extern long keyctl_read_key(key_serial_t, char __user *, size_t);
2281da177e4SLinus Torvalds extern long keyctl_chown_key(key_serial_t, uid_t, gid_t);
2291da177e4SLinus Torvalds extern long keyctl_setperm_key(key_serial_t, key_perm_t);
2301da177e4SLinus Torvalds extern long keyctl_instantiate_key(key_serial_t, const void __user *,
2311da177e4SLinus Torvalds 				   size_t, key_serial_t);
2321da177e4SLinus Torvalds extern long keyctl_negate_key(key_serial_t, unsigned, key_serial_t);
2333e30148cSDavid Howells extern long keyctl_set_reqkey_keyring(int);
234017679c4SDavid Howells extern long keyctl_set_timeout(key_serial_t, unsigned);
235b5f545c8SDavid Howells extern long keyctl_assume_authority(key_serial_t);
23670a5bb72SDavid Howells extern long keyctl_get_security(key_serial_t keyid, char __user *buffer,
23770a5bb72SDavid Howells 				size_t buflen);
238ee18d64cSDavid Howells extern long keyctl_session_to_parent(void);
239fdd1b945SDavid Howells extern long keyctl_reject_key(key_serial_t, unsigned, unsigned, key_serial_t);
240ee009e4aSDavid Howells extern long keyctl_instantiate_key_iov(key_serial_t,
241ee009e4aSDavid Howells 				       const struct iovec __user *,
242ee009e4aSDavid Howells 				       unsigned, key_serial_t);
243fd75815fSDavid Howells extern long keyctl_invalidate_key(key_serial_t);
244ee009e4aSDavid Howells 
245b353a1f7SAl Viro struct iov_iter;
246ee009e4aSDavid Howells extern long keyctl_instantiate_key_common(key_serial_t,
247b353a1f7SAl Viro 					  struct iov_iter *,
248b353a1f7SAl Viro 					  key_serial_t);
2496563c91fSMat Martineau extern long keyctl_restrict_keyring(key_serial_t id,
2506563c91fSMat Martineau 				    const char __user *_type,
2516563c91fSMat Martineau 				    const char __user *_restriction);
252f36f8c75SDavid Howells #ifdef CONFIG_PERSISTENT_KEYRINGS
253f36f8c75SDavid Howells extern long keyctl_get_persistent(uid_t, key_serial_t);
254f36f8c75SDavid Howells extern unsigned persistent_keyring_expiry;
255f36f8c75SDavid Howells #else
256f36f8c75SDavid Howells static inline long keyctl_get_persistent(uid_t uid, key_serial_t destring)
257f36f8c75SDavid Howells {
258f36f8c75SDavid Howells 	return -EOPNOTSUPP;
259f36f8c75SDavid Howells }
260f36f8c75SDavid Howells #endif
2611da177e4SLinus Torvalds 
262ddbb4114SMat Martineau #ifdef CONFIG_KEY_DH_OPERATIONS
263ddbb4114SMat Martineau extern long keyctl_dh_compute(struct keyctl_dh_params __user *, char __user *,
264f1c316a3SStephan Mueller 			      size_t, struct keyctl_kdf_params __user *);
265f1c316a3SStephan Mueller extern long __keyctl_dh_compute(struct keyctl_dh_params __user *, char __user *,
266f1c316a3SStephan Mueller 				size_t, struct keyctl_kdf_params *);
267f1c316a3SStephan Mueller #ifdef CONFIG_KEYS_COMPAT
268f1c316a3SStephan Mueller extern long compat_keyctl_dh_compute(struct keyctl_dh_params __user *params,
269f1c316a3SStephan Mueller 				char __user *buffer, size_t buflen,
270f1c316a3SStephan Mueller 				struct compat_keyctl_kdf_params __user *kdf);
271f1c316a3SStephan Mueller #endif
272f1c316a3SStephan Mueller #define KEYCTL_KDF_MAX_OUTPUT_LEN	1024	/* max length of KDF output */
273f1c316a3SStephan Mueller #define KEYCTL_KDF_MAX_OI_LEN		64	/* max length of otherinfo */
274ddbb4114SMat Martineau #else
275ddbb4114SMat Martineau static inline long keyctl_dh_compute(struct keyctl_dh_params __user *params,
2764693fc73SStephan Mueller 				     char __user *buffer, size_t buflen,
277f1c316a3SStephan Mueller 				     struct keyctl_kdf_params __user *kdf)
278ddbb4114SMat Martineau {
279ddbb4114SMat Martineau 	return -EOPNOTSUPP;
280ddbb4114SMat Martineau }
281f1c316a3SStephan Mueller 
282f1c316a3SStephan Mueller #ifdef CONFIG_KEYS_COMPAT
283f1c316a3SStephan Mueller static inline long compat_keyctl_dh_compute(
284f1c316a3SStephan Mueller 				struct keyctl_dh_params __user *params,
285f1c316a3SStephan Mueller 				char __user *buffer, size_t buflen,
286f1c316a3SStephan Mueller 				struct keyctl_kdf_params __user *kdf)
287f1c316a3SStephan Mueller {
288f1c316a3SStephan Mueller 	return -EOPNOTSUPP;
289f1c316a3SStephan Mueller }
290f1c316a3SStephan Mueller #endif
291ddbb4114SMat Martineau #endif
292ddbb4114SMat Martineau 
29300d60fd3SDavid Howells #ifdef CONFIG_ASYMMETRIC_KEY_TYPE
29400d60fd3SDavid Howells extern long keyctl_pkey_query(key_serial_t,
29500d60fd3SDavid Howells 			      const char __user *,
29600d60fd3SDavid Howells 			      struct keyctl_pkey_query __user *);
29700d60fd3SDavid Howells 
29800d60fd3SDavid Howells extern long keyctl_pkey_verify(const struct keyctl_pkey_params __user *,
29900d60fd3SDavid Howells 			       const char __user *,
30000d60fd3SDavid Howells 			       const void __user *, const void __user *);
30100d60fd3SDavid Howells 
30200d60fd3SDavid Howells extern long keyctl_pkey_e_d_s(int,
30300d60fd3SDavid Howells 			      const struct keyctl_pkey_params __user *,
30400d60fd3SDavid Howells 			      const char __user *,
30500d60fd3SDavid Howells 			      const void __user *, void __user *);
30600d60fd3SDavid Howells #else
30700d60fd3SDavid Howells static inline long keyctl_pkey_query(key_serial_t id,
30800d60fd3SDavid Howells 				     const char __user *_info,
30900d60fd3SDavid Howells 				     struct keyctl_pkey_query __user *_res)
31000d60fd3SDavid Howells {
31100d60fd3SDavid Howells 	return -EOPNOTSUPP;
31200d60fd3SDavid Howells }
31300d60fd3SDavid Howells 
31400d60fd3SDavid Howells static inline long keyctl_pkey_verify(const struct keyctl_pkey_params __user *params,
31500d60fd3SDavid Howells 				      const char __user *_info,
31600d60fd3SDavid Howells 				      const void __user *_in,
31700d60fd3SDavid Howells 				      const void __user *_in2)
31800d60fd3SDavid Howells {
31900d60fd3SDavid Howells 	return -EOPNOTSUPP;
32000d60fd3SDavid Howells }
32100d60fd3SDavid Howells 
32200d60fd3SDavid Howells static inline long keyctl_pkey_e_d_s(int op,
32300d60fd3SDavid Howells 				     const struct keyctl_pkey_params __user *params,
32400d60fd3SDavid Howells 				     const char __user *_info,
32500d60fd3SDavid Howells 				     const void __user *_in,
32600d60fd3SDavid Howells 				     void __user *_out)
32700d60fd3SDavid Howells {
32800d60fd3SDavid Howells 	return -EOPNOTSUPP;
32900d60fd3SDavid Howells }
33000d60fd3SDavid Howells #endif
33100d60fd3SDavid Howells 
33245e0f30cSDavid Howells extern long keyctl_capabilities(unsigned char __user *_buffer, size_t buflen);
33345e0f30cSDavid Howells 
3341da177e4SLinus Torvalds /*
335973c9f4fSDavid Howells  * Debugging key validation
3361da177e4SLinus Torvalds  */
3371da177e4SLinus Torvalds #ifdef KEY_DEBUGGING
3381da177e4SLinus Torvalds extern void __key_check(const struct key *);
3391da177e4SLinus Torvalds 
3401da177e4SLinus Torvalds static inline void key_check(const struct key *key)
3411da177e4SLinus Torvalds {
3421da177e4SLinus Torvalds 	if (key && (IS_ERR(key) || key->magic != KEY_DEBUG_MAGIC))
3431da177e4SLinus Torvalds 		__key_check(key);
3441da177e4SLinus Torvalds }
3451da177e4SLinus Torvalds 
3461da177e4SLinus Torvalds #else
3471da177e4SLinus Torvalds 
3481da177e4SLinus Torvalds #define key_check(key) do {} while(0)
3491da177e4SLinus Torvalds 
3501da177e4SLinus Torvalds #endif
3511da177e4SLinus Torvalds 
3521da177e4SLinus Torvalds #endif /* _INTERNAL_H */
353