Skip to content

Commit

Permalink
KEYS: DH: don't feed uninitialized "otherinfo" into KDF
Browse files Browse the repository at this point in the history
If userspace called KEYCTL_DH_COMPUTE with kdf_params containing NULL
otherinfo but nonzero otherinfolen, the kernel would allocate a buffer
for the otherinfo, then feed it into the KDF without initializing it.
Fix this by always doing the copy from userspace (which will fail with
EFAULT in this scenario).

Signed-off-by: Eric Biggers <[email protected]>
Signed-off-by: David Howells <[email protected]>
Acked-by: Stephan Mueller <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
ebiggers authored and James Morris committed Jun 9, 2017
1 parent bbe2404 commit 281590b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion security/keys/dh.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ long __keyctl_dh_compute(struct keyctl_dh_params __user *params,
* Concatenate SP800-56A otherinfo past DH shared secret -- the
* input to the KDF is (DH shared secret || otherinfo)
*/
if (kdfcopy && kdfcopy->otherinfo &&
if (kdfcopy &&
copy_from_user(kbuf + resultlen, kdfcopy->otherinfo,
kdfcopy->otherinfolen) != 0) {
ret = -EFAULT;
Expand Down

0 comments on commit 281590b

Please sign in to comment.