25 Apr, 2015

1 commit

  • Pull md updates from Neil Brown:
    "More updates that usual this time. A few have performance impacts
    which hould mostly be positive, but RAID5 (in particular) can be very
    work-load ensitive... We'll have to wait and see.

    Highlights:

    - "experimental" code for managing md/raid1 across a cluster using
    DLM. Code is not ready for general use and triggers a WARNING if
    used. However it is looking good and mostly done and having in
    mainline will help co-ordinate development.

    - RAID5/6 can now batch multiple (4K wide) stripe_heads so as to
    handle a full (chunk wide) stripe as a single unit.

    - RAID6 can now perform read-modify-write cycles which should help
    performance on larger arrays: 6 or more devices.

    - RAID5/6 stripe cache now grows and shrinks dynamically. The value
    set is used as a minimum.

    - Resync is now allowed to go a little faster than the 'mininum' when
    there is competing IO. How much faster depends on the speed of the
    devices, so the effective minimum should scale with device speed to
    some extent"

    * tag 'md/4.1' of git://neil.brown.name/md: (58 commits)
    md/raid5: don't do chunk aligned read on degraded array.
    md/raid5: allow the stripe_cache to grow and shrink.
    md/raid5: change ->inactive_blocked to a bit-flag.
    md/raid5: move max_nr_stripes management into grow_one_stripe and drop_one_stripe
    md/raid5: pass gfp_t arg to grow_one_stripe()
    md/raid5: introduce configuration option rmw_level
    md/raid5: activate raid6 rmw feature
    md/raid6 algorithms: xor_syndrome() for SSE2
    md/raid6 algorithms: xor_syndrome() for generic int
    md/raid6 algorithms: improve test program
    md/raid6 algorithms: delta syndrome functions
    raid5: handle expansion/resync case with stripe batching
    raid5: handle io error of batch list
    RAID5: batch adjacent full stripe write
    raid5: track overwrite disk count
    raid5: add a new flag to track if a stripe can be batched
    raid5: use flex_array for scribble data
    md raid0: access mddev->queue (request queue member) conditionally because it is not set when accessed from dm-raid
    md: allow resync to go faster when there is competing IO.
    md: remove 'go_faster' option from ->sync_request()
    ...

    Linus Torvalds
     

22 Apr, 2015

1 commit

  • Glue it altogehter. The raid6 rmw path should work the same as the
    already existing raid5 logic. So emulate the prexor handling/flags
    and split functions as needed.

    1) Enable xor_syndrome() in the async layer.

    2) Split ops_run_prexor() into RAID4/5 and RAID6 logic. Xor the syndrome
    at the start of a rmw run as we did it before for the single parity.

    3) Take care of rmw run in ops_run_reconstruct6(). Again process only
    the changed pages to get syndrome back into sync.

    4) Enhance set_syndrome_sources() to fill NULL pages if we are in a rmw
    run. The lower layers will calculate start & end pages from that and
    call the xor_syndrome() correspondingly.

    5) Adapt the several places where we ignored Q handling up to now.

    Performance numbers for a single E5630 system with a mix of 10 7200k
    desktop/server disks. 300 seconds random write with 8 threads onto a
    3,2TB (10*400GB) RAID6 64K chunk without spare (group_thread_cnt=4)

    bsize rmw_level=1 rmw_level=0 rmw_level=1 rmw_level=0
    skip_copy=1 skip_copy=1 skip_copy=0 skip_copy=0
    4K 115 KB/s 141 KB/s 165 KB/s 140 KB/s
    8K 225 KB/s 275 KB/s 324 KB/s 274 KB/s
    16K 434 KB/s 536 KB/s 640 KB/s 534 KB/s
    32K 751 KB/s 1,051 KB/s 1,234 KB/s 1,045 KB/s
    64K 1,339 KB/s 1,958 KB/s 2,282 KB/s 1,962 KB/s
    128K 2,673 KB/s 3,862 KB/s 4,113 KB/s 3,898 KB/s
    256K 7,685 KB/s 7,539 KB/s 7,557 KB/s 7,638 KB/s
    512K 19,556 KB/s 19,558 KB/s 19,652 KB/s 19,688 Kb/s

    Signed-off-by: Markus Stockhausen
    Signed-off-by: NeilBrown

    Markus Stockhausen
     

16 Apr, 2015

