xref: /openbmc/linux/security/keys/internal.h (revision afc360e8)
12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2973c9f4fSDavid Howells /* Authentication token and access key management internal defs
31da177e4SLinus Torvalds  *
476181c13SDavid Howells  * Copyright (C) 2003-5, 2007 Red Hat, Inc. All Rights Reserved.
51da177e4SLinus Torvalds  * Written by David Howells (dhowells@redhat.com)
61da177e4SLinus Torvalds  */
71da177e4SLinus Torvalds 
81da177e4SLinus Torvalds #ifndef _INTERNAL_H
91da177e4SLinus Torvalds #define _INTERNAL_H
101da177e4SLinus Torvalds 
11d84f4f99SDavid Howells #include <linux/sched.h>
125dd43ce2SIngo Molnar #include <linux/wait_bit.h>
135b825c3aSIngo Molnar #include <linux/cred.h>
1476181c13SDavid Howells #include <linux/key-type.h>
15413cd3d9SOleg Nesterov #include <linux/task_work.h>
16ddbb4114SMat Martineau #include <linux/keyctl.h>
17ddb99e11SElena Reshetova #include <linux/refcount.h>
18f7e47677SDavid Howells #include <linux/watch_queue.h>
19f1c316a3SStephan Mueller #include <linux/compat.h>
204f088249SWaiman Long #include <linux/mm.h>
214f088249SWaiman Long #include <linux/vmalloc.h>
221da177e4SLinus Torvalds 
23a27bb332SKent Overstreet struct iovec;
24a27bb332SKent Overstreet 
2576181c13SDavid Howells #ifdef __KDEBUG
2676181c13SDavid Howells #define kenter(FMT, ...) \
27dd6f953aSHarvey Harrison 	printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)
2876181c13SDavid Howells #define kleave(FMT, ...) \
29dd6f953aSHarvey Harrison 	printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
3076181c13SDavid Howells #define kdebug(FMT, ...) \
31d84f4f99SDavid Howells 	printk(KERN_DEBUG "   "FMT"\n", ##__VA_ARGS__)
323e30148cSDavid Howells #else
3376181c13SDavid Howells #define kenter(FMT, ...) \
34dd6f953aSHarvey Harrison 	no_printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)
3576181c13SDavid Howells #define kleave(FMT, ...) \
36dd6f953aSHarvey Harrison 	no_printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
3776181c13SDavid Howells #define kdebug(FMT, ...) \
3876181c13SDavid Howells 	no_printk(KERN_DEBUG FMT"\n", ##__VA_ARGS__)
393e30148cSDavid Howells #endif
403e30148cSDavid Howells 
410c061b57SDavid Howells extern struct key_type key_type_dead;
421da177e4SLinus Torvalds extern struct key_type key_type_user;
439f6ed2caSJeff Layton extern struct key_type key_type_logon;
441da177e4SLinus Torvalds 
451da177e4SLinus Torvalds /*****************************************************************************/
461da177e4SLinus Torvalds /*
47973c9f4fSDavid Howells  * Keep track of keys for a user.
48973c9f4fSDavid Howells  *
49973c9f4fSDavid Howells  * This needs to be separate to user_struct to avoid a refcount-loop
50973c9f4fSDavid Howells  * (user_struct pins some keyrings which pin this struct).
51973c9f4fSDavid Howells  *
52973c9f4fSDavid Howells  * We also keep track of keys under request from userspace for this UID here.
531da177e4SLinus Torvalds  */
541da177e4SLinus Torvalds struct key_user {
551da177e4SLinus Torvalds 	struct rb_node		node;
5676181c13SDavid Howells 	struct mutex		cons_lock;	/* construction initiation lock */
571da177e4SLinus Torvalds 	spinlock_t		lock;
58ddb99e11SElena Reshetova 	refcount_t		usage;		/* for accessing qnkeys & qnbytes */
591da177e4SLinus Torvalds 	atomic_t		nkeys;		/* number of keys */
601da177e4SLinus Torvalds 	atomic_t		nikeys;		/* number of instantiated keys */
619a56c2dbSEric W. Biederman 	kuid_t			uid;
621da177e4SLinus Torvalds 	int			qnkeys;		/* number of keys allocated to this user */
631da177e4SLinus Torvalds 	int			qnbytes;	/* number of bytes allocated to this user */
641da177e4SLinus Torvalds };
651da177e4SLinus Torvalds 
661da177e4SLinus Torvalds extern struct rb_root	key_user_tree;
671da177e4SLinus Torvalds extern spinlock_t	key_user_lock;
681da177e4SLinus Torvalds extern struct key_user	root_key_user;
691da177e4SLinus Torvalds 
709a56c2dbSEric W. Biederman extern struct key_user *key_user_lookup(kuid_t uid);
711da177e4SLinus Torvalds extern void key_user_put(struct key_user *user);
721da177e4SLinus Torvalds 
730b77f5bfSDavid Howells /*
74973c9f4fSDavid Howells  * Key quota limits.
750b77f5bfSDavid Howells  * - root has its own separate limits to everyone else
760b77f5bfSDavid Howells  */
770b77f5bfSDavid Howells extern unsigned key_quota_root_maxkeys;
780b77f5bfSDavid Howells extern unsigned key_quota_root_maxbytes;
790b77f5bfSDavid Howells extern unsigned key_quota_maxkeys;
800b77f5bfSDavid Howells extern unsigned key_quota_maxbytes;
810b77f5bfSDavid Howells 
820b77f5bfSDavid Howells #define KEYQUOTA_LINK_BYTES	4		/* a link in a keyring is worth 4 bytes */
831da177e4SLinus Torvalds 
841da177e4SLinus Torvalds 
858bc16deaSDavid Howells extern struct kmem_cache *key_jar;
861da177e4SLinus Torvalds extern struct rb_root key_serial_tree;
871da177e4SLinus Torvalds extern spinlock_t key_serial_lock;
8876181c13SDavid Howells extern struct mutex key_construction_mutex;
891da177e4SLinus Torvalds extern wait_queue_head_t request_key_conswq;
901da177e4SLinus Torvalds 
91355ef8e1SDavid Howells extern void key_set_index_key(struct keyring_index_key *index_key);
92e9e349b0SDavid Howells extern struct key_type *key_type_lookup(const char *type);
93e9e349b0SDavid Howells extern void key_type_put(struct key_type *ktype);
94e9e349b0SDavid Howells 
95df593ee2SDavid Howells extern int __key_link_lock(struct key *keyring,
96df593ee2SDavid Howells 			   const struct keyring_index_key *index_key);
97ed0ac5c7SDavid Howells extern int __key_move_lock(struct key *l_keyring, struct key *u_keyring,
98ed0ac5c7SDavid Howells 			   const struct keyring_index_key *index_key);
99f70e2e06SDavid Howells extern int __key_link_begin(struct key *keyring,
10016feef43SDavid Howells 			    const struct keyring_index_key *index_key,
101b2a4df20SDavid Howells 			    struct assoc_array_edit **_edit);
102f70e2e06SDavid Howells extern int __key_link_check_live_key(struct key *keyring, struct key *key);
103f7e47677SDavid Howells extern void __key_link(struct key *keyring, struct key *key,
104f7e47677SDavid Howells 		       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) */
130dcf49dbcSDavid Howells #define KEYRING_SEARCH_RECURSE		0x0040	/* Search child keyrings also */
1311da177e4SLinus Torvalds 
132b2a4df20SDavid Howells 	int (*iterator)(const void *object, void *iterator_data);
133b2a4df20SDavid Howells 
1344bdf0bc3SDavid Howells 	/* Internal stuff */
1354bdf0bc3SDavid Howells 	int			skipped_ret;
1364bdf0bc3SDavid Howells 	bool			possessed;
1374bdf0bc3SDavid Howells 	key_ref_t		result;
138074d5898SBaolin Wang 	time64_t		now;
1394bdf0bc3SDavid Howells };
1404bdf0bc3SDavid Howells 
1410c903ab6SDavid Howells extern bool key_default_cmp(const struct key *key,
142c06cfb08SDavid Howells 			    const struct key_match_data *match_data);
143e59428f7SDavid Howells extern key_ref_t keyring_search_rcu(key_ref_t keyring_ref,
1444bdf0bc3SDavid Howells 				    struct keyring_search_context *ctx);
1454bdf0bc3SDavid Howells 
146e59428f7SDavid Howells extern key_ref_t search_cred_keyrings_rcu(struct keyring_search_context *ctx);
147e59428f7SDavid Howells extern key_ref_t search_process_keyrings_rcu(struct keyring_search_context *ctx);
1481da177e4SLinus Torvalds 
149237bbd29SEric Biggers extern struct key *find_keyring_by_name(const char *name, bool uid_keyring);
1501da177e4SLinus Torvalds 
1510f44e4d9SDavid Howells extern int look_up_user_keyrings(struct key **, struct key **);
1520f44e4d9SDavid Howells extern struct key *get_user_session_keyring_rcu(const struct cred *);
153d84f4f99SDavid Howells extern int install_thread_keyring_to_cred(struct cred *);
154d84f4f99SDavid Howells extern int install_process_keyring_to_cred(struct cred *);
155685bfd2cSOleg Nesterov extern int install_session_keyring_to_cred(struct cred *, struct key *);
1563e30148cSDavid Howells 
1573e30148cSDavid Howells extern struct key *request_key_and_link(struct key_type *type,
1583e30148cSDavid Howells 					const char *description,
159a58946c1SDavid Howells 					struct key_tag *domain_tag,
1604a38e122SDavid Howells 					const void *callout_info,
1614a38e122SDavid Howells 					size_t callout_len,
1624e54f085SDavid Howells 					void *aux,
1637e047ef5SDavid Howells 					struct key *dest_keyring,
1647e047ef5SDavid Howells 					unsigned long flags);
1653e30148cSDavid Howells 
1660c903ab6SDavid Howells extern bool lookup_user_key_possessed(const struct key *key,
16746291959SDavid Howells 				      const struct key_match_data *match_data);
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);
177*afc360e8SDavid Howells void key_set_expiry(struct key *key, time64_t expiry);
178074d5898SBaolin Wang extern void key_schedule_gc(time64_t gc_at);
179fd75815fSDavid Howells extern void key_schedule_gc_links(void);
1800c061b57SDavid Howells extern void key_gc_keytype(struct key_type *ktype);
1815d135440SDavid Howells 
182e9e349b0SDavid Howells extern int key_task_permission(const key_ref_t key_ref,
183d84f4f99SDavid Howells 			       const struct cred *cred,
1848c0637e9SDavid Howells 			       enum key_need_perm need_perm);
185e9e349b0SDavid Howells 
notify_key(struct key * key,enum key_notification_subtype subtype,u32 aux)186f7e47677SDavid Howells static inline void notify_key(struct key *key,
187f7e47677SDavid Howells 			      enum key_notification_subtype subtype, u32 aux)
188f7e47677SDavid Howells {
189f7e47677SDavid Howells #ifdef CONFIG_KEY_NOTIFICATIONS
190f7e47677SDavid Howells 	struct key_notification n = {
191f7e47677SDavid Howells 		.watch.type	= WATCH_TYPE_KEY_NOTIFY,
192f7e47677SDavid Howells 		.watch.subtype	= subtype,
193f7e47677SDavid Howells 		.watch.info	= watch_sizeof(n),
194f7e47677SDavid Howells 		.key_id		= key_serial(key),
195f7e47677SDavid Howells 		.aux		= aux,
196f7e47677SDavid Howells 	};
197f7e47677SDavid Howells 
198f7e47677SDavid Howells 	post_watch_notification(key->watchers, &n.watch, current_cred(),
199f7e47677SDavid Howells 				n.key_id);
200f7e47677SDavid Howells #endif
201f7e47677SDavid Howells }
202e9e349b0SDavid Howells 
203973c9f4fSDavid Howells /*
204973c9f4fSDavid Howells  * Check to see whether permission is granted to use a key in the desired way.
205973c9f4fSDavid Howells  */
key_permission(const key_ref_t key_ref,enum key_need_perm need_perm)2068c0637e9SDavid Howells static inline int key_permission(const key_ref_t key_ref,
2078c0637e9SDavid Howells 				 enum key_need_perm need_perm)
208e9e349b0SDavid Howells {
2098c0637e9SDavid Howells 	return key_task_permission(key_ref, current_cred(), need_perm);
210e9e349b0SDavid Howells }
211e9e349b0SDavid Howells 
2123e30148cSDavid Howells extern struct key_type key_type_request_key_auth;
2133e30148cSDavid Howells extern struct key *request_key_auth_new(struct key *target,
214822ad64dSDavid Howells 					const char *op,
2154a38e122SDavid Howells 					const void *callout_info,
2168bbf4976SDavid Howells 					size_t callout_len,
2178bbf4976SDavid Howells 					struct key *dest_keyring);
2183e30148cSDavid Howells 
2193e30148cSDavid Howells extern struct key *key_get_instantiation_authkey(key_serial_t target_id);
2201da177e4SLinus Torvalds 
2211da177e4SLinus Torvalds /*
222fd75815fSDavid Howells  * Determine whether a key is dead.
223fd75815fSDavid Howells  */
key_is_dead(const struct key * key,time64_t limit)224074d5898SBaolin Wang static inline bool key_is_dead(const struct key *key, time64_t limit)
225fd75815fSDavid Howells {
226*afc360e8SDavid Howells 	time64_t expiry = key->expiry;
227*afc360e8SDavid Howells 
228*afc360e8SDavid Howells 	if (expiry != TIME64_MAX) {
229*afc360e8SDavid Howells 		if (!(key->type->flags & KEY_TYPE_INSTANT_REAP))
230*afc360e8SDavid Howells 			expiry += key_gc_delay;
231*afc360e8SDavid Howells 		if (expiry <= limit)
232*afc360e8SDavid Howells 			return true;
233*afc360e8SDavid Howells 	}
234*afc360e8SDavid Howells 
235fd75815fSDavid Howells 	return
236fd75815fSDavid Howells 		key->flags & ((1 << KEY_FLAG_DEAD) |
237fd75815fSDavid Howells 			      (1 << KEY_FLAG_INVALIDATED)) ||
238218e6424SDavid Howells 		key->domain_tag->removed;
239fd75815fSDavid Howells }
240fd75815fSDavid Howells 
241fd75815fSDavid Howells /*
242973c9f4fSDavid Howells  * keyctl() functions
2431da177e4SLinus Torvalds  */
2441da177e4SLinus Torvalds extern long keyctl_get_keyring_ID(key_serial_t, int);
2451da177e4SLinus Torvalds extern long keyctl_join_session_keyring(const char __user *);
2461da177e4SLinus Torvalds extern long keyctl_update_key(key_serial_t, const void __user *, size_t);
2471da177e4SLinus Torvalds extern long keyctl_revoke_key(key_serial_t);
2481da177e4SLinus Torvalds extern long keyctl_keyring_clear(key_serial_t);
2491da177e4SLinus Torvalds extern long keyctl_keyring_link(key_serial_t, key_serial_t);
250ed0ac5c7SDavid Howells extern long keyctl_keyring_move(key_serial_t, key_serial_t, key_serial_t, unsigned int);
2511da177e4SLinus Torvalds extern long keyctl_keyring_unlink(key_serial_t, key_serial_t);
2521da177e4SLinus Torvalds extern long keyctl_describe_key(key_serial_t, char __user *, size_t);
2531da177e4SLinus Torvalds extern long keyctl_keyring_search(key_serial_t, const char __user *,
2541da177e4SLinus Torvalds 				  const char __user *, key_serial_t);
2551da177e4SLinus Torvalds extern long keyctl_read_key(key_serial_t, char __user *, size_t);
2561da177e4SLinus Torvalds extern long keyctl_chown_key(key_serial_t, uid_t, gid_t);
257028db3e2SLinus Torvalds extern long keyctl_setperm_key(key_serial_t, key_perm_t);
2581da177e4SLinus Torvalds extern long keyctl_instantiate_key(key_serial_t, const void __user *,
2591da177e4SLinus Torvalds 				   size_t, key_serial_t);
2601da177e4SLinus Torvalds extern long keyctl_negate_key(key_serial_t, unsigned, key_serial_t);
2613e30148cSDavid Howells extern long keyctl_set_reqkey_keyring(int);
262017679c4SDavid Howells extern long keyctl_set_timeout(key_serial_t, unsigned);
263b5f545c8SDavid Howells extern long keyctl_assume_authority(key_serial_t);
26470a5bb72SDavid Howells extern long keyctl_get_security(key_serial_t keyid, char __user *buffer,
26570a5bb72SDavid Howells 				size_t buflen);
266ee18d64cSDavid Howells extern long keyctl_session_to_parent(void);
267fdd1b945SDavid Howells extern long keyctl_reject_key(key_serial_t, unsigned, unsigned, key_serial_t);
268ee009e4aSDavid Howells extern long keyctl_instantiate_key_iov(key_serial_t,
269ee009e4aSDavid Howells 				       const struct iovec __user *,
270ee009e4aSDavid Howells 				       unsigned, key_serial_t);
271fd75815fSDavid Howells extern long keyctl_invalidate_key(key_serial_t);
2726563c91fSMat Martineau extern long keyctl_restrict_keyring(key_serial_t id,
2736563c91fSMat Martineau 				    const char __user *_type,
2746563c91fSMat Martineau 				    const char __user *_restriction);
275f36f8c75SDavid Howells #ifdef CONFIG_PERSISTENT_KEYRINGS
276f36f8c75SDavid Howells extern long keyctl_get_persistent(uid_t, key_serial_t);
277f36f8c75SDavid Howells extern unsigned persistent_keyring_expiry;
278f36f8c75SDavid Howells #else
keyctl_get_persistent(uid_t uid,key_serial_t destring)279f36f8c75SDavid Howells static inline long keyctl_get_persistent(uid_t uid, key_serial_t destring)
280f36f8c75SDavid Howells {
281f36f8c75SDavid Howells 	return -EOPNOTSUPP;
282f36f8c75SDavid Howells }
283f36f8c75SDavid Howells #endif
2841da177e4SLinus Torvalds 
285ddbb4114SMat Martineau #ifdef CONFIG_KEY_DH_OPERATIONS
286ddbb4114SMat Martineau extern long keyctl_dh_compute(struct keyctl_dh_params __user *, char __user *,
287f1c316a3SStephan Mueller 			      size_t, struct keyctl_kdf_params __user *);
288f1c316a3SStephan Mueller extern long __keyctl_dh_compute(struct keyctl_dh_params __user *, char __user *,
289f1c316a3SStephan Mueller 				size_t, struct keyctl_kdf_params *);
290601f0093SEric Biggers #ifdef CONFIG_COMPAT
291f1c316a3SStephan Mueller extern long compat_keyctl_dh_compute(struct keyctl_dh_params __user *params,
292f1c316a3SStephan Mueller 				char __user *buffer, size_t buflen,
293f1c316a3SStephan Mueller 				struct compat_keyctl_kdf_params __user *kdf);
294f1c316a3SStephan Mueller #endif
295f1c316a3SStephan Mueller #define KEYCTL_KDF_MAX_OUTPUT_LEN	1024	/* max length of KDF output */
296f1c316a3SStephan Mueller #define KEYCTL_KDF_MAX_OI_LEN		64	/* max length of otherinfo */
297ddbb4114SMat Martineau #else
keyctl_dh_compute(struct keyctl_dh_params __user * params,char __user * buffer,size_t buflen,struct keyctl_kdf_params __user * kdf)298ddbb4114SMat Martineau static inline long keyctl_dh_compute(struct keyctl_dh_params __user *params,
2994693fc73SStephan Mueller 				     char __user *buffer, size_t buflen,
300f1c316a3SStephan Mueller 				     struct keyctl_kdf_params __user *kdf)
301ddbb4114SMat Martineau {
302ddbb4114SMat Martineau 	return -EOPNOTSUPP;
303ddbb4114SMat Martineau }
304f1c316a3SStephan Mueller 
305601f0093SEric Biggers #ifdef CONFIG_COMPAT
compat_keyctl_dh_compute(struct keyctl_dh_params __user * params,char __user * buffer,size_t buflen,struct keyctl_kdf_params __user * kdf)306f1c316a3SStephan Mueller static inline long compat_keyctl_dh_compute(
307f1c316a3SStephan Mueller 				struct keyctl_dh_params __user *params,
308f1c316a3SStephan Mueller 				char __user *buffer, size_t buflen,
309f1c316a3SStephan Mueller 				struct keyctl_kdf_params __user *kdf)
310f1c316a3SStephan Mueller {
311f1c316a3SStephan Mueller 	return -EOPNOTSUPP;
312f1c316a3SStephan Mueller }
313f1c316a3SStephan Mueller #endif
314ddbb4114SMat Martineau #endif
315ddbb4114SMat Martineau 
31600d60fd3SDavid Howells #ifdef CONFIG_ASYMMETRIC_KEY_TYPE
31700d60fd3SDavid Howells extern long keyctl_pkey_query(key_serial_t,
31800d60fd3SDavid Howells 			      const char __user *,
31900d60fd3SDavid Howells 			      struct keyctl_pkey_query __user *);
32000d60fd3SDavid Howells 
32100d60fd3SDavid Howells extern long keyctl_pkey_verify(const struct keyctl_pkey_params __user *,
32200d60fd3SDavid Howells 			       const char __user *,
32300d60fd3SDavid Howells 			       const void __user *, const void __user *);
32400d60fd3SDavid Howells 
32500d60fd3SDavid Howells extern long keyctl_pkey_e_d_s(int,
32600d60fd3SDavid Howells 			      const struct keyctl_pkey_params __user *,
32700d60fd3SDavid Howells 			      const char __user *,
32800d60fd3SDavid Howells 			      const void __user *, void __user *);
32900d60fd3SDavid Howells #else
keyctl_pkey_query(key_serial_t id,const char __user * _info,struct keyctl_pkey_query __user * _res)33000d60fd3SDavid Howells static inline long keyctl_pkey_query(key_serial_t id,
33100d60fd3SDavid Howells 				     const char __user *_info,
33200d60fd3SDavid Howells 				     struct keyctl_pkey_query __user *_res)
33300d60fd3SDavid Howells {
33400d60fd3SDavid Howells 	return -EOPNOTSUPP;
33500d60fd3SDavid Howells }
33600d60fd3SDavid Howells 
keyctl_pkey_verify(const struct keyctl_pkey_params __user * params,const char __user * _info,const void __user * _in,const void __user * _in2)33700d60fd3SDavid Howells static inline long keyctl_pkey_verify(const struct keyctl_pkey_params __user *params,
33800d60fd3SDavid Howells 				      const char __user *_info,
33900d60fd3SDavid Howells 				      const void __user *_in,
34000d60fd3SDavid Howells 				      const void __user *_in2)
34100d60fd3SDavid Howells {
34200d60fd3SDavid Howells 	return -EOPNOTSUPP;
34300d60fd3SDavid Howells }
34400d60fd3SDavid Howells 
keyctl_pkey_e_d_s(int op,const struct keyctl_pkey_params __user * params,const char __user * _info,const void __user * _in,void __user * _out)34500d60fd3SDavid Howells static inline long keyctl_pkey_e_d_s(int op,
34600d60fd3SDavid Howells 				     const struct keyctl_pkey_params __user *params,
34700d60fd3SDavid Howells 				     const char __user *_info,
34800d60fd3SDavid Howells 				     const void __user *_in,
34900d60fd3SDavid Howells 				     void __user *_out)
35000d60fd3SDavid Howells {
35100d60fd3SDavid Howells 	return -EOPNOTSUPP;
35200d60fd3SDavid Howells }
35300d60fd3SDavid Howells #endif
35400d60fd3SDavid Howells 
35545e0f30cSDavid Howells extern long keyctl_capabilities(unsigned char __user *_buffer, size_t buflen);
35645e0f30cSDavid Howells 
357f7e47677SDavid Howells #ifdef CONFIG_KEY_NOTIFICATIONS
358f7e47677SDavid Howells extern long keyctl_watch_key(key_serial_t, int, int);
359f7e47677SDavid Howells #else
keyctl_watch_key(key_serial_t key_id,int watch_fd,int watch_id)360f7e47677SDavid Howells static inline long keyctl_watch_key(key_serial_t key_id, int watch_fd, int watch_id)
361f7e47677SDavid Howells {
362f7e47677SDavid Howells 	return -EOPNOTSUPP;
363f7e47677SDavid Howells }
364f7e47677SDavid Howells #endif
365f7e47677SDavid Howells 
3661da177e4SLinus Torvalds /*
367973c9f4fSDavid Howells  * Debugging key validation
3681da177e4SLinus Torvalds  */
3691da177e4SLinus Torvalds #ifdef KEY_DEBUGGING
3701da177e4SLinus Torvalds extern void __key_check(const struct key *);
3711da177e4SLinus Torvalds 
key_check(const struct key * key)3721da177e4SLinus Torvalds static inline void key_check(const struct key *key)
3731da177e4SLinus Torvalds {
3741da177e4SLinus Torvalds 	if (key && (IS_ERR(key) || key->magic != KEY_DEBUG_MAGIC))
3751da177e4SLinus Torvalds 		__key_check(key);
3761da177e4SLinus Torvalds }
3771da177e4SLinus Torvalds 
3781da177e4SLinus Torvalds #else
3791da177e4SLinus Torvalds 
3801da177e4SLinus Torvalds #define key_check(key) do {} while(0)
3811da177e4SLinus Torvalds 
3821da177e4SLinus Torvalds #endif
3831da177e4SLinus Torvalds #endif /* _INTERNAL_H */
384