28 Aug, 2020

1 commit


25 Aug, 2020

2 commits

  • Building ARM allmodconfig leads to the following warnings:

    arch/arm/crypto/curve25519-glue.c:73:12: error: implicit declaration of function 'sg_copy_to_buffer' [-Werror=implicit-function-declaration]
    arch/arm/crypto/curve25519-glue.c:74:9: error: implicit declaration of function 'sg_nents_for_len' [-Werror=implicit-function-declaration]
    arch/arm/crypto/curve25519-glue.c:88:11: error: implicit declaration of function 'sg_copy_from_buffer' [-Werror=implicit-function-declaration]

    Include to fix such warnings

    Reported-by: Olof's autobuilder
    Fixes: 0c3dc787a62a ("crypto: algapi - Remove skbuff.h inclusion")
    Signed-off-by: Fabio Estevam
    Acked-by: Ard Biesheuvel
    Acked-by: Jason A. Donenfeld
    Signed-off-by: Herbert Xu

    Fabio Estevam
     
  • The stm32 driver was missing a number of includes that we being
    pulled in by unrelated header files. As the indirect inclusion
    went away, it now fails to build.

    This patch adds the missing inclusions.

    Reported-by: kernel test robot
    Fixes: 0c3dc787a62a ("crypto: algapi - Remove skbuff.h inclusion")
    Signed-off-by: Herbert Xu

    Herbert Xu
     

21 Aug, 2020

