Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions | Variables
internal.h File Reference
#include <linux/sched.h>
#include <linux/key-type.h>
#include <linux/task_work.h>

Go to the source code of this file.

Data Structures

struct  key_user
 
struct  request_key_auth
 

Macros

#define kenter(FMT,...)   no_printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)
 
#define kleave(FMT,...)   no_printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
 
#define kdebug(FMT,...)   no_printk(KERN_DEBUG FMT"\n", ##__VA_ARGS__)
 
#define KEYQUOTA_LINK_BYTES   4 /* a link in a keyring is worth 4 bytes */
 
#define KEY_LOOKUP_CREATE   0x01
 
#define KEY_LOOKUP_PARTIAL   0x02
 
#define KEY_LOOKUP_FOR_UNLINK   0x04
 
#define KEY_VIEW   0x01 /* require permission to view attributes */
 
#define KEY_READ   0x02 /* require permission to read content */
 
#define KEY_WRITE   0x04 /* require permission to update / modify */
 
#define KEY_SEARCH   0x08 /* require permission to search (keyring) or find (key) */
 
#define KEY_LINK   0x10 /* require permission to link */
 
#define KEY_SETATTR   0x20 /* require permission to change attributes */
 
#define KEY_ALL   0x3f /* all the above permissions */
 
#define key_check(key)   do {} while(0)
 

Typedefs

typedef int(* key_match_func_t )(const struct key *, const void *)
 

Functions

struct key_userkey_user_lookup (kuid_t uid)
 
void key_user_put (struct key_user *user)
 
struct key_type * key_type_lookup (const char *type)
 
void key_type_put (struct key_type *ktype)
 
int __key_link_begin (struct key *keyring, const struct key_type *type, const char *description, unsigned long *_prealloc)
 
int __key_link_check_live_key (struct key *keyring, struct key *key)
 
void __key_link (struct key *keyring, struct key *key, unsigned long *_prealloc)
 
void __key_link_end (struct key *keyring, struct key_type *type, unsigned long prealloc)
 
key_ref_t __keyring_search_one (key_ref_t keyring_ref, const struct key_type *type, const char *description, key_perm_t perm)
 
struct keykeyring_search_instkey (struct key *keyring, key_serial_t target_id)
 
key_ref_t keyring_search_aux (key_ref_t keyring_ref, const struct cred *cred, struct key_type *type, const void *description, key_match_func_t match, bool no_state_check)
 
key_ref_t search_my_process_keyrings (struct key_type *type, const void *description, key_match_func_t match, bool no_state_check, const struct cred *cred)
 
key_ref_t search_process_keyrings (struct key_type *type, const void *description, key_match_func_t match, const struct cred *cred)
 
struct keyfind_keyring_by_name (const char *name, bool skip_perm_check)
 
int install_user_keyrings (void)
 
int install_thread_keyring_to_cred (struct cred *)
 
int install_process_keyring_to_cred (struct cred *)
 
int install_session_keyring_to_cred (struct cred *, struct key *)
 
struct keyrequest_key_and_link (struct key_type *type, const char *description, const void *callout_info, size_t callout_len, void *aux, struct key *dest_keyring, unsigned long flags)
 
int lookup_user_key_possessed (const struct key *key, const void *target)
 
key_ref_t lookup_user_key (key_serial_t id, unsigned long flags, key_perm_t perm)
 
long join_session_keyring (const char *name)
 
void key_change_session_keyring (struct callback_head *twork)
 
void keyring_gc (struct key *keyring, time_t limit)
 
void key_schedule_gc (time_t gc_at)
 
void key_schedule_gc_links (void)
 
void key_gc_keytype (struct key_type *ktype)
 
int key_task_permission (const key_ref_t key_ref, const struct cred *cred, key_perm_t perm)
 
struct keyrequest_key_auth_new (struct key *target, const void *callout_info, size_t callout_len, struct key *dest_keyring)
 
struct keykey_get_instantiation_authkey (key_serial_t target_id)
 
long keyctl_get_keyring_ID (key_serial_t, int)
 
long keyctl_join_session_keyring (const char __user *)
 
long keyctl_update_key (key_serial_t, const void __user *, size_t)
 
long keyctl_revoke_key (key_serial_t)
 
long keyctl_keyring_clear (key_serial_t)
 
long keyctl_keyring_link (key_serial_t, key_serial_t)
 
long keyctl_keyring_unlink (key_serial_t, key_serial_t)
 
long keyctl_describe_key (key_serial_t, char __user *, size_t)
 
long keyctl_keyring_search (key_serial_t, const char __user *, const char __user *, key_serial_t)
 
long keyctl_read_key (key_serial_t, char __user *, size_t)
 
long keyctl_chown_key (key_serial_t, uid_t, gid_t)
 
