Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Try to remove an fscrypt master encryption key

Proto:static int do_remove_key(struct file *filp, void __user *_uarg, bool all_users)

Type:int

Parameter:

TypeParameterName
struct file *filp
void __user *_uarg
boolall_users
761  sb = i_sb
762  __user * uarg = _uarg
766  status_flags = 0
770  If copy_from_user( & arg, uarg, size of arg ) Then Return -EFAULT
773  If Not valid_key_spec( & key_spec) Then Return -EINVAL
776  If memchr_inv - Find an unmatching character in an area of memory.*@start: The memory area*@c: Find a character other than c*@bytes: The size of the area.* returns the address of the first character other than @c, or %NULL Then Return -EINVAL
783  If of FSCRYPT_KEY_SPEC_TYPE_* == v1 policy keys are specified by an arbitrary 8-byte key "descriptor",* matching fscrypt_policy_v1::master_key_descriptor. && Not Check operation authority Then Return -EACCES
788  key = Find the specified master key in ->s_master_keys.* Returns ERR_PTR(-ENOKEY) if not found.
789  If IS_ERR(key) Then Return PTR_ERR(key)
791  mk = data[0]
793  lock for writing
796  If Keyring which contains a key of type 'key_type_fscrypt_user' for each* user who has added this key && nr_leaves_on_tree != 0 Then
797  If all_users Then err = keyring_clear(Keyring which contains a key of type 'key_type_fscrypt_user' for each* user who has added this key)
799  Else err = Remove the current user's "key" from ->mk_users.* The master key's key->sem must be held for write.* Returns 0 if removed, -ENOKEY if not found, or another -errno code.
801  If err Then
803  Go to out_put_key
805  If nr_leaves_on_tree != 0 Then
813  err = 0
815  Go to out_put_key
820  dead = false
821  If is_master_key_secret_present( & 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) Then
822  lock for writing
823  wipe_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)
824  dead = _dec_and_test - decrement a refcount and test if it is 0*@r: the refcount* Similar to atomic_dec_and_test(), it will WARN on underflow and fail to* decrement when saturated at REFCOUNT_SATURATED
825  lease a write lock
827  lease a write lock
828  If dead Then
833  key_invalidate(key)
834  err = 0
835  Else
837  err = try_to_lock_encrypted_files(sb, mk)
838  If err == -EBUSY Then
841  err = 0
850  out_put_key :
851  key_put(key)
852  If err == 0 Then err = Write a simple value into user space(status_flags, & utput )
854  Return err
Caller
NameDescribe
fscrypt_ioctl_remove_key
fscrypt_ioctl_remove_key_all_users