Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/linux/key-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ struct key_type {
const void *in, const void *in2);

/* internal fields */
atomic64_t index_id; /* Opaque keyring index ID */
struct list_head link; /* link in types list */
struct lock_class_key lock_class; /* key->sem lock class */
} __randomize_layout;
Expand Down
5 changes: 0 additions & 5 deletions include/linux/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ struct keyring_name;

struct key_tag {
struct rcu_head rcu;
atomic64_t index_id; /* Opaque keyring index ID */
refcount_t usage;
bool removed; /* T when subject removed */
};
Expand All @@ -131,8 +130,6 @@ struct keyring_index_key {
struct key_type *type;
struct key_tag *domain_tag; /* Domain of operation */
const char *description;
u64 type_id; /* Cached index IDs */
u64 domain_id;
};

union key_payload {
Expand Down Expand Up @@ -254,8 +251,6 @@ struct key {
struct key_type *type; /* type of key */
struct key_tag *domain_tag; /* Domain of operation */
char *description;
u64 type_id;
u64 domain_id;
};
};

Expand Down
1 change: 1 addition & 0 deletions security/keys/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ static noinline void key_gc_unused_keys(struct list_head *keys)
key_user_put(key->user);
key_put_tag(key->domain_tag);
kfree(key->description);
key_free_index_key(key);

#ifdef CONFIG_KEYP
kmem_cache_free(key_union_jar, (struct key_union *)(key->graveyard_link.next));
Expand Down
9 changes: 6 additions & 3 deletions security/keys/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ extern spinlock_t key_serial_lock;
extern struct mutex key_construction_mutex;
extern wait_queue_head_t request_key_conswq;

extern void key_set_index_key(struct keyring_index_key *index_key);
void key_set_index_key(struct keyring_index_key *index_key);
int key_alloc_index_key(struct key *key);
void key_free_index_key(struct key *key);
#ifdef CONFIG_KEYP
extern void iee_key_set_index_key(struct keyring_index_key *index_key);
void iee_key_set_index_key(struct keyring_index_key *index_key);
#endif
extern struct key_type *key_type_lookup(const char *type);
extern void key_type_put(struct key_type *ktype);
Expand All @@ -104,7 +106,7 @@ extern int __key_link_lock(struct key *keyring,
const struct keyring_index_key *index_key);
extern int __key_move_lock(struct key *l_keyring, struct key *u_keyring,
const struct keyring_index_key *index_key);
extern int __key_link_begin(struct key *keyring,
extern int __key_link_begin(struct key *keyring, struct key *key,
const struct keyring_index_key *index_key,
struct assoc_array_edit **_edit);
extern int __key_link_check_live_key(struct key *keyring, struct key *key);
Expand All @@ -119,6 +121,7 @@ extern key_ref_t find_key_to_update(key_ref_t keyring_ref,

struct keyring_search_context {
struct keyring_index_key index_key;
const void *private_index_key;
const struct cred *cred;
struct key_match_data match_data;
unsigned flags;
Expand Down
11 changes: 8 additions & 3 deletions security/keys/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ struct key *key_alloc(struct key_type *type, const char *desc,
key->index_key.type = type;
key_set_index_key(&key->index_key);
#endif
ret = key_alloc_index_key(key);
if (ret < 0)
goto security_error;

#ifdef CONFIG_KEYP
iee_set_key_usage(key, 1, REFCOUNT_SET);
Expand Down Expand Up @@ -433,6 +436,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
return key;

security_error:
key_free_index_key(key);
kfree(key->description);
#ifdef CONFIG_KEYP
if (key_union)
Expand All @@ -455,6 +459,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
goto error;

no_memory_3:
key_free_index_key(key);
#ifdef CONFIG_KEYP
if (key_union)
kmem_cache_free(key_union_jar, key_union);
Expand Down Expand Up @@ -674,7 +679,7 @@ int key_instantiate_and_link(struct key *key,
if (ret < 0)
goto error;

ret = __key_link_begin(keyring, &key->index_key, &edit);
ret = __key_link_begin(keyring, key, &key->index_key, &edit);
if (ret < 0)
goto error_link_end;

Expand Down Expand Up @@ -751,7 +756,7 @@ int key_reject_and_link(struct key *key,
__key_link_end(keyring, &key->index_key, edit);
return -EPERM;
}
link_ret = __key_link_begin(keyring, &key->index_key, &edit);
link_ret = __key_link_begin(keyring, key, &key->index_key, &edit);
if (link_ret < 0)
__key_link_end(keyring, &key->index_key, edit);
}
Expand Down Expand Up @@ -1059,7 +1064,7 @@ static key_ref_t __key_create_or_update(key_ref_t keyring_ref,
goto error_free_prep;
}

ret = __key_link_begin(keyring, &index_key, &edit);
ret = __key_link_begin(keyring, key, &index_key, &edit);
if (ret < 0) {
key_ref = ERR_PTR(ret);
goto error_link_end;
Expand Down
Loading
Loading