Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/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()
  ...
  • Loading branch information
torvalds committed Jun 11, 2017
2 parents 6d53cef + 92347cf commit 3262764
Show file tree
Hide file tree
Showing 19 changed files with 330 additions and 330 deletions.
4 changes: 0 additions & 4 deletions arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1084,10 +1084,6 @@ config SYSVIPC_COMPAT
def_bool y
depends on COMPAT && SYSVIPC

config KEYS_COMPAT
def_bool y
depends on COMPAT && KEYS

endmenu

menu "Power management options"
Expand Down
5 changes: 0 additions & 5 deletions arch/powerpc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1199,11 +1199,6 @@ source "arch/powerpc/Kconfig.debug"

source "security/Kconfig"

config KEYS_COMPAT
bool
depends on COMPAT && KEYS
default y

source "crypto/Kconfig"

config PPC_LIB_RHEAP
Expand Down
3 changes: 0 additions & 3 deletions arch/s390/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,6 @@ config COMPAT
config SYSVIPC_COMPAT
def_bool y if COMPAT && SYSVIPC

config KEYS_COMPAT
def_bool y if COMPAT && KEYS

config SMP
def_bool y
prompt "Symmetric multi-processing support"
Expand Down
3 changes: 0 additions & 3 deletions arch/sparc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,6 @@ config SYSVIPC_COMPAT
depends on COMPAT && SYSVIPC
default y

config KEYS_COMPAT
def_bool y if COMPAT && KEYS

endmenu

source "net/Kconfig"
Expand Down
4 changes: 0 additions & 4 deletions arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2776,10 +2776,6 @@ config COMPAT_FOR_U64_ALIGNMENT
config SYSVIPC_COMPAT
def_bool y
depends on SYSVIPC

config KEYS_COMPAT
def_bool y
depends on KEYS
endif

endmenu
Expand Down
4 changes: 2 additions & 2 deletions crypto/asymmetric_keys/verify_pefile.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ static int pefile_digest_pe(const void *pebuf, unsigned int pelen,
}

error:
kfree(desc);
kzfree(desc);
error_no_desc:
crypto_free_shash(tfm);
kleave(" = %d", ret);
Expand Down Expand Up @@ -450,6 +450,6 @@ int verify_pefile_signature(const void *pebuf, unsigned pelen,
ret = pefile_digest_pe(pebuf, pelen, &ctx);

error:
kfree(ctx.digest);
kzfree(ctx.digest);
return ret;
}
1 change: 1 addition & 0 deletions crypto/asymmetric_keys/x509_cert_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
}
}

ret = -ENOMEM;
cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL);
if (!cert->pub->key)
goto error_decode;
Expand Down
1 change: 0 additions & 1 deletion include/linux/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ struct key {
#ifdef KEY_DEBUGGING
unsigned magic;
#define KEY_DEBUG_MAGIC 0x18273645u
#define KEY_DEBUG_MAGIC_X 0xf8e9dacbu
#endif

unsigned long flags; /* status flags (change with bitops) */
Expand Down
4 changes: 2 additions & 2 deletions include/uapi/linux/keyctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ struct keyctl_dh_params {
};

struct keyctl_kdf_params {
char *hashname;
char *otherinfo;
char __user *hashname;
char __user *otherinfo;
__u32 otherinfolen;
__u32 __spare[8];
};
Expand Down
6 changes: 5 additions & 1 deletion security/keys/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ config KEYS

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

config KEYS_COMPAT
def_bool y
depends on COMPAT && KEYS

config PERSISTENT_KEYRINGS
bool "Enable register of persistent per-UID keyrings"
depends on KEYS
Expand Down Expand Up @@ -89,9 +93,9 @@ config ENCRYPTED_KEYS
config KEY_DH_OPERATIONS
bool "Diffie-Hellman operations on retained keys"
depends on KEYS
select MPILIB
select CRYPTO
select CRYPTO_HASH
select CRYPTO_DH
help
This option provides support for calculating Diffie-Hellman
public keys and shared secrets using values stored as keys
Expand Down
Loading

0 comments on commit 3262764

Please sign in to comment.