Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. May 02, 2023
  2. Mar 14, 2023
    • Herbert Xu's avatar
      crypto: api - Check CRYPTO_USER instead of NET for report · c0f9e01d
      Herbert Xu authored
      
      The report function is currently conditionalised on CONFIG_NET.
      As it's only used by CONFIG_CRYPTO_USER, conditionalising on that
      instead of CONFIG_NET makes more sense.
      
      This gets rid of a rarely used code-path.
      
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      c0f9e01d
    • Herbert Xu's avatar
      crypto: acomp - Count error stats differently · 0a742389
      Herbert Xu authored
      
      Move all stat code specific to acomp into the acomp code.
      
      While we're at it, change the stats so that bytes and counts
      are always incremented even in case of error.  This allows the
      reference counting to be removed as we can now increment the
      counters prior to the operation.
      
      After the operation we simply increase the error count if necessary.
      This is safe as errors can only occur synchronously (or rather,
      the existing code already ignored asynchronous errors which are
      only visible to the callback function).
      
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      0a742389
  3. Jul 09, 2020
    • Barry Song's avatar
      crypto: api - permit users to specify numa node of acomp hardware · 7bc13b5b
      Barry Song authored
      
      For a Linux server with NUMA, there are possibly multiple (de)compressors
      which are either local or remote to some NUMA node. Some drivers will
      automatically use the (de)compressor near the CPU calling acomp_alloc().
      However, it is not necessarily correct because users who send acomp_req
      could be from different NUMA node with the CPU which allocates acomp.
      
      Just like kernel has kmalloc() and kmalloc_node(), here crypto can have
      same support.
      
      Cc: Seth Jennings <sjenning@redhat.com>
      Cc: Dan Streetman <ddstreet@ieee.org>
      Cc: Vitaly Wool <vitaly.wool@konsulko.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarBarry Song <song.bao.hua@hisilicon.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      7bc13b5b
  4. Dec 20, 2019
    • Eric Biggers's avatar
      crypto: algapi - make unregistration functions return void · c6d633a9
      Eric Biggers authored
      
      Some of the algorithm unregistration functions return -ENOENT when asked
      to unregister a non-registered algorithm, while others always return 0
      or always return void.  But no users check the return value, except for
      two of the bulk unregistration functions which print a message on error
      but still always return 0 to their caller, and crypto_del_alg() which
      calls crypto_unregister_instance() which always returns 0.
      
      Since unregistering a non-registered algorithm is always a kernel bug
      but there isn't anything callers should do to handle this situation at
      runtime, let's simplify things by making all the unregistration
      functions return void, and moving the error message into
      crypto_unregister_alg() and upgrading it to a WARN().
      
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      c6d633a9
  5. May 30, 2019
  6. Nov 09, 2018
    • Eric Biggers's avatar
      crypto: user - clean up report structure copying · 37db69e0
      Eric Biggers authored
      There have been a pretty ridiculous number of issues with initializing
      the report structures that are copied to userspace by NETLINK_CRYPTO.
      Commit 4473710d ("crypto: user - Prepare for CRYPTO_MAX_ALG_NAME
      expansion") replaced some strncpy()s with strlcpy()s, thereby
      introducing information leaks.  Later two other people tried to replace
      other strncpy()s with strlcpy() too, which would have introduced even
      more information leaks:
      
          - https://lore.kernel.org/patchwork/patch/954991/
          - https://patchwork.kernel.org/patch/10434351/
      
      Commit cac5818c
      
       ("crypto: user - Implement a generic crypto
      statistics") also uses the buggy strlcpy() approach and therefore leaks
      uninitialized memory to userspace.  A fix was proposed, but it was
      originally incomplete.
      
      Seeing as how apparently no one can get this right with the current
      approach, change all the reporting functions to:
      
      - Start by memsetting the report structure to 0.  This guarantees it's
        always initialized, regardless of what happens later.
      - Initialize all strings using strscpy().  This is safe after the
        memset, ensures null termination of long strings, avoids unnecessary
        work, and avoids the -Wstringop-truncation warnings from gcc.
      - Use sizeof(var) instead of sizeof(type).  This is more robust against
        copy+paste errors.
      
      For simplicity, also reuse the -EMSGSIZE return value from nla_put().
      
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      37db69e0
  7. Apr 21, 2017
  8. Jan 12, 2017
    • Gideon Israel Dsouza's avatar
      crypto: Replaced gcc specific attributes with macros from compiler.h · d8c34b94
      Gideon Israel Dsouza authored
      Continuing from this commit: 52f5684c
      
      
      ("kernel: use macros from compiler.h instead of __attribute__((...))")
      
      I submitted 4 total patches. They are part of task I've taken up to
      increase compiler portability in the kernel. I've cleaned up the
      subsystems under /kernel /mm /block and /security, this patch targets
      /crypto.
      
      There is <linux/compiler.h> which provides macros for various gcc specific
      constructs. Eg: __weak for __attribute__((weak)). I've cleaned all
      instances of gcc specific attributes with the right macros for the crypto
      subsystem.
      
      I had to make one additional change into compiler-gcc.h for the case when
      one wants to use this: __attribute__((aligned) and not specify an alignment
      factor. From the gcc docs, this will result in the largest alignment for
      that data type on the target machine so I've named the macro
      __aligned_largest. Please advise if another name is more appropriate.
      
      Signed-off-by: default avatarGideon Israel Dsouza <gidisrael@gmail.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      d8c34b94
  9. Oct 24, 2016