31 Aug, 2020

1 commit

  • Pull crypto fixes from Herbert Xu:

    - fix regression in af_alg that affects iwd

    - restore polling delay in qat

    - fix double free in ingenic on error path

    - fix potential build failure in sa2ul due to missing Kconfig dependency

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
    crypto: af_alg - Work around empty control messages without MSG_MORE
    crypto: sa2ul - add Kconfig selects to fix build error
    crypto: ingenic - Drop kfree for memory allocated with devm_kzalloc
    crypto: qat - add delay before polling mailbox

    Linus Torvalds
     

27 Aug, 2020

1 commit

  • The iwd daemon uses libell which sets up the skcipher operation with
    two separate control messages. As the first control message is sent
    without MSG_MORE, it is interpreted as an empty request.

    While libell should be fixed to use MSG_MORE where appropriate, this
    patch works around the bug in the kernel so that existing binaries
    continue to work.

    We will print a warning however.

    A separate issue is that the new kernel code no longer allows the
    control message to be sent twice within the same request. This
    restriction is obviously incompatible with what iwd was doing (first
    setting an IV and then sending the real control message). This
    patch changes the kernel so that this is explicitly allowed.

    Reported-by: Caleb Jorden
    Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when...")
    Cc:
    Signed-off-by: Herbert Xu

    Herbert Xu
     

24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

15 Aug, 2020

1 commit


13 Aug, 2020

1 commit

  • In skcipher_accept_parent_nokey() the whole af_alg_ctx structure is
    cleared by memset() after allocation, so add such memset() also to
    aead_accept_parent_nokey() so that the new "init" field is also
    initialized to zero. Without that the initial ctx->init checks might
    randomly return true and cause errors.

    While there, also remove the redundant zero assignments in both
    functions.

    Found via libkcapi testsuite.

    Cc: Stephan Mueller
    Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when ctx->more is zero")
    Suggested-by: Herbert Xu
    Signed-off-by: Ondrej Mosnacek
    Signed-off-by: Herbert Xu

    Ondrej Mosnacek
     

08 Aug, 2020

1 commit

  • As said by Linus:

    A symmetric naming is only helpful if it implies symmetries in use.
    Otherwise it's actively misleading.

    In "kzalloc()", the z is meaningful and an important part of what the
    caller wants.

    In "kzfree()", the z is actively detrimental, because maybe in the
    future we really _might_ want to use that "memfill(0xdeadbeef)" or
    something. The "zero" part of the interface isn't even _relevant_.

    The main reason that kzfree() exists is to clear sensitive information
    that should not be leaked to other future users of the same memory
    objects.

    Rename kzfree() to kfree_sensitive() to follow the example of the recently
    added kvfree_sensitive() and make the intention of the API more explicit.
    In addition, memzero_explicit() is used to clear the memory to make sure
    that it won't get optimized away by the compiler.

    The renaming is done by using the command sequence:

    git grep -w --name-only kzfree |\
    xargs sed -i 's/kzfree/kfree_sensitive/'

    followed by some editing of the kfree_sensitive() kerneldoc and adding
    a kzfree backward compatibility macro in slab.h.

    [akpm@linux-foundation.org: fs/crypto/inline_crypt.c needs linux/slab.h]
    [akpm@linux-foundation.org: fix fs/crypto/inline_crypt.c some more]

    Suggested-by: Joe Perches
    Signed-off-by: Waiman Long
    Signed-off-by: Andrew Morton
    Acked-by: David Howells
    Acked-by: Michal Hocko
    Acked-by: Johannes Weiner
    Cc: Jarkko Sakkinen
    Cc: James Morris
    Cc: "Serge E. Hallyn"
    Cc: Joe Perches
    Cc: Matthew Wilcox
    Cc: David Rientjes
    Cc: Dan Carpenter
    Cc: "Jason A . Donenfeld"
    Link: http://lkml.kernel.org/r/20200616154311.12314-3-longman@redhat.com
    Signed-off-by: Linus Torvalds

    Waiman Long
     

07 Aug, 2020

