Skip to content
  1. Sep 18, 2020
    • Muchun Song's avatar
      kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler · cb3f77d7
      Muchun Song authored
      commit 0cb2f137 upstream.
      
      We found a case of kernel panic on our server. The stack trace is as
      follows(omit some irrelevant information):
      
        BUG: kernel NULL pointer dereference, address: 0000000000000080
        RIP: 0010:kprobe_ftrace_handler+0x5e/0xe0
        RSP: 0018:ffffb512c6550998 EFLAGS: 00010282
        RAX: 0000000000000000 RBX: ffff8e9d16eea018 RCX: 0000000000000000
        RDX: ffffffffbe1179c0 RSI: ffffffffc0535564 RDI: ffffffffc0534ec0
        RBP: ffffffffc0534ec1 R08: ffff8e9d1bbb0f00 R09: 0000000000000004
        R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
        R13: ffff8e9d1f797060 R14: 000000000000bacc R15: ffff8e9ce13eca00
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000000080 CR3: 00000008453d0005 CR4: 00000000003606e0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
         <IRQ>
         ftrace_ops_assist_func+0x56/0xe0
         ftrace_call+0x5/0x34
         tcpa_statistic_send+0x5/0x130 [ttcp_engine]
      
      The tcpa_statistic_send is the function being kprobed. After analysis,
      the root cause is that the fourth parameter regs of kprobe_ftrace_handler
      is NULL. Why regs is NULL? We use the crash tool to analyze the kdump.
      
        crash> dis tcpa_statistic_send -r
               <tcpa_statistic_send>: callq 0xffffffffbd8018c0 <ftrace_caller>
      
      The tcpa_statistic_send calls ftrace_caller instead of ftrace_regs_caller.
      So it is reasonable that the fourth parameter regs of kprobe_ftrace_handler
      is NULL. In theory, we should call the ftrace_regs_caller instead of the
      ftrace_caller. After in-depth analysis, we found a reproducible path.
      
        Writing a simple kernel module which starts a periodic timer. The
        timer's handler is named 'kprobe_test_timer_handler'. The module
        name is kprobe_test.ko.
      
        1) insmod kprobe_test.ko
        2) bpftrace -e 'kretprobe:kprobe_test_timer_handler {}'
        3) echo 0 > /proc/sys/kernel/ftrace_enabled
        4) rmmod kprobe_test
        5) stop step 2) kprobe
        6) insmod kprobe_test.ko
        7) bpftrace -e 'kretprobe:kprobe_test_timer_handler {}'
      
      We mark the kprobe as GONE but not disarm the kprobe in the step 4).
      The step 5) also do not disarm the kprobe when unregister kprobe. So
      we do not remove the ip from the filter. In this case, when the module
      loads again in the step 6), we will replace the code to ftrace_caller
      via the ftrace_module_enable(). When we register kprobe again, we will
      not replace ftrace_caller to ftrace_regs_caller because the ftrace is
      disabled in the step 3). So the step 7) will trigger kernel panic. Fix
      this problem by disarming the kprobe when the module is going away.
      
      Link: https://lkml.kernel.org/r/20200728064536.24405-1-songmuchun@bytedance.com
      
      
      
      Cc: stable@vger.kernel.org
      Fixes: ae6aa16f ("kprobes: introduce ftrace based optimization")
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Co-developed-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
      Signed-off-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      cb3f77d7
    • Chengming Zhou's avatar
      ftrace: Setup correct FTRACE_FL_REGS flags for module · 4bfa8b59
      Chengming Zhou authored
      commit 8a224ffb upstream.
      
      When module loaded and enabled, we will use __ftrace_replace_code
      for module if any ftrace_ops referenced it found. But we will get
      wrong ftrace_addr for module rec in ftrace_get_addr_new, because
      rec->flags has not been setup correctly. It can cause the callback
      function of a ftrace_ops has FTRACE_OPS_FL_SAVE_REGS to be called
      with pt_regs set to NULL.
      So setup correct FTRACE_FL_REGS flags for rec when we call
      referenced_filters to find ftrace_ops references it.
      
      Link: https://lkml.kernel.org/r/20200728180554.65203-1-zhouchengming@bytedance.com
      
      
      
      Cc: stable@vger.kernel.org
      Fixes: 8c4f3c3f ("ftrace: Check module functions being traced on reload")
      Signed-off-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
      Signed-off-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      4bfa8b59
    • Michal Koutný's avatar
      mm/page_counter.c: fix protection usage propagation · 113ccc66
      Michal Koutný authored
      
      
      commit a6f23d14 upstream.
      
      When workload runs in cgroups that aren't directly below root cgroup and
      their parent specifies reclaim protection, it may end up ineffective.
      
      The reason is that propagate_protected_usage() is not called in all
      hierarchy up.  All the protected usage is incorrectly accumulated in the
      workload's parent.  This means that siblings_low_usage is overestimated
      and effective protection underestimated.  Even though it is transitional
      phenomenon (uncharge path does correct propagation and fixes the wrong
      children_low_usage), it can undermine the intended protection
      unexpectedly.
      
      We have noticed this problem while seeing a swap out in a descendant of a
      protected memcg (intermediate node) while the parent was conveniently
      under its protection limit and the memory pressure was external to that
      hierarchy.  Michal has pinpointed this down to the wrong
      siblings_low_usage which led to the unwanted reclaim.
      
      The fix is simply updating children_low_usage in respective ancestors also
      in the charging path.
      
      Fixes: 23067153 ("mm: memory.low hierarchical behavior")
      Signed-off-by: default avatarMichal Koutný <mkoutny@suse.com>
      Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarRoman Gushchin <guro@fb.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: <stable@vger.kernel.org>	[4.18+]
      Link: http://lkml.kernel.org/r/20200803153231.15477-1-mhocko@kernel.org
      
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      113ccc66
    • Eric Sandeen's avatar
      xfs: fix boundary test in xfs_attr_shortform_verify · 70d12ec7
      Eric Sandeen authored
      
      
      commit f4020438 upstream.
      
      The boundary test for the fixed-offset parts of xfs_attr_sf_entry in
      xfs_attr_shortform_verify is off by one, because the variable array
      at the end is defined as nameval[1] not nameval[].
      Hence we need to subtract 1 from the calculation.
      
      This can be shown by:
      
      # touch file
      # setfattr -n root.a file
      
      and verifications will fail when it's written to disk.
      
      This only matters for a last attribute which has a single-byte name
      and no value, otherwise the combination of namelen & valuelen will
      push endp further out and this test won't fail.
      
      Fixes: 1e1bbd8e ("xfs: create structure verifier function for shortform xattrs")
      Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
      Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      70d12ec7
    • zhangyi (F)'s avatar
      jbd2: add the missing unlock_buffer() in the error path of jbd2_write_superblock() · df4f1edd
      zhangyi (F) authored
      
      
      commit ef3f5830 upstream.
      
      jbd2_write_superblock() is under the buffer lock of journal superblock
      before ending that superblock write, so add a missing unlock_buffer() in
      in the error path before submitting buffer.
      
      Fixes: 742b06b5 ("jbd2: check superblock mapped prior to committing")
      Signed-off-by: default avatarzhangyi (F) <yi.zhang@huawei.com>
      Reviewed-by: default avatarRitesh Harjani <riteshh@linux.ibm.com>
      Cc: stable@kernel.org
      Link: https://lore.kernel.org/r/20200620061948.2049579-1-yi.zhang@huawei.com
      
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      df4f1edd
    • Eric Sandeen's avatar
      ext4: fix potential negative array index in do_split() · b1cc5906
      Eric Sandeen authored
      
      
      commit 5872331b upstream.
      
      If for any reason a directory passed to do_split() does not have enough
      active entries to exceed half the size of the block, we can end up
      iterating over all "count" entries without finding a split point.
      
      In this case, count == move, and split will be zero, and we will
      attempt a negative index into map[].
      
      Guard against this by detecting this case, and falling back to
      split-to-half-of-count instead; in this case we will still have
      plenty of space (> half blocksize) in each split block.
      
      Fixes: ef2b02d3 ("ext34: ensure do_split leaves enough free space in both blocks")
      Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
      Reviewed-by: default avatarAndreas Dilger <adilger@dilger.ca>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/f53e246b-647c-64bb-16ec-135383c70ad7@redhat.com
      
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      b1cc5906
    • Mikulas Patocka's avatar
      ext2: fix missing percpu_counter_inc · b5a77806
      Mikulas Patocka authored
      commit bc2fbaa4 upstream.
      
      sbi->s_freeinodes_counter is only decreased by the ext2 code, it is never
      increased. This patch fixes it.
      
      Note that sbi->s_freeinodes_counter is only used in the algorithm that
      tries to find the group for new allocations, so this bug is not easily
      visible (the only visibility is that the group finding algorithm selects
      inoptinal result).
      
      Link: https://lore.kernel.org/r/alpine.LRH.2.02.2004201538300.19436@file01.intranet.prod.int.rdu2.redhat.com
      
      
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Cc: stable@vger.kernel.org
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      b5a77806
    • Huacai Chen's avatar
      MIPS: CPU#0 is not hotpluggable · 299eee36
      Huacai Chen authored
      
      
      commit 9cce844a upstream.
      
      Now CPU#0 is not hotpluggable on MIPS, so prevent to create /sys/devices
      /system/cpu/cpu0/online which confuses some user-space tools.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      299eee36
    • Lukas Wunner's avatar
      driver core: Avoid binding drivers to dead devices · a5879011
      Lukas Wunner authored
      
      
      commit 65488832 upstream.
      
      Commit 3451a495 ("driver core: Establish order of operations for
      device_add and device_del via bitflag") sought to prevent asynchronous
      driver binding to a device which is being removed.  It added a
      per-device "dead" flag which is checked in the following code paths:
      
      * asynchronous binding in __driver_attach_async_helper()
      *  synchronous binding in device_driver_attach()
      * asynchronous binding in __device_attach_async_helper()
      
      It did *not* check the flag upon:
      
      *  synchronous binding in __device_attach()
      
      However __device_attach() may also be called asynchronously from:
      
      deferred_probe_work_func()
        bus_probe_device()
          device_initial_probe()
            __device_attach()
      
      So if the commit's intention was to check the "dead" flag in all
      asynchronous code paths, then a check is also necessary in
      __device_attach().  Add the missing check.
      
      Fixes: 3451a495 ("driver core: Establish order of operations for device_add and device_del via bitflag")
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Cc: stable@vger.kernel.org # v5.1+
      Cc: Alexander Duyck <alexander.h.duyck@linux.intel.com>
      Link: https://lore.kernel.org/r/de88a23a6fe0ef70f7cfd13c8aea9ab51b4edab6.1594214103.git.lukas@wunner.de
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      a5879011
    • Coly Li's avatar
      bcache: fix overflow in offset_to_stripe() · 031ee800
      Coly Li authored
      
      
      commit 7a148126 upstream.
      
      offset_to_stripe() returns the stripe number (in type unsigned int) from
      an offset (in type uint64_t) by the following calculation,
      	do_div(offset, d->stripe_size);
      For large capacity backing device (e.g. 18TB) with small stripe size
      (e.g. 4KB), the result is 4831838208 and exceeds UINT_MAX. The actual
      returned value which caller receives is 536870912, due to the overflow.
      
      Indeed in bcache_device_init(), bcache_device->nr_stripes is limited in
      range [1, INT_MAX]. Therefore all valid stripe numbers in bcache are
      in range [0, bcache_dev->nr_stripes - 1].
      
      This patch adds a upper limition check in offset_to_stripe(): the max
      valid stripe number should be less than bcache_device->nr_stripes. If
      the calculated stripe number from do_div() is equal to or larger than
      bcache_device->nr_stripe, -EINVAL will be returned. (Normally nr_stripes
      is less than INT_MAX, exceeding upper limitation doesn't mean overflow,
      therefore -EOVERFLOW is not used as error code.)
      
      This patch also changes nr_stripes' type of struct bcache_device from
      'unsigned int' to 'int', and return value type of offset_to_stripe()
      from 'unsigned int' to 'int', to match their exact data ranges.
      
      All locations where bcache_device->nr_stripes and offset_to_stripe() are
      referenced also get updated for the above type change.
      
      Reported-and-tested-by: default avatarKen Raeburn <raeburn@redhat.com>
      Signed-off-by: default avatarColy Li <colyli@suse.de>
      Cc: stable@vger.kernel.org
      Link: https://bugzilla.redhat.com/show_bug.cgi?id=1783075
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      031ee800
    • Coly Li's avatar
      bcache: allocate meta data pages as compound pages · 8dae4320
      Coly Li authored
      
      
      commit 5fe48867 upstream.
      
      There are some meta data of bcache are allocated by multiple pages,
      and they are used as bio bv_page for I/Os to the cache device. for
      example cache_set->uuids, cache->disk_buckets, journal_write->data,
      bset_tree->data.
      
      For such meta data memory, all the allocated pages should be treated
      as a single memory block. Then the memory management and underlying I/O
      code can treat them more clearly.
      
      This patch adds __GFP_COMP flag to all the location allocating >0 order
      pages for the above mentioned meta data. Then their pages are treated
      as compound pages now.
      
      Signed-off-by: default avatarColy Li <colyli@suse.de>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      8dae4320
    • ChangSyun Peng's avatar
      md/raid5: Fix Force reconstruct-write io stuck in degraded raid5 · 96ef36af
      ChangSyun Peng authored
      
      
      commit a1c6ae3d upstream.
      
      In degraded raid5, we need to read parity to do reconstruct-write when
      data disks fail. However, we can not read parity from
      handle_stripe_dirtying() in force reconstruct-write mode.
      
      Reproducible Steps:
      
      1. Create degraded raid5
      mdadm -C /dev/md2 --assume-clean -l5 -n3 /dev/sda2 /dev/sdb2 missing
      2. Set rmw_level to 0
      echo 0 > /sys/block/md2/md/rmw_level
      3. IO to raid5
      
      Now some io may be stuck in raid5. We can use handle_stripe_fill() to read
      the parity in this situation.
      
      Cc: <stable@vger.kernel.org> # v4.4+
      Reviewed-by: default avatarAlex Wu <alexwu@synology.com>
      Reviewed-by: default avatarBingJing Chang <bingjingc@synology.com>
      Reviewed-by: default avatarDanny Shih <dannyshih@synology.com>
      Signed-off-by: default avatarChangSyun Peng <allenpeng@synology.com>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      96ef36af
    • Kees Cook's avatar
      net/compat: Add missing sock updates for SCM_RIGHTS · 3c2b34f2
      Kees Cook authored
      
      
      commit d9539752 upstream.
      
      Add missed sock updates to compat path via a new helper, which will be
      used more in coming patches. (The net/core/scm.c code is left as-is here
      to assist with -stable backports for the compat path.)
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Sargun Dhillon <sargun@sargun.me>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: stable@vger.kernel.org
      Fixes: 48a87cc2 ("net: netprio: fd passed in SCM_RIGHTS datagram not set correctly")
      Fixes: d8429506 ("net: net_cls: fd passed in SCM_RIGHTS datagram not set correctly")
      Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      3c2b34f2
    • Jonathan McDowell's avatar
      net: stmmac: dwmac1000: provide multicast filter fallback · a21eb0f4
      Jonathan McDowell authored
      
      
      commit 592d751c upstream.
      
      If we don't have a hardware multicast filter available then instead of
      silently failing to listen for the requested ethernet broadcast
      addresses fall back to receiving all multicast packets, in a similar
      fashion to other drivers with no multicast filter.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJonathan McDowell <noodles@earth.li>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      a21eb0f4
    • Jonathan McDowell's avatar
      net: ethernet: stmmac: Disable hardware multicast filter · eb5a7d39
      Jonathan McDowell authored
      
      
      commit df43dd52 upstream.
      
      The IPQ806x does not appear to have a functional multicast ethernet
      address filter. This was observed as a failure to correctly receive IPv6
      packets on a LAN to the all stations address. Checking the vendor driver
      shows that it does not attempt to enable the multicast filter and
      instead falls back to receiving all multicast packets, internally
      setting ALLMULTI.
      
      Use the new fallback support in the dwmac1000 driver to correctly
      achieve the same with the mainline IPQ806x driver. Confirmed to fix IPv6
      functionality on an RB3011 router.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJonathan McDowell <noodles@earth.li>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      eb5a7d39
    • Eugeniu Rosca's avatar
      media: vsp1: dl: Fix NULL pointer dereference on unbind · 5d387e6d
      Eugeniu Rosca authored
      
      
      commit c92d30e4 upstream.
      
      In commit f3b98e3c ("media: vsp1: Provide support for extended
      command pools"), the vsp pointer used for referencing the VSP1 device
      structure from a command pool during vsp1_dl_ext_cmd_pool_destroy() was
      not populated.
      
      Correctly assign the pointer to prevent the following
      null-pointer-dereference when removing the device:
      
      [*] h3ulcb-kf #>
      echo fea28000.vsp > /sys/bus/platform/devices/fea28000.vsp/driver/unbind
       Unable to handle kernel NULL pointer dereference at virtual address 0000000000000028
       Mem abort info:
         ESR = 0x96000006
         EC = 0x25: DABT (current EL), IL = 32 bits
         SET = 0, FnV = 0
         EA = 0, S1PTW = 0
       Data abort info:
         ISV = 0, ISS = 0x00000006
         CM = 0, WnR = 0
       user pgtable: 4k pages, 48-bit VAs, pgdp=00000007318be000
       [0000000000000028] pgd=00000007333a1003, pud=00000007333a6003, pmd=0000000000000000
       Internal error: Oops: 96000006 [#1] PREEMPT SMP
       Modules linked in:
       CPU: 1 PID: 486 Comm: sh Not tainted 5.7.0-rc6-arm64-renesas-00118-ge644645abf47 #185
       Hardware name: Renesas H3ULCB Kingfisher board based on r8a77951 (DT)
       pstate: 40000005 (nZcv daif -PAN -UAO)
       pc : vsp1_dlm_destroy+0xe4/0x11c
       lr : vsp1_dlm_destroy+0xc8/0x11c
       sp : ffff800012963b60
       x29: ffff800012963b60 x28: ffff0006f83fc440
       x27: 0000000000000000 x26: ffff0006f5e13e80
       x25: ffff0006f5e13ed0 x24: ffff0006f5e13ed0
       x23: ffff0006f5e13ed0 x22: dead000000000122
       x21: ffff0006f5e3a080 x20: ffff0006f5df2938
       x19: ffff0006f5df2980 x18: 0000000000000003
       x17: 0000000000000000 x16: 0000000000000016
       x15: 0000000000000003 x14: 00000000000393c0
       x13: ffff800011a5ec18 x12: ffff800011d8d000
       x11: ffff0006f83fcc68 x10: ffff800011a53d70
       x9 : ffff8000111f3000 x8 : 0000000000000000
       x7 : 0000000000210d00 x6 : 0000000000000000
       x5 : ffff800010872e60 x4 : 0000000000000004
       x3 : 0000000078068000 x2 : ffff800012781000
       x1 : 0000000000002c00 x0 : 0000000000000000
       Call trace:
        vsp1_dlm_destroy+0xe4/0x11c
        vsp1_wpf_destroy+0x10/0x20
        vsp1_entity_destroy+0x24/0x4c
        vsp1_destroy_entities+0x54/0x130
        vsp1_remove+0x1c/0x40
        platform_drv_remove+0x28/0x50
        __device_release_driver+0x178/0x220
        device_driver_detach+0x44/0xc0
        unbind_store+0xe0/0x104
        drv_attr_store+0x20/0x30
        sysfs_kf_write+0x48/0x70
        kernfs_fop_write+0x148/0x230
        __vfs_write+0x18/0x40
        vfs_write+0xdc/0x1c4
        ksys_write+0x68/0xf0
        __arm64_sys_write+0x18/0x20
        el0_svc_common.constprop.0+0x70/0x170
        do_el0_svc+0x20/0x80
        el0_sync_handler+0x134/0x1b0
        el0_sync+0x140/0x180
       Code: b40000c2 f9403a60 d2800084 a9400663 (f9401400)
       ---[ end trace 3875369841fb288a ]---
      
      Fixes: f3b98e3c ("media: vsp1: Provide support for extended command pools")
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Tested-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      5d387e6d
    • Paul Cercueil's avatar
      pinctrl: ingenic: Enhance support for IRQ_TYPE_EDGE_BOTH · e97d6ccd
      Paul Cercueil authored
      
      
      commit 1c95348b upstream.
      
      Ingenic SoCs don't natively support registering an interrupt for both
      rising and falling edges. This has to be emulated in software.
      
      Until now, this was emulated by switching back and forth between
      IRQ_TYPE_EDGE_RISING and IRQ_TYPE_EDGE_FALLING according to the level of
      the GPIO. While this worked most of the time, when used with GPIOs that
      need debouncing, some events would be lost. For instance, between the
      time a falling-edge interrupt happens and the interrupt handler
      configures the hardware for rising-edge, the level of the pin may have
      already risen, and the rising-edge event is lost.
      
      To address that issue, instead of switching back and forth between
      IRQ_TYPE_EDGE_RISING and IRQ_TYPE_EDGE_FALLING, we now switch back and
      forth between IRQ_TYPE_LEVEL_LOW and IRQ_TYPE_LEVEL_HIGH. Since we
      always switch in the interrupt handler, they actually permit to detect
      level changes. In the example above, if the pin level rises before
      switching the IRQ type from IRQ_TYPE_LEVEL_LOW to IRQ_TYPE_LEVEL_HIGH,
      a new interrupt will raise as soon as the handler exits, and the
      rising-edge event will be properly detected.
      
      Fixes: e72394e2 ("pinctrl: ingenic: Merge GPIO functionality")
      Reported-by: default avatarJoão Henrique <johnnyonflame@hotmail.com>
      Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
      Tested-by: default avatarJoão Henrique <johnnyonflame@hotmail.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200622214548.265417-1-paul@crapouillou.net
      
      
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      e97d6ccd
    • Michael Ellerman's avatar
      powerpc: Allow 4224 bytes of stack expansion for the signal frame · bd5fc469
      Michael Ellerman authored
      
      
      commit 63dee5df upstream.
      
      We have powerpc specific logic in our page fault handling to decide if
      an access to an unmapped address below the stack pointer should expand
      the stack VMA.
      
      The code was originally added in 2004 "ported from 2.4". The rough
      logic is that the stack is allowed to grow to 1MB with no extra
      checking. Over 1MB the access must be within 2048 bytes of the stack
      pointer, or be from a user instruction that updates the stack pointer.
      
      The 2048 byte allowance below the stack pointer is there to cover the
      288 byte "red zone" as well as the "about 1.5kB" needed by the signal
      delivery code.
      
      Unfortunately since then the signal frame has expanded, and is now
      4224 bytes on 64-bit kernels with transactional memory enabled. This
      means if a process has consumed more than 1MB of stack, and its stack
      pointer lies less than 4224 bytes from the next page boundary, signal
      delivery will fault when trying to expand the stack and the process
      will see a SEGV.
      
      The total size of the signal frame is the size of struct rt_sigframe
      (which includes the red zone) plus __SIGNAL_FRAMESIZE (128 bytes on
      64-bit).
      
      The 2048 byte allowance was correct until 2008 as the signal frame
      was:
      
      struct rt_sigframe {
              struct ucontext    uc;                           /*     0  1440 */
              /* --- cacheline 11 boundary (1408 bytes) was 32 bytes ago --- */
              long unsigned int          _unused[2];           /*  1440    16 */
              unsigned int               tramp[6];             /*  1456    24 */
              struct siginfo *           pinfo;                /*  1480     8 */
              void *                     puc;                  /*  1488     8 */
              struct siginfo     info;                         /*  1496   128 */
              /* --- cacheline 12 boundary (1536 bytes) was 88 bytes ago --- */
              char                       abigap[288];          /*  1624   288 */
      
              /* size: 1920, cachelines: 15, members: 7 */
              /* padding: 8 */
      };
      
      1920 + 128 = 2048
      
      Then in commit ce48b210 ("powerpc: Add VSX context save/restore,
      ptrace and signal support") (Jul 2008) the signal frame expanded to
      2304 bytes:
      
      struct rt_sigframe {
              struct ucontext    uc;                           /*     0  1696 */	<--
              /* --- cacheline 13 boundary (1664 bytes) was 32 bytes ago --- */
              long unsigned int          _unused[2];           /*  1696    16 */
              unsigned int               tramp[6];             /*  1712    24 */
              struct siginfo *           pinfo;                /*  1736     8 */
              void *                     puc;                  /*  1744     8 */
              struct siginfo     info;                         /*  1752   128 */
              /* --- cacheline 14 boundary (1792 bytes) was 88 bytes ago --- */
              char                       abigap[288];          /*  1880   288 */
      
              /* size: 2176, cachelines: 17, members: 7 */
              /* padding: 8 */
      };
      
      2176 + 128 = 2304
      
      At this point we should have been exposed to the bug, though as far as
      I know it was never reported. I no longer have a system old enough to
      easily test on.
      
      Then in 2010 commit 320b2b8d ("mm: keep a guard page below a
      grow-down stack segment") caused our stack expansion code to never
      trigger, as there was always a VMA found for a write up to PAGE_SIZE
      below r1.
      
      That meant the bug was hidden as we continued to expand the signal
      frame in commit 2b0a576d ("powerpc: Add new transactional memory
      state to the signal context") (Feb 2013):
      
      struct rt_sigframe {
              struct ucontext    uc;                           /*     0  1696 */
              /* --- cacheline 13 boundary (1664 bytes) was 32 bytes ago --- */
              struct ucontext    uc_transact;                  /*  1696  1696 */	<--
              /* --- cacheline 26 boundary (3328 bytes) was 64 bytes ago --- */
              long unsigned int          _unused[2];           /*  3392    16 */
              unsigned int               tramp[6];             /*  3408    24 */
              struct siginfo *           pinfo;                /*  3432     8 */
              void *                     puc;                  /*  3440     8 */
              struct siginfo     info;                         /*  3448   128 */
              /* --- cacheline 27 boundary (3456 bytes) was 120 bytes ago --- */
              char                       abigap[288];          /*  3576   288 */
      
              /* size: 3872, cachelines: 31, members: 8 */
              /* padding: 8 */
              /* last cacheline: 32 bytes */
      };
      
      3872 + 128 = 4000
      
      And commit 573ebfa6 ("powerpc: Increase stack redzone for 64-bit
      userspace to 512 bytes") (Feb 2014):
      
      struct rt_sigframe {
              struct ucontext    uc;                           /*     0  1696 */
              /* --- cacheline 13 boundary (1664 bytes) was 32 bytes ago --- */
              struct ucontext    uc_transact;                  /*  1696  1696 */
              /* --- cacheline 26 boundary (3328 bytes) was 64 bytes ago --- */
              long unsigned int          _unused[2];           /*  3392    16 */
              unsigned int               tramp[6];             /*  3408    24 */
              struct siginfo *           pinfo;                /*  3432     8 */
              void *                     puc;                  /*  3440     8 */
              struct siginfo     info;                         /*  3448   128 */
              /* --- cacheline 27 boundary (3456 bytes) was 120 bytes ago --- */
              char                       abigap[512];          /*  3576   512 */	<--
      
              /* size: 4096, cachelines: 32, members: 8 */
              /* padding: 8 */
      };
      
      4096 + 128 = 4224
      
      Then finally in 2017, commit 1be7107f ("mm: larger stack guard
      gap, between vmas") exposed us to the existing bug, because it changed
      the stack VMA to be the correct/real size, meaning our stack expansion
      code is now triggered.
      
      Fix it by increasing the allowance to 4224 bytes.
      
      Hard-coding 4224 is obviously unsafe against future expansions of the
      signal frame in the same way as the existing code. We can't easily use
      sizeof() because the signal frame structure is not in a header. We
      will either fix that, or rip out all the custom stack expansion
      checking logic entirely.
      
      Fixes: ce48b210 ("powerpc: Add VSX context save/restore, ptrace and signal support")
      Cc: stable@vger.kernel.org # v2.6.27+
      Reported-by: default avatarTom Lane <tgl@sss.pgh.pa.us>
      Tested-by: default avatarDaniel Axtens <dja@axtens.net>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200724092528.1578671-2-mpe@ellerman.id.au
      
      
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      bd5fc469
    • Paul Aurich's avatar
      cifs: Fix leak when handling lease break for cached root fid · 9afeb7f6
      Paul Aurich authored
      
      
      commit baf57b56 upstream.
      
      Handling a lease break for the cached root didn't free the
      smb2_lease_break_work allocation, resulting in a leak:
      
          unreferenced object 0xffff98383a5af480 (size 128):
            comm "cifsd", pid 684, jiffies 4294936606 (age 534.868s)
            hex dump (first 32 bytes):
              c0 ff ff ff 1f 00 00 00 88 f4 5a 3a 38 98 ff ff  ..........Z:8...
              88 f4 5a 3a 38 98 ff ff 80 88 d6 8a ff ff ff ff  ..Z:8...........
            backtrace:
              [<0000000068957336>] smb2_is_valid_oplock_break+0x1fa/0x8c0
              [<0000000073b70b9e>] cifs_demultiplex_thread+0x73d/0xcc0
              [<00000000905fa372>] kthread+0x11c/0x150
              [<0000000079378e4e>] ret_from_fork+0x22/0x30
      
      Avoid this leak by only allocating when necessary.
      
      Fixes: a93864d9 ("cifs: add lease tracking to the cached root fid")
      Signed-off-by: default avatarPaul Aurich <paul@darkrain42.org>
      CC: Stable <stable@vger.kernel.org> # v4.18+
      Reviewed-by: default avatarAurelien Aptel <aaptel@suse.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      9afeb7f6
    • Max Filippov's avatar
      xtensa: fix xtensa_pmu_setup prototype · 33575562
      Max Filippov authored
      
      
      commit 6d65d376 upstream.
      
      Fix the following build error in configurations with
      CONFIG_XTENSA_VARIANT_HAVE_PERF_EVENTS=y:
      
        arch/xtensa/kernel/perf_event.c:420:29: error: passing argument 3 of
        ‘cpuhp_setup_state’ from incompatible pointer type
      
      Cc: stable@vger.kernel.org
      Fixes: 25a77b55 ("xtensa/perf: Convert the hotplug notifier to state machine callbacks")
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      33575562
    • Max Filippov's avatar
      xtensa: add missing exclusive access state management · f154bb84
      Max Filippov authored
      
      
      commit a0fc1436 upstream.
      
      The result of the s32ex opcode is recorded in the ATOMCTL special
      register and must be retrieved with the getex opcode. Context switch
      between s32ex and getex may trash the ATOMCTL register and result in
      duplicate update or missing update of the atomic variable.
      Add atomctl8 field to the struct thread_info and use getex to swap
      ATOMCTL bit 8 as a part of context switch.
      Clear exclusive access monitor on kernel entry.
      
      Cc: stable@vger.kernel.org
      Fixes: f7c34874 ("xtensa: add exclusive atomics support")
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      f154bb84
    • Alexandru Ardelean's avatar
      iio: dac: ad5592r: fix unbalanced mutex unlocks in ad5592r_read_raw() · d7a0ae03
      Alexandru Ardelean authored
      
      
      commit 65afb093 upstream.
      
      There are 2 exit paths where the lock isn't held, but try to unlock the
      mutex when exiting. In these places we should just return from the
      function.
      
      A neater approach would be to cleanup the ad5592r_read_raw(), but that
      would make this patch more difficult to backport to stable versions.
      
      Fixes 56ca9db8: ("iio: dac: Add support for the AD5592R/AD5593R ADCs/DACs")
      Reported-by: default avatarCharles Stanhope <charles.stanhope@gmail.com>
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      d7a0ae03
    • Christian Eggers's avatar
      dt-bindings: iio: io-channel-mux: Fix compatible string in example code · 5727687b
      Christian Eggers authored
      
      
      commit add48ba4 upstream.
      
      The correct compatible string is "gpio-mux" (see
      bindings/mux/gpio-mux.txt).
      
      Cc: stable@vger.kernel.org # v4.13+
      Reviewed-by: default avatarPeter Rosin <peda@axentia.se>
      Signed-off-by: default avatarChristian Eggers <ceggers@arri.de>
      Link: https://lore.kernel.org/r/20200727101605.24384-1-ceggers@arri.de
      
      
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      5727687b
    • Shaokun Zhang's avatar
      arm64: perf: Correct the event index in sysfs · 45fba5e9
      Shaokun Zhang authored
      
      
      commit 539707ca upstream.
      
      When PMU event ID is equal or greater than 0x4000, it will be reduced
      by 0x4000 and it is not the raw number in the sysfs. Let's correct it
      and obtain the raw event ID.
      
      Before this patch:
      cat /sys/bus/event_source/devices/armv8_pmuv3_0/events/sample_feed
      event=0x001
      After this patch:
      cat /sys/bus/event_source/devices/armv8_pmuv3_0/events/sample_feed
      event=0x4001
      
      Signed-off-by: default avatarShaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/1592487344-30555-3-git-send-email-zhangshaokun@hisilicon.com
      
      
      [will: fixed formatting of 'if' condition]
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      45fba5e9
    • Filipe Manana's avatar
      btrfs: fix memory leaks after failure to lookup checksums during inode logging · 4f1f59d9
      Filipe Manana authored
      
      
      commit 4f26433e upstream.
      
      While logging an inode, at copy_items(), if we fail to lookup the checksums
      for an extent we release the destination path, free the ins_data array and
      then return immediately. However a previous iteration of the for loop may
      have added checksums to the ordered_sums list, in which case we leak the
      memory used by them.
      
      So fix this by making sure we iterate the ordered_sums list and free all
      its checksums before returning.
      
      Fixes: 3650860b ("Btrfs: remove almost all of the BUG()'s from tree-log.c")
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.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>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      4f1f59d9
    • Josef Bacik's avatar
      btrfs: only search for left_info if there is no right_info in try_merge_free_space · 212d957d
      Josef Bacik authored
      
      
      commit bf53d468 upstream.
      
      In try_to_merge_free_space we attempt to find entries to the left and
      right of the entry we are adding to see if they can be merged.  We
      search for an entry past our current info (saved into right_info), and
      then if right_info exists and it has a rb_prev() we save the rb_prev()
      into left_info.
      
      However there's a slight problem in the case that we have a right_info,
      but no entry previous to that entry.  At that point we will search for
      an entry just before the info we're attempting to insert.  This will
      simply find right_info again, and assign it to left_info, making them
      both the same pointer.
      
      Now if right_info _can_ be merged with the range we're inserting, we'll
      add it to the info and free right_info.  However further down we'll
      access left_info, which was right_info, and thus get a use-after-free.
      
      Fix this by only searching for the left entry if we don't find a right
      entry at all.
      
      The CVE referenced had a specially crafted file system that could
      trigger this use-after-free. However with the tree checker improvements
      we no longer trigger the conditions for the UAF.  But the original
      conditions still apply, hence this fix.
      
      Reference: CVE-2019-19448
      Fixes: 96303081 ("Btrfs: use hybrid extents+bitmap rb tree for free space")
      CC: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      212d957d
    • David Sterba's avatar
      btrfs: fix messages after changing compression level by remount · b7dc59ad
      David Sterba authored
      
      
      commit 27942c99 upstream.
      
      Reported by Forza on IRC that remounting with compression options does
      not reflect the change in level, or at least it does not appear to do so
      according to the messages:
      
        mount -o compress=zstd:1 /dev/sda /mnt
        mount -o remount,compress=zstd:15 /mnt
      
      does not print the change to the level to syslog:
      
        [   41.366060] BTRFS info (device vda): use zstd compression, level 1
        [   41.368254] BTRFS info (device vda): disk space caching is enabled
        [   41.390429] BTRFS info (device vda): disk space caching is enabled
      
      What really happens is that the message is lost but the level is actualy
      changed.
      
      There's another weird output, if compression is reset to 'no':
      
        [   45.413776] BTRFS info (device vda): use no compression, level 4
      
      To fix that, save the previous compression level and print the message
      in that case too and use separate message for 'no' compression.
      
      CC: stable@vger.kernel.org # 4.19+
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      b7dc59ad
    • Josef Bacik's avatar
      btrfs: move the chunk_mutex in btrfs_read_chunk_tree · 06cab2ea
      Josef Bacik authored
      
      
      commit 01d01caf upstream.
      
      We are currently getting this lockdep splat in btrfs/161:
      
        ======================================================
        WARNING: possible circular locking dependency detected
        5.8.0-rc5+ #20 Tainted: G            E
        ------------------------------------------------------
        mount/678048 is trying to acquire lock:
        ffff9b769f15b6e0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: clone_fs_devices+0x4d/0x170 [btrfs]
      
        but task is already holding lock:
        ffff9b76abdb08d0 (&fs_info->chunk_mutex){+.+.}-{3:3}, at: btrfs_read_chunk_tree+0x6a/0x800 [btrfs]
      
        which lock already depends on the new lock.
      
        the existing dependency chain (in reverse order) is:
      
        -> #1 (&fs_info->chunk_mutex){+.+.}-{3:3}:
      	 __mutex_lock+0x8b/0x8f0
      	 btrfs_init_new_device+0x2d2/0x1240 [btrfs]
      	 btrfs_ioctl+0x1de/0x2d20 [btrfs]
      	 ksys_ioctl+0x87/0xc0
      	 __x64_sys_ioctl+0x16/0x20
      	 do_syscall_64+0x52/0xb0
      	 entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
        -> #0 (&fs_devs->device_list_mutex){+.+.}-{3:3}:
      	 __lock_acquire+0x1240/0x2460
      	 lock_acquire+0xab/0x360
      	 __mutex_lock+0x8b/0x8f0
      	 clone_fs_devices+0x4d/0x170 [btrfs]
      	 btrfs_read_chunk_tree+0x330/0x800 [btrfs]
      	 open_ctree+0xb7c/0x18ce [btrfs]
      	 btrfs_mount_root.cold+0x13/0xfa [btrfs]
      	 legacy_get_tree+0x30/0x50
      	 vfs_get_tree+0x28/0xc0
      	 fc_mount+0xe/0x40
      	 vfs_kern_mount.part.0+0x71/0x90
      	 btrfs_mount+0x13b/0x3e0 [btrfs]
      	 legacy_get_tree+0x30/0x50
      	 vfs_get_tree+0x28/0xc0
      	 do_mount+0x7de/0xb30
      	 __x64_sys_mount+0x8e/0xd0
      	 do_syscall_64+0x52/0xb0
      	 entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
        other info that might help us debug this:
      
         Possible unsafe locking scenario:
      
      	 CPU0                    CPU1
      	 ----                    ----
          lock(&fs_info->chunk_mutex);
      				 lock(&fs_devs->device_list_mutex);
      				 lock(&fs_info->chunk_mutex);
          lock(&fs_devs->device_list_mutex);
      
         *** DEADLOCK ***
      
        3 locks held by mount/678048:
         #0: ffff9b75ff5fb0e0 (&type->s_umount_key#63/1){+.+.}-{3:3}, at: alloc_super+0xb5/0x380
         #1: ffffffffc0c2fbc8 (uuid_mutex){+.+.}-{3:3}, at: btrfs_read_chunk_tree+0x54/0x800 [btrfs]
         #2: ffff9b76abdb08d0 (&fs_info->chunk_mutex){+.+.}-{3:3}, at: btrfs_read_chunk_tree+0x6a/0x800 [btrfs]
      
        stack backtrace:
        CPU: 2 PID: 678048 Comm: mount Tainted: G            E     5.8.0-rc5+ #20
        Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./890FX Deluxe5, BIOS P1.40 05/03/2011
        Call Trace:
         dump_stack+0x96/0xd0
         check_noncircular+0x162/0x180
         __lock_acquire+0x1240/0x2460
         ? asm_sysvec_apic_timer_interrupt+0x12/0x20
         lock_acquire+0xab/0x360
         ? clone_fs_devices+0x4d/0x170 [btrfs]
         __mutex_lock+0x8b/0x8f0
         ? clone_fs_devices+0x4d/0x170 [btrfs]
         ? rcu_read_lock_sched_held+0x52/0x60
         ? cpumask_next+0x16/0x20
         ? module_assert_mutex_or_preempt+0x14/0x40
         ? __module_address+0x28/0xf0
         ? clone_fs_devices+0x4d/0x170 [btrfs]
         ? static_obj+0x4f/0x60
         ? lockdep_init_map_waits+0x43/0x200
         ? clone_fs_devices+0x4d/0x170 [btrfs]
         clone_fs_devices+0x4d/0x170 [btrfs]
         btrfs_read_chunk_tree+0x330/0x800 [btrfs]
         open_ctree+0xb7c/0x18ce [btrfs]
         ? super_setup_bdi_name+0x79/0xd0
         btrfs_mount_root.cold+0x13/0xfa [btrfs]
         ? vfs_parse_fs_string+0x84/0xb0
         ? rcu_read_lock_sched_held+0x52/0x60
         ? kfree+0x2b5/0x310
         legacy_get_tree+0x30/0x50
         vfs_get_tree+0x28/0xc0
         fc_mount+0xe/0x40
         vfs_kern_mount.part.0+0x71/0x90
         btrfs_mount+0x13b/0x3e0 [btrfs]
         ? cred_has_capability+0x7c/0x120
         ? rcu_read_lock_sched_held+0x52/0x60
         ? legacy_get_tree+0x30/0x50
         legacy_get_tree+0x30/0x50
         vfs_get_tree+0x28/0xc0
         do_mount+0x7de/0xb30
         ? memdup_user+0x4e/0x90
         __x64_sys_mount+0x8e/0xd0
         do_syscall_64+0x52/0xb0
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      This is because btrfs_read_chunk_tree() can come upon DEV_EXTENT's and
      then read the device, which takes the device_list_mutex.  The
      device_list_mutex needs to be taken before the chunk_mutex, so this is a
      problem.  We only really need the chunk mutex around adding the chunk,
      so move the mutex around read_one_chunk.
      
      An argument could be made that we don't even need the chunk_mutex here
      as it's during mount, and we are protected by various other locks.
      However we already have special rules for ->device_list_mutex, and I'd
      rather not have another special case for ->chunk_mutex.
      
      CC: stable@vger.kernel.org # 4.19+
      Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      06cab2ea
    • Josef Bacik's avatar
      btrfs: open device without device_list_mutex · 9453c6b4
      Josef Bacik authored
      
      
      commit 18c850fd upstream.
      
      There's long existed a lockdep splat because we open our bdev's under
      the ->device_list_mutex at mount time, which acquires the bd_mutex.
      Usually this goes unnoticed, but if you do loopback devices at all
      suddenly the bd_mutex comes with a whole host of other dependencies,
      which results in the splat when you mount a btrfs file system.
      
      ======================================================
      WARNING: possible circular locking dependency detected
      5.8.0-0.rc3.1.fc33.x86_64+debug #1 Not tainted
      ------------------------------------------------------
      systemd-journal/509 is trying to acquire lock:
      ffff970831f84db0 (&fs_info->reloc_mutex){+.+.}-{3:3}, at: btrfs_record_root_in_trans+0x44/0x70 [btrfs]
      
      but task is already holding lock:
      ffff97083144d598 (sb_pagefaults){.+.+}-{0:0}, at: btrfs_page_mkwrite+0x59/0x560 [btrfs]
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
       -> #6 (sb_pagefaults){.+.+}-{0:0}:
             __sb_start_write+0x13e/0x220
             btrfs_page_mkwrite+0x59/0x560 [btrfs]
             do_page_mkwrite+0x4f/0x130
             do_wp_page+0x3b0/0x4f0
             handle_mm_fault+0xf47/0x1850
             do_user_addr_fault+0x1fc/0x4b0
             exc_page_fault+0x88/0x300
             asm_exc_page_fault+0x1e/0x30
      
       -> #5 (&mm->mmap_lock#2){++++}-{3:3}:
             __might_fault+0x60/0x80
             _copy_from_user+0x20/0xb0
             get_sg_io_hdr+0x9a/0xb0
             scsi_cmd_ioctl+0x1ea/0x2f0
             cdrom_ioctl+0x3c/0x12b4
             sr_block_ioctl+0xa4/0xd0
             block_ioctl+0x3f/0x50
             ksys_ioctl+0x82/0xc0
             __x64_sys_ioctl+0x16/0x20
             do_syscall_64+0x52/0xb0
             entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
       -> #4 (&cd->lock){+.+.}-{3:3}:
             __mutex_lock+0x7b/0x820
             sr_block_open+0xa2/0x180
             __blkdev_get+0xdd/0x550
             blkdev_get+0x38/0x150
             do_dentry_open+0x16b/0x3e0
             path_openat+0x3c9/0xa00
             do_filp_open+0x75/0x100
             do_sys_openat2+0x8a/0x140
             __x64_sys_openat+0x46/0x70
             do_syscall_64+0x52/0xb0
             entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
       -> #3 (&bdev->bd_mutex){+.+.}-{3:3}:
             __mutex_lock+0x7b/0x820
             __blkdev_get+0x6a/0x550
             blkdev_get+0x85/0x150
             blkdev_get_by_path+0x2c/0x70
             btrfs_get_bdev_and_sb+0x1b/0xb0 [btrfs]
             open_fs_devices+0x88/0x240 [btrfs]
             btrfs_open_devices+0x92/0xa0 [btrfs]
             btrfs_mount_root+0x250/0x490 [btrfs]
             legacy_get_tree+0x30/0x50
             vfs_get_tree+0x28/0xc0
             vfs_kern_mount.part.0+0x71/0xb0
             btrfs_mount+0x119/0x380 [btrfs]
             legacy_get_tree+0x30/0x50
             vfs_get_tree+0x28/0xc0
             do_mount+0x8c6/0xca0
             __x64_sys_mount+0x8e/0xd0
             do_syscall_64+0x52/0xb0
             entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
       -> #2 (&fs_devs->device_list_mutex){+.+.}-{3:3}:
             __mutex_lock+0x7b/0x820
             btrfs_run_dev_stats+0x36/0x420 [btrfs]
             commit_cowonly_roots+0x91/0x2d0 [btrfs]
             btrfs_commit_transaction+0x4e6/0x9f0 [btrfs]
             btrfs_sync_file+0x38a/0x480 [btrfs]
             __x64_sys_fdatasync+0x47/0x80
             do_syscall_64+0x52/0xb0
             entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
       -> #1 (&fs_info->tree_log_mutex){+.+.}-{3:3}:
             __mutex_lock+0x7b/0x820
             btrfs_commit_transaction+0x48e/0x9f0 [btrfs]
             btrfs_sync_file+0x38a/0x480 [btrfs]
             __x64_sys_fdatasync+0x47/0x80
             do_syscall_64+0x52/0xb0
             entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
       -> #0 (&fs_info->reloc_mutex){+.+.}-{3:3}:
             __lock_acquire+0x1241/0x20c0
             lock_acquire+0xb0/0x400
             __mutex_lock+0x7b/0x820
             btrfs_record_root_in_trans+0x44/0x70 [btrfs]
             start_transaction+0xd2/0x500 [btrfs]
             btrfs_dirty_inode+0x44/0xd0 [btrfs]
             file_update_time+0xc6/0x120
             btrfs_page_mkwrite+0xda/0x560 [btrfs]
             do_page_mkwrite+0x4f/0x130
             do_wp_page+0x3b0/0x4f0
             handle_mm_fault+0xf47/0x1850
             do_user_addr_fault+0x1fc/0x4b0
             exc_page_fault+0x88/0x300
             asm_exc_page_fault+0x1e/0x30
      
      other info that might help us debug this:
      
      Chain exists of:
        &fs_info->reloc_mutex --> &mm->mmap_lock#2 --> sb_pagefaults
      
      Possible unsafe locking scenario:
      
           CPU0                    CPU1
           ----                    ----
       lock(sb_pagefaults);
                                   lock(&mm->mmap_lock#2);
                                   lock(sb_pagefaults);
       lock(&fs_info->reloc_mutex);
      
       *** DEADLOCK ***
      
      3 locks held by systemd-journal/509:
       #0: ffff97083bdec8b8 (&mm->mmap_lock#2){++++}-{3:3}, at: do_user_addr_fault+0x12e/0x4b0
       #1: ffff97083144d598 (sb_pagefaults){.+.+}-{0:0}, at: btrfs_page_mkwrite+0x59/0x560 [btrfs]
       #2: ffff97083144d6a8 (sb_internal){.+.+}-{0:0}, at: start_transaction+0x3f8/0x500 [btrfs]
      
      stack backtrace:
      CPU: 0 PID: 509 Comm: systemd-journal Not tainted 5.8.0-0.rc3.1.fc33.x86_64+debug #1
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
      Call Trace:
       dump_stack+0x92/0xc8
       check_noncircular+0x134/0x150
       __lock_acquire+0x1241/0x20c0
       lock_acquire+0xb0/0x400
       ? btrfs_record_root_in_trans+0x44/0x70 [btrfs]
       ? lock_acquire+0xb0/0x400
       ? btrfs_record_root_in_trans+0x44/0x70 [btrfs]
       __mutex_lock+0x7b/0x820
       ? btrfs_record_root_in_trans+0x44/0x70 [btrfs]
       ? kvm_sched_clock_read+0x14/0x30
       ? sched_clock+0x5/0x10
       ? sched_clock_cpu+0xc/0xb0
       btrfs_record_root_in_trans+0x44/0x70 [btrfs]
       start_transaction+0xd2/0x500 [btrfs]
       btrfs_dirty_inode+0x44/0xd0 [btrfs]
       file_update_time+0xc6/0x120
       btrfs_page_mkwrite+0xda/0x560 [btrfs]
       ? sched_clock+0x5/0x10
       do_page_mkwrite+0x4f/0x130
       do_wp_page+0x3b0/0x4f0
       handle_mm_fault+0xf47/0x1850
       do_user_addr_fault+0x1fc/0x4b0
       exc_page_fault+0x88/0x300
       ? asm_exc_page_fault+0x8/0x30
       asm_exc_page_fault+0x1e/0x30
      RIP: 0033:0x7fa3972fdbfe
      Code: Bad RIP value.
      
      Fix this by not holding the ->device_list_mutex at this point.  The
      device_list_mutex exists to protect us from modifying the device list
      while the file system is running.
      
      However it can also be modified by doing a scan on a device.  But this
      action is specifically protected by the uuid_mutex, which we are holding
      here.  We cannot race with opening at this point because we have the
      ->s_mount lock held during the mount.  Not having the
      ->device_list_mutex here is perfectly safe as we're not going to change
      the devices at this point.
      
      CC: stable@vger.kernel.org # 4.19+
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      [ add some comments ]
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      9453c6b4
    • Anand Jain's avatar
      btrfs: don't traverse into the seed devices in show_devname · bbefb46b
      Anand Jain authored
      
      
      commit 4faf55b0 upstream.
      
      ->show_devname currently shows the lowest devid in the list. As the seed
      devices have the lowest devid in the sprouted filesystem, the userland
      tool such as findmnt end up seeing seed device instead of the device from
      the read-writable sprouted filesystem. As shown below.
      
       mount /dev/sda /btrfs
       mount: /btrfs: WARNING: device write-protected, mounted read-only.
      
       findmnt --output SOURCE,TARGET,UUID /btrfs
       SOURCE   TARGET UUID
       /dev/sda /btrfs 899f7027-3e46-4626-93e7-7d4c9ad19111
      
       btrfs dev add -f /dev/sdb /btrfs
      
       umount /btrfs
       mount /dev/sdb /btrfs
      
       findmnt --output SOURCE,TARGET,UUID /btrfs
       SOURCE   TARGET UUID
       /dev/sda /btrfs 899f7027-3e46-4626-93e7-7d4c9ad19111
      
      All sprouts from a single seed will show the same seed device and the
      same fsid. That's confusing.
      This is causing problems in our prototype as there isn't any reference
      to the sprout file-system(s) which is being used for actual read and
      write.
      
      This was added in the patch which implemented the show_devname in btrfs
      commit 9c5085c1 ("Btrfs: implement ->show_devname").
      I tried to look for any particular reason that we need to show the seed
      device, there isn't any.
      
      So instead, do not traverse through the seed devices, just show the
      lowest devid in the sprouted fsid.
      
      After the patch:
      
       mount /dev/sda /btrfs
       mount: /btrfs: WARNING: device write-protected, mounted read-only.
      
       findmnt --output SOURCE,TARGET,UUID /btrfs
       SOURCE   TARGET UUID
       /dev/sda /btrfs 899f7027-3e46-4626-93e7-7d4c9ad19111
      
       btrfs dev add -f /dev/sdb /btrfs
       mount -o rw,remount /dev/sdb /btrfs
      
       findmnt --output SOURCE,TARGET,UUID /btrfs
       SOURCE   TARGET UUID
       /dev/sdb /btrfs 595ca0e6-b82e-46b5-b9e2-c72a6928be48
      
       mount /dev/sda /btrfs1
       mount: /btrfs1: WARNING: device write-protected, mounted read-only.
      
       btrfs dev add -f /dev/sdc /btrfs1
      
       findmnt --output SOURCE,TARGET,UUID /btrfs1
       SOURCE   TARGET  UUID
       /dev/sdc /btrfs1 ca1dbb7a-8446-4f95-853c-a20f3f82bdbb
      
       cat /proc/self/mounts | grep btrfs
       /dev/sdb /btrfs btrfs rw,relatime,noacl,space_cache,subvolid=5,subvol=/ 0 0
       /dev/sdc /btrfs1 btrfs ro,relatime,noacl,space_cache,subvolid=5,subvol=/ 0 0
      
      Reported-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      CC: stable@vger.kernel.org # 4.19+
      Tested-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      bbefb46b
    • Tom Rix's avatar
      btrfs: ref-verify: fix memory leak in add_block_entry · a4988cb5
      Tom Rix authored
      
      
      commit d60ba8de upstream.
      
      clang static analysis flags this error
      
      fs/btrfs/ref-verify.c:290:3: warning: Potential leak of memory pointed to by 're' [unix.Malloc]
                      kfree(be);
                      ^~~~~
      
      The problem is in this block of code:
      
      	if (root_objectid) {
      		struct root_entry *exist_re;
      
      		exist_re = insert_root_entry(&exist->roots, re);
      		if (exist_re)
      			kfree(re);
      	}
      
      There is no 'else' block freeing when root_objectid is 0. Add the
      missing kfree to the else branch.
      
      Fixes: fd708b81 ("Btrfs: add a extent ref verify tool")
      CC: stable@vger.kernel.org # 4.19+
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      a4988cb5
    • Qu Wenruo's avatar
      btrfs: don't allocate anonymous block device for user invisible roots · be334bdb
      Qu Wenruo authored
      
      
      commit 851fd730 upstream.
      
      [BUG]
      When a lot of subvolumes are created, there is a user report about
      transaction aborted:
      
        BTRFS: Transaction aborted (error -24)
        WARNING: CPU: 17 PID: 17041 at fs/btrfs/transaction.c:1576 create_pending_snapshot+0xbc4/0xd10 [btrfs]
        RIP: 0010:create_pending_snapshot+0xbc4/0xd10 [btrfs]
        Call Trace:
         create_pending_snapshots+0x82/0xa0 [btrfs]
         btrfs_commit_transaction+0x275/0x8c0 [btrfs]
         btrfs_mksubvol+0x4b9/0x500 [btrfs]
         btrfs_ioctl_snap_create_transid+0x174/0x180 [btrfs]
         btrfs_ioctl_snap_create_v2+0x11c/0x180 [btrfs]
         btrfs_ioctl+0x11a4/0x2da0 [btrfs]
         do_vfs_ioctl+0xa9/0x640
         ksys_ioctl+0x67/0x90
         __x64_sys_ioctl+0x1a/0x20
         do_syscall_64+0x5a/0x110
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        ---[ end trace 33f2f83f3d5250e9 ]---
        BTRFS: error (device sda1) in create_pending_snapshot:1576: errno=-24 unknown
        BTRFS info (device sda1): forced readonly
        BTRFS warning (device sda1): Skipping commit of aborted transaction.
        BTRFS: error (device sda1) in cleanup_transaction:1831: errno=-24 unknown
      
      [CAUSE]
      The error is EMFILE (Too many files open) and comes from the anonymous
      block device allocation. The ids are in a shared pool of size 1<<20.
      
      The ids are assigned to live subvolumes, ie. the root structure exists
      in memory (eg. after creation or after the root appears in some path).
      The pool could be exhausted if the numbers are not reclaimed fast
      enough, after subvolume deletion or if other system component uses the
      anon block devices.
      
      [WORKAROUND]
      Since it's not possible to completely solve the problem, we can only
      minimize the time the id is allocated to a subvolume root.
      
      Firstly, we can reduce the use of anon_dev by trees that are not
      subvolume roots, like data reloc tree.
      
      This patch will do extra check on root objectid, to skip roots that
      don't need anon_dev.  Currently it's only data reloc tree and orphan
      roots.
      
      Reported-by: default avatarGreed Rong <greedrong@gmail.com>
      Link: https://lore.kernel.org/linux-btrfs/CA+UqX+NTrZ6boGnWHhSeZmEY5J76CTqmYjO2S+=tHJX7nb9DPw@mail.gmail.com/
      
      
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      be334bdb
    • Qu Wenruo's avatar
      btrfs: free anon block device right after subvolume deletion · adba1076
      Qu Wenruo authored
      
      
      commit 082b6c97 upstream.
      
      [BUG]
      When a lot of subvolumes are created, there is a user report about
      transaction aborted caused by slow anonymous block device reclaim:
      
        BTRFS: Transaction aborted (error -24)
        WARNING: CPU: 17 PID: 17041 at fs/btrfs/transaction.c:1576 create_pending_snapshot+0xbc4/0xd10 [btrfs]
        RIP: 0010:create_pending_snapshot+0xbc4/0xd10 [btrfs]
        Call Trace:
         create_pending_snapshots+0x82/0xa0 [btrfs]
         btrfs_commit_transaction+0x275/0x8c0 [btrfs]
         btrfs_mksubvol+0x4b9/0x500 [btrfs]
         btrfs_ioctl_snap_create_transid+0x174/0x180 [btrfs]
         btrfs_ioctl_snap_create_v2+0x11c/0x180 [btrfs]
         btrfs_ioctl+0x11a4/0x2da0 [btrfs]
         do_vfs_ioctl+0xa9/0x640
         ksys_ioctl+0x67/0x90
         __x64_sys_ioctl+0x1a/0x20
         do_syscall_64+0x5a/0x110
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        ---[ end trace 33f2f83f3d5250e9 ]---
        BTRFS: error (device sda1) in create_pending_snapshot:1576: errno=-24 unknown
        BTRFS info (device sda1): forced readonly
        BTRFS warning (device sda1): Skipping commit of aborted transaction.
        BTRFS: error (device sda1) in cleanup_transaction:1831: errno=-24 unknown
      
      [CAUSE]
      The anonymous device pool is shared and its size is 1M. It's possible to
      hit that limit if the subvolume deletion is not fast enough and the
      subvolumes to be cleaned keep the ids allocated.
      
      [WORKAROUND]
      We can't avoid the anon device pool exhaustion but we can shorten the
      time the id is attached to the subvolume root once the subvolume becomes
      invisible to the user.
      
      Reported-by: default avatarGreed Rong <greedrong@gmail.com>
      Link: https://lore.kernel.org/linux-btrfs/CA+UqX+NTrZ6boGnWHhSeZmEY5J76CTqmYjO2S+=tHJX7nb9DPw@mail.gmail.com/
      
      
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      adba1076
    • Christian Marangi's avatar
      PCI: qcom: Add support for tx term offset for rev 2.1.0 · 0d349891
      Christian Marangi authored
      commit de3c4bf6 upstream.
      
      Add tx term offset support to pcie qcom driver need in some revision of
      the ipq806x SoC. Ipq8064 needs tx term offset set to 7.
      
      Link: https://lore.kernel.org/r/20200615210608.21469-9-ansuelsmth@gmail.com
      
      
      Fixes: 82a82383 ("PCI: qcom: Add Qualcomm PCIe controller driver")
      Signed-off-by: default avatarSham Muthayyan <smuthayy@codeaurora.org>
      Signed-off-by: default avatarAnsuel Smith <ansuelsmth@gmail.com>
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: default avatarStanimir Varbanov <svarbanov@mm-sol.com>
      Cc: stable@vger.kernel.org # v4.5+
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      0d349891
    • Christian Marangi's avatar
      PCI: qcom: Define some PARF params needed for ipq8064 SoC · 36883152
      Christian Marangi authored
      commit 5149901e upstream.
      
      Set some specific value for Tx De-Emphasis, Tx Swing and Rx equalization
      needed on some ipq8064 based device (Netgear R7800 for example). Without
      this the system locks on kernel load.
      
      Link: https://lore.kernel.org/r/20200615210608.21469-8-ansuelsmth@gmail.com
      
      
      Fixes: 82a82383 ("PCI: qcom: Add Qualcomm PCIe controller driver")
      Signed-off-by: default avatarAnsuel Smith <ansuelsmth@gmail.com>
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Acked-by: default avatarStanimir Varbanov <svarbanov@mm-sol.com>
      Cc: stable@vger.kernel.org # v4.5+
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      36883152
    • Rajat Jain's avatar
      PCI: Add device even if driver attach failed · 8fe3d7b5
      Rajat Jain authored
      commit 2194bc7c upstream.
      
      device_attach() returning failure indicates a driver error while trying to
      probe the device. In such a scenario, the PCI device should still be added
      in the system and be visible to the user.
      
      When device_attach() fails, merely warn about it and keep the PCI device in
      the system.
      
      This partially reverts ab1a187b ("PCI: Check device_attach() return
      value always").
      
      Link: https://lore.kernel.org/r/20200706233240.3245512-1-rajatja@google.com
      
      
      Signed-off-by: default avatarRajat Jain <rajatja@google.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: stable@vger.kernel.org	# v4.6+
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      8fe3d7b5
    • Kai-Heng Feng's avatar
      PCI: Mark AMD Navi10 GPU rev 0x00 ATS as broken · 3d6b4de1
      Kai-Heng Feng authored
      commit 45beb31d upstream.
      
      We are seeing AMD Radeon Pro W5700 doesn't work when IOMMU is enabled:
      
        iommu ivhd0: AMD-Vi: Event logged [IOTLB_INV_TIMEOUT device=63:00.0 address=0x42b5b01a0]
        iommu ivhd0: AMD-Vi: Event logged [IOTLB_INV_TIMEOUT device=63:00.0 address=0x42b5b01c0]
      
      The error also makes graphics driver fail to probe the device.
      
      It appears to be the same issue as commit 5e89cd30 ("PCI: Mark AMD
      Navi14 GPU rev 0xc5 ATS as broken") addresses, and indeed the same ATS
      quirk can workaround the issue.
      
      See-also: 5e89cd30 ("PCI: Mark AMD Navi14 GPU rev 0xc5 ATS as broken")
      See-also: d28ca864 ("PCI: Mark AMD Stoney Radeon R7 GPU ATS as broken")
      See-also: 9b44b0b0 ("PCI: Mark AMD Stoney GPU ATS as broken")
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=208725
      Link: https://lore.kernel.org/r/20200728104554.28927-1-kai.heng.feng@canonical.com
      
      
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      3d6b4de1
    • Rafael J. Wysocki's avatar
      PCI: hotplug: ACPI: Fix context refcounting in acpiphp_grab_context() · 6584ec11
      Rafael J. Wysocki authored
      
      
      commit dae68d7f upstream.
      
      If context is not NULL in acpiphp_grab_context(), but the
      is_going_away flag is set for the device's parent, the reference
      counter of the context needs to be decremented before returning
      NULL or the context will never be freed, so make that happen.
      
      Fixes: edf5bf34 ("ACPI / dock: Use callback pointers from devices' ACPI hotplug contexts")
      Reported-by: default avatarVasily Averin <vvs@virtuozzo.com>
      Cc: 3.15+ <stable@vger.kernel.org> # 3.15+
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      6584ec11
    • Steve French's avatar
      smb3: warn on confusing error scenario with sec=krb5 · 2116713a
      Steve French authored
      
      
      commit 0a018944 upstream.
      
      When mounting with Kerberos, users have been confused about the
      default error returned in scenarios in which either keyutils is
      not installed or the user did not properly acquire a krb5 ticket.
      Log a warning message in the case that "ENOKEY" is returned
      from the get_spnego_key upcall so that users can better understand
      why mount failed in those two cases.
      
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      2116713a
  2. Sep 04, 2020