3 commits

  • Commit 9c521a200bc3 ("crypto: api - remove instance when test failed")
    tried to grab a module reference count before the module was even set.

    Worse, it then goes on to free the module reference count after it is
    set so you quickly end up with a negative module reference count which
    prevents people from using any instances belonging to that module.

    This patch moves the module initialisation before the reference
    count.

    Reported-by: Linus Torvalds
    Signed-off-by: Herbert Xu
    Signed-off-by: Linus Torvalds

    Herbert Xu
     
  • The networking updates from David Miller removed the iocb argument from
    sendmsg and recvmsg (in commit 1b784140474e: "net: Remove iocb argument
    from sendmsg and recvmsg"), but the crypto code had added new instances
    of them.

    When I pulled the crypto update, it was a silent semantic mis-merge, and
    I overlooked the new warning messages in my test-build. I try to fix
    those in the merge itself, but that relies on me noticing. Oh well.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • Pull crypto update from Herbert Xu:
    "Here is the crypto update for 4.1:

    New interfaces:
    - user-space interface for AEAD
    - user-space interface for RNG (i.e., pseudo RNG)

    New hashes:
    - ARMv8 SHA1/256
    - ARMv8 AES
    - ARMv8 GHASH
    - ARM assembler and NEON SHA256
    - MIPS OCTEON SHA1/256/512
    - MIPS img-hash SHA1/256 and MD5
    - Power 8 VMX AES/CBC/CTR/GHASH
    - PPC assembler AES, SHA1/256 and MD5
    - Broadcom IPROC RNG driver

    Cleanups/fixes:
    - prevent internal helper algos from being exposed to user-space
    - merge common code from assembly/C SHA implementations
    - misc fixes"

    * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (169 commits)
    crypto: arm - workaround for building with old binutils
    crypto: arm/sha256 - avoid sha256 code on ARMv7-M
    crypto: x86/sha512_ssse3 - move SHA-384/512 SSSE3 implementation to base layer
    crypto: x86/sha256_ssse3 - move SHA-224/256 SSSE3 implementation to base layer
    crypto: x86/sha1_ssse3 - move SHA-1 SSSE3 implementation to base layer
    crypto: arm64/sha2-ce - move SHA-224/256 ARMv8 implementation to base layer
    crypto: arm64/sha1-ce - move SHA-1 ARMv8 implementation to base layer
    crypto: arm/sha2-ce - move SHA-224/256 ARMv8 implementation to base layer
    crypto: arm/sha256 - move SHA-224/256 ASM/NEON implementation to base layer
    crypto: arm/sha1-ce - move SHA-1 ARMv8 implementation to base layer
    crypto: arm/sha1_neon - move SHA-1 NEON implementation to base layer
    crypto: arm/sha1 - move SHA-1 ARM asm implementation to base layer
    crypto: sha512-generic - move to generic glue implementation
    crypto: sha256-generic - move to generic glue implementation
    crypto: sha1-generic - move to generic glue implementation
    crypto: sha512 - implement base layer for SHA-512
    crypto: sha256 - implement base layer for SHA-256
    crypto: sha1 - implement base layer for SHA-1
    crypto: api - remove instance when test failed
    crypto: api - Move alg ref count init to crypto_check_alg
    ...

    Linus Torvalds
     

12 Apr, 2015

1 commit


10 Apr, 2015

5 commits

  • This updated the generic SHA-512 implementation to use the
    generic shared SHA-512 glue code.

    It also implements a .finup hook crypto_sha512_finup() and exports
    it to other modules. The import and export() functions and the
    .statesize member are dropped, since the default implementation
    is perfectly suitable for this module.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • This updates the generic SHA-256 implementation to use the
    new shared SHA-256 glue code.

    It also implements a .finup hook crypto_sha256_finup() and exports
    it to other modules. The import and export() functions and the
    .statesize member are dropped, since the default implementation
    is perfectly suitable for this module.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • This updated the generic SHA-1 implementation to use the generic
    shared SHA-1 glue code.

    It also implements a .finup hook crypto_sha1_finup() and exports
    it to other modules. The import and export() functions and the
    .statesize member are dropped, since the default implementation
    is perfectly suitable for this module.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • A cipher instance is added to the list of instances unconditionally
    regardless of whether the associated test failed. However, a failed
    test implies that during another lookup, the cipher instance will
    be added to the list again as it will not be found by the lookup
    code.

    That means that the list can be filled up with instances whose tests
    failed.

    Note: tests only fail in reality in FIPS mode when a cipher is not
    marked as fips_allowed=1. This can be seen with cmac(des3_ede) that does
    not have a fips_allowed=1. When allocating the cipher, the allocation
    fails with -ENOENT due to the missing fips_allowed=1 flag (which
    causes the testmgr to return EINVAL). Yet, the instance of
    cmac(des3_ede) is shown in /proc/crypto. Allocating the cipher again
    fails again, but a 2nd instance is listed in /proc/crypto.

    The patch simply de-registers the instance when the testing failed.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • We currently initialise the crypto_alg ref count in the function
    __crypto_register_alg. As one of the callers of that function
    crypto_register_instance needs to obtain a ref count before it
    calls __crypto_register_alg, we need to move the initialisation
    out of there.

    Since both callers of __crypto_register_alg call crypto_check_alg,
    this is the logical place to perform the initialisation.

    Signed-off-by: Herbert Xu
    Acked-by: Stephan Mueller

    Herbert Xu
     

09 Apr, 2015

1 commit


08 Apr, 2015

1 commit

  • The function crypto_alg_match returns an algorithm without taking
    any references on it. This means that the algorithm can be freed
    at any time, therefore all users of crypto_alg_match are buggy.

    This patch fixes this by taking a reference count on the algorithm
    to prevent such races.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

07 Apr, 2015

1 commit


03 Apr, 2015

2 commits


02 Apr, 2015

3 commits


31 Mar, 2015

5 commits

  • The mcryptd is used as a wrapper around internal ciphers. Therefore,
    the mcryptd must process the internal cipher by marking mcryptd as
    internal if the underlying cipher is an internal cipher.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • With ciphers that now cannot be accessed via the kernel crypto API,
    callers shall be able to identify the ciphers that are not callable. The
    /proc/crypto file is added a boolean field identifying that such
    internal ciphers.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • The cryptd is used as a wrapper around internal ciphers. Therefore, the
    cryptd must process the internal cipher by marking cryptd as internal if
    the underlying cipher is an internal cipher.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • Allocate the ciphers irrespectively if they are marked as internal
    or not. As all ciphers, including the internal ciphers will be
    processed by the testmgr, it needs to be able to allocate those
    ciphers.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • Several hardware related cipher implementations are implemented as
    follows: a "helper" cipher implementation is registered with the
    kernel crypto API.

    Such helper ciphers are never intended to be called by normal users. In
    some cases, calling them via the normal crypto API may even cause
    failures including kernel crashes. In a normal case, the "wrapping"
    ciphers that use the helpers ensure that these helpers are invoked
    such that they cannot cause any calamity.

    Considering the AF_ALG user space interface, unprivileged users can
    call all ciphers registered with the crypto API, including these
    helper ciphers that are not intended to be called directly. That
    means, with AF_ALG user space may invoke these helper ciphers
    and may cause undefined states or side effects.

    To avoid any potential side effects with such helpers, the patch
    prevents the helpers to be called directly. A new cipher type
    flag is added: CRYPTO_ALG_INTERNAL. This flag shall be used
    to mark helper ciphers. These ciphers can only be used if the
    caller invoke the cipher with CRYPTO_ALG_INTERNAL in the type and
    mask field.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     

25 Mar, 2015

1 commit


24 Mar, 2015

2 commits


16 Mar, 2015

1 commit


13 Mar, 2015

1 commit


12 Mar, 2015

1 commit


11 Mar, 2015

1 commit

  • Commit 5be4d4c94b1f ("crypto: replace scatterwalk_sg_next with sg_next")
    did not consider the fact that scatterwalk_sg_next() was looking at
    sg entry length, while sg_next() looks at the "chained" sg bit.

    This should have no effect in theory. However in practice, there are
    cases where the sg table is initialized to a number of entries and
    some of them are not properly configured. While scatterwalk_sg_next()
    would have returned NULL (since sg length = 0 and sg page_link = 0),
    sg_next() happily returns the next unconfigured sg entry.

    insmod tcrypt.ko mode=500 sec=1

    testing speed of async cbc(aes) (cbc-aes-talitos) encryption
    test 0 (128 bit key, 16 byte blocks):
    Unable to handle kernel paging request for data at address 0x00000000
    Faulting instruction address: 0xc00d79e4
    Oops: Kernel access of bad area, sig: 11 [#1]
    SMP NR_CPUS=8 P1022 DS
    Modules linked in: tcrypt(+) talitos
    CPU: 0 PID: 2670 Comm: insmod Not tainted 4.0.0-rc1-QorIQ-SDK-V1.6+g904f1ca82209 #1
    task: e8de3200 ti: e70bc000 task.ti: e70bc000
    NIP: c00d79e4 LR: f92d223c CTR: c00d79c8
    REGS: e70bda00 TRAP: 0300 Not tainted (4.0.0-rc1-QorIQ-SDK-V1.6+g904f1ca82209)
    MSR: 00029000 CR: 84428f22 XER: 00000000
    DEAR: 00000000 ESR: 00000000
    GPR00: f92d223c e70bdab0 e8de3200 00000000 e70bdbb8 00000001 00000000 00000000
    GPR08: 00000000 00000000 c08b0380 27282010 c00d79c8 1003a634 00000000 e70bdf1c
    GPR16: e70bdef0 00000020 00000000 c08c0000 00000010 00000000 e70bdbb8 00000010
    GPR24: e976d3a8 00000010 00000000 e70bdbd8 e8961010 00000001 c086e560 00000000
    NIP [c00d79e4] page_address+0x1c/0x110
    LR [f92d223c] talitos_map_sg+0x130/0x184 [talitos]
    Call Trace:
    [e70bdab0] [00000010] 0x10 (unreliable)
    [e70bdad0] [f92d223c] talitos_map_sg+0x130/0x184 [talitos]
    [e70bdb00] [f92d30d8] common_nonsnoop.constprop.13+0xc0/0x304 [talitos]
    [e70bdb30] [f933fd90] test_acipher_speed+0x434/0x7dc [tcrypt]
    [e70bdcc0] [f934318c] do_test+0x2478/0x306c [tcrypt]
    [e70bdd80] [f11fe058] tcrypt_mod_init+0x58/0x100 [tcrypt]
    [e70bdda0] [c0002354] do_one_initcall+0x90/0x1f4
    [e70bde10] [c061fe00] do_init_module+0x60/0x1ac
    [e70bde30] [c00a79f0] load_module+0x185c/0x1f88
    [e70bdee0] [c00a82b0] SyS_finit_module+0x7c/0x98
    [e70bdf40] [c000e8b0] ret_from_syscall+0x0/0x3c

    Signed-off-by: Herbert Xu

    Horia Geant?
     

10 Mar, 2015

1 commit


09 Mar, 2015

1 commit

  • Change the RNGs to always return 0 in success case.

    This patch ensures that seqiv.c works with RNGs other than krng. seqiv
    expects that any return code other than 0 is an error. Without the
    patch, rfc4106(gcm(aes)) will not work when using a DRBG or an ANSI
    X9.31 RNG.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     

04 Mar, 2015

5 commits

  • The DRBG code contains memset(0) calls to initialize a varaible
    that are not necessary as the variable is always overwritten by
    the processing.

    This patch increases the CTR and Hash DRBGs by about 5%.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • The CTR DRBG only encrypts one single block at a time. Thus, use the
    single block crypto API to avoid additional overhead from the block
    chaining modes.

    With the patch, the speed of the DRBG increases between 30% and 40%.

    The DRBG still passes the CTR DRBG CAVS test.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • Integrate the module into the kernel config tree.

    Signed-off-by: Markus Stockhausen
    Signed-off-by: Herbert Xu

    Markus Stockhausen
     
  • Enable compilation of the AEAD AF_ALG support and provide a Kconfig
    option to compile the AEAD AF_ALG support.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • This patch adds the AEAD support for AF_ALG.

    The implementation is based on algif_skcipher, but contains heavy
    modifications to streamline the interface for AEAD uses.

    To use AEAD, the user space consumer has to use the salg_type named
    "aead".

    The AEAD implementation includes some overhead to calculate the size of
    the ciphertext, because the AEAD implementation of the kernel crypto API
    makes implied assumption on the location of the authentication tag. When
    performing an encryption, the tag will be added to the created
    ciphertext (note, the tag is placed adjacent to the ciphertext). For
    decryption, the caller must hand in the ciphertext with the tag appended
    to the ciphertext. Therefore, the selection of the used memory
    needs to add/subtract the tag size from the source/destination buffers
    depending on the encryption type. The code is provided with comments
    explaining when and how that operation is performed.

    A fully working example using all aspects of AEAD is provided at
    http://www.chronox.de/libkcapi.html

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     

03 Mar, 2015

1 commit

  • After TIPC doesn't depend on iocb argument in its internal
    implementations of sendmsg() and recvmsg() hooks defined in proto
    structure, no any user is using iocb argument in them at all now.
    Then we can drop the redundant iocb argument completely from kinds of
    implementations of both sendmsg() and recvmsg() in the entire
    networking stack.

    Cc: Christoph Hellwig
    Suggested-by: Al Viro
    Signed-off-by: Ying Xue
    Signed-off-by: David S. Miller

    Ying Xue
     

02 Mar, 2015

1 commit