Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /* user-type.h: User-defined key type
0003  *
0004  * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved.
0005  * Written by David Howells (dhowells@redhat.com)
0006  */
0007 
0008 #ifndef _KEYS_USER_TYPE_H
0009 #define _KEYS_USER_TYPE_H
0010 
0011 #include <linux/key.h>
0012 #include <linux/rcupdate.h>
0013 
0014 #ifdef CONFIG_KEYS
0015 
0016 /*****************************************************************************/
0017 /*
0018  * the payload for a key of type "user" or "logon"
0019  * - once filled in and attached to a key:
0020  *   - the payload struct is invariant may not be changed, only replaced
0021  *   - the payload must be read with RCU procedures or with the key semaphore
0022  *     held
0023  *   - the payload may only be replaced with the key semaphore write-locked
0024  * - the key's data length is the size of the actual data, not including the
0025  *   payload wrapper
0026  */
0027 struct user_key_payload {
0028     struct rcu_head rcu;        /* RCU destructor */
0029     unsigned short  datalen;    /* length of this data */
0030     char        data[] __aligned(__alignof__(u64)); /* actual data */
0031 };
0032 
0033 extern struct key_type key_type_user;
0034 extern struct key_type key_type_logon;
0035 
0036 struct key_preparsed_payload;
0037 
0038 extern int user_preparse(struct key_preparsed_payload *prep);
0039 extern void user_free_preparse(struct key_preparsed_payload *prep);
0040 extern int user_update(struct key *key, struct key_preparsed_payload *prep);
0041 extern void user_revoke(struct key *key);
0042 extern void user_destroy(struct key *key);
0043 extern void user_describe(const struct key *user, struct seq_file *m);
0044 extern long user_read(const struct key *key, char *buffer, size_t buflen);
0045 
0046 static inline const struct user_key_payload *user_key_payload_rcu(const struct key *key)
0047 {
0048     return (struct user_key_payload *)dereference_key_rcu(key);
0049 }
0050 
0051 static inline struct user_key_payload *user_key_payload_locked(const struct key *key)
0052 {
0053     return (struct user_key_payload *)dereference_key_locked((struct key *)key);
0054 }
0055 
0056 #endif /* CONFIG_KEYS */
0057 
0058 #endif /* _KEYS_USER_TYPE_H */