Skip to content

Commit 3262764

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull key subsystem fixes from James Morris: "Here are a bunch of fixes for Linux keyrings, including: - Fix up the refcount handling now that key structs use the refcount_t type and the refcount_t ops don't allow a 0->1 transition. - Fix a potential NULL deref after error in x509_cert_parse(). - Don't put data for the crypto algorithms to use on the stack. - Fix the handling of a null payload being passed to add_key(). - Fix incorrect cleanup an uninitialised key_preparsed_payload in key_update(). - Explicit sanitisation of potentially secure data before freeing. - Fixes for the Diffie-Helman code" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (23 commits) KEYS: fix refcount_inc() on zero KEYS: Convert KEYCTL_DH_COMPUTE to use the crypto KPP API crypto : asymmetric_keys : verify_pefile:zero memory content before freeing KEYS: DH: add __user annotations to keyctl_kdf_params KEYS: DH: ensure the KDF counter is properly aligned KEYS: DH: don't feed uninitialized "otherinfo" into KDF KEYS: DH: forbid using digest_null as the KDF hash KEYS: sanitize key structs before freeing KEYS: trusted: sanitize all key material KEYS: encrypted: sanitize all key material KEYS: user_defined: sanitize key payloads KEYS: sanitize add_key() and keyctl() key payloads KEYS: fix freeing uninitialized memory in key_update() KEYS: fix dereferencing NULL payload with nonzero length KEYS: encrypted: use constant-time HMAC comparison KEYS: encrypted: fix race causing incorrect HMAC calculations KEYS: encrypted: fix buffer overread in valid_master_desc() KEYS: encrypted: avoid encrypting/decrypting stack buffers KEYS: put keyring if install_session_keyring_to_cred() fails KEYS: Delete an error message for a failed memory allocation in get_derived_key() ...
2 parents 6d53cef + 92347cf commit 3262764

File tree

19 files changed

+330
-330
lines changed

19 files changed

+330
-330
lines changed

arch/arm64/Kconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,10 +1084,6 @@ config SYSVIPC_COMPAT
10841084
def_bool y
10851085
depends on COMPAT && SYSVIPC
10861086

1087-
config KEYS_COMPAT
1088-
def_bool y
1089-
depends on COMPAT && KEYS
1090-
10911087
endmenu
10921088

10931089
menu "Power management options"

arch/powerpc/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,11 +1199,6 @@ source "arch/powerpc/Kconfig.debug"
11991199

12001200
source "security/Kconfig"
12011201

1202-
config KEYS_COMPAT
1203-
bool
1204-
depends on COMPAT && KEYS
1205-
default y
1206-
12071202
source "crypto/Kconfig"
12081203

12091204
config PPC_LIB_RHEAP

arch/s390/Kconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,6 @@ config COMPAT
363363
config SYSVIPC_COMPAT
364364
def_bool y if COMPAT && SYSVIPC
365365

366-
config KEYS_COMPAT
367-
def_bool y if COMPAT && KEYS
368-
369366
config SMP
370367
def_bool y
371368
prompt "Symmetric multi-processing support"

arch/sparc/Kconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,6 @@ config SYSVIPC_COMPAT
577577
depends on COMPAT && SYSVIPC
578578
default y
579579

580-
config KEYS_COMPAT
581-
def_bool y if COMPAT && KEYS
582-
583580
endmenu
584581

585582
source "net/Kconfig"

arch/x86/Kconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,10 +2776,6 @@ config COMPAT_FOR_U64_ALIGNMENT
27762776
config SYSVIPC_COMPAT
27772777
def_bool y
27782778
depends on SYSVIPC
2779-
2780-
config KEYS_COMPAT
2781-
def_bool y
2782-
depends on KEYS
27832779
endif
27842780

27852781
endmenu

crypto/asymmetric_keys/verify_pefile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ static int pefile_digest_pe(const void *pebuf, unsigned int pelen,
381381
}
382382

383383
error:
384-
kfree(desc);
384+
kzfree(desc);
385385
error_no_desc:
386386
crypto_free_shash(tfm);
387387
kleave(" = %d", ret);
@@ -450,6 +450,6 @@ int verify_pefile_signature(const void *pebuf, unsigned pelen,
450450
ret = pefile_digest_pe(pebuf, pelen, &ctx);
451451

452452
error:
453-
kfree(ctx.digest);
453+
kzfree(ctx.digest);
454454
return ret;
455455
}

crypto/asymmetric_keys/x509_cert_parser.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
102102
}
103103
}
104104

105+
ret = -ENOMEM;
105106
cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL);
106107
if (!cert->pub->key)
107108
goto error_decode;

include/linux/key.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ struct key {
173173
#ifdef KEY_DEBUGGING
174174
unsigned magic;
175175
#define KEY_DEBUG_MAGIC 0x18273645u
176-
#define KEY_DEBUG_MAGIC_X 0xf8e9dacbu
177176
#endif
178177

179178
unsigned long flags; /* status flags (change with bitops) */

include/uapi/linux/keyctl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ struct keyctl_dh_params {
7070
};
7171

7272
struct keyctl_kdf_params {
73-
char *hashname;
74-
char *otherinfo;
73+
char __user *hashname;
74+
char __user *otherinfo;
7575
__u32 otherinfolen;
7676
__u32 __spare[8];
7777
};

security/keys/Kconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ config KEYS
2020

2121
If you are unsure as to whether this is required, answer N.
2222

23+
config KEYS_COMPAT
24+
def_bool y
25+
depends on COMPAT && KEYS
26+
2327
config PERSISTENT_KEYRINGS
2428
bool "Enable register of persistent per-UID keyrings"
2529
depends on KEYS
@@ -89,9 +93,9 @@ config ENCRYPTED_KEYS
8993
config KEY_DH_OPERATIONS
9094
bool "Diffie-Hellman operations on retained keys"
9195
depends on KEYS
92-
select MPILIB
9396
select CRYPTO
9497
select CRYPTO_HASH
98+
select CRYPTO_DH
9599
help
96100
This option provides support for calculating Diffie-Hellman
97101
public keys and shared secrets using values stored as keys

0 commit comments

Comments
 (0)