long keyctl_setperm_key (key_serial_t, key_perm_t)
 
long keyctl_instantiate_key (key_serial_t, const void __user *, size_t, key_serial_t)
 
long keyctl_negate_key (key_serial_t, unsigned, key_serial_t)
 
long keyctl_set_reqkey_keyring (int)
 
long keyctl_set_timeout (key_serial_t, unsigned)
 
long keyctl_assume_authority (key_serial_t)
 
long keyctl_get_security (key_serial_t keyid, char __user *buffer, size_t buflen)
 
long keyctl_session_to_parent (void)
 
long keyctl_reject_key (key_serial_t, unsigned, unsigned, key_serial_t)
 
long keyctl_instantiate_key_iov (key_serial_t, const struct iovec __user *, unsigned, key_serial_t)
 
long keyctl_invalidate_key (key_serial_t)
 
long keyctl_instantiate_key_common (key_serial_t, const struct iovec *, unsigned, size_t, key_serial_t)
 

Variables

struct key_type key_type_dead
 
struct key_type key_type_user
 
struct key_type key_type_logon
 
struct rb_root key_user_tree
 
spinlock_t key_user_lock
 
struct key_user root_key_user
 
unsigned key_quota_root_maxkeys
 
unsigned key_quota_root_maxbytes
 
unsigned key_quota_maxkeys
 
unsigned key_quota_maxbytes
 
struct kmem_cachekey_jar
 
struct rb_root key_serial_tree
 
spinlock_t key_serial_lock
 
struct mutex key_construction_mutex
 
wait_queue_head_t request_key_conswq
 
struct work_struct key_gc_work
 
unsigned key_gc_delay
 
struct key_type key_type_request_key_auth
 

Macro Definition Documentation

#define kdebug (   FMT,
  ... 
)    no_printk(KERN_DEBUG FMT"\n", ##__VA_ARGS__)

Definition at line 31 of file internal.h.

#define kenter (   FMT,
  ... 
)    no_printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)

Definition at line 27 of file internal.h.

#define KEY_ALL   0x3f /* all the above permissions */

Definition at line 178 of file internal.h.

#define key_check (   key)    do {} while(0)

Definition at line 260 of file internal.h.

#define KEY_LINK   0x10 /* require permission to link */

Definition at line 176 of file internal.h.

#define KEY_LOOKUP_CREATE   0x01

Definition at line 145 of file internal.h.

#define KEY_LOOKUP_FOR_UNLINK   0x04

Definition at line 147 of file internal.h.

#define KEY_LOOKUP_PARTIAL   0x02

Definition at line 146 of file internal.h.

#define KEY_READ   0x02 /* require permission to read content */

Definition at line 173 of file internal.h.

#define KEY_SEARCH   0x08 /* require permission to search (keyring) or find (key) */

Definition at line 175 of file internal.h.

#define KEY_SETATTR   0x20 /* require permission to change attributes */

Definition at line 177 of file internal.h.

#define KEY_VIEW   0x01 /* require permission to view attributes */

Definition at line 172 of file internal.h.

#define KEY_WRITE   0x04 /* require permission to update / modify */

Definition at line 174 of file internal.h.

#define KEYQUOTA_LINK_BYTES   4 /* a link in a keyring is worth 4 bytes */

Definition at line 76 of file internal.h.

#define kleave (   FMT,
  ... 
)    no_printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)

Definition at line 29 of file internal.h.

Typedef Documentation

typedef int(* key_match_func_t)(const struct key *, const void *)

Definition at line 108 of file internal.h.

Function Documentation

void __key_link ( struct key keyring,
struct key key,
unsigned long _prealloc 
)

Definition at line 900 of file keyring.c.

int __key_link_begin ( struct key keyring,
const struct key_type *  type,
const char description,
unsigned long _prealloc 
)

Definition at line 751 of file keyring.c.

int __key_link_check_live_key ( struct key keyring,
struct key key 
)

Definition at line 883 of file keyring.c.

void __key_link_end ( struct key keyring,
struct key_type *  type,
unsigned long  prealloc 
)

Definition at line 961 of file keyring.c.

key_ref_t __keyring_search_one ( key_ref_t  keyring_ref,
const struct key_type *  type,
const char description,
key_perm_t  perm 
)

Definition at line 541 of file keyring.c.

struct key* find_keyring_by_name ( const char name,
bool  skip_perm_check 
)
read

Definition at line 596 of file keyring.c.

int install_process_keyring_to_cred ( struct cred )

Definition at line 170 of file process_keys.c.

int install_session_keyring_to_cred ( struct cred ,
struct key  
)

Definition at line 224 of file process_keys.c.

int install_thread_keyring_to_cred ( struct cred )

Definition at line 128 of file process_keys.c.

int install_user_keyrings ( void  )

