Skip to content

Commit 9cb2bf5

Browse files
committed
Merge tag 'keys-next-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd
Pull keys updates from Jarkko Sakkinen. Avoid using stack addresses for sg lists. And a cleanup. * tag 'keys-next-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd: KEYS: trusted: dcp: fix improper sg use with CONFIG_VMAP_STACK=y keys: drop shadowing dead prototype
2 parents 7004a2e + e8d9fab commit 9cb2bf5

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

include/keys/system_keyring.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ static inline void __init set_machine_trusted_keys(struct key *keyring)
7373
}
7474
#endif
7575

76-
extern struct pkcs7_message *pkcs7;
7776
#ifdef CONFIG_SYSTEM_BLACKLIST_KEYRING
7877
extern int mark_hash_blacklisted(const u8 *hash, size_t hash_len,
7978
enum blacklist_hash_type hash_type);
@@ -93,6 +92,7 @@ static inline int is_binary_blacklisted(const u8 *hash, size_t hash_len)
9392
}
9493
#endif
9594

95+
struct pkcs7_message;
9696
#ifdef CONFIG_SYSTEM_REVOCATION_LIST
9797
extern int add_key_to_revocation_list(const char *data, size_t size);
9898
extern int is_key_on_revocation_list(struct pkcs7_message *pkcs7);

security/keys/trusted-keys/trusted_dcp.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,16 @@ static int trusted_dcp_seal(struct trusted_key_payload *p, char *datablob)
201201
{
202202
struct dcp_blob_fmt *b = (struct dcp_blob_fmt *)p->blob;
203203
int blen, ret;
204-
u8 plain_blob_key[AES_KEYSIZE_128];
204+
u8 *plain_blob_key;
205205

206206
blen = calc_blob_len(p->key_len);
207207
if (blen > MAX_BLOB_SIZE)
208208
return -E2BIG;
209209

210+
plain_blob_key = kmalloc(AES_KEYSIZE_128, GFP_KERNEL);
211+
if (!plain_blob_key)
212+
return -ENOMEM;
213+
210214
b->fmt_version = DCP_BLOB_VERSION;
211215
get_random_bytes(b->nonce, AES_KEYSIZE_128);
212216
get_random_bytes(plain_blob_key, AES_KEYSIZE_128);
@@ -229,7 +233,8 @@ static int trusted_dcp_seal(struct trusted_key_payload *p, char *datablob)
229233
ret = 0;
230234

231235
out:
232-
memzero_explicit(plain_blob_key, sizeof(plain_blob_key));
236+
memzero_explicit(plain_blob_key, AES_KEYSIZE_128);
237+
kfree(plain_blob_key);
233238

234239
return ret;
235240
}
@@ -238,7 +243,7 @@ static int trusted_dcp_unseal(struct trusted_key_payload *p, char *datablob)
238243
{
239244
struct dcp_blob_fmt *b = (struct dcp_blob_fmt *)p->blob;
240245
int blen, ret;
241-
u8 plain_blob_key[AES_KEYSIZE_128];
246+
u8 *plain_blob_key = NULL;
242247

243248
if (b->fmt_version != DCP_BLOB_VERSION) {
244249
pr_err("DCP blob has bad version: %i, expected %i\n",
@@ -256,6 +261,12 @@ static int trusted_dcp_unseal(struct trusted_key_payload *p, char *datablob)
256261
goto out;
257262
}
258263

264+
plain_blob_key = kmalloc(AES_KEYSIZE_128, GFP_KERNEL);
265+
if (!plain_blob_key) {
266+
ret = -ENOMEM;
267+
goto out;
268+
}
269+
259270
ret = decrypt_blob_key(b->blob_key, plain_blob_key);
260271
if (ret) {
261272
pr_err("Unable to decrypt blob key: %i\n", ret);
@@ -271,7 +282,10 @@ static int trusted_dcp_unseal(struct trusted_key_payload *p, char *datablob)
271282

272283
ret = 0;
273284
out:
274-
memzero_explicit(plain_blob_key, sizeof(plain_blob_key));
285+
if (plain_blob_key) {
286+
memzero_explicit(plain_blob_key, AES_KEYSIZE_128);
287+
kfree(plain_blob_key);
288+
}
275289

276290
return ret;
277291
}

0 commit comments

Comments
 (0)