1. 09 Mar, 2022 2 commits
    • Eric Biggers's avatar
      KEYS: asymmetric: properly validate hash_algo and encoding · 590bfb57
      Eric Biggers authored
      It is insecure to allow arbitrary hash algorithms and signature
      encodings to be used with arbitrary signature algorithms.  Notably,
      ECDSA, ECRDSA, and SM2 all sign/verify raw hash values and don't
      disambiguate between different hash algorithms like RSA PKCS#1 v1.5
      padding does.  Therefore, they need to be restricted to certain sets of
      hash algorithms (ideally just one, but in practice small sets are used).
      Additionally, the encoding is an integral part of modern signature
      algorithms, and is not supposed to vary.
      
      Therefore, tighten the checks of hash_algo and encoding done by
      software_key_determine_akcipher().
      
      Also rearrange the parameters to software_key_determine_akcipher() to
      put the public_key first, as this is the most important parameter and it
      often determines everything else.
      
      Fixes: 299f561a ("x509: Add support for parsing x509 certs with ECDSA keys")
      Fixes: 21552563 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
      Fixes: 0d7a7864 ("crypto: ecrdsa - add EC-RDSA (GOST 34.10) algorithm")
      Cc: stable@vger.kernel.org
      Tested-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Tested-by: default avatarTianjia Zhang <tianjia.zhang@linux.alibaba.com>
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Reviewed-by: default avatarVitaly Chikunov <vt@altlinux.org>
      Reviewed-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      590bfb57
    • Eric Biggers's avatar
      KEYS: asymmetric: enforce that sig algo matches key algo · 2abc9c24
      Eric Biggers authored
      Most callers of public_key_verify_signature(), including most indirect
      callers via verify_signature() as well as pkcs7_verify_sig_chain(),
      don't check that public_key_signature::pkey_algo matches
      public_key::pkey_algo.  These should always match.  However, a malicious
      signature could intentionally declare an unintended algorithm.  It is
      essential that such signatures be rejected outright, or that the
      algorithm of the *key* be used -- not the algorithm of the signature as
      that would allow attackers to choose the algorithm used.
      
      Currently, public_key_verify_signature() correctly uses the key's
      algorithm when deciding which akcipher to allocate.  That's good.
      However, it uses the signature's algorithm when deciding whether to do
      the first step of SM2, which is incorrect.  Also, v4.19 and older
      kernels used the signature's algorithm for the entire process.
      
      Prevent such errors by making public_key_verify_signature() enforce that
      the signature's algorithm (if given) matches the key's algorithm.
      
      Also remove two checks of this done by callers, which are now redundant.
      
      Cc: stable@vger.kernel.org
      Tested-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Tested-by: default avatarTianjia Zhang <tianjia.zhang@linux.alibaba.com>
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Reviewed-by: default avatarVitaly Chikunov <vt@altlinux.org>
      Reviewed-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      2abc9c24
  2. 08 Mar, 2022 21 commits
  3. 07 Mar, 2022 4 commits
    • Linus Torvalds's avatar
      Merge tag 'mtd/fixes-for-5.17-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux · ea4424be
      Linus Torvalds authored
      Pull MTD fix from Miquel Raynal:
       "As part of a previous changeset introducing support for the K3
        architecture, the OMAP_GPMC (a non visible symbol) got selected by the
        selection of MTD_NAND_OMAP2 instead of doing so from the architecture
        directly (like for the other users of these two drivers). Indeed, from
        a hardware perspective, the OMAP NAND controller needs the GPMC to
        work.
      
        This led to a robot error which got addressed in fix merge into -rc4.
        Unfortunately, the approach at this time still used "select" and lead
        to further build error reports (sparc64:allmodconfig).
      
        This time we switch to 'depends on' in order to prevent random
        misconfigurations. The different dependencies will however need a
        future cleanup"
      
      * tag 'mtd/fixes-for-5.17-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux:
        mtd: rawnand: omap2: Actually prevent invalid configuration and build error
      ea4424be
    • Linus Torvalds's avatar
      Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost · 06be3029
      Linus Torvalds authored
      Pull virtio fixes from Michael Tsirkin:
       "Some last minute fixes that took a while to get ready. Not
        regressions, but they look safe and seem to be worth to have"
      
      * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
        tools/virtio: handle fallout from folio work
        tools/virtio: fix virtio_test execution
        vhost: remove avail_event arg from vhost_update_avail_event()
        virtio: drop default for virtio-mem
        vdpa: fix use-after-free on vp_vdpa_remove
        virtio-blk: Remove BUG_ON() in virtio_queue_rq()
        virtio-blk: Don't use MAX_DISCARD_SEGMENTS if max_discard_seg is zero
        vhost: fix hung thread due to erroneous iotlb entries
        vduse: Fix returning wrong type in vduse_domain_alloc_iova()
        vdpa/mlx5: add validation for VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET command
        vdpa/mlx5: should verify CTRL_VQ feature exists for MQ
        vdpa: factor out vdpa_set_features_unlocked for vdpa internal use
        virtio_console: break out of buf poll on remove
        virtio: document virtio_reset_device
        virtio: acknowledge all features before access
        virtio: unexport virtio_finalize_features
      06be3029
    • Halil Pasic's avatar
      swiotlb: rework "fix info leak with DMA_FROM_DEVICE" · aa6f8dcb
      Halil Pasic authored
      Unfortunately, we ended up merging an old version of the patch "fix info
      leak with DMA_FROM_DEVICE" instead of merging the latest one. Christoph
      (the swiotlb maintainer), he asked me to create an incremental fix
      (after I have pointed this out the mix up, and asked him for guidance).
      So here we go.
      
      The main differences between what we got and what was agreed are:
      * swiotlb_sync_single_for_device is also required to do an extra bounce
      * We decided not to introduce DMA_ATTR_OVERWRITE until we have exploiters
      * The implantation of DMA_ATTR_OVERWRITE is flawed: DMA_ATTR_OVERWRITE
        must take precedence over DMA_ATTR_SKIP_CPU_SYNC
      
      Thus this patch removes DMA_ATTR_OVERWRITE, and makes
      swiotlb_sync_single_for_device() bounce unconditionally (that is, also
      when dir == DMA_TO_DEVICE) in order do avoid synchronising back stale
      data from the swiotlb buffer.
      
      Let me note, that if the size used with dma_sync_* API is less than the
      size used with dma_[un]map_*, under certain circumstances we may still
      end up with swiotlb not being transparent. In that sense, this is no
      perfect fix either.
      
      To get this bullet proof, we would have to bounce the entire
      mapping/bounce buffer. For that we would have to figure out the starting
      address, and the size of the mapping in
      swiotlb_sync_single_for_device(). While this does seem possible, there
      seems to be no firm consensus on how things are supposed to work.
      Signed-off-by: default avatarHalil Pasic <pasic@linux.ibm.com>
      Fixes: ddbd89de ("swiotlb: fix info leak with DMA_FROM_DEVICE")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      aa6f8dcb
    • Roger Quadros's avatar
      mtd: rawnand: omap2: Actually prevent invalid configuration and build error · 42da5a4b
      Roger Quadros authored
      The root of the problem is that we are selecting symbols that have
      dependencies. This can cause random configurations that can fail.
      The cleanest solution is to avoid using select.
      
      This driver uses interfaces from the OMAP_GPMC driver so we have to
      depend on it instead.
      
      Fixes: 4cd335da ("mtd: rawnand: omap2: Prevent invalid configuration and build error")
      Signed-off-by: default avatarRoger Quadros <rogerq@kernel.org>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Tested-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Link: https://lore.kernel.org/linux-mtd/20220219193600.24892-1-rogerq@kernel.org
      42da5a4b
  4. 06 Mar, 2022 13 commits