Definition at line 43 of file process_keys.c.

long join_session_keyring ( const char name)

Definition at line 765 of file process_keys.c.

void key_change_session_keyring ( struct callback_head twork)

Definition at line 838 of file process_keys.c.

void key_gc_keytype ( struct key_type *  ktype)

Definition at line 113 of file gc.c.

struct key* key_get_instantiation_authkey ( key_serial_t  target_id)
read

Definition at line 240 of file request_key_auth.c.

void key_schedule_gc ( time_t  gc_at)

Definition at line 56 of file gc.c.

void key_schedule_gc_links ( void  )

Definition at line 77 of file gc.c.

int key_task_permission ( const key_ref_t  key_ref,
const struct cred cred,
key_perm_t  perm 
)

key_task_permission - Check a key can be used : The key to check. : The credentials to use. : The permissions to check for.

Check to see whether permission is granted to use a key in the desired way, but permit the security modules to override.

The caller must hold either a ref on cred or must hold the RCU readlock.

Returns 0 if successful, -EACCES if access is denied based on the permissions bits or the LSM check.

Definition at line 30 of file permission.c.

struct key_type* key_type_lookup ( const char type)
read

Definition at line 661 of file key.c.

void key_type_put ( struct key_type *  ktype)

Definition at line 704 of file key.c.

struct key_user* key_user_lookup ( kuid_t  uid)
read

Definition at line 54 of file key.c.

void key_user_put ( struct key_user user)

Definition at line 123 of file key.c.

long keyctl_assume_authority ( key_serial_t  )

Definition at line 1364 of file keyctl.c.

long keyctl_chown_key ( key_serial_t  ,
uid_t  ,
gid_t   
)

Definition at line 779 of file keyctl.c.

long keyctl_describe_key ( key_serial_t  ,
char __user ,
size_t   
)

Definition at line 541 of file keyctl.c.

long keyctl_get_keyring_ID ( key_serial_t  ,
int   
)

Definition at line 248 of file keyctl.c.

long keyctl_get_security ( key_serial_t  keyid,
char __user buffer,
size_t  buflen 
)

Definition at line 1411 of file keyctl.c.

long keyctl_instantiate_key ( key_serial_t  ,
const void __user ,
size_t  ,
key_serial_t   
)

Definition at line 1095 of file keyctl.c.

long keyctl_instantiate_key_common ( key_serial_t  ,
const struct iovec ,
unsigned  ,
size_t  ,
key_serial_t   
)

Definition at line 1010 of file keyctl.c.

long keyctl_instantiate_key_iov ( key_serial_t  ,
const struct iovec __user ,
unsigned  ,
key_serial_t   
)

Definition at line 1121 of file keyctl.c.

long keyctl_invalidate_key ( key_serial_t  )

Definition at line 396 of file keyctl.c.

long keyctl_join_session_keyring ( const char __user )

Definition at line 277 of file keyctl.c.

long keyctl_keyring_clear ( key_serial_t  )

Definition at line 425 of file keyctl.c.

long keyctl_keyring_link ( key_serial_t  ,
key_serial_t   
)

Definition at line 467 of file keyctl.c.

long keyctl_keyring_search ( key_serial_t  ,
const char __user ,
const char __user ,
key_serial_t   
)

Definition at line 619 of file keyctl.c.

long keyctl_keyring_unlink ( key_serial_t  ,
key_serial_t   
)

Definition at line 502 of file keyctl.c.

long keyctl_negate_key ( key_serial_t  ,
unsigned  ,
key_serial_t   
)

Definition at line 1167 of file keyctl.c.

long keyctl_read_key ( key_serial_t  ,
char __user ,
size_t   
)

Definition at line 713 of file keyctl.c.

long keyctl_reject_key ( key_serial_t  ,
unsigned  ,
unsigned  ,
key_serial_t   
)

Definition at line 1187 of file keyctl.c.

long keyctl_revoke_key ( key_serial_t  )

Definition at line 362 of file keyctl.c.

long keyctl_session_to_parent ( void  )

Definition at line 1475 of file keyctl.c.

long keyctl_set_reqkey_keyring ( int  )

Definition at line 1245 of file keyctl.c.

long keyctl_set_timeout ( key_serial_t  ,
unsigned   
)

Definition at line 1310 of file keyctl.c.

long keyctl_setperm_key ( key_serial_t  ,
key_perm_t   
)

Definition at line 896 of file keyctl.c.

long keyctl_update_key ( key_serial_t  ,
const void __user ,
size_t   
)

Definition at line 310 of file keyctl.c.

void keyring_gc ( struct key keyring,
time_t  limit 
)

Definition at line 1195 of file keyring.c.

key_ref_t keyring_search_aux ( key_ref_t  keyring_ref,
const struct cred cred,
struct key_type *  type,
const void description,
key_match_func_t  match,
bool  no_state_check 
)

