Skip to content
  1. Jul 25, 2020
    • Linus Torvalds's avatar
      Merge tag 'for-5.8-rc6-tag' of... · 06697042
      Linus Torvalds authored
      Merge tag 'for-5.8-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into master
      
      Pull btrfs fixes from David Sterba:
       "A few resouce leak fixes from recent patches, all are stable material.
      
        The problems have been observed during testing or have a reproducer"
      
      * tag 'for-5.8-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
        btrfs: fix mount failure caused by race with umount
        btrfs: fix page leaks after failure to lock page for delalloc
        btrfs: qgroup: fix data leak caused by race between writeback and truncate
        btrfs: fix double free on ulist after backref resolution failure
      06697042
    • Linus Torvalds's avatar
      Merge tag 'zonefs-5.8-rc7' of... · 6a343656
      Linus Torvalds authored
      Merge tag 'zonefs-5.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs into master
      
      Pull zonefs fixes from Damien Le Moal:
       "Two fixes, the first one to remove compilation warnings and the second
        to avoid potentially inefficient allocation of BIOs for direct writes
        into sequential zones"
      
      * tag 'zonefs-5.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs:
        zonefs: count pages after truncating the iterator
        zonefs: Fix compilation warning
      6a343656
    • Linus Torvalds's avatar
      Merge tag 'io_uring-5.8-2020-07-24' of git://git.kernel.dk/linux-block into master · 1f68f31b
      Linus Torvalds authored
      Pull io_uring fixes from Jens Axboe:
      
       - Fix discrepancy in how sqe->flags are treated for a few requests,
         this makes it consistent (Daniele)
      
       - Ensure that poll driven retry works with double waitqueue poll users
      
       - Fix a missing io_req_init_async() (Pavel)
      
      * tag 'io_uring-5.8-2020-07-24' of git://git.kernel.dk/linux-block:
        io_uring: missed req_init_async() for IOSQE_ASYNC
        io_uring: always allow drain/link/hardlink/async sqe flags
        io_uring: ensure double poll additions work with both request types
      1f68f31b
    • Linus Torvalds's avatar
      Merge tag 'iommu-fix-v5.8-rc6' of... · 5a0b8af0
      Linus Torvalds authored
      Merge tag 'iommu-fix-v5.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu into master
      
      Pull iommu fix from Joerg Roedel:
       "Fix a NULL-ptr dereference in the QCOM IOMMU driver"
      
      * tag 'iommu-fix-v5.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
        iommu/qcom: Use domain rather than dev as tlb cookie
      5a0b8af0
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma into master · fcef1046
      Linus Torvalds authored
      Pull rdma fixes from Jason Gunthorpe:
       "One merge window regression, some corruption bugs in HNS and a few
        more syzkaller fixes:
      
         - Two long standing syzkaller races
      
         - Fix incorrect HW configuration in HNS
      
         - Restore accidentally dropped locking in IB CM
      
         - Fix ODP prefetch bug added in the big rework several versions ago"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
        RDMA/mlx5: Prevent prefetch from racing with implicit destruction
        RDMA/cm: Protect access to remote_sidr_table
        RDMA/core: Fix race in rdma_alloc_commit_uobject()
        RDMA/hns: Fix wrong PBL offset when VA is not aligned to PAGE_SIZE
        RDMA/hns: Fix wrong assignment of lp_pktn_ini in QPC
        RDMA/mlx5: Use xa_lock_irq when access to SRQ table
      fcef1046
    • Linus Torvalds's avatar
      Merge tag 'for-5.8/dm-fixes-3' of... · a38a19ef
      Linus Torvalds authored
      Merge tag 'for-5.8/dm-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm into master
      
      Pull device mapper fix from Mike Snitzer:
       "A stable fix for DM integrity target's integrity recalculation that
        gets skipped when resuming a device. This is a fix for a previous
        stable@ fix"
      
      * tag 'for-5.8/dm-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
        dm integrity: fix integrity recalculation that is improperly skipped
      a38a19ef
    • Linus Torvalds's avatar
      Merge branch 'i2c/for-current' of... · c615035b
      Linus Torvalds authored
      Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux into master
      
      Pull i2c fixes from Wolfram Sang:
       "Again some driver bugfixes and some documentation fixes"
      
      * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
        i2c: i2c-qcom-geni: Fix DMA transfer race
        i2c: rcar: always clear ICSAR to avoid side effects
        MAINTAINERS: i2c: at91: handover maintenance to Codrin Ciubotariu
        i2c: drop duplicated word in the header file
        i2c: cadence: Clear HOLD bit at correct time in Rx path
        Revert "i2c: cadence: Fix the hold bit setting"
      c615035b
    • Linus Torvalds's avatar
      Merge tag 'mmc-v5.8-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc into master · b85bcb78
      Linus Torvalds authored
      Pull MMC fix from Ulf Hansson:
       "Fix clock divider calculation in the ASPEED SDHCI controller"
      
      * tag 'mmc-v5.8-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc:
        mmc: sdhci-of-aspeed: Fix clock divider calculation
      b85bcb78
    • Linus Torvalds's avatar
      Merge tag 'drm-fixes-2020-07-24' of git://anongit.freedesktop.org/drm/drm into master · 88fff0b7
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "Quiet fixes, I may have a single regression fix follow up to this for
        nouveau, but it might be next week, Ben was testing it a bit more .
      
        Otherwise two amdgpu fixes, one lima and one sun4i:
      
        amdgpu:
          - Fix crash when overclocking VegaM
          - Fix possible crash when editing dpm levels
      
        sun4i:
          - Fix inverted HPD result; fixes an earlier fix
      
        lima:
          - fix timeout during reset"
      
      * tag 'drm-fixes-2020-07-24' of git://anongit.freedesktop.org/drm/drm:
        drm/amdgpu: Fix NULL dereference in dpm sysfs handlers
        drm/amd/powerplay: fix a crash when overclocking Vega M
        drm/lima: fix wait pp reset timeout
        drm: sun4i: hdmi: Fix inverted HPD result
      88fff0b7
  2. Jul 24, 2020
    • Linus Torvalds's avatar
      Merge tag 's390-5.8-6' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux into master · f37e99ac
      Linus Torvalds authored
      Pull s390 fixes from Heiko Carstens:
      
       - Change cpum_cf/perf counter name from DFLT_CCERROR to DFLT_CCFINISH
         to reflect reality and avoid further confusion. This is a user space
         visible change therefore the commit has also a stable tag for 5.7,
         where this counter was introduced.
      
       - Add Matthew Rosato as s390 IOMMU maintainer.
      
      * tag 's390-5.8-6' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
        MAINTAINERS: add Matthew for s390 IOMMU
        s390/cpum_cf,perf: change DFLT_CCERROR counter name
      f37e99ac
    • Douglas Anderson's avatar
      i2c: i2c-qcom-geni: Fix DMA transfer race · 02b9aec5
      Douglas Anderson authored
      When I have KASAN enabled on my kernel and I start stressing the
      touchscreen my system tends to hang.  The touchscreen is one of the
      only things that does a lot of big i2c transfers and ends up hitting
      the DMA paths in the geni i2c driver.  It appears that KASAN adds
      enough delay in my system to tickle a race condition in the DMA setup
      code.
      
      When the system hangs, I found that it was running the geni_i2c_irq()
      over and over again.  It had these:
      
      m_stat   = 0x04000080
      rx_st    = 0x30000011
      dm_tx_st = 0x00000000
      dm_rx_st = 0x00000000
      dma      = 0x00000001
      
      Notably we're in DMA mode but are getting M_RX_IRQ_EN and
      M_RX_FIFO_WATERMARK_EN over and over again.
      
      Putting some traces in geni_i2c_rx_one_msg() showed that when we
      failed we were getting to the start of geni_i2c_rx_one_msg() but were
      never executing geni_se_rx_dma_prep().
      
      I believe that the problem here is that we are starting the geni
      command before we run geni_se_rx_dma_prep().  If a transfer makes it
      far enough before we do that then we get into the state I have
      observed.  Let's change the order, which seems to work fine.
      
      Although problems were seen on the RX path, code inspection suggests
      that the TX should be changed too.  Change it as well.
      
      Fixes: 37692de5
      
       ("i2c: i2c-qcom-geni: Add bus driver for the Qualcomm GENI I2C controller")
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Tested-by: default avatarSai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>
      Reviewed-by: default avatarAkash Asthana <akashast@codeaurora.org>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Reviewed-by: default avatarMukesh Kumar Savaliya <msavaliy@codeaurora.org>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      02b9aec5
    • Wolfram Sang's avatar
      i2c: rcar: always clear ICSAR to avoid side effects · eb015971
      Wolfram Sang authored
      On R-Car Gen2, we get a timeout when reading from the address set in
      ICSAR, even though the slave interface is disabled. Clearing it fixes
      this situation. Note that Gen3 is not affected.
      
      To reproduce: bind and undbind an I2C slave on some bus, run
      'i2cdetect' on that bus.
      
      Fixes: de20d185
      
       ("i2c: rcar: add slave support")
      Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      eb015971
    • Mikulas Patocka's avatar
      dm integrity: fix integrity recalculation that is improperly skipped · 5df96f2b
      Mikulas Patocka authored
      Commit adc0daad ("dm: report suspended
      device during destroy") broke integrity recalculation.
      
      The problem is dm_suspended() returns true not only during suspend,
      but also during resume. So this race condition could occur:
      1. dm_integrity_resume calls queue_work(ic->recalc_wq, &ic->recalc_work)
      2. integrity_recalc (&ic->recalc_work) preempts the current thread
      3. integrity_recalc calls if (unlikely(dm_suspended(ic->ti))) goto unlock_ret;
      4. integrity_recalc exits and no recalculating is done.
      
      To fix this race condition, add a function dm_post_suspending that is
      only true during the postsuspend phase and use it instead of
      dm_suspended().
      
      Signed-off-by: Mikulas Patocka <mpatocka redhat com>
      Fixes: adc0daad
      
       ("dm: report suspended device during destroy")
      Cc: stable vger kernel org # v4.18+
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      5df96f2b
    • Pavel Begunkov's avatar
      io_uring: missed req_init_async() for IOSQE_ASYNC · 3e863ea3
      Pavel Begunkov authored
      
      
      IOSQE_ASYNC branch of io_queue_sqe() is another place where an
      unitialised req->work can be accessed (i.e. prior io_req_init_async()).
      Nothing really bad though, it just looses IO_WQ_WORK_CONCURRENT flag.
      
      Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      3e863ea3
  3. Jul 23, 2020
    • Dave Airlie's avatar
      Merge tag 'amd-drm-fixes-5.8-2020-07-22' of... · d8904ca9
      Dave Airlie authored
      
      Merge tag 'amd-drm-fixes-5.8-2020-07-22' of git://people.freedesktop.org/~agd5f/linux into drm-fixes
      
      amd-drm-fixes-5.8-2020-07-22:
      
      amdgpu:
      - Fix crash when overclocking VegaM
      - Fix possible crash when editing dpm levels
      
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      From: Alex Deucher <alexdeucher@gmail.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200723032608.3865-1-alexander.deucher@amd.com
      d8904ca9
    • Dave Airlie's avatar
      Merge tag 'drm-misc-fixes-2020-07-22' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes · 26a2be07
      Dave Airlie authored
      
      
       * sun4i: Fix inverted HPD result; fixes an earlier fix
       * lima: fix timeout during reset
      
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      
      From: Thomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200722070321.GA29190@linux-uq9g
      26a2be07
    • Linus Torvalds's avatar
      Merge tag 'media/v5.8-3' of... · d15be546
      Linus Torvalds authored
      Merge tag 'media/v5.8-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media into master
      
      Pull media fixes from Mauro Carvalho Chehab:
       "A series of fixes for the upcoming atomisp driver. They solve issues
        when probing atomisp on devices with multiple cameras and get rid of
        warnings when built with W=1.
      
        The diffstat is a bit long, as this driver has several abstractions.
        The patches that solved the issues with W=1 had to get rid of some
        duplicated code (there used to have 2 versions of the same code, one
        for ISP2401 and another one for ISP2400).
      
        As this driver is not in 5.7, such changes won't cause regressions"
      
      * tag 'media/v5.8-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (38 commits)
        Revert "media: atomisp: keep the ISP powered on when setting it"
        media: atomisp: fix mask and shift operation on ISPSSPM0
        media: atomisp: move system_local consts into a C file
        media: atomisp: get rid of version-specific system_local.h
        media: atomisp: move global stuff into a common header
        media: atomisp: remove non-used 32-bits consts at system_local
        media: atomisp: get rid of some unused static vars
        media: atomisp: Fix error code in ov5693_probe()
        media: atomisp: Replace trace_printk by pr_info
        media: atomisp: Fix __func__ style warnings
        media: atomisp: fix help message for ISP2401 selection
        media: atomisp: i2c: atomisp-ov2680.c: fixed a brace coding style issue.
        media: atomisp: make const arrays static, makes object smaller
        media: atomisp: Clean up non-existing folders from Makefile
        media: atomisp: Get rid of ACPI specifics in gmin_subdev_add()
        media: atomisp: Provide Gmin subdev as parameter to gmin_subdev_add()
        media: atomisp: Use temporary variable for device in gmin_subdev_add()
        media: atomisp: Refactor PMIC detection to a separate function
        media: atomisp: Deduplicate return ret in gmin_i2c_write()
        media: atomisp: Make pointer to PMIC client global
        ...
      d15be546
    • Linus Torvalds's avatar
      Merge tag 'exfat-for-5.8-rc7' of... · 071fb1bc
      Linus Torvalds authored
      Merge tag 'exfat-for-5.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat into master
      
      Pull exfat fixes from Namjae Jeon:
      
       - fix overflow issue at sector calculation
      
       - fix wrong hint_stat initialization
      
       - fix wrong size update of stream entry
      
       - fix endianness of upname in name_hash computation
      
      * tag 'exfat-for-5.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat:
        exfat: fix name_hash computation on big endian systems
        exfat: fix wrong size update of stream entry by typo
        exfat: fix wrong hint_stat initialization in exfat_find_dir_entry()
        exfat: fix overflow issue in exfat_cluster_to_sector()
      071fb1bc
  4. Jul 22, 2020
    • Rob Clark's avatar
      iommu/qcom: Use domain rather than dev as tlb cookie · 1014a2f8
      Rob Clark authored
      
      
      The device may be torn down, but the domain should still be valid.  Lets
      use that as the tlb flush ops cookie.
      
      Fixes a problem reported in [1]
      
      [1] https://lkml.org/lkml/2020/7/20/104
      
      Reported-by: default avatarNaresh Kamboju <naresh.kamboju@linaro.org>
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Tested-by: default avatarNaresh Kamboju <naresh.kamboju@linaro.org>
      Fixes: 09b5dfff
      
       ("iommu/qcom: Use accessor functions for iommu private data")
      Link: https://lore.kernel.org/r/20200720155217.274994-1-robdclark@gmail.com
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      1014a2f8
    • Gerald Schaefer's avatar
    • Ludovic Desroches's avatar
      MAINTAINERS: i2c: at91: handover maintenance to Codrin Ciubotariu · 436d1767
      Ludovic Desroches authored
      
      
      My colleague Codrin Ciubotariu, now, maintains this driver internally.
      Then I handover the mainline maintenance to him.
      
      Signed-off-by: default avatarLudovic Desroches <ludovic.desroches@microchip.com>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      436d1767
    • Randy Dunlap's avatar
      i2c: drop duplicated word in the header file · aca7ed09
      Randy Dunlap authored
      
      
      Drop the doubled word "be" in a comment.
      
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      aca7ed09
    • Raviteja Narayanam's avatar
      i2c: cadence: Clear HOLD bit at correct time in Rx path · 12d4d9ec
      Raviteja Narayanam authored
      
      
      There are few issues on Zynq SOC observed in the stress tests causing
      timeout errors. Even though all the data is received, timeout error
      is thrown. This is due to an IP bug in which the COMP bit in ISR is
      not set at end of transfer and completion interrupt is not generated.
      
      This bug is seen on Zynq platforms when the following condition occurs:
      Master read & HOLD bit set & Transfer size register reaches '0'.
      
      One workaround is to clear the HOLD bit before the transfer size
      register reaches '0'. The current implementation checks for this at
      the start of the loop and also only for less than FIFO DEPTH case
      (ignoring the equal to case).
      
      So clear the HOLD bit when the data yet to receive is less than or
      equal to the FIFO DEPTH. This avoids the IP bug condition.
      
      Signed-off-by: default avatarRaviteja Narayanam <raviteja.narayanam@xilinx.com>
      Acked-by: default avatarMichal Simek <michal.simek@xilinx.com>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      12d4d9ec
    • Raviteja Narayanam's avatar
      Revert "i2c: cadence: Fix the hold bit setting" · 0db9254d
      Raviteja Narayanam authored
      This reverts commit d358def7
      
      .
      
      There are two issues with "i2c: cadence: Fix the hold bit setting" commit.
      
      1. In case of combined message request from user space, when the HOLD
      bit is cleared in cdns_i2c_mrecv function, a STOP condition is sent
      on the bus even before the last message is started. This is because when
      the HOLD bit is cleared, the FIFOS are empty and there is no pending
      transfer. The STOP condition should occur only after the last message
      is completed.
      
      2. The code added by the commit is redundant. Driver is handling the
      setting/clearing of HOLD bit in right way before the commit.
      
      The setting of HOLD bit based on 'bus_hold_flag' is taken care in
      cdns_i2c_master_xfer function even before cdns_i2c_msend/cdns_i2c_recv
      functions.
      
      The clearing of HOLD bit is taken care at the end of cdns_i2c_msend and
      cdns_i2c_recv functions based on bus_hold_flag and byte count.
      Since clearing of HOLD bit is done after the slave address is written to
      the register (writing to address register triggers the message transfer),
      it is ensured that STOP condition occurs at the right time after
      completion of the pending transfer (last message).
      
      Signed-off-by: default avatarRaviteja Narayanam <raviteja.narayanam@xilinx.com>
      Acked-by: default avatarMichal Simek <michal.simek@xilinx.com>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      0db9254d
    • Boris Burkov's avatar
      btrfs: fix mount failure caused by race with umount · 48cfa61b
      Boris Burkov authored
      
      
      It is possible to cause a btrfs mount to fail by racing it with a slow
      umount. The crux of the sequence is generic_shutdown_super not yet
      calling sop->put_super before btrfs_mount_root calls btrfs_open_devices.
      If that occurs, btrfs_open_devices will decide the opened counter is
      non-zero, increment it, and skip resetting fs_devices->total_rw_bytes to
      0. From here, mount will call sget which will result in grab_super
      trying to take the super block umount semaphore. That semaphore will be
      held by the slow umount, so mount will block. Before up-ing the
      semaphore, umount will delete the super block, resulting in mount's sget
      reliably allocating a new one, which causes the mount path to dutifully
      fill it out, and increment total_rw_bytes a second time, which causes
      the mount to fail, as we see double the expected bytes.
      
      Here is the sequence laid out in greater detail:
      
      CPU0                                                    CPU1
      down_write sb->s_umount
      btrfs_kill_super
        kill_anon_super(sb)
          generic_shutdown_super(sb);
            shrink_dcache_for_umount(sb);
            sync_filesystem(sb);
            evict_inodes(sb); // SLOW
      
                                                    btrfs_mount_root
                                                      btrfs_scan_one_device
                                                      fs_devices = device->fs_devices
                                                      fs_info->fs_devices = fs_devices
                                                      // fs_devices-opened makes this a no-op
                                                      btrfs_open_devices(fs_devices, mode, fs_type)
                                                      s = sget(fs_type, test, set, flags, fs_info);
                                                        find sb in s_instances
                                                        grab_super(sb);
                                                          down_write(&s->s_umount); // blocks
      
            sop->put_super(sb)
              // sb->fs_devices->opened == 2; no-op
            spin_lock(&sb_lock);
            hlist_del_init(&sb->s_instances);
            spin_unlock(&sb_lock);
            up_write(&sb->s_umount);
                                                          return 0;
                                                        retry lookup
                                                        don't find sb in s_instances (deleted by CPU0)
                                                        s = alloc_super
                                                        return s;
                                                      btrfs_fill_super(s, fs_devices, data)
                                                        open_ctree // fs_devices total_rw_bytes improperly set!
                                                          btrfs_read_chunk_tree
                                                            read_one_dev // increment total_rw_bytes again!!
                                                            super_total_bytes < fs_devices->total_rw_bytes // ERROR!!!
      
      To fix this, we clear total_rw_bytes from within btrfs_read_chunk_tree
      before the calls to read_one_dev, while holding the sb umount semaphore
      and the uuid mutex.
      
      To reproduce, it is sufficient to dirty a decent number of inodes, then
      quickly umount and mount.
      
        for i in $(seq 0 500)
        do
          dd if=/dev/zero of="/mnt/foo/$i" bs=1M count=1
        done
        umount /mnt/foo&
        mount /mnt/foo
      
      does the trick for me.
      
      CC: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarBoris Burkov <boris@bur.io>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      48cfa61b
    • Robbie Ko's avatar
      btrfs: fix page leaks after failure to lock page for delalloc · 5909ca11
      Robbie Ko authored
      
      
      When locking pages for delalloc, we check if it's dirty and mapping still
      matches. If it does not match, we need to return -EAGAIN and release all
      pages. Only the current page was put though, iterate over all the
      remaining pages too.
      
      CC: stable@vger.kernel.org # 4.14+
      Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
      Signed-off-by: default avatarRobbie Ko <robbieko@synology.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      5909ca11
    • Qu Wenruo's avatar
      btrfs: qgroup: fix data leak caused by race between writeback and truncate · fa91e4aa
      Qu Wenruo authored
      [BUG]
      When running tests like generic/013 on test device with btrfs quota
      enabled, it can normally lead to data leak, detected at unmount time:
      
        BTRFS warning (device dm-3): qgroup 0/5 has unreleased space, type 0 rsv 4096
        ------------[ cut here ]------------
        WARNING: CPU: 11 PID: 16386 at fs/btrfs/disk-io.c:4142 close_ctree+0x1dc/0x323 [btrfs]
        RIP: 0010:close_ctree+0x1dc/0x323 [btrfs]
        Call Trace:
         btrfs_put_super+0x15/0x17 [btrfs]
         generic_shutdown_super+0x72/0x110
         kill_anon_super+0x18/0x30
         btrfs_kill_super+0x17/0x30 [btrfs]
         deactivate_locked_super+0x3b/0xa0
         deactivate_super+0x40/0x50
         cleanup_mnt+0x135/0x190
         __cleanup_mnt+0x12/0x20
         task_work_run+0x64/0xb0
         __prepare_exit_to_usermode+0x1bc/0x1c0
         __syscall_return_slowpath+0x47/0x230
         do_syscall_64+0x64/0xb0
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        ---[ end trace caf08beafeca2392 ]---
        BTRFS error (device dm-3): qgroup reserved space leaked
      
      [CAUSE]
      In the offending case, the offending operations are:
      2/6: writev f2X[269 1 0 0 0 0] [1006997,67,288] 0
      2/7: truncate f2X[269 1 0 0 48 1026293] 18388 0
      
      The following sequence of events could happen after the writev():
      	CPU1 (writeback)		|		CPU2 (truncate)
      -----------------------------------------------------------------
      btrfs_writepages()			|
      |- extent_write_cache_pages()		|
         |- Got page for 1003520		|
         |  1003520 is Dirty, no writeback	|
         |  So (!clear_page_dirty_for_io())   |
         |  gets called for it		|
         |- Now page 1003520 is Clean.	|
         |					| btrfs_setattr()
         |					| |- btrfs_setsize()
         |					|    |- truncate_setsize()
         |					|       New i_size is 18388
         |- __extent_writepage()		|
         |  |- page_offset() > i_size		|
            |- btrfs_invalidatepage()		|
      	 |- Page is clean, so no qgroup |
      	    callback executed
      
      This means, the qgroup reserved data space is not properly released in
      btrfs_invalidatepage() as the page is Clean.
      
      [FIX]
      Instead of checking the dirty bit of a page, call
      btrfs_qgroup_free_data() unconditionally in btrfs_invalidatepage().
      
      As qgroup rsv are completely bound to the QGROUP_RESERVED bit of
      io_tree, not bound to page status, thus we won't cause double freeing
      anyway.
      
      Fixes: 0b34c261
      
       ("btrfs: qgroup: Prevent qgroup->reserved from going subzero")
      CC: stable@vger.kernel.org # 4.14+
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      fa91e4aa
    • Paweł Gronowski's avatar
      drm/amdgpu: Fix NULL dereference in dpm sysfs handlers · 38e0c89a
      Paweł Gronowski authored
      
      
      NULL dereference occurs when string that is not ended with space or
      newline is written to some dpm sysfs interface (for example pp_dpm_sclk).
      This happens because strsep replaces the tmp with NULL if the delimiter
      is not present in string, which is then dereferenced by tmp[0].
      
      Reproduction example:
      sudo sh -c 'echo -n 1 > /sys/class/drm/card0/device/pp_dpm_sclk'
      
      Signed-off-by: default avatarPaweł Gronowski <me@woland.xyz>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      38e0c89a
    • Qiu Wenbo's avatar
      drm/amd/powerplay: fix a crash when overclocking Vega M · 88bb16ad
      Qiu Wenbo authored
      Avoid kernel crash when vddci_control is SMU7_VOLTAGE_CONTROL_NONE and
      vddci_voltage_table is empty. It has been tested on Intel Hades Canyon
      (i7-8809G).
      
      Bug: https://bugzilla.kernel.org/show_bug.cgi?id=208489
      Fixes: ac7822b0
      
       ("drm/amd/powerplay: add smumgr support for VEGAM (v2)")
      Reviewed-by: default avatarEvan Quan <evan.quan@amd.com>
      Signed-off-by: default avatarQiu Wenbo <qiuwenbo@phytium.com.cn>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      88bb16ad
    • Filipe Manana's avatar
      btrfs: fix double free on ulist after backref resolution failure · 580c079b
      Filipe Manana authored
      At btrfs_find_all_roots_safe() we allocate a ulist and set the **roots
      argument to point to it. However if later we fail due to an error returned
      by find_parent_nodes(), we free that ulist but leave a dangling pointer in
      the **roots argument. Upon receiving the error, a caller of this function
      can attempt to free the same ulist again, resulting in an invalid memory
      access.
      
      One such scenario is during qgroup accounting:
      
      btrfs_qgroup_account_extents()
      
       --> calls btrfs_find_all_roots() passes &new_roots (a stack allocated
           pointer) to btrfs_find_all_roots()
      
         --> btrfs_find_all_roots() just calls btrfs_find_all_roots_safe()
             passing &new_roots to it
      
           --> allocates ulist and assigns its address to **roots (which
               points to new_roots from btrfs_qgroup_account_extents())
      
           --> find_parent_nodes() returns an error, so we free the ulist
               and leave **roots pointing to it after returning
      
       --> btrfs_qgroup_account_extents() sees btrfs_find_all_roots() returned
           an error and jumps to the label 'cleanup', which just tries to
           free again the same ulist
      
      Stack trace example:
      
       ------------[ cut here ]------------
       BTRFS: tree first key check failed
       WARNING: CPU: 1 PID: 1763215 at fs/btrfs/disk-io.c:422 btrfs_verify_level_key+0xe0/0x180 [btrfs]
       Modules linked in: dm_snapshot dm_thin_pool (...)
       CPU: 1 PID: 1763215 Comm: fsstress Tainted: G        W         5.8.0-rc3-btrfs-next-64 #1
       Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
       RIP: 0010:btrfs_verify_level_key+0xe0/0x180 [btrfs]
       Code: 28 5b 5d (...)
       RSP: 0018:ffffb89b473779a0 EFLAGS: 00010286
       RAX: 0000000000000000 RBX: ffff90397759bf08 RCX: 0000000000000000
       RDX: 0000000000000001 RSI: 0000000000000027 RDI: 00000000ffffffff
       RBP: ffff9039a419c000 R08: 0000000000000000 R09: 0000000000000000
       R10: 0000000000000000 R11: ffffb89b43301000 R12: 000000000000005e
       R13: ffffb89b47377a2e R14: ffffb89b473779af R15: 0000000000000000
       FS:  00007fc47e1e1000(0000) GS:ffff9039ac200000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 00007fc47e1df000 CR3: 00000003d9e4e001 CR4: 00000000003606e0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
       Call Trace:
        read_block_for_search+0xf6/0x350 [btrfs]
        btrfs_next_old_leaf+0x242/0x650 [btrfs]
        resolve_indirect_refs+0x7cf/0x9e0 [btrfs]
        find_parent_nodes+0x4ea/0x12c0 [btrfs]
        btrfs_find_all_roots_safe+0xbf/0x130 [btrfs]
        btrfs_qgroup_account_extents+0x9d/0x390 [btrfs]
        btrfs_commit_transaction+0x4f7/0xb20 [btrfs]
        btrfs_sync_file+0x3d4/0x4d0 [btrfs]
        do_fsync+0x38/0x70
        __x64_sys_fdatasync+0x13/0x20
        do_syscall_64+0x5c/0xe0
        entry_SYSCALL_64_after_hwframe+0x44/0xa9
       RIP: 0033:0x7fc47e2d72e3
       Code: Bad RIP value.
       RSP: 002b:00007fffa32098c8 EFLAGS: 00000246 ORIG_RAX: 000000000000004b
       RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fc47e2d72e3
       RDX: 00007fffa3209830 RSI: 00007fffa3209830 RDI: 0000000000000003
       RBP: 000000000000072e R08: 0000000000000001 R09: 0000000000000003
       R10: 0000000000000000 R11: 0000000000000246 R12: 00000000000003e8
       R13: 0000000051eb851f R14: 00007fffa3209970 R15: 00005607c4ac8b50
       irq event stamp: 0
       hardirqs last  enabled at (0): [<0000000000000000>] 0x0
       hardirqs last disabled at (0): [<ffffffffb8eb5e85>] copy_process+0x755/0x1eb0
       softirqs last  enabled at (0): [<ffffffffb8eb5e85>] copy_process+0x755/0x1eb0
       softirqs last disabled at (0): [<0000000000000000>] 0x0
       ---[ end trace 8639237550317b48 ]---
       BTRFS error (device sdc): tree first key mismatch detected, bytenr=62324736 parent_transid=94 key expected=(262,108,1351680) has=(259,108,1921024)
       general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b6b6b: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC PTI
       CPU: 2 PID: 1763215 Comm: fsstress Tainted: G        W         5.8.0-rc3-btrfs-next-64 #1
       Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
       RIP: 0010:ulist_release+0x14/0x60 [btrfs]
       Code: c7 07 00 (...)
       RSP: 0018:ffffb89b47377d60 EFLAGS: 00010282
       RAX: 6b6b6b6b6b6b6b6b RBX: ffff903959b56b90 RCX: 0000000000000000
       RDX: 0000000000000001 RSI: 0000000000270024 RDI: ffff9036e2adc840
       RBP: ffff9036e2adc848 R08: 0000000000000000 R09: 0000000000000000
       R10: 0000000000000000 R11: 0000000000000000 R12: ffff9036e2adc840
       R13: 0000000000000015 R14: ffff9039a419ccf8 R15: ffff90395d605840
       FS:  00007fc47e1e1000(0000) GS:ffff9039ac600000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 00007f8c1c0a51c8 CR3: 00000003d9e4e004 CR4: 00000000003606e0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
       Call Trace:
        ulist_free+0x13/0x20 [btrfs]
        btrfs_qgroup_account_extents+0xf3/0x390 [btrfs]
        btrfs_commit_transaction+0x4f7/0xb20 [btrfs]
        btrfs_sync_file+0x3d4/0x4d0 [btrfs]
        do_fsync+0x38/0x70
        __x64_sys_fdatasync+0x13/0x20
        do_syscall_64+0x5c/0xe0
        entry_SYSCALL_64_after_hwframe+0x44/0xa9
       RIP: 0033:0x7fc47e2d72e3
       Code: Bad RIP value.
       RSP: 002b:00007fffa32098c8 EFLAGS: 00000246 ORIG_RAX: 000000000000004b
       RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fc47e2d72e3
       RDX: 00007fffa3209830 RSI: 00007fffa3209830 RDI: 0000000000000003
       RBP: 000000000000072e R08: 0000000000000001 R09: 0000000000000003
       R10: 0000000000000000 R11: 0000000000000246 R12: 00000000000003e8
       R13: 0000000051eb851f R14: 00007fffa3209970 R15: 00005607c4ac8b50
       Modules linked in: dm_snapshot dm_thin_pool (...)
       ---[ end trace 8639237550317b49 ]---
       RIP: 0010:ulist_release+0x14/0x60 [btrfs]
       Code: c7 07 00 (...)
       RSP: 0018:ffffb89b47377d60 EFLAGS: 00010282
       RAX: 6b6b6b6b6b6b6b6b RBX: ffff903959b56b90 RCX: 0000000000000000
       RDX: 0000000000000001 RSI: 0000000000270024 RDI: ffff9036e2adc840
       RBP: ffff9036e2adc848 R08: 0000000000000000 R09: 0000000000000000
       R10: 0000000000000000 R11: 0000000000000000 R12: ffff9036e2adc840
       R13: 0000000000000015 R14: ffff9039a419ccf8 R15: ffff90395d605840
       FS:  00007fc47e1e1000(0000) GS:ffff9039ad200000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 00007f6a776f7d40 CR3: 00000003d9e4e002 CR4: 00000000003606e0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      
      Fix this by making btrfs_find_all_roots_safe() set *roots to NULL after
      it frees the ulist.
      
      Fixes: 8da6d581
      
       ("Btrfs: added btrfs_find_all_roots()")
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      580c079b
    • Jason Gunthorpe's avatar
      RDMA/mlx5: Prevent prefetch from racing with implicit destruction · a862192e
      Jason Gunthorpe authored
      Prefetch work in mlx5_ib_prefetch_mr_work can be queued and able to run
      concurrently with destruction of the implicit MR. The num_deferred_work
      was intended to serialize this, but there is a race:
      
             CPU0                                          CPU1
      
          mlx5_ib_free_implicit_mr()
            xa_erase(odp_mkeys)
            synchronize_srcu()
            __xa_erase(implicit_children)
                                            mlx5_ib_prefetch_mr_work()
                                              pagefault_mr()
                                               pagefault_implicit_mr()
                                                implicit_get_child_mr()
                                                 xa_cmpxchg()
                                              atomic_dec_and_test(num_deferred_mr)
            wait_event(imr->q_deferred_work)
            ib_umem_odp_release(odp_imr)
              kfree(odp_imr)
      
      At this point in mlx5_ib_free_implicit_mr() the implicit_children list is
      supposed to be empty forever so that destroy_unused_implicit_child_mr()
      and related are not and will not be running.
      
      Since it is not empty the destroy_unused_implicit_child_mr() flow ends up
      touching deallocated memory as mlx5_ib_free_implicit_mr() already tore down the
      imr parent.
      
      The solution is to flush out the prefetch wq by driving num_deferred_work
      to zero after creation of new prefetch work is blocked.
      
      Fixes: 5256edcb
      
       ("RDMA/mlx5: Rework implicit ODP destroy")
      Link: https://lore.kernel.org/r/20200719065435.130722-1-leon@kernel.org
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      a862192e
  5. Jul 21, 2020
  6. Jul 20, 2020