Skip to content

Commit 817aef2

Browse files
Yanniktorvalds
authored andcommitted
Replace magic for trusting the secondary keyring with #define
Replace the use of a magic number that indicates that verify_*_signature() should use the secondary keyring with a symbol. Signed-off-by: Yannik Sembritzki <[email protected]> Signed-off-by: David Howells <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4e31843 commit 817aef2

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

certs/system_keyring.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/cred.h>
1616
#include <linux/err.h>
1717
#include <linux/slab.h>
18+
#include <linux/verification.h>
1819
#include <keys/asymmetric-type.h>
1920
#include <keys/system_keyring.h>
2021
#include <crypto/pkcs7.h>
@@ -230,7 +231,7 @@ int verify_pkcs7_signature(const void *data, size_t len,
230231

231232
if (!trusted_keys) {
232233
trusted_keys = builtin_trusted_keys;
233-
} else if (trusted_keys == (void *)1UL) {
234+
} else if (trusted_keys == VERIFY_USE_SECONDARY_KEYRING) {
234235
#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING
235236
trusted_keys = secondary_trusted_keys;
236237
#else

crypto/asymmetric_keys/pkcs7_key_type.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static int pkcs7_preparse(struct key_preparsed_payload *prep)
6363

6464
return verify_pkcs7_signature(NULL, 0,
6565
prep->data, prep->datalen,
66-
(void *)1UL, usage,
66+
VERIFY_USE_SECONDARY_KEYRING, usage,
6767
pkcs7_view_content, prep);
6868
}
6969

include/linux/verification.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
#ifndef _LINUX_VERIFICATION_H
1313
#define _LINUX_VERIFICATION_H
1414

15+
/*
16+
* Indicate that both builtin trusted keys and secondary trusted keys
17+
* should be used.
18+
*/
19+
#define VERIFY_USE_SECONDARY_KEYRING ((struct key *)1UL)
20+
1521
/*
1622
* The use to which an asymmetric key is being put.
1723
*/

0 commit comments

Comments
 (0)