keyring_search_aux - Search a keyring tree for a key matching some criteria : A pointer to the keyring with possession indicator. : The credentials to use for permissions checks. : The type of key to search for. : Parameter for . : Function to rule on whether or not a key is the one required. : Don't check if a matching key is bad

Search the supplied keyring tree for a key that matches the criteria given. The root keyring and any linked keyrings must grant Search permission to the caller to be searchable and keys can only be found if they too grant Search to the caller. The possession flag on the root keyring pointer controls use of the possessor bits in permissions checking of the entire tree. In addition, the LSM gets to forbid keyring searches and key matches.

The search is performed as a breadth-then-depth search up to the prescribed limit (KEYRING_SEARCH_MAX_DEPTH).

Keys are matched to the type provided and are then filtered by the match function, which is given the description to use in any way it sees fit. The match function may use any attributes of a key that it wishes to to determine the match. Normally the match function from the key type would be used.

RCU is used to prevent the keyring key lists from disappearing without the need to take lots of locks.

Returns a pointer to the found key and increments the key usage count if successful; -EAGAIN if no matching keys were found, or if expired or revoked keys were found; -ENOKEY if only negative keys were found; -ENOTDIR if the specified keyring wasn't a keyring.

In the case of a successful return, the possession attribute from is propagated to the returned key reference.

Definition at line 318 of file keyring.c.

struct key* keyring_search_instkey ( struct key keyring,
key_serial_t  target_id 
)
read
key_ref_t lookup_user_key ( key_serial_t  id,
unsigned long  flags,
key_perm_t  perm 
)

Definition at line 536 of file process_keys.c.

int lookup_user_key_possessed ( const struct key key,
const void target 
)

Definition at line 513 of file process_keys.c.

struct key* request_key_and_link ( struct key_type *  type,
const char description,
const void callout_info,
size_t  callout_len,
void aux,
struct key dest_keyring,
unsigned long  flags 
)
read

request_key_and_link - Request a key and cache it in a keyring. : The type of key we want. : The searchable description of the key. : The data to pass to the instantiation upcall (or NULL). : The length of callout_info. : Auxiliary data for the upcall. : Where to cache the key. : Flags to key_alloc().

A key matching the specified criteria is searched for in the process's keyrings and returned with its usage count incremented if found. Otherwise, if callout_info is not NULL, a key will be allocated and some service (probably in userspace) will be asked to instantiate it.

If successfully found or created, the key will be linked to the destination keyring if one is provided.

Returns a pointer to the key if successful; -EACCES, -ENOKEY, -EKEYREVOKED or -EKEYEXPIRED if an inaccessible, negative, revoked or expired key was found; -ENOKEY if no key was found and no was given; -EDQUOT if insufficient key quota was available to create a new key; or -ENOMEM if insufficient memory was available.

If the returned key was created, then it may still be under construction, and wait_for_key_construction() should be used to wait for that to complete.

Definition at line 508 of file request_key.c.

struct key* request_key_auth_new ( struct key target,
const void callout_info,
size_t  callout_len,
struct key dest_keyring 
)
read

Definition at line 133 of file request_key_auth.c.

key_ref_t search_my_process_keyrings ( struct key_type *  type,
const void description,
key_match_func_t  match,
bool  no_state_check,
const struct cred cred 
)

Definition at line 332 of file process_keys.c.

key_ref_t search_process_keyrings ( struct key_type *  type,
const void description,
key_match_func_t  match,
const struct cred cred 
)

Definition at line 454 of file process_keys.c.

Variable Documentation

struct mutex key_construction_mutex
unsigned key_gc_delay

Definition at line 21 of file gc.c.

struct work_struct key_gc_work
struct kmem_cache* key_jar

Definition at line 23 of file key.c.

unsigned key_quota_maxbytes

Definition at line 33 of file key.c.

unsigned key_quota_maxkeys

Definition at line 32 of file key.c.

unsigned key_quota_root_maxbytes

Definition at line 31 of file key.c.

unsigned key_quota_root_maxkeys

Definition at line 30 of file key.c.

spinlock_t key_serial_lock
struct rb_root key_serial_tree

Definition at line 24 of file key.c.

struct key_type key_type_dead

Definition at line 48 of file gc.c.

struct key_type key_type_logon

Definition at line 46 of file user_defined.c.

struct key_type key_type_request_key_auth

Definition at line 32 of file request_key_auth.c.

struct key_type key_type_user

Definition at line 27 of file user_defined.c.

spinlock_t key_user_lock
struct rb_root key_user_tree

Definition at line 27 of file key.c.

wait_queue_head_t request_key_conswq
struct key_user root_key_user

Definition at line 31 of file process_keys.c.