1 commit

  • Pull sched/fifo updates from Ingo Molnar:
    "This adds the sched_set_fifo*() encapsulation APIs to remove static
    priority level knowledge from non-scheduler code.

    The three APIs for non-scheduler code to set SCHED_FIFO are:

    - sched_set_fifo()
    - sched_set_fifo_low()
    - sched_set_normal()

    These are two FIFO priority levels: default (high), and a 'low'
    priority level, plus sched_set_normal() to set the policy back to
    non-SCHED_FIFO.

    Since the changes affect a lot of non-scheduler code, we kept this in
    a separate tree"

    * tag 'sched-fifo-2020-08-04' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (24 commits)
    sched,tracing: Convert to sched_set_fifo()
    sched: Remove sched_set_*() return value
    sched: Remove sched_setscheduler*() EXPORTs
    sched,psi: Convert to sched_set_fifo_low()
    sched,rcutorture: Convert to sched_set_fifo_low()
    sched,rcuperf: Convert to sched_set_fifo_low()
    sched,locktorture: Convert to sched_set_fifo()
    sched,irq: Convert to sched_set_fifo()
    sched,watchdog: Convert to sched_set_fifo()
    sched,serial: Convert to sched_set_fifo()
    sched,powerclamp: Convert to sched_set_fifo()
    sched,ion: Convert to sched_set_normal()
    sched,powercap: Convert to sched_set_fifo*()
    sched,spi: Convert to sched_set_fifo*()
    sched,mmc: Convert to sched_set_fifo*()
    sched,ivtv: Convert to sched_set_fifo*()
    sched,drm/scheduler: Convert to sched_set_fifo*()
    sched,msm: Convert to sched_set_fifo*()
    sched,psci: Convert to sched_set_fifo*()
    sched,drbd: Convert to sched_set_fifo*()
    ...

    Linus Torvalds
     

06 Aug, 2020

1 commit

  • Pull networking updates from David Miller:

    1) Support 6Ghz band in ath11k driver, from Rajkumar Manoharan.

    2) Support UDP segmentation in code TSO code, from Eric Dumazet.

    3) Allow flashing different flash images in cxgb4 driver, from Vishal
    Kulkarni.

    4) Add drop frames counter and flow status to tc flower offloading,
    from Po Liu.

    5) Support n-tuple filters in cxgb4, from Vishal Kulkarni.

    6) Various new indirect call avoidance, from Eric Dumazet and Brian
    Vazquez.

    7) Fix BPF verifier failures on 32-bit pointer arithmetic, from
    Yonghong Song.

    8) Support querying and setting hardware address of a port function via
    devlink, use this in mlx5, from Parav Pandit.

    9) Support hw ipsec offload on bonding slaves, from Jarod Wilson.

    10) Switch qca8k driver over to phylink, from Jonathan McDowell.

    11) In bpftool, show list of processes holding BPF FD references to
    maps, programs, links, and btf objects. From Andrii Nakryiko.

    12) Several conversions over to generic power management, from Vaibhav
    Gupta.

    13) Add support for SO_KEEPALIVE et al. to bpf_setsockopt(), from Dmitry
    Yakunin.

    14) Various https url conversions, from Alexander A. Klimov.

    15) Timestamping and PHC support for mscc PHY driver, from Antoine
    Tenart.

    16) Support bpf iterating over tcp and udp sockets, from Yonghong Song.

    17) Support 5GBASE-T i40e NICs, from Aleksandr Loktionov.

    18) Add kTLS RX HW offload support to mlx5e, from Tariq Toukan.

    19) Fix the ->ndo_start_xmit() return type to be netdev_tx_t in several
    drivers. From Luc Van Oostenryck.

    20) XDP support for xen-netfront, from Denis Kirjanov.

    21) Support receive buffer autotuning in MPTCP, from Florian Westphal.

    22) Support EF100 chip in sfc driver, from Edward Cree.

    23) Add XDP support to mvpp2 driver, from Matteo Croce.

    24) Support MPTCP in sock_diag, from Paolo Abeni.

    25) Commonize UDP tunnel offloading code by creating udp_tunnel_nic
    infrastructure, from Jakub Kicinski.

    26) Several pci_ --> dma_ API conversions, from Christophe JAILLET.

    27) Add FLOW_ACTION_POLICE support to mlxsw, from Ido Schimmel.

    28) Add SK_LOOKUP bpf program type, from Jakub Sitnicki.

    29) Refactor a lot of networking socket option handling code in order to
    avoid set_fs() calls, from Christoph Hellwig.

    30) Add rfc4884 support to icmp code, from Willem de Bruijn.

    31) Support TBF offload in dpaa2-eth driver, from Ioana Ciornei.

    32) Support XDP_REDIRECT in qede driver, from Alexander Lobakin.

    33) Support PCI relaxed ordering in mlx5 driver, from Aya Levin.

    34) Support TCP syncookies in MPTCP, from Flowian Westphal.

    35) Fix several tricky cases of PMTU handling wrt. briding, from Stefano
    Brivio.

    * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (2056 commits)
    net: thunderx: initialize VF's mailbox mutex before first usage
    usb: hso: remove bogus check for EINPROGRESS
    usb: hso: no complaint about kmalloc failure
    hso: fix bailout in error case of probe
    ip_tunnel_core: Fix build for archs without _HAVE_ARCH_IPV6_CSUM
    selftests/net: relax cpu affinity requirement in msg_zerocopy test
    mptcp: be careful on subflow creation
    selftests: rtnetlink: make kci_test_encap() return sub-test result
    selftests: rtnetlink: correct the final return value for the test
    net: dsa: sja1105: use detected device id instead of DT one on mismatch
    tipc: set ub->ifindex for local ipv6 address
    ipv6: add ipv6_dev_find()
    net: openvswitch: silence suspicious RCU usage warning
    Revert "vxlan: fix tos value before xmit"
    ptp: only allow phase values lower than 1 period
    farsync: switch from 'pci_' to 'dma_' API
    wan: wanxl: switch from 'pci_' to 'dma_' API
    hv_netvsc: do not use VF device if link is down
    dpaa2-eth: Fix passing zero to 'PTR_ERR' warning
    net: macb: Properly handle phylink on at91sam9x
    ...

    Linus Torvalds
     

