1. 16 Nov, 2020 1 commit
  2. 13 Nov, 2020 1 commit
  3. 12 Nov, 2020 6 commits
    • Mark Brown's avatar
      Merge series "Use-after-free be gone" from Lukas Wunner <lukas@wunner.de>: · c371dcf5
      Mark Brown authored
      Here's my proposal to fix the use-after-free bugs reported by
      Sascha Hauer and Florian Fainelli:
      
      I scrutinized all SPI drivers in the v5.10 tree:
      
      * There are 9 drivers with a use-after-free in the ->remove() hook
        caused by accessing driver private data after spi_unregister_controller().
      
      * There are 8 drivers which leak the spi_controller in the ->probe()
        error path because of a missing spi_controller_put().
      
      I'm introducing devm_spi_alloc_master/slave() which automatically
      calls spi_controller_put() on ->remove().  This fixes both classes
      of bugs while at the same time reducing code amount and complexity
      in the ->probe() hook.
      
      I propose that spi_controller_unregister() should no longer release
      a reference on the spi_controller.  Instead, drivers need to either
      do it themselves or use one of the devm functions introduced herein.
      The vast majority of drivers can be converted to the devm functions.
      See the commit message of patch [1/4] for the rationale and details.
      
      Enclosed are patches for 3 Broadcom drivers.
      Patches for the other drivers are on this branch:
      https://github.com/l1k/linux/commits/spi_fixes
      
      @Florian Fainelli:  Could you verify that there are no KASAN splats or
      leaks with these patches?  Unfortunately I do not have any SPI-capable
      hardware at my disposal right now, so can only compile-test.  You may
      want to augment spi_controller_release() with a printk() to log when
      the spi_controller is freed.
      
      @Mark Brown:  Patches [2/4] to [4/4] reference the SHA-1 of patch [1/4]
      in their stable tags.  Because the hash is unknown to me until you apply
      the patch, I've used "123456789abc" as a placeholder.  You'll have to
      replace the hash if/when applying.  Alternatively, only apply patch [1/4]
      and I'll repost the other patches with the hash fixed up.
      
      Thanks!
      
      Lukas Wunner (4):
        spi: Introduce device-managed SPI controller allocation
        spi: bcm2835: Fix use-after-free on unbind
        spi: bcm2835aux: Fix use-after-free on unbind
        spi: bcm-qspi: Fix use-after-free on unbind
      
       drivers/spi/spi-bcm-qspi.c   | 34 ++++++++-------------
       drivers/spi/spi-bcm2835.c    | 24 +++++----------
       drivers/spi/spi-bcm2835aux.c | 21 +++++--------
       drivers/spi/spi.c            | 58 +++++++++++++++++++++++++++++++++++-
       include/linux/spi/spi.h      | 19 ++++++++++++
       5 files changed, 103 insertions(+), 53 deletions(-)
      
      --
      2.28.0
      c371dcf5
    • Lukas Wunner's avatar
      spi: lpspi: Fix use-after-free on unbind · 4def49da
      Lukas Wunner authored
      Normally the last reference on an spi_controller is released by
      spi_unregister_controller().  In the case of the i.MX lpspi driver,
      the spi_controller is registered with devm_spi_register_controller(),
      so spi_unregister_controller() is invoked automatically after the driver
      has unbound.
      
      However the driver already releases the last reference in
      fsl_lpspi_remove() through a gratuitous call to spi_master_put(),
      causing a use-after-free when spi_unregister_controller() is
      subsequently invoked by the devres framework.
      
      Fix by dropping the superfluous spi_master_put().
      
      Fixes: 944c01a8 ("spi: lpspi: enable runtime pm for lpspi")
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Cc: <stable@vger.kernel.org> # v5.2+
      Cc: Han Xu <han.xu@nxp.com>
      Link: https://lore.kernel.org/r/ab3c0b18bd820501a12c85e440006e09ec0e275f.1604874488.git.lukas@wunner.deSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      4def49da
    • Lukas Wunner's avatar
      spi: bcm-qspi: Fix use-after-free on unbind · 63c5395b
      Lukas Wunner authored
      bcm_qspi_remove() calls spi_unregister_master() even though
      bcm_qspi_probe() calls devm_spi_register_master().  The spi_master is
      therefore unregistered and freed twice on unbind.
      
      Moreover, since commit 0392727c ("spi: bcm-qspi: Handle clock probe
      deferral"), bcm_qspi_probe() leaks the spi_master allocation if the call
      to devm_clk_get_optional() fails.
      
      Fix by switching over to the new devm_spi_alloc_master() helper which
      keeps the private data accessible until the driver has unbound and also
      avoids the spi_master leak on probe.
      
      While at it, fix an ordering issue in bcm_qspi_remove() wherein
      spi_unregister_master() is called after uninitializing the hardware,
      disabling the clock and freeing an IRQ data structure.  The correct
      order is to call spi_unregister_master() *before* those teardown steps
      because bus accesses may still be ongoing until that function returns.
      
      Fixes: fa236a7e ("spi: bcm-qspi: Add Broadcom MSPI driver")
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Cc: <stable@vger.kernel.org> # v4.9+: 123456789abc: spi: Introduce device-managed SPI controller allocation
      Cc: <stable@vger.kernel.org> # v4.9+
      Cc: Kamal Dasu <kdasu.kdev@gmail.com>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/5e31a9a59fd1c0d0b795b2fe219f25e5ee855f9d.1605121038.git.lukas@wunner.deSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      63c5395b
    • Lukas Wunner's avatar
      spi: bcm2835aux: Fix use-after-free on unbind · e13ee6cc
      Lukas Wunner authored
      bcm2835aux_spi_remove() accesses the driver's private data after calling
      spi_unregister_master() even though that function releases the last
      reference on the spi_master and thereby frees the private data.
      
      Fix by switching over to the new devm_spi_alloc_master() helper which
      keeps the private data accessible until the driver has unbound.
      
      Fixes: b9dd3f6d ("spi: bcm2835aux: Fix controller unregister order")
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Cc: <stable@vger.kernel.org> # v4.4+: 123456789abc: spi: Introduce device-managed SPI controller allocation
      Cc: <stable@vger.kernel.org> # v4.4+: b9dd3f6d: spi: bcm2835aux: Fix controller unregister order
      Cc: <stable@vger.kernel.org> # v4.4+
      Link: https://lore.kernel.org/r/b290b06357d0c0bdee9cecc539b840a90630f101.1605121038.git.lukas@wunner.deSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      e13ee6cc
    • Lukas Wunner's avatar
      spi: bcm2835: Fix use-after-free on unbind · e1483ac0
      Lukas Wunner authored
      bcm2835_spi_remove() accesses the driver's private data after calling
      spi_unregister_controller() even though that function releases the last
      reference on the spi_controller and thereby frees the private data.
      
      Fix by switching over to the new devm_spi_alloc_master() helper which
      keeps the private data accessible until the driver has unbound.
      
      Fixes: f8043872 ("spi: add driver for BCM2835")
      Reported-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
      Reported-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Cc: <stable@vger.kernel.org> # v3.10+: 123456789abc: spi: Introduce device-managed SPI controller allocation
      Cc: <stable@vger.kernel.org> # v3.10+
      Cc: Vladimir Oltean <olteanv@gmail.com>
      Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/ad66e0a0ad96feb848814842ecf5b6a4539ef35c.1605121038.git.lukas@wunner.deSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      e1483ac0
    • Lukas Wunner's avatar
      spi: Introduce device-managed SPI controller allocation · 5e844cc3
      Lukas Wunner authored
      SPI driver probing currently comprises two steps, whereas removal
      comprises only one step:
      
          spi_alloc_master()
          spi_register_controller()
      
          spi_unregister_controller()
      
      That's because spi_unregister_controller() calls device_unregister()
      instead of device_del(), thereby releasing the reference on the
      spi_controller which was obtained by spi_alloc_master().
      
      An SPI driver's private data is contained in the same memory allocation
      as the spi_controller struct.  Thus, once spi_unregister_controller()
      has been called, the private data is inaccessible.  But some drivers
      need to access it after spi_unregister_controller() to perform further
      teardown steps.
      
      Introduce devm_spi_alloc_master() and devm_spi_alloc_slave(), which
      release a reference on the spi_controller struct only after the driver
      has unbound, thereby keeping the memory allocation accessible.  Change
      spi_unregister_controller() to not release a reference if the
      spi_controller was allocated by one of these new devm functions.
      
      The present commit is small enough to be backportable to stable.
      It allows fixing drivers which use the private data in their ->remove()
      hook after it's been freed.  It also allows fixing drivers which neglect
      to release a reference on the spi_controller in the probe error path.
      
      Long-term, most SPI drivers shall be moved over to the devm functions
      introduced herein.  The few that can't shall be changed in a treewide
      commit to explicitly release the last reference on the controller.
      That commit shall amend spi_unregister_controller() to no longer release
      a reference, thereby completing the migration.
      
      As a result, the behaviour will be less surprising and more consistent
      with subsystems such as IIO, which also includes the private data in the
      allocation of the generic iio_dev struct, but calls device_del() in
      iio_device_unregister().
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Link: https://lore.kernel.org/r/272bae2ef08abd21388c98e23729886663d19192.1605121038.git.lukas@wunner.deSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      5e844cc3
  4. 11 Nov, 2020 2 commits
  5. 06 Nov, 2020 1 commit
  6. 04 Nov, 2020 1 commit
  7. 29 Oct, 2020 1 commit
  8. 28 Oct, 2020 1 commit
  9. 25 Oct, 2020 17 commits
  10. 24 Oct, 2020 9 commits
    • Linus Torvalds's avatar
      Merge tag 'block-5.10-2020-10-24' of git://git.kernel.dk/linux-block · d7691390
      Linus Torvalds authored
      Pull block fixes from Jens Axboe:
      
       - NVMe pull request from Christoph
           - rdma error handling fixes (Chao Leng)
           - fc error handling and reconnect fixes (James Smart)
           - fix the qid displace when tracing ioctl command (Keith Busch)
           - don't use BLK_MQ_REQ_NOWAIT for passthru (Chaitanya Kulkarni)
           - fix MTDT for passthru (Logan Gunthorpe)
           - blacklist Write Same on more devices (Kai-Heng Feng)
           - fix an uninitialized work struct (zhenwei pi)"
      
       - lightnvm out-of-bounds fix (Colin)
      
       - SG allocation leak fix (Doug)
      
       - rnbd fixes (Gioh, Guoqing, Jack)
      
       - zone error translation fixes (Keith)
      
       - kerneldoc markup fix (Mauro)
      
       - zram lockdep fix (Peter)
      
       - Kill unused io_context members (Yufen)
      
       - NUMA memory allocation cleanup (Xianting)
      
       - NBD config wakeup fix (Xiubo)
      
      * tag 'block-5.10-2020-10-24' of git://git.kernel.dk/linux-block: (27 commits)
        block: blk-mq: fix a kernel-doc markup
        nvme-fc: shorten reconnect delay if possible for FC
        nvme-fc: wait for queues to freeze before calling update_hr_hw_queues
        nvme-fc: fix error loop in create_hw_io_queues
        nvme-fc: fix io timeout to abort I/O
        null_blk: use zone status for max active/open
        nvmet: don't use BLK_MQ_REQ_NOWAIT for passthru
        nvmet: cleanup nvmet_passthru_map_sg()
        nvmet: limit passthru MTDS by BIO_MAX_PAGES
        nvmet: fix uninitialized work for zero kato
        nvme-pci: disable Write Zeroes on Sandisk Skyhawk
        nvme: use queuedata for nvme_req_qid
        nvme-rdma: fix crash due to incorrect cqe
        nvme-rdma: fix crash when connect rejected
        block: remove unused members for io_context
        blk-mq: remove the calling of local_memory_node()
        zram: Fix __zram_bvec_{read,write}() locking order
        skd_main: remove unused including <linux/version.h>
        sgl_alloc_order: fix memory leak
        lightnvm: fix out-of-bounds write to array devices->info[]
        ...
      d7691390
    • Linus Torvalds's avatar
      Merge tag 'io_uring-5.10-2020-10-24' of git://git.kernel.dk/linux-block · af004187
      Linus Torvalds authored
      Pull io_uring fixes from Jens Axboe:
      
       - fsize was missed in previous unification of work flags
      
       - Few fixes cleaning up the flags unification creds cases (Pavel)
      
       - Fix NUMA affinities for completely unplugged/replugged node for io-wq
      
       - Two fallout fixes from the set_fs changes. One local to io_uring, one
         for the splice entry point that io_uring uses.
      
       - Linked timeout fixes (Pavel)
      
       - Removal of ->flush() ->files work-around that we don't need anymore
         with referenced files (Pavel)
      
       - Various cleanups (Pavel)
      
      * tag 'io_uring-5.10-2020-10-24' of git://git.kernel.dk/linux-block:
        splice: change exported internal do_splice() helper to take kernel offset
        io_uring: make loop_rw_iter() use original user supplied pointers
        io_uring: remove req cancel in ->flush()
        io-wq: re-set NUMA node affinities if CPUs come online
        io_uring: don't reuse linked_timeout
        io_uring: unify fsize with def->work_flags
        io_uring: fix racy REQ_F_LINK_TIMEOUT clearing
        io_uring: do poll's hash_node init in common code
        io_uring: inline io_poll_task_handler()
        io_uring: remove extra ->file check in poll prep
        io_uring: make cached_cq_overflow non atomic_t
        io_uring: inline io_fail_links()
        io_uring: kill ref get/drop in personality init
        io_uring: flags-based creds init in queue
      af004187
    • Linus Torvalds's avatar
      Merge tag 'libata-5.10-2020-10-24' of git://git.kernel.dk/linux-block · cb6b2897
      Linus Torvalds authored
      Pull libata fixes from Jens Axboe:
       "Two minor libata fixes:
      
         - Fix a DMA boundary mask regression for sata_rcar (Geert)
      
         - kerneldoc markup fix (Mauro)"
      
      * tag 'libata-5.10-2020-10-24' of git://git.kernel.dk/linux-block:
        ata: fix some kernel-doc markups
        ata: sata_rcar: Fix DMA boundary mask
      cb6b2897
    • Linus Torvalds's avatar
      Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · 0eac1102
      Linus Torvalds authored
      Pull misc vfs updates from Al Viro:
       "Assorted stuff all over the place (the largest group here is
        Christoph's stat cleanups)"
      
      * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
        fs: remove KSTAT_QUERY_FLAGS
        fs: remove vfs_stat_set_lookup_flags
        fs: move vfs_fstatat out of line
        fs: implement vfs_stat and vfs_lstat in terms of vfs_fstatat
        fs: remove vfs_statx_fd
        fs: omfs: use kmemdup() rather than kmalloc+memcpy
        [PATCH] reduce boilerplate in fsid handling
        fs: Remove duplicated flag O_NDELAY occurring twice in VALID_OPEN_FLAGS
        selftests: mount: add nosymfollow tests
        Add a "nosymfollow" mount option.
      0eac1102
    • Linus Torvalds's avatar
      Merge tag 'dma-mapping-5.10-1' of git://git.infradead.org/users/hch/dma-mapping · 1b307ac8
      Linus Torvalds authored
      Pull dma-mapping fixes from Christoph Hellwig:
      
       - document the new dma_{alloc,free}_pages() API
      
       - two fixups for the dma-mapping.h split
      
      * tag 'dma-mapping-5.10-1' of git://git.infradead.org/users/hch/dma-mapping:
        dma-mapping: document dma_{alloc,free}_pages
        dma-mapping: move more functions to dma-map-ops.h
        ARM/sa1111: add a missing include of dma-map-ops.h
      1b307ac8
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 9bf8d8bc
      Linus Torvalds authored
      Pull KVM fixes from Paolo Bonzini:
       "Two fixes for this merge window, and an unrelated bugfix for a host
        hang"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: ioapic: break infinite recursion on lazy EOI
        KVM: vmx: rename pi_init to avoid conflict with paride
        KVM: x86/mmu: Avoid modulo operator on 64-bit value to fix i386 build
      9bf8d8bc
    • Linus Torvalds's avatar
      Merge tag 'x86_seves_fixes_for_v5.10_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · c51ae124
      Linus Torvalds authored
      Pull x86 SEV-ES fixes from Borislav Petkov:
       "Three fixes to SEV-ES to correct setting up the new early pagetable on
        5-level paging machines, to always map boot_params and the kernel
        cmdline, and disable stack protector for ../compressed/head{32,64}.c.
        (Arvind Sankar)"
      
      * tag 'x86_seves_fixes_for_v5.10_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/boot/64: Explicitly map boot_params and command line
        x86/head/64: Disable stack protection for head$(BITS).o
        x86/boot/64: Initialize 5-level paging variables earlier
      c51ae124
    • Willy Tarreau's avatar
      random32: add a selftest for the prandom32 code · c6e169bc
      Willy Tarreau authored
      Given that this code is new, let's add a selftest for it as well.
      It doesn't rely on fixed sets, instead it picks 1024 numbers and
      verifies that they're not more correlated than desired.
      
      Link: https://lore.kernel.org/netdev/20200808152628.GA27941@SDF.ORG/
      Cc: George Spelvin <lkml@sdf.org>
      Cc: Amit Klein <aksecurity@gmail.com>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: tytso@mit.edu
      Cc: Florian Westphal <fw@strlen.de>
      Cc: Marc Plumb <lkml.mplumb@gmail.com>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      c6e169bc
    • Willy Tarreau's avatar
      random32: add noise from network and scheduling activity · 3744741a
      Willy Tarreau authored
      With the removal of the interrupt perturbations in previous random32
      change (random32: make prandom_u32() output unpredictable), the PRNG
      has become 100% deterministic again. While SipHash is expected to be
      way more robust against brute force than the previous Tausworthe LFSR,
      there's still the risk that whoever has even one temporary access to
      the PRNG's internal state is able to predict all subsequent draws till
      the next reseed (roughly every minute). This may happen through a side
      channel attack or any data leak.
      
      This patch restores the spirit of commit f227e3ec ("random32: update
      the net random state on interrupt and activity") in that it will perturb
      the internal PRNG's statee using externally collected noise, except that
      it will not pick that noise from the random pool's bits nor upon
      interrupt, but will rather combine a few elements along the Tx path
      that are collectively hard to predict, such as dev, skb and txq
      pointers, packet length and jiffies values. These ones are combined
      using a single round of SipHash into a single long variable that is
      mixed with the net_rand_state upon each invocation.
      
      The operation was inlined because it produces very small and efficient
      code, typically 3 xor, 2 add and 2 rol. The performance was measured
      to be the same (even very slightly better) than before the switch to
      SipHash; on a 6-core 12-thread Core i7-8700k equipped with a 40G NIC
      (i40e), the connection rate dropped from 556k/s to 555k/s while the
      SYN cookie rate grew from 5.38 Mpps to 5.45 Mpps.
      
      Link: https://lore.kernel.org/netdev/20200808152628.GA27941@SDF.ORG/
      Cc: George Spelvin <lkml@sdf.org>
      Cc: Amit Klein <aksecurity@gmail.com>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: tytso@mit.edu
      Cc: Florian Westphal <fw@strlen.de>
      Cc: Marc Plumb <lkml.mplumb@gmail.com>
      Tested-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      3744741a