1. 25 9月, 2018 1 次提交
  2. 05 9月, 2018 1 次提交
  3. 09 7月, 2018 1 次提交
  4. 27 6月, 2018 1 次提交
    • E
      dh key: fix rounding up KDF output length · 3619dec5
      Eric Biggers 提交于
      Commit 383203ef ("dh key: get rid of stack allocated array") changed
      kdf_ctr() to assume that the length of key material to derive is a
      multiple of the digest size.  The length was supposed to be rounded up
      accordingly.  However, the round_up() macro was used which only gives
      the correct result on power-of-2 arguments, whereas not all hash
      algorithms have power-of-2 digest sizes.  In some cases this resulted in
      a write past the end of the 'outbuf' buffer.
      
      Fix it by switching to roundup(), which works for non-power-of-2 inputs.
      
      Reported-by: syzbot+486f97f892efeb2075a3@syzkaller.appspotmail.com
      Reported-by: syzbot+29d17b7898b41ee120a5@syzkaller.appspotmail.com
      Reported-by: syzbot+8a608baf8751184ec727@syzkaller.appspotmail.com
      Reported-by: syzbot+d04e58bd384f1fe0b112@syzkaller.appspotmail.com
      Fixes: 383203ef ("dh key: get rid of stack allocated array")
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      Acked-by: NTycho Andersen <tycho@tycho.ws>
      Signed-off-by: NJames Morris <james.morris@microsoft.com>
      3619dec5
  5. 12 5月, 2018 2 次提交
    • T
      dh key: get rid of stack allocated array for zeroes · 890e2abe
      Tycho Andersen 提交于
      We're interested in getting rid of all of the stack allocated arrays in
      the kernel: https://lkml.org/lkml/2018/3/7/621
      
      This case is interesting, since we really just need an array of bytes that
      are zero. The loop already ensures that if the array isn't exactly the
      right size that enough zero bytes will be copied in. So, instead of
      choosing this value to be the size of the hash, let's just choose it to be
      32, since that is a common size, is not too big, and will not result in too
      many extra iterations of the loop.
      
      v2: split out from other patch, just hardcode array size instead of
          dynamically allocating something the right size
      v3: fix typo of 256 -> 32
      Signed-off-by: NTycho Andersen <tycho@tycho.ws>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      CC: David Howells <dhowells@redhat.com>
      CC: James Morris <jmorris@namei.org>
      CC: "Serge E. Hallyn" <serge@hallyn.com>
      CC: Eric Biggers <ebiggers3@gmail.com>
      Signed-off-by: NJames Morris <james.morris@microsoft.com>
      890e2abe
    • T
      dh key: get rid of stack allocated array · 383203ef
      Tycho Andersen 提交于
      We're interested in getting rid of all of the stack allocated arrays in the
      kernel: https://lkml.org/lkml/2018/3/7/621
      
      This particular vla is used as a temporary output buffer in case there is
      too much hash output for the destination buffer. Instead, let's just
      allocate a buffer that's big enough initially, but only copy back to
      userspace the amount that was originally asked for.
      
      v2: allocate enough in the original output buffer vs creating a temporary
          output buffer
      Signed-off-by: NTycho Andersen <tycho@tycho.ws>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      CC: David Howells <dhowells@redhat.com>
      CC: James Morris <jmorris@namei.org>
      CC: "Serge E. Hallyn" <serge@hallyn.com>
      CC: Eric Biggers <ebiggers3@gmail.com>
      Signed-off-by: NJames Morris <james.morris@microsoft.com>
      383203ef
  6. 14 7月, 2017 1 次提交
  7. 09 6月, 2017 4 次提交
  8. 05 4月, 2017 1 次提交
    • S
      KEYS: add SP800-56A KDF support for DH · f1c316a3
      Stephan Mueller 提交于
      SP800-56A defines the use of DH with key derivation function based on a
      counter. The input to the KDF is defined as (DH shared secret || other
      information). The value for the "other information" is to be provided by
      the caller.
      
      The KDF is implemented using the hash support from the kernel crypto API.
      The implementation uses the symmetric hash support as the input to the
      hash operation is usually very small. The caller is allowed to specify
      the hash name that he wants to use to derive the key material allowing
      the use of all supported hashes provided with the kernel crypto API.
      
      As the KDF implements the proper truncation of the DH shared secret to
      the requested size, this patch fills the caller buffer up to its size.
      
      The patch is tested with a new test added to the keyutils user space
      code which uses a CAVS test vector testing the compliance with
      SP800-56A.
      Signed-off-by: NStephan Mueller <smueller@chronox.de>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      f1c316a3
  9. 02 3月, 2017 1 次提交
    • D
      KEYS: Differentiate uses of rcu_dereference_key() and user_key_payload() · 0837e49a
      David Howells 提交于
      rcu_dereference_key() and user_key_payload() are currently being used in
      two different, incompatible ways:
      
       (1) As a wrapper to rcu_dereference() - when only the RCU read lock used
           to protect the key.
      
       (2) As a wrapper to rcu_dereference_protected() - when the key semaphor is
           used to protect the key and the may be being modified.
      
      Fix this by splitting both of the key wrappers to produce:
      
       (1) RCU accessors for keys when caller has the key semaphore locked:
      
      	dereference_key_locked()
      	user_key_payload_locked()
      
       (2) RCU accessors for keys when caller holds the RCU read lock:
      
      	dereference_key_rcu()
      	user_key_payload_rcu()
      
      This should fix following warning in the NFS idmapper
      
        ===============================
        [ INFO: suspicious RCU usage. ]
        4.10.0 #1 Tainted: G        W
        -------------------------------
        ./include/keys/user-type.h:53 suspicious rcu_dereference_protected() usage!
        other info that might help us debug this:
        rcu_scheduler_active = 2, debug_locks = 0
        1 lock held by mount.nfs/5987:
          #0:  (rcu_read_lock){......}, at: [<d000000002527abc>] nfs_idmap_get_key+0x15c/0x420 [nfsv4]
        stack backtrace:
        CPU: 1 PID: 5987 Comm: mount.nfs Tainted: G        W       4.10.0 #1
        Call Trace:
          dump_stack+0xe8/0x154 (unreliable)
          lockdep_rcu_suspicious+0x140/0x190
          nfs_idmap_get_key+0x380/0x420 [nfsv4]
          nfs_map_name_to_uid+0x2a0/0x3b0 [nfsv4]
          decode_getfattr_attrs+0xfac/0x16b0 [nfsv4]
          decode_getfattr_generic.constprop.106+0xbc/0x150 [nfsv4]
          nfs4_xdr_dec_lookup_root+0xac/0xb0 [nfsv4]
          rpcauth_unwrap_resp+0xe8/0x140 [sunrpc]
          call_decode+0x29c/0x910 [sunrpc]
          __rpc_execute+0x140/0x8f0 [sunrpc]
          rpc_run_task+0x170/0x200 [sunrpc]
          nfs4_call_sync_sequence+0x68/0xa0 [nfsv4]
          _nfs4_lookup_root.isra.44+0xd0/0xf0 [nfsv4]
          nfs4_lookup_root+0xe0/0x350 [nfsv4]
          nfs4_lookup_root_sec+0x70/0xa0 [nfsv4]
          nfs4_find_root_sec+0xc4/0x100 [nfsv4]
          nfs4_proc_get_rootfh+0x5c/0xf0 [nfsv4]
          nfs4_get_rootfh+0x6c/0x190 [nfsv4]
          nfs4_server_common_setup+0xc4/0x260 [nfsv4]
          nfs4_create_server+0x278/0x3c0 [nfsv4]
          nfs4_remote_mount+0x50/0xb0 [nfsv4]
          mount_fs+0x74/0x210
          vfs_kern_mount+0x78/0x220
          nfs_do_root_mount+0xb0/0x140 [nfsv4]
          nfs4_try_mount+0x60/0x100 [nfsv4]
          nfs_fs_mount+0x5ec/0xda0 [nfs]
          mount_fs+0x74/0x210
          vfs_kern_mount+0x78/0x220
          do_mount+0x254/0xf70
          SyS_mount+0x94/0x100
          system_call+0x38/0xe0
      Reported-by: NJan Stancek <jstancek@redhat.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Tested-by: NJan Stancek <jstancek@redhat.com>
      Signed-off-by: NJames Morris <james.l.morris@oracle.com>
      0837e49a
  10. 03 6月, 2016 1 次提交
  11. 13 4月, 2016 1 次提交
    • M
      KEYS: Add KEYCTL_DH_COMPUTE command · ddbb4114
      Mat Martineau 提交于
      This adds userspace access to Diffie-Hellman computations through a
      new keyctl() syscall command to calculate shared secrets or public
      keys using input parameters stored in the keyring.
      
      Input key ids are provided in a struct due to the current 5-arg limit
      for the keyctl syscall. Only user keys are supported in order to avoid
      exposing the content of logon or encrypted keys.
      
      The output is written to the provided buffer, based on the assumption
      that the values are only needed in userspace.
      
      Future support for other types of key derivation would involve a new
      command, like KEYCTL_ECDH_COMPUTE.
      
      Once Diffie-Hellman support is included in the crypto API, this code
      can be converted to use the crypto API to take advantage of possible
      hardware acceleration and reduce redundant code.
      Signed-off-by: NMat Martineau <mathew.j.martineau@linux.intel.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      ddbb4114