05 Aug, 2020

1 commit

  • Pull documentation updates from Jonathan Corbet:
    "It's been a busy cycle for documentation - hopefully the busiest for a
    while to come. Changes include:

    - Some new Chinese translations

    - Progress on the battle against double words words and non-HTTPS
    URLs

    - Some block-mq documentation

    - More RST conversions from Mauro. At this point, that task is
    essentially complete, so we shouldn't see this kind of churn again
    for a while. Unless we decide to switch to asciidoc or
    something...:)

    - Lots of typo fixes, warning fixes, and more"

    * tag 'docs-5.9' of git://git.lwn.net/linux: (195 commits)
    scripts/kernel-doc: optionally treat warnings as errors
    docs: ia64: correct typo
    mailmap: add entry for
    doc/zh_CN: add cpu-load Chinese version
    Documentation/admin-guide: tainted-kernels: fix spelling mistake
    MAINTAINERS: adjust kprobes.rst entry to new location
    devices.txt: document rfkill allocation
    PCI: correct flag name
    docs: filesystems: vfs: correct flag name
    docs: filesystems: vfs: correct sync_mode flag names
    docs: path-lookup: markup fixes for emphasis
    docs: path-lookup: more markup fixes
    docs: path-lookup: fix HTML entity mojibake
    CREDITS: Replace HTTP links with HTTPS ones
    docs: process: Add an example for creating a fixes tag
    doc/zh_CN: add Chinese translation prefer section
    doc/zh_CN: add clearing-warn-once Chinese version
    doc/zh_CN: add admin-guide index
    doc:it_IT: process: coding-style.rst: Correct __maybe_unused compiler label
    futex: MAINTAINERS: Re-add selftests directory
    ...

    Linus Torvalds
     

04 Aug, 2020

1 commit

  • Pull crypto updates from Herbert Xu:
    "API:
    - Add support for allocating transforms on a specific NUMA Node
    - Introduce the flag CRYPTO_ALG_ALLOCATES_MEMORY for storage users

    Algorithms:
    - Drop PMULL based ghash on arm64
    - Fixes for building with clang on x86
    - Add sha256 helper that does the digest in one go
    - Add SP800-56A rev 3 validation checks to dh

    Drivers:
    - Permit users to specify NUMA node in hisilicon/zip
    - Add support for i.MX6 in imx-rngc
    - Add sa2ul crypto driver
    - Add BA431 hwrng driver
    - Add Ingenic JZ4780 and X1000 hwrng driver
    - Spread IRQ affinity in inside-secure and marvell/cesa"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (157 commits)
    crypto: sa2ul - Fix inconsistent IS_ERR and PTR_ERR
    hwrng: core - remove redundant initialization of variable ret
    crypto: x86/curve25519 - Remove unused carry variables
    crypto: ingenic - Add hardware RNG for Ingenic JZ4780 and X1000
    dt-bindings: RNG: Add Ingenic RNG bindings.
    crypto: caam/qi2 - add module alias
    crypto: caam - add more RNG hw error codes
    crypto: caam/jr - remove incorrect reference to caam_jr_register()
    crypto: caam - silence .setkey in case of bad key length
    crypto: caam/qi2 - create ahash shared descriptors only once
    crypto: caam/qi2 - fix error reporting for caam_hash_alloc
    crypto: caam - remove deadcode on 32-bit platforms
    crypto: ccp - use generic power management
    crypto: xts - Replace memcpy() invocation with simple assignment
    crypto: marvell/cesa - irq balance
    crypto: inside-secure - irq balance
    crypto: ecc - SP800-56A rev 3 local public key validation
    crypto: dh - SP800-56A rev 3 local public key validation
    crypto: dh - check validity of Z before export
    lib/mpi: Add mpi_sub_ui()
    ...

    Linus Torvalds
     

