Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\crypto\keyring.c Create Date:2022-07-28 20:23:53
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Allocate a new fscrypt_master_key which contains the given secret, set it as* the payload of a new 'struct key' of type fscrypt, and link the 'struct key'* into the given keyring. Synchronized by fscrypt_add_key_mutex.

Proto:static int add_new_master_key(struct fscrypt_master_key_secret *secret, const struct fscrypt_key_specifier *mk_spec, struct key *keyring)

Type:int

Parameter:

TypeParameterName
struct fscrypt_master_key_secret *secret
const struct fscrypt_key_specifier *mk_spec
struct key *keyring
332  mk = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
333  If Not mk Then Return -ENOMEM
336  For v1 policy keys: an arbitrary key descriptor which was assigned by* userspace (->descriptor).* For v2 policy keys: a cryptographic hash of this key (->identifier). = mk_spec
338  move_master_key_secret( & The secret key material. After FS_IOC_REMOVE_ENCRYPTION_KEY is* executed, this is wiped and no new inodes can be unlocked with this* key; however, there may still be inodes in ->mk_decrypted_inodes* which could not be evicted, secret)
339  init_rwsem( & mk_secret_sem)
341  _set - set a refcount's value*@r: the refcount*@n: value to which the refcount will be set
342  Initialization list head
343  Process spin lock initialization( & mk_decrypted_inodes_lock)
345  If of FSCRYPT_KEY_SPEC_TYPE_* == v2 policy keys are specified by a 16-byte key "identifier" which the kernel* calculates as a cryptographic hash of the key itself,* matching fscrypt_policy_v2::master_key_identifier. Then
346  err = allocate_master_key_users_keyring(mk)
347  If err Then Go to out_free_mk
349  err = Give the current user a "key" in ->mk_users. This charges the user's quota* and marks the master key as added by the current user, so that it cannot be* removed by another user with the key. Either the master key's key->sem must
350  If err Then Go to out_free_mk
359  format_mk_description(description, mk_spec)
360  key = key_alloc( & Type of key in ->s_master_keys, description, GLOBAL_ROOT_UID, GLOBAL_ROOT_GID, current_cred - Access the current task's subjective credentials* Access the subjective credentials of the current task. RCU-safe,* since nobody else can modify it.(), possessor can find a key in search / search a keyring | KEY_USR_SEARCH | user permissions... , in quota , NULL)
364  If IS_ERR(key) Then
365  err = PTR_ERR(key)
366  Go to out_free_mk
368  err = key_instantiate_and_link(key, mk, size of mk , keyring, NULL)
369  key_put(key)
370  If err Then Go to out_free_mk
373  Return 0
375  out_free_mk :
376  free_master_key(mk)
377  Return err
Caller
NameDescribe
add_master_key