Skip to content
Snippets Groups Projects
  1. Jul 08, 2023
  2. Jul 07, 2023
  3. Jul 05, 2023
  4. Jun 27, 2023
  5. Jun 24, 2023
  6. Jun 23, 2023
  7. Jun 20, 2023
  8. Jun 18, 2023
    • David Howells's avatar
      crypto: Fix af_alg_sendmsg(MSG_SPLICE_PAGES) sglist limit · 43804992
      David Howells authored
      
      When af_alg_sendmsg() calls extract_iter_to_sg(), it passes MAX_SGL_ENTS as
      the maximum number of elements that may be written to, but some of the
      elements may already have been used (as recorded in sgl->cur), so
      extract_iter_to_sg() may end up overrunning the scatterlist.
      
      Fix this to limit the number of elements to "MAX_SGL_ENTS - sgl->cur".
      
      Note: It probably makes sense in future to alter the behaviour of
      extract_iter_to_sg() to stop if "sgtable->nents >= sg_max" instead, but
      this is a smaller fix for now.
      
      The bug causes errors looking something like:
      
      BUG: KASAN: slab-out-of-bounds in sg_assign_page include/linux/scatterlist.h:109 [inline]
      BUG: KASAN: slab-out-of-bounds in sg_set_page include/linux/scatterlist.h:139 [inline]
      BUG: KASAN: slab-out-of-bounds in extract_bvec_to_sg lib/scatterlist.c:1183 [inline]
      BUG: KASAN: slab-out-of-bounds in extract_iter_to_sg lib/scatterlist.c:1352 [inline]
      BUG: KASAN: slab-out-of-bounds in extract_iter_to_sg+0x17a6/0x1960 lib/scatterlist.c:1339
      
      Fixes: bf63e250 ("crypto: af_alg: Support MSG_SPLICE_PAGES")
      Reported-by: default avatar <syzbot+6efc50cc1f8d718d6cb7@syzkaller.appspotmail.com>
      Link: https://lore.kernel.org/r/000000000000b2585a05fdeb8379@google.com/
      
      
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Tested-by: default avatar <syzbot+6efc50cc1f8d718d6cb7@syzkaller.appspotmail.com>
      cc: Herbert Xu <herbert@gondor.apana.org.au>
      cc: "David S. Miller" <davem@davemloft.net>
      cc: Eric Dumazet <edumazet@google.com>
      cc: Jakub Kicinski <kuba@kernel.org>
      cc: Paolo Abeni <pabeni@redhat.com>
      cc: Jens Axboe <axboe@kernel.dk>
      cc: Matthew Wilcox <willy@infradead.org>
      cc: linux-crypto@vger.kernel.org
      cc: netdev@vger.kernel.org
      Acked-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      43804992
  9. Jun 16, 2023
  10. Jun 13, 2023
  11. Jun 08, 2023
  12. Jun 02, 2023
  13. May 24, 2023
  14. May 12, 2023
    • Stephan Müller's avatar
      crypto: jitter - add interface for gathering of raw entropy · 69f1c387
      Stephan Müller authored
      
      The test interface allows a privileged process to capture the raw
      unconditioned noise that is collected by the Jitter RNG for statistical
      analysis. Such testing allows the analysis how much entropy
      the Jitter RNG noise source provides on a given platform. The obtained
      data is the time stamp sampled by the Jitter RNG. Considering that
      the Jitter RNG inserts the delta of this time stamp compared to the
      immediately preceding time stamp, the obtained data needs to be
      post-processed accordingly to obtain the data the Jitter RNG inserts
      into its entropy pool.
      
      The raw entropy collection is provided to obtain the raw unmodified
      time stamps that are about to be added to the Jitter RNG entropy pool
      and are credited with entropy. Thus, this patch adds an interface
      which renders the Jitter RNG insecure. This patch is NOT INTENDED
      FOR PRODUCTION SYSTEMS, but solely for development/test systems to
      verify the available entropy rate.
      
      Access to the data is given through the jent_raw_hires debugfs file.
      The data buffer should be multiples of sizeof(u32) to fill the entire
      buffer. Using the option jitterentropy_testing.boot_raw_hires_test=1
      the raw noise of the first 1000 entropy events since boot can be
      sampled.
      
      This test interface allows generating the data required for
      analysis whether the Jitter RNG is in compliance with SP800-90B
      sections 3.1.3 and 3.1.4.
      
      If the test interface is not compiled, its code is a noop which has no
      impact on the performance.
      
      Signed-off-by: default avatarStephan Mueller <smueller@chronox.de>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      69f1c387
    • Stephan Müller's avatar
      crypto: jitter - replace LFSR with SHA3-256 · bb897c55
      Stephan Müller authored
      
      Using the kernel crypto API, the SHA3-256 algorithm is used as
      conditioning element to replace the LFSR in the Jitter RNG. All other
      parts of the Jitter RNG are unchanged.
      
      The application and use of the SHA-3 conditioning operation is identical
      to the user space Jitter RNG 3.4.0 by applying the following concept:
      
      - the Jitter RNG initializes a SHA-3 state which acts as the "entropy
        pool" when the Jitter RNG is allocated.
      
      - When a new time delta is obtained, it is inserted into the "entropy
        pool" with a SHA-3 update operation. Note, this operation in most of
        the cases is a simple memcpy() onto the SHA-3 stack.
      
      - To cause a true SHA-3 operation for each time delta operation, a
        second SHA-3 operation is performed hashing Jitter RNG status
        information. The final message digest is also inserted into the
        "entropy pool" with a SHA-3 update operation. Yet, this data is not
        considered to provide any entropy, but it shall stir the entropy pool.
      
      - To generate a random number, a SHA-3 final operation is performed to
        calculate a message digest followed by an immediate SHA-3 init to
        re-initialize the "entropy pool". The obtained message digest is one
        block of the Jitter RNG that is returned to the caller.
      
      Mathematically speaking, the random number generated by the Jitter RNG
      is:
      
      aux_t = SHA-3(Jitter RNG state data)
      
      Jitter RNG block = SHA-3(time_i || aux_i || time_(i-1) || aux_(i-1) ||
                               ... || time_(i-255) || aux_(i-255))
      
      when assuming that the OSR = 1, i.e. the default value.
      
      This operation implies that the Jitter RNG has an output-blocksize of
      256 bits instead of the 64 bits of the LFSR-based Jitter RNG that is
      replaced with this patch.
      
      The patch also replaces the varying number of invocations of the
      conditioning function with one fixed number of invocations. The use
      of the conditioning function consistent with the userspace Jitter RNG
      library version 3.4.0.
      
      The code is tested with a system that exhibited the least amount of
      entropy generated by the Jitter RNG: the SiFive Unmatched RISC-V
      system. The measured entropy rate is well above the heuristically
      implied entropy value of 1 bit of entropy per time delta. On all other
      tested systems, the measured entropy rate is even higher by orders
      of magnitude. The measurement was performed using updated tooling
      provided with the user space Jitter RNG library test framework.
      
      The performance of the Jitter RNG with this patch is about en par
      with the performance of the Jitter RNG without the patch.
      
      Signed-off-by: default avatarStephan Mueller <smueller@chronox.de>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      bb897c55
    • Herbert Xu's avatar
      crypto: hash - Make crypto_ahash_alg helper available · 3908edf8
      Herbert Xu authored
      
      Move the crypto_ahash_alg helper into include/crypto/internal so
      that drivers can use it.
      
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      3908edf8
    • Herbert Xu's avatar
      crypto: hash - Add statesize to crypto_ahash · c7535fb2
      Herbert Xu authored
      
      As ahash drivers may need to use fallbacks, their state size
      is thus variable.  Deal with this by making it an attribute
      of crypto_ahash.
      
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      c7535fb2
  15. May 02, 2023
Loading