31 Jul, 2020

5 commits

  • Colin reports that the memcpy() call in xts_cts_final() trigggers a
    "Overlapping buffer in memory copy" warning in Coverity, which is a
    false postive, given that tail is guaranteed to be smaller than or
    equal to the distance between source and destination.

    However, given that any additional bytes that we copy will be ignored
    anyway, we can simply copy XTS_BLOCK_SIZE unconditionally, which means
    we can use struct assignment of the array members instead, which is
    likely to be more efficient as well.

    Addresses-Coverity: ("Overlapping buffer in memory copy")
    Fixes: 8083b1bf8163 ("crypto: xts - add support for ciphertext stealing")
    Reported-by: Colin Ian King
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • After the generation of a local public key, SP800-56A rev 3 section
    5.6.2.1.3 mandates a validation of that key with a full validation
    compliant to section 5.6.2.3.3.

    Only if the full validation passes, the key is allowed to be used.

    The patch adds the full key validation compliant to 5.6.2.3.3 and
    performs the required check on the generated public key.

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

    Stephan Müller
     
  • After the generation of a local public key, SP800-56A rev 3 section
    5.6.2.1.3 mandates a validation of that key with a full validation
    compliant to section 5.6.2.3.1.

    Only if the full validation passes, the key is allowed to be used.

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

    Stephan Müller
     
  • SP800-56A rev3 section 5.7.1.1 step 2 mandates that the validity of the
    calculated shared secret is verified before the data is returned to the
    caller. This patch adds the validation check.

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

    Stephan Müller
     
  • SP800-56A rev3 section 5.7.1.2 step 2 mandates that the validity of the
    calculated shared secret is verified before the data is returned to the
    caller. Thus, the export function and the validity check functions are
    reversed. In addition, the sensitive variables of priv and rand_z are
    zeroized.

    Signed-off-by: Stephan Mueller
    Reviewed-by: Vitaly Chikunov
    Acked-by: Neil Horman
    Signed-off-by: Herbert Xu

    Stephan Müller
     

26 Jul, 2020

1 commit

  • The UDP reuseport conflict was a little bit tricky.

    The net-next code, via bpf-next, extracted the reuseport handling
    into a helper so that the BPF sk lookup code could invoke it.

    At the same time, the logic for reuseport handling of unconnected
    sockets changed via commit efc6b6f6c3113e8b203b9debfb72d81e0f3dcace
    which changed the logic to carry on the reuseport result into the
    rest of the lookup loop if we do not return immediately.

    This requires moving the reuseport_has_conns() logic into the callers.

    While we are here, get rid of inline directives as they do not belong
    in foo.c files.

    The other changes were cases of more straightforward overlapping
    modifications.

    Signed-off-by: David S. Miller

    David S. Miller
     

25 Jul, 2020

1 commit

  • Rework the remaining setsockopt code to pass a sockptr_t instead of a
    plain user pointer. This removes the last remaining set_fs(KERNEL_DS)
    outside of architecture specific code.

    Signed-off-by: Christoph Hellwig
    Acked-by: Stefan Schmidt [ieee802154]
    Acked-by: Matthieu Baerts
    Signed-off-by: David S. Miller

    Christoph Hellwig
     

23 Jul, 2020