33 commits

  • When the devices are removed or not existing, the corresponding algorithms
    which are registered by 'hisi-zip' driver can't be used.

    Move 'hisi_zip_register_to_crypto' from 'hisi_zip_init' to
    'hisi_zip_probe'. The algorithms will be registered to crypto only when
    there is device bind on the driver. And when the devices are removed,
    the algorithms will be unregistered.

    In the previous process, the function 'xxx_register_to_crypto' need a lock
    and a static variable to judge if the registration is the first time.
    Move this action into the function 'hisi_qm_alg_register'. Each device
    will call 'hisi_qm_alg_register' to add itself to qm list in probe process
    and registering algs when the qm list is empty.

    Signed-off-by: Yang Shen
    Reviewed-by: Zhou Wang
    Signed-off-by: Herbert Xu

    Yang Shen
     
  • Call trace will appear in the Hisilicon crypto driver unbinding or
    disabling SRIOV during task running with TFMs on the corresponding
    function.
    The log looks like this:
    [ 293.908078] Call trace:
    [ 293.908080] __queue_work+0x494/0x548
    [ 293.908081] queue_work_on+0x84/0xd8
    [ 293.908092] qm_irq+0x4c/0xd0 [hisi_qm]
    [ 293.908096] __handle_irq_event_percpu+0x74/0x2a0
    [ 293.908098] handle_irq_event_percpu+0x40/0x98
    [ 293.908099] handle_irq_event+0x4c/0x80
    [ 293.908101] handle_fasteoi_irq+0xb0/0x170
    [ 293.908102] generic_handle_irq+0x3c/0x58
    [ 293.908103] __handle_domain_irq+0x68/0xc0
    [ 293.908104] gic_handle_irq+0xb4/0x298
    [ 293.908105] el1_irq+0xcc/0x180
    [ 293.908107] arch_cpu_idle+0x38/0x228
    [ 293.908110] default_idle_call+0x20/0x40
    [ 293.908113] do_idle+0x1cc/0x2b8
    [ 293.908114] cpu_startup_entry+0x2c/0x30
    [ 293.908115] rest_init+0xdc/0xe8
    [ 293.908117] arch_call_rest_init+0x14/0x1c
    [ 293.908117] start_kernel+0x490/0x4c4

    This patch adds a waiting logic as user doing the above two operations
    to avoid panic. The two operations will hold on in the driver
    remove function until the tasks release all their relative TFMs.

    Signed-off-by: Hui Tang
    Signed-off-by: Weili Qian
    Signed-off-by: Yang Shen
    Reviewed-by: Zhou Wang
    Signed-off-by: Herbert Xu

    Weili Qian
     
  • Since the drivers such as HPRE/SEC/ZIP do not implement
    'pci_driver.shutdow', a RAS will be triggered at OS rebooting or shutting
    down as the hardware device is processing request.
    The log looks like this:
    NOTICE: [NimbusSecNodeType1]:[2372L]This is sec, Base = 0x141800000
    NOTICE: [NimbusSecHandle]:[2319L] SecIntSt = 0x3
    NOTICE: [NimbusSecHandle]:[2320L] SecQmIntStatus = 0x2
    NOTICE: [PrintSecurityType]:[344L] SecurityType is RECOVERABLE!

    This patch offers a new API in qm to shutdown devices, and add shutdown
    callbacks in ACC driver based on this new API.

    So the running devices will be stopped when the OS reboot or shutdown.

    Signed-off-by: Yang Shen
    Reviewed-by: Zhou Wang
    Signed-off-by: Herbert Xu

    Yang Shen
     
  • When PF FLR, the hardware will actively trigger the VF FLR. Configuration
    space of VF needs to be saved and restored to ensure that it is available
    after the PF FLR.

    Fixes: 7ce396fa12a9("crypto: hisilicon - add FLR support")
    Signed-off-by: Shukun Tan
    Signed-off-by: Yang Shen
    Reviewed-by: Zhou Wang
    Signed-off-by: Herbert Xu

    Shukun Tan
     
  • Now, there are three reasons of stopping: 'NORMAL', 'SOFT_RESET' and 'FLR'.
    In order to keep this, explicitly pass the stop reason as an input
    parameter of 'hisi_qm_stop' function.

    Fixes: b67202e8ed30("crypto: hisilicon/qm - add state machine for QM")
    Signed-off-by: Shukun Tan
    Signed-off-by: Yang Shen
    Reviewed-by: Zhou Wang
    Signed-off-by: Herbert Xu

    Yang Shen
     
  • Increasing depth of 'event queue' from 1024 to 2048, which equals to twice
    depth of 'completion queue'. It will fix the easily happened 'event queue
    overflow' as using 1024 queue depth for 'event queue'.

    Fixes: 263c9959c937("crypto: hisilicon - add queue management driver...")
    Signed-off-by: Shukun Tan
    Signed-off-by: Yang Shen
    Reviewed-by: Zhou Wang
    Signed-off-by: Herbert Xu

    Shukun Tan
     
  • The queue depth is 1024, so the condition for judging the queue full
    should be 1023, otherwise the hardware cannot judge whether the queue
    is empty or full.

    Fixes: 263c9959c937("crypto: hisilicon - add queue management driver...")
    Signed-off-by: Hui Tang
    Signed-off-by: Yang Shen
    Reviewed-by: Zhou Wang
    Signed-off-by: Herbert Xu

    Hui Tang
     
  • Requests will be sent continuously as resetting, which will cause 'printk'
    flooding. Using 'dev_info_ratelimited' can solve this problem well.

    Fixes: b67202e8ed30("crypto: hisilicon/qm - add state machine for QM")
    Signed-off-by: Yang Shen
    Reviewed-by: Zhou Wang
    Signed-off-by: Herbert Xu

    Yang Shen
     
  • The used reference count is used for counting the number of 'sqe' which
    is under processing. This reference count should be cleared as starting
    'qp', otherwise the 'used' will be messy when allocating this 'qp' again.

    Fixes: 5308f6600a39("crypto: hisilicon - QM memory management...")
    Signed-off-by: Shukun Tan
    Signed-off-by: Yang Shen
    Reviewed-by: Zhou Wang
    Signed-off-by: Herbert Xu

    Shukun Tan
     
  • Save the string address before pass to strsep, release it at end.
    Because strsep will update the string address to point after the
    token.

    Fixes: c31dc9fe165d("crypto: hisilicon/qm - add DebugFS for xQC and...")
    Signed-off-by: Sihang Chen
    Signed-off-by: Yang Shen
    Reviewed-by: Zhou Wang
    Signed-off-by: Herbert Xu

    Sihang Chen
     
  • Drivers shouldn't be enabled by default unless there is a very good
    reason to do so. There doesn't seem to be any such reason for the
    virtio crypto driver, so change it to the default of 'n'.

    Signed-off-by: Ram Muthiah
    [EB: adjusted commit message]
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Ram Muthiah
     
  • engine->stat_irq_thresh was initialized after device_create_file() in
    the probe function, the initialization may race with call to
    spacc_stat_irq_thresh_store() which updates engine->stat_irq_thresh,
    therefore initialize it before creating the file in probe function.

    Found by Linux Driver Verification project (linuxtesting.org).

    Fixes: ce92136843cb ("crypto: picoxcell - add support for the...")
    Signed-off-by: Madhuparna Bhowmik
    Acked-by: Jamie Iles
    Signed-off-by: Herbert Xu

    Madhuparna Bhowmik
     
  • Revert "crypto: hash - Add real ahash walk interface"
    This reverts commit 75ecb231ff45b54afa9f4ec9137965c3c00868f4.

    The callers of the functions in this commit were removed in ab8085c130ed

    Remove these unused calls.

    Fixes: ab8085c130ed ("crypto: x86 - remove SHA multibuffer routines and mcryptd")
    Cc: Ard Biesheuvel
    Signed-off-by: Ira Weiny
    Signed-off-by: Herbert Xu

    Ira Weiny
     
  • Once the crypto hash walk is started by crypto_hash_walk_first()
    returning non-zero, crypto_hash_walk_done() must be called to unmap any
    memory which was mapped by *_walk_first().

    Ensure crypto_hash_walk_done() is called properly by:

    1) Re-arranging the check for device data to be prior to calling
    *_walk_first()
    2) on error call crypto_hash_walk_done() with an error code to
    allow the hash walk code to clean up.

    While we are at it clean up the 'out' label to be more meaningful.

    Signed-off-by: Ira Weiny
    Signed-off-by: Herbert Xu

    Ira Weiny
     
  • clang static analysis reports this problem

    intel-rng.c:333:2: warning: Assigned value is garbage or undefined
    void __iomem *mem = mem;
    ^~~~~~~~~~~~~~~~~ ~~~

    Because mem is assigned before it is used, this is not
    a real problem. But the initialization is strange and not
    needed, so remove it.

    Signed-off-by: Tom Rix
    Signed-off-by: Herbert Xu

    Tom Rix
     
  • Currently the debugfs fops are defined in caam/intern.h. This causes
    problems because it creates identical static functions and variables
    in multiple files. It also creates warnings when those files don't
    use the fops.

    This patch moves them into a standalone file, debugfs.c.

    It also removes unnecessary uses of ifdefs on CONFIG_DEBUG_FS.

    Signed-off-by: Herbert Xu
    [Moved most of debugfs-related operations into debugfs.c.]
    Signed-off-by: Horia Geantă
    Signed-off-by: Herbert Xu

    Horia Geantă
     
  • The current code waits for data to be available before attempting a
    second read. However the second read would not be executed as the
    while loop will exit.

    This fix does not wait if all data has been read (skips the call to
    msleep(0)) and reads a second time if partial data was retrieved on
    the first read.

    Worth noticing that since msleep(0) schedules a one jiffy timeout is
    better to skip such a call.

    Signed-off-by: Jorge Ramirez-Ortiz
    Reviewed-by: Sumit Garg
    Signed-off-by: Herbert Xu

    Jorge Ramirez-Ortiz
     
  • Data rates of MAX_UINT32 will schedule an unnecessary one jiffy
    timeout on the call to msleep. Avoid this scenario by using 0 as the
    unlimited data rate.

    Signed-off-by: Jorge Ramirez-Ortiz
    Reviewed-by: Sumit Garg
    Signed-off-by: Herbert Xu

    Jorge Ramirez-Ortiz
     
  • Current minimum required version of binutils is 2.23,
    which supports CRC32 instruction mnemonic.

    Replace the byte-wise specification of CRC32 with this proper mnemonic.
    The compiler is now able to pass memory operand to the instruction,
    so there is no need for a temporary register anymore.

    Some examples of the improvement:

    12a: 48 8b 08 mov (%rax),%rcx
    12d: f2 48 0f 38 f1 f1 crc32q %rcx,%rsi
    133: 48 83 c0 08 add $0x8,%rax
    137: 48 39 d0 cmp %rdx,%rax
    13a: 75 ee jne 12a

    to:

    125: f2 48 0f 38 f1 06 crc32q (%rsi),%rax
    12b: 48 83 c6 08 add $0x8,%rsi
    12f: 48 39 d6 cmp %rdx,%rsi
    132: 75 f1 jne 125

    and:

    146: 0f b6 08 movzbl (%rax),%ecx
    149: f2 0f 38 f0 f1 crc32b %cl,%esi
    14e: 48 83 c0 01 add $0x1,%rax
    152: 48 39 d0 cmp %rdx,%rax
    155: 75 ef jne 146

    to:

    13b: f2 0f 38 f0 02 crc32b (%rdx),%eax
    140: 48 83 c2 01 add $0x1,%rdx
    144: 48 39 ca cmp %rcx,%rdx
    147: 75 f2 jne 13b

    As the compiler has some more freedom w.r.t. register allocation,
    there is also a couple of reg-reg moves removed.

    There are no hidden states for CRC32 insn, so there is no need to mark
    assembly as volatile.

    v2: Introduce CRC32_INST define.

    Signed-off-by: Uros Bizjak
    CC: Herbert Xu
    CC: "David S. Miller"
    CC: Thomas Gleixner
    CC: Ingo Molnar
    CC: Borislav Petkov
    CC: "H. Peter Anvin"
    Signed-off-by: Herbert Xu

    Uros Bizjak
     
  • Remove the bitlocker cipher which is not supported by
    the kernel.

    Signed-off-by: Gilad Ben-Yossef
    Signed-off-by: Herbert Xu

    Gilad Ben-Yossef
     
  • Remove the implementaion of automatic advancement of sector size in IV for
    storage ciphers as its use is not supproted by the kernel.

    Signed-off-by: Gilad Ben-Yossef
    Signed-off-by: Herbert Xu

    Gilad Ben-Yossef
     
  • Currently if you speed test a hash that requires a key you'll get an
    error because tcrypt does not set a key by default. This patch
    allows a key to be set using the new module parameter klen.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • Update the size used in 'dma_free_coherent()' in order to match the one
    used in the corresponding 'dma_alloc_coherent()', in 'setup_crypt_desc()'.

    Fixes: 81bef0150074 ("crypto: ixp4xx - Hardware crypto support for IXP4xx CPUs")
    Signed-off-by: Christophe JAILLET
    Signed-off-by: Herbert Xu

    Christophe JAILLET
     
  • In case of memory allocation failure, a negative error code should
    be returned.

    Fixes: 785e5c616c849 ("crypto: mediatek - Add crypto driver support for some MediaTek chips")
    Cc: Ryder Lee
    Signed-off-by: Tianjia Zhang
    Signed-off-by: Herbert Xu

    Tianjia Zhang
     
  • This patch fixes most sparse warnings in the cesa driver. The only
    ones remaining are to do with copying data between iomem pointers and
    SG lists.

    Most changes are trivial. The following are the noteworthy ones:

    - Removal of swab in mv_cesa_aes_setkey. This appears to be bogus
    as everything gets swabbed again later on so for BE this ends up
    being different from LE. The change takes the LE behaviour as the
    correct one.

    - next_dma in mv_cesa_tdma_chain was not swabbed.

    Signed-off-by: Herbert Xu
    Reported-by: kernel test robot
    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • The async path cannot use MAY_BACKLOG because it is not meant to
    block, which is what MAY_BACKLOG does. On the other hand, both
    the sync and async paths can make use of MAY_SLEEP.

    Fixes: 83094e5e9e49 ("crypto: af_alg - add async support to...")
    Cc:
    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • I removed the MAY_BACKLOG flag on the aio path a while ago but
    the error check still incorrectly interpreted EBUSY as success.
    This may cause the submitter to wait for a request that will never
    complete.

    Fixes: dad419970637 ("crypto: algif_skcipher - Do not set...")
    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • Drop the doubled word "failed" in pr_err() messages.

    Signed-off-by: Randy Dunlap
    Cc: Herbert Xu
    Cc: "David S. Miller"
    Cc: linux-crypto@vger.kernel.org
    Signed-off-by: Herbert Xu

    Randy Dunlap
     
  • Drop the doubled word "a".

    Signed-off-by: Randy Dunlap
    Cc: Herbert Xu
    Cc: "David S. Miller"
    Cc: linux-crypto@vger.kernel.org
    Signed-off-by: Herbert Xu

    Randy Dunlap
     
  • Change the doubled word "at" to "at a".

    Signed-off-by: Randy Dunlap
    Cc: Herbert Xu
    Cc: "David S. Miller"
    Cc: linux-crypto@vger.kernel.org
    Signed-off-by: Herbert Xu

    Randy Dunlap
     
  • Drop the doubled word "the".
    Change "at at" to "at a".

    Signed-off-by: Randy Dunlap
    Cc: Herbert Xu
    Cc: "David S. Miller"
    Cc: linux-crypto@vger.kernel.org
    Signed-off-by: Herbert Xu

    Randy Dunlap
     
  • Drop the doubled word "is".

    Signed-off-by: Randy Dunlap
    Cc: Herbert Xu
    Cc: "David S. Miller"
    Cc: linux-crypto@vger.kernel.org
    Signed-off-by: Herbert Xu

    Randy Dunlap
     
  • The wrappers in include/linux/pci-dma-compat.h should go away.

    The patch has been generated with the coccinelle script below and has been
    hand modified to replace GFP_ with a correct flag.
    It has been compile tested.

    When memory is allocated in 'hifn_probe()' GFP_KERNEL can be used
    because it is a probe function and no spin_lock is taken.

    @@
    @@
    - PCI_DMA_BIDIRECTIONAL
    + DMA_BIDIRECTIONAL

    @@
    @@
    - PCI_DMA_TODEVICE
    + DMA_TO_DEVICE

    @@
    @@
    - PCI_DMA_FROMDEVICE
    + DMA_FROM_DEVICE

    @@
    @@
    - PCI_DMA_NONE
    + DMA_NONE

    @@
    expression e1, e2, e3;
    @@
    - pci_alloc_consistent(e1, e2, e3)
    + dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

    @@
    expression e1, e2, e3;
    @@
    - pci_zalloc_consistent(e1, e2, e3)
    + dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_free_consistent(e1, e2, e3, e4)
    + dma_free_coherent(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_map_single(e1, e2, e3, e4)
    + dma_map_single(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_unmap_single(e1, e2, e3, e4)
    + dma_unmap_single(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4, e5;
    @@
    - pci_map_page(e1, e2, e3, e4, e5)
    + dma_map_page(&e1->dev, e2, e3, e4, e5)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_unmap_page(e1, e2, e3, e4)
    + dma_unmap_page(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_map_sg(e1, e2, e3, e4)
    + dma_map_sg(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_unmap_sg(e1, e2, e3, e4)
    + dma_unmap_sg(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
    + dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_single_for_device(e1, e2, e3, e4)
    + dma_sync_single_for_device(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
    + dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_sg_for_device(e1, e2, e3, e4)
    + dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2;
    @@
    - pci_dma_mapping_error(e1, e2)
    + dma_mapping_error(&e1->dev, e2)

    @@
    expression e1, e2;
    @@
    - pci_set_dma_mask(e1, e2)
    + dma_set_mask(&e1->dev, e2)

    @@
    expression e1, e2;
    @@
    - pci_set_consistent_dma_mask(e1, e2)
    + dma_set_coherent_mask(&e1->dev, e2)

    Signed-off-by: Christophe JAILLET
    Signed-off-by: Herbert Xu

    Christophe JAILLET
     

20 Aug, 2020

1 commit

  • The header file algapi.h includes skbuff.h unnecessarily since
    all we need is a forward declaration for struct sk_buff. This
    patch removes that inclusion.

    Unfortunately skbuff.h pulls in a lot of things and drivers over
    the years have come to rely on it so this patch adds a lot of
    missing inclusions that result from this.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

19 Aug, 2020

1 commit

  • This patch moves crypto_yield into internal.h as it's only used
    by internal code such as skcipher. It also adds a missing inclusion
    of sched.h which is required for cond_resched.

    The header files in internal.h have been cleaned up to remove some
    ancient junk and add some more specific inclusions.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

17 Aug, 2020

2 commits

  • Linus Torvalds
     
  • Pull io_uring fixes from Jens Axboe:
    "A few differerent things in here.

    Seems like syzbot got some more io_uring bits wired up, and we got a
    handful of reports and the associated fixes are in here.

    General fixes too, and a lot of them marked for stable.

    Lastly, a bit of fallout from the async buffered reads, where we now
    more easily trigger short reads. Some applications don't really like
    that, so the io_read() code now handles short reads internally, and
    got a cleanup along the way so that it's now easier to read (and
    documented). We're now passing tests that failed before"

    * tag 'io_uring-5.9-2020-08-15' of git://git.kernel.dk/linux-block:
    io_uring: short circuit -EAGAIN for blocking read attempt
    io_uring: sanitize double poll handling
    io_uring: internally retry short reads
    io_uring: retain iov_iter state over io_read/io_write calls
    task_work: only grab task signal lock when needed
    io_uring: enable lookup of links holding inflight files
    io_uring: fail poll arm on queue proc failure
    io_uring: hold 'ctx' reference around task_work queue + execute
    fs: RWF_NOWAIT should imply IOCB_NOIO
    io_uring: defer file table grabbing request cleanup for locked requests
    io_uring: add missing REQ_F_COMP_LOCKED for nested requests
    io_uring: fix recursive completion locking on oveflow flush
    io_uring: use TWA_SIGNAL for task_work uncondtionally
    io_uring: account locked memory before potential error case
    io_uring: set ctx sq/cq entry count earlier
    io_uring: Fix NULL pointer dereference in loop_rw_iter()
    io_uring: add comments on how the async buffered read retry works
    io_uring: io_async_buf_func() need not test page bit

    Linus Torvalds