Lines Matching refs:mk

41 static void free_master_key(struct fscrypt_master_key *mk)  in free_master_key()  argument
45 wipe_master_key_secret(&mk->mk_secret); in free_master_key()
48 fscrypt_destroy_prepared_key(&mk->mk_direct_keys[i]); in free_master_key()
49 fscrypt_destroy_prepared_key(&mk->mk_iv_ino_lblk_64_keys[i]); in free_master_key()
50 fscrypt_destroy_prepared_key(&mk->mk_iv_ino_lblk_32_keys[i]); in free_master_key()
53 key_put(mk->mk_users); in free_master_key()
54 kfree_sensitive(mk); in free_master_key()
81 const struct fscrypt_master_key *mk = key->payload.data[0]; in fscrypt_key_describe() local
83 if (!is_master_key_secret_present(&mk->mk_secret)) in fscrypt_key_describe()
255 static int allocate_master_key_users_keyring(struct fscrypt_master_key *mk) in allocate_master_key_users_keyring() argument
261 mk->mk_spec.u.identifier); in allocate_master_key_users_keyring()
269 mk->mk_users = keyring; in allocate_master_key_users_keyring()
277 static struct key *find_master_key_user(struct fscrypt_master_key *mk) in find_master_key_user() argument
281 format_mk_user_description(description, mk->mk_spec.u.identifier); in find_master_key_user()
282 return search_fscrypt_keyring(mk->mk_users, &key_type_fscrypt_user, in find_master_key_user()
292 static int add_master_key_user(struct fscrypt_master_key *mk) in add_master_key_user() argument
298 format_mk_user_description(description, mk->mk_spec.u.identifier); in add_master_key_user()
305 err = key_instantiate_and_link(mk_user, NULL, 0, mk->mk_users, NULL); in add_master_key_user()
316 static int remove_master_key_user(struct fscrypt_master_key *mk) in remove_master_key_user() argument
321 mk_user = find_master_key_user(mk); in remove_master_key_user()
324 err = key_unlink(mk->mk_users, mk_user); in remove_master_key_user()
338 struct fscrypt_master_key *mk; in add_new_master_key() local
343 mk = kzalloc(sizeof(*mk), GFP_KERNEL); in add_new_master_key()
344 if (!mk) in add_new_master_key()
347 mk->mk_spec = *mk_spec; in add_new_master_key()
349 move_master_key_secret(&mk->mk_secret, secret); in add_new_master_key()
351 refcount_set(&mk->mk_refcount, 1); /* secret is present */ in add_new_master_key()
352 INIT_LIST_HEAD(&mk->mk_decrypted_inodes); in add_new_master_key()
353 spin_lock_init(&mk->mk_decrypted_inodes_lock); in add_new_master_key()
356 err = allocate_master_key_users_keyring(mk); in add_new_master_key()
359 err = add_master_key_user(mk); in add_new_master_key()
378 err = key_instantiate_and_link(key, mk, sizeof(*mk), keyring, NULL); in add_new_master_key()
386 free_master_key(mk); in add_new_master_key()
392 static int add_existing_master_key(struct fscrypt_master_key *mk, in add_existing_master_key() argument
403 if (mk->mk_users) { in add_existing_master_key()
404 mk_user = find_master_key_user(mk); in add_existing_master_key()
414 rekey = !is_master_key_secret_present(&mk->mk_secret); in add_existing_master_key()
415 if (rekey && !refcount_inc_not_zero(&mk->mk_refcount)) in add_existing_master_key()
419 if (mk->mk_users) { in add_existing_master_key()
420 err = add_master_key_user(mk); in add_existing_master_key()
422 if (rekey && refcount_dec_and_test(&mk->mk_refcount)) in add_existing_master_key()
430 move_master_key_secret(&mk->mk_secret, secret); in add_existing_master_key()
735 struct fscrypt_master_key *mk; in fscrypt_verify_key_added() local
746 mk = key->payload.data[0]; in fscrypt_verify_key_added()
747 mk_user = find_master_key_user(mk); in fscrypt_verify_key_added()
780 static void evict_dentries_for_decrypted_inodes(struct fscrypt_master_key *mk) in evict_dentries_for_decrypted_inodes() argument
786 spin_lock(&mk->mk_decrypted_inodes_lock); in evict_dentries_for_decrypted_inodes()
788 list_for_each_entry(ci, &mk->mk_decrypted_inodes, ci_master_key_link) { in evict_dentries_for_decrypted_inodes()
797 spin_unlock(&mk->mk_decrypted_inodes_lock); in evict_dentries_for_decrypted_inodes()
803 spin_lock(&mk->mk_decrypted_inodes_lock); in evict_dentries_for_decrypted_inodes()
806 spin_unlock(&mk->mk_decrypted_inodes_lock); in evict_dentries_for_decrypted_inodes()
811 struct fscrypt_master_key *mk) in check_for_busy_inodes() argument
818 spin_lock(&mk->mk_decrypted_inodes_lock); in check_for_busy_inodes()
820 list_for_each(pos, &mk->mk_decrypted_inodes) in check_for_busy_inodes()
824 spin_unlock(&mk->mk_decrypted_inodes_lock); in check_for_busy_inodes()
831 list_first_entry(&mk->mk_decrypted_inodes, in check_for_busy_inodes()
836 spin_unlock(&mk->mk_decrypted_inodes_lock); in check_for_busy_inodes()
844 sb->s_id, busy_count, master_key_spec_type(&mk->mk_spec), in check_for_busy_inodes()
845 master_key_spec_len(&mk->mk_spec), (u8 *)&mk->mk_spec.u, in check_for_busy_inodes()
851 struct fscrypt_master_key *mk) in try_to_lock_encrypted_files() argument
876 evict_dentries_for_decrypted_inodes(mk); in try_to_lock_encrypted_files()
885 err2 = check_for_busy_inodes(sb, mk); in try_to_lock_encrypted_files()
917 struct fscrypt_master_key *mk; in do_remove_key() local
943 mk = key->payload.data[0]; in do_remove_key()
948 if (mk->mk_users && mk->mk_users->keys.nr_leaves_on_tree != 0) { in do_remove_key()
950 err = keyring_clear(mk->mk_users); in do_remove_key()
952 err = remove_master_key_user(mk); in do_remove_key()
957 if (mk->mk_users->keys.nr_leaves_on_tree != 0) { in do_remove_key()
973 if (is_master_key_secret_present(&mk->mk_secret)) { in do_remove_key()
974 wipe_master_key_secret(&mk->mk_secret); in do_remove_key()
975 dead = refcount_dec_and_test(&mk->mk_refcount); in do_remove_key()
987 err = try_to_lock_encrypted_files(sb, mk); in do_remove_key()
1049 struct fscrypt_master_key *mk; in fscrypt_ioctl_get_key_status() local
1073 mk = key->payload.data[0]; in fscrypt_ioctl_get_key_status()
1076 if (!is_master_key_secret_present(&mk->mk_secret)) { in fscrypt_ioctl_get_key_status()
1083 if (mk->mk_users) { in fscrypt_ioctl_get_key_status()
1086 arg.user_count = mk->mk_users->keys.nr_leaves_on_tree; in fscrypt_ioctl_get_key_status()
1087 mk_user = find_master_key_user(mk); in fscrypt_ioctl_get_key_status()