5 commits

  • Delete the doubled word "from" in multiple places.

    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
     
  • Rationale:
    Reduces attack surface on kernel devs opening the links for MITM
    as HTTPS traffic is much harder to manipulate.

    Deterministic algorithm:
    For each file:
    If not .svg:
    For each line:
    If doesn't contain `\bxmlns\b`:
    For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
    If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
    If both the HTTP and HTTPS versions
    return 200 OK and serve the same content:
    Replace HTTP with HTTPS.

    Signed-off-by: Alexander A. Klimov
    Signed-off-by: Herbert Xu

    Alexander A. Klimov
     
  • There's no reason to have two interfaces when there's only one caller.
    Removing _possible saves text and simplifies future changes.

    Signed-off-by: Daniel Jordan
    Cc: Herbert Xu
    Cc: Steffen Klassert
    Cc: linux-crypto@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Herbert Xu

    Daniel Jordan
     
  • padata_stop() has two callers and is unnecessary in both cases. When
    pcrypt calls it before padata_free(), it's being unloaded so there are
    no outstanding padata jobs[0]. When __padata_free() calls it, it's
    either along the same path or else pcrypt initialization failed, which
    of course means there are also no outstanding jobs.

    Removing it simplifies padata and saves text.

    [0] https://lore.kernel.org/linux-crypto/20191119225017.mjrak2fwa5vccazl@gondor.apana.org.au/

    Signed-off-by: Daniel Jordan
    Cc: Herbert Xu
    Cc: Steffen Klassert
    Cc: linux-crypto@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Herbert Xu

    Daniel Jordan
     
  • padata_start() is only used right after pcrypt allocates an instance
    with all possible CPUs, when PADATA_INVALID can't happen, so there's no
    need for a separate "start" step. It can be done during allocation to
    save text, make using padata easier, and avoid unneeded calls in the
    future.

    Signed-off-by: Daniel Jordan
    Cc: Herbert Xu
    Cc: Steffen Klassert
    Cc: linux-crypto@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Herbert Xu

    Daniel Jordan
     

20 Jul, 2020

1 commit


16 Jul, 2020

