函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\crypto\keyring.c Create Date:2022-07-29 10:57:20
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称: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.

函数原型:static int add_new_master_key(struct fscrypt_master_key_secret *secret, const struct fscrypt_key_specifier *mk_spec, struct key *keyring)

返回类型:int

参数:

类型参数名称
struct fscrypt_master_key_secret *secret
const struct fscrypt_key_specifier *mk_spec
struct key *keyring
332  mk等于分配内存并置零
333  如果非mk则返回:负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  初始化链表头
343  spin_lock_init( & mk_decrypted_inodes_lock)
345  如果 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.
346  err等于allocate_master_key_users_keyring(mk)
347  如果err则转到: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  如果err则转到: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  如果是错误
365  err等于错误
366  转到:out_free_mk
368  err等于key_instantiate_and_link(key, mk, mk的长度, keyring, NULL)
369  key_put(key)
370  如果err则转到:out_free_mk
373  返回:0
375  out_free_mk :
376  free_master_key(mk)
377  返回:err
调用者
名称描述
add_master_key