7 commits

  • Overly-generic names can cause problems like naming collisions,
    confusing crash reports, and reduced grep-ability. E.g. see
    commit d099ea6e6fde ("crypto - Avoid free() namespace collision").

    Clean this up for the lrw template by prefixing the names with "lrw_".

    (I didn't use "crypto_lrw_" instead because that seems overkill.)

    Also constify the tfm context in a couple places.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • Overly-generic names can cause problems like naming collisions,
    confusing crash reports, and reduced grep-ability. E.g. see
    commit d099ea6e6fde ("crypto - Avoid free() namespace collision").

    Clean this up for the xts template by prefixing the names with "xts_".

    (I didn't use "crypto_xts_" instead because that seems overkill.)

    Also constify the tfm context in a couple places, and make
    xts_free_instance() use the instance context structure so that it
    doesn't just assume the crypto_skcipher_spawn is at the beginning.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • CRYPTO_ALG_NEED_FALLBACK is handled inconsistently. When it's requested
    to be clear, some templates propagate that request to child algorithms,
    while others don't.

    It's apparently desired for NEED_FALLBACK to be propagated, to avoid
    deadlocks where a module tries to load itself while it's being
    initialized, and to avoid unnecessarily complex fallback chains where we
    have e.g. cbc-aes-$driver falling back to cbc(aes-$driver) where
    aes-$driver itself falls back to aes-generic, instead of cbc-aes-$driver
    simply falling back to cbc(aes-generic). There have been a number of
    fixes to this effect:

    commit 89027579bc6c ("crypto: xts - Propagate NEED_FALLBACK bit")
    commit d2c2a85cfe82 ("crypto: ctr - Propagate NEED_FALLBACK bit")
    commit e6c2e65c70a6 ("crypto: cbc - Propagate NEED_FALLBACK bit")

    But it seems that other templates can have the same problems too.

    To avoid this whack-a-mole, just add NEED_FALLBACK to INHERITED_FLAGS so
    that it's always inherited.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • The flag CRYPTO_ALG_ASYNC is "inherited" in the sense that when a
    template is instantiated, the template will have CRYPTO_ALG_ASYNC set if
    any of the algorithms it uses has CRYPTO_ALG_ASYNC set.

    We'd like to add a second flag (CRYPTO_ALG_ALLOCATES_MEMORY) that gets
    "inherited" in the same way. This is difficult because the handling of
    CRYPTO_ALG_ASYNC is hardcoded everywhere. Address this by:

    - Add CRYPTO_ALG_INHERITED_FLAGS, which contains the set of flags that
    have these inheritance semantics.

    - Add crypto_algt_inherited_mask(), for use by template ->create()
    methods. It returns any of these flags that the user asked to be
    unset and thus must be passed in the 'mask' to crypto_grab_*().

    - Also modify crypto_check_attr_type() to handle computing the 'mask'
    so that most templates can just use this.

    - Make crypto_grab_*() propagate these flags to the template instance
    being created so that templates don't have to do this themselves.

    Make crypto/simd.c propagate these flags too, since it "wraps" another
    algorithm, similar to a template.

    Based on a patch by Mikulas Patocka
    (https://lore.kernel.org/r/alpine.LRH.2.02.2006301414580.30526@file01.intranet.prod.int.rdu2.redhat.com).

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • seqiv_create() is pointless because it just checks that the template is
    being instantiated as an AEAD, then calls seqiv_aead_create(). But
    seqiv_aead_create() does the exact same check, via aead_geniv_alloc().

    Just remove seqiv_create() and use seqiv_aead_create() directly.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • The type and mask arguments to aead_geniv_alloc() are always 0, so
    remove them.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • Fix to return negative error code -ENOMEM from kmalloc() error handling
    case instead of 0, as done elsewhere in this function.

    Fixes: f1774cb8956a ("X.509: parse public key parameters from x509 for akcipher")
    Signed-off-by: Wei Yongjun
    Signed-off-by: David Howells
    Signed-off-by: Linus Torvalds

    Wei Yongjun
     

09 Jul, 2020

2 commits

  • 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
    Cc: Dan Streetman
    Cc: Vitaly Wool
    Cc: Andrew Morton
    Cc: Jonathan Cameron
    Signed-off-by: Barry Song
    Signed-off-by: Herbert Xu

    Barry Song
     
  • Some user-space programs rely on crypto requests that have no
    control metadata. This broke when a check was added to require
    the presence of control metadata with the ctx->init flag.

    This patch fixes the regression by setting ctx->init as long as
    one sendmsg(2) has been made, with or without a control message.

    Reported-by: Sachin Sant
    Reported-by: Naresh Kamboju
    Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when...")
    Signed-off-by: Herbert Xu

    Herbert Xu
     

20 Jun, 2020

1 commit

  • This file is almost compatible with ReST. Just minor changes
    were needed:

    - Adjust document and titles markups;
    - Adjust numbered list markups;
    - Add a comments markup for the Contents section;
    - Add markups for literal blocks.

    Acked-by: Jarkko Sakkinen
    Signed-off-by: Mauro Carvalho Chehab
    Link: https://lore.kernel.org/r/c2275ea94e0507a01b020ab66dfa824d8b1c2545.1592203650.git.mchehab+huawei@kernel.org
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

18 Jun, 2020

2 commits

  • AEAD does not support partial requests so we must not wake up
    while ctx->more is set. In order to distinguish between the
    case of no data sent yet and a zero-length request, a new init
    flag has been added to ctx.

    SKCIPHER has also been modified to ensure that at least a block
    of data is available if there is more data to come.

    Fixes: 2d97591ef43d ("crypto: af_alg - consolidation of...")
    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • The locking in af_alg_release_parent is broken as the BH socket
    lock can only be taken if there is a code-path to handle the case
    where the lock is owned by process-context. Instead of adding
    such handling, we can fix this by changing the ref counts to
    atomic_t.

    This patch also modifies the main refcnt to include both normal
    and nokey sockets. This way we don't have to fudge the nokey
    ref count when a socket changes from nokey to normal.

    Credits go to Mauricio Faria de Oliveira who diagnosed this bug
    and sent a patch for it:

    https://lore.kernel.org/linux-crypto/20200605161657.535043-1-mfo@canonical.com/

    Reported-by: Brian Moyles
    Reported-by: Mauricio Faria de Oliveira
    Fixes: 37f96694cf73 ("crypto: af_alg - Use bh_lock_sock in...")
    Cc:
    Signed-off-by: Herbert Xu

    Herbert Xu
     

15 Jun, 2020

4 commits

  • Because SCHED_FIFO is a broken scheduler model (see previous patches)
    take away the priority field, the kernel can't possibly make an
    informed decision.

    Use sched_set_fifo() to request SCHED_FIFO and delegate
    actual priority selection to userspace. Effectively no change in
    behaviour.

    Signed-off-by: Peter Zijlstra (Intel)
    Reviewed-by: Ingo Molnar
    Acked-by: Herbert Xu

    Peter Zijlstra
     
  • The Jitter RNG is unconditionally allocated as a seed source follwoing
    the patch 97f2650e5040. Thus, the instance must always be deallocated.

    Reported-by: syzbot+2e635807decef724a1fa@syzkaller.appspotmail.com
    Fixes: 97f2650e5040 ("crypto: drbg - always seeded with SP800-90B ...")
    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Müller
     
  • When a crypto template needs to be instantiated, CRYPTO_MSG_ALG_REQUEST
    is sent to crypto_chain. cryptomgr_schedule_probe() handles this by
    starting a thread to instantiate the template, then waiting for this
    thread to complete via crypto_larval::completion.

    This can deadlock because instantiating the template may require loading
    modules, and this (apparently depending on userspace) may need to wait
    for the crc-t10dif module (lib/crc-t10dif.c) to be loaded. But
    crc-t10dif's module_init function uses crypto_register_notifier() and
    therefore takes crypto_chain.rwsem for write. That can't proceed until
    the notifier callback has finished, as it holds this semaphore for read.

    Fix this by removing the wait on crypto_larval::completion from within
    cryptomgr_schedule_probe(). It's actually unnecessary because
    crypto_alg_mod_lookup() calls crypto_larval_wait() itself after sending
    CRYPTO_MSG_ALG_REQUEST.

    This only actually became a problem in v4.20 due to commit b76377543b73
    ("crc-t10dif: Pick better transform if one becomes available"), but the
    unnecessary wait was much older.

    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207159
    Reported-by: Mike Gerow
    Fixes: 398710379f51 ("crypto: algapi - Move larval completion into algboss")
    Cc: # v3.6+
    Cc: Martin K. Petersen
    Signed-off-by: Eric Biggers
    Reported-by: Kai Lüke
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • Somewhere along the line the cap on the SG list length for receive
    was lost. This patch restores it and removes the subsequent test
    which is now redundant.

    Fixes: 2d97591ef43d ("crypto: af_alg - consolidation of...")
    Cc:
    Signed-off-by: Herbert Xu
    Reviewed-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Herbert Xu
     

11 Jun, 2020

1 commit

  • Pull READ/WRITE_ONCE rework from Will Deacon:
    "This the READ_ONCE rework I've been working on for a while, which
    bumps the minimum GCC version and improves code-gen on arm64 when
    stack protector is enabled"

    [ Side note: I'm _really_ tempted to raise the minimum gcc version to
    4.9, so that we can just say that we require _Generic() support.

    That would allow us to more cleanly handle a lot of the cases where we
    depend on very complex macros with 'sizeof' or __builtin_choose_expr()
    with __builtin_types_compatible_p() etc.

    This branch has a workaround for sparse not handling _Generic(),
    either, but that was already fixed in the sparse development branch,
    so it's really just gcc-4.9 that we'd require. - Linus ]

    * 'rwonce/rework' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux:
    compiler_types.h: Use unoptimized __unqual_scalar_typeof for sparse
    compiler_types.h: Optimize __unqual_scalar_typeof compilation time
    compiler.h: Enforce that READ_ONCE_NOCHECK() access size is sizeof(long)
    compiler-types.h: Include naked type in __pick_integer_type() match
    READ_ONCE: Fix comment describing 2x32-bit atomicity
    gcov: Remove old GCC 3.4 support
    arm64: barrier: Use '__unqual_scalar_typeof' for acquire/release macros
    locking/barriers: Use '__unqual_scalar_typeof' for load-acquire macros
    READ_ONCE: Drop pointer qualifiers when reading from scalar types
    READ_ONCE: Enforce atomicity for {READ,WRITE}_ONCE() memory accesses
    READ_ONCE: Simplify implementations of {READ,WRITE}_ONCE()
    arm64: csum: Disable KASAN for do_csum()
    fault_inject: Don't rely on "return value" from WRITE_ONCE()
    net: tls: Avoid assigning 'const' pointer to non-const pointer
    netfilter: Avoid assigning 'const' pointer to non-const pointer
    compiler/gcc: Raise minimum GCC version for kernel builds to 4.8

    Linus Torvalds