1. 31 Jul, 2020 40 commits
    • John David Anglin's avatar
      parisc: Add atomic64_set_release() define to avoid CPU soft lockups · 518d1af9
      John David Anglin authored
      commit be6577af upstream.
      
      Stalls are quite frequent with recent kernels. I enabled
      CONFIG_SOFTLOCKUP_DETECTOR and I caught the following stall:
      
      watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [cc1:22803]
      CPU: 0 PID: 22803 Comm: cc1 Not tainted 5.6.17+ #3
      Hardware name: 9000/800/rp3440
       IAOQ[0]: d_alloc_parallel+0x384/0x688
       IAOQ[1]: d_alloc_parallel+0x388/0x688
       RP(r2): d_alloc_parallel+0x134/0x688
      Backtrace:
       [<000000004036974c>] __lookup_slow+0xa4/0x200
       [<0000000040369fc8>] walk_component+0x288/0x458
       [<000000004036a9a0>] path_lookupat+0x88/0x198
       [<000000004036e748>] filename_lookup+0xa0/0x168
       [<000000004036e95c>] user_path_at_empty+0x64/0x80
       [<000000004035d93c>] vfs_statx+0x104/0x158
       [<000000004035dfcc>] __do_sys_lstat64+0x44/0x80
       [<000000004035e5a0>] sys_lstat64+0x20/0x38
       [<0000000040180054>] syscall_exit+0x0/0x14
      
      The code was stuck in this loop in d_alloc_parallel:
      
          4037d414:   0e 00 10 dc     ldd 0(r16),ret0
          4037d418:   c7 fc 5f ed     bb,< ret0,1f,4037d414 <d_alloc_parallel+0x384>
          4037d41c:   08 00 02 40     nop
      
      This is the inner loop of bit_spin_lock which is called by hlist_bl_unlock in
      d_alloc_parallel:
      
      static inline void bit_spin_lock(int bitnum, unsigned long *addr)
      {
              /*
               * Assuming the lock is uncontended, this never enters
               * the body of the outer loop. If it is contended, then
               * within the inner loop a non-atomic test is used to
               * busywait with less bus contention for a good time to
               * attempt to acquire the lock bit.
               */
              preempt_disable();
      #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
              while (unlikely(test_and_set_bit_lock(bitnum, addr))) {
                      preempt_enable();
                      do {
                              cpu_relax();
                      } while (test_bit(bitnum, addr));
                      preempt_disable();
              }
      #endif
              __acquire(bitlock);
      }
      
      After consideration, I realized that we must be losing bit unlocks.
      Then, I noticed that we missed defining atomic64_set_release().
      Adding this define fixes the stalls in bit operations.
      Signed-off-by: default avatarDave Anglin <dave.anglin@bell.net>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      518d1af9
    • Michael J. Ruhl's avatar
      io-mapping: indicate mapping failure · 77f6d936
      Michael J. Ruhl authored
      commit e0b3e0b1 upstream.
      
      The !ATOMIC_IOMAP version of io_maping_init_wc will always return
      success, even when the ioremap fails.
      
      Since the ATOMIC_IOMAP version returns NULL when the init fails, and
      callers check for a NULL return on error this is unexpected.
      
      During a device probe, where the ioremap failed, a crash can look like
      this:
      
          BUG: unable to handle page fault for address: 0000000000210000
           #PF: supervisor write access in kernel mode
           #PF: error_code(0x0002) - not-present page
           Oops: 0002 [#1] PREEMPT SMP
           CPU: 0 PID: 177 Comm:
           RIP: 0010:fill_page_dma [i915]
             gen8_ppgtt_create [i915]
             i915_ppgtt_create [i915]
             intel_gt_init [i915]
             i915_gem_init [i915]
             i915_driver_probe [i915]
             pci_device_probe
             really_probe
             driver_probe_device
      
      The remap failure occurred much earlier in the probe.  If it had been
      propagated, the driver would have exited with an error.
      
      Return NULL on ioremap failure.
      
      [akpm@linux-foundation.org: detect ioremap_wc() errors earlier]
      
      Fixes: cafaf14a ("io-mapping: Always create a struct to hold metadata about the io-mapping")
      Signed-off-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Mike Rapoport <rppt@linux.ibm.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/20200721171936.81563-1-michael.j.ruhl@intel.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      77f6d936
    • Hugh Dickins's avatar
      mm/memcg: fix refcount error while moving and swapping · bcd79c5d
      Hugh Dickins authored
      commit 8d22a935 upstream.
      
      It was hard to keep a test running, moving tasks between memcgs with
      move_charge_at_immigrate, while swapping: mem_cgroup_id_get_many()'s
      refcount is discovered to be 0 (supposedly impossible), so it is then
      forced to REFCOUNT_SATURATED, and after thousands of warnings in quick
      succession, the test is at last put out of misery by being OOM killed.
      
      This is because of the way moved_swap accounting was saved up until the
      task move gets completed in __mem_cgroup_clear_mc(), deferred from when
      mem_cgroup_move_swap_account() actually exchanged old and new ids.
      Concurrent activity can free up swap quicker than the task is scanned,
      bringing id refcount down 0 (which should only be possible when
      offlining).
      
      Just skip that optimization: do that part of the accounting immediately.
      
      Fixes: 615d66c3 ("mm: memcontrol: fix memcg id ref counter on swap charge move")
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarAlex Shi <alex.shi@linux.alibaba.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Alex Shi <alex.shi@linux.alibaba.com>
      Cc: Shakeel Butt <shakeelb@google.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/alpine.LSU.2.11.2007071431050.4726@eggly.anvilsSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bcd79c5d
    • Fangrui Song's avatar
      Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang cross compilation · d98d9582
      Fangrui Song authored
      commit ca9b31f6 upstream.
      
      When CROSS_COMPILE is set (e.g. aarch64-linux-gnu-), if
      $(CROSS_COMPILE)elfedit is found at /usr/bin/aarch64-linux-gnu-elfedit,
      GCC_TOOLCHAIN_DIR will be set to /usr/bin/.  --prefix= will be set to
      /usr/bin/ and Clang as of 11 will search for both
      $(prefix)aarch64-linux-gnu-$needle and $(prefix)$needle.
      
      GCC searchs for $(prefix)aarch64-linux-gnu/$version/$needle,
      $(prefix)aarch64-linux-gnu/$needle and $(prefix)$needle. In practice,
      $(prefix)aarch64-linux-gnu/$needle rarely contains executables.
      
      To better model how GCC's -B/--prefix takes in effect in practice, newer
      Clang (since
      https://github.com/llvm/llvm-project/commit/3452a0d8c17f7166f479706b293caf6ac76ffd90)
      only searches for $(prefix)$needle. Currently it will find /usr/bin/as
      instead of /usr/bin/aarch64-linux-gnu-as.
      
      Set --prefix= to $(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
      (/usr/bin/aarch64-linux-gnu-) so that newer Clang can find the
      appropriate cross compiling GNU as (when -no-integrated-as is in
      effect).
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarFangrui Song <maskray@google.com>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Tested-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Tested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://github.com/ClangBuiltLinux/linux/issues/1099Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d98d9582
    • Tetsuo Handa's avatar
      vt: Reject zero-sized screen buffer size. · 3307b4ec
      Tetsuo Handa authored
      commit ce684552 upstream.
      
      syzbot is reporting general protection fault in do_con_write() [1] caused
      by vc->vc_screenbuf == ZERO_SIZE_PTR caused by vc->vc_screenbuf_size == 0
      caused by vc->vc_cols == vc->vc_rows == vc->vc_size_row == 0 caused by
      fb_set_var() from ioctl(FBIOPUT_VSCREENINFO) on /dev/fb0 , for
      gotoxy(vc, 0, 0) from reset_terminal() from vc_init() from vc_allocate()
       from con_install() from tty_init_dev() from tty_open() on such console
      causes vc->vc_pos == 0x10000000e due to
      ((unsigned long) ZERO_SIZE_PTR) + -1U * 0 + (-1U << 1).
      
      I don't think that a console with 0 column or 0 row makes sense. And it
      seems that vc_do_resize() does not intend to allow resizing a console to
      0 column or 0 row due to
      
        new_cols = (cols ? cols : vc->vc_cols);
        new_rows = (lines ? lines : vc->vc_rows);
      
      exception.
      
      Theoretically, cols and rows can be any range as long as
      0 < cols * rows * 2 <= KMALLOC_MAX_SIZE is satisfied (e.g.
      cols == 1048576 && rows == 2 is possible) because of
      
        vc->vc_size_row = vc->vc_cols << 1;
        vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row;
      
      in visual_init() and kzalloc(vc->vc_screenbuf_size) in vc_allocate().
      
      Since we can detect cols == 0 or rows == 0 via screenbuf_size = 0 in
      visual_init(), we can reject kzalloc(0). Then, vc_allocate() will return
      an error, and con_write() will not be called on a console with 0 column
      or 0 row.
      
      We need to make sure that integer overflow in visual_init() won't happen.
      Since vc_do_resize() restricts cols <= 32767 and rows <= 32767, applying
      1 <= cols <= 32767 and 1 <= rows <= 32767 restrictions to vc_allocate()
      will be practically fine.
      
      This patch does not touch con_init(), for returning -EINVAL there
      does not help when we are not returning -ENOMEM.
      
      [1] https://syzkaller.appspot.com/bug?extid=017265e8553724e514e8Reported-and-tested-by: default avatarsyzbot <syzbot+017265e8553724e514e8@syzkaller.appspotmail.com>
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200712111013.11881-1-penguin-kernel@I-love.SAKURA.ne.jpSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3307b4ec
    • Serge Semin's avatar
      serial: 8250_mtk: Fix high-speed baud rates clamping · bce9a1f2
      Serge Semin authored
      commit 551e553f upstream.
      
      Commit 7b668c06 ("serial: 8250: Fix max baud limit in generic 8250
      port") fixed limits of a baud rate setting for a generic 8250 port.
      In other words since that commit the baud rate has been permitted to be
      within [uartclk / 16 / UART_DIV_MAX; uartclk / 16], which is absolutely
      normal for a standard 8250 UART port. But there are custom 8250 ports,
      which provide extended baud rate limits. In particular the Mediatek 8250
      port can work with baud rates up to "uartclk" speed.
      
      Normally that and any other peculiarity is supposed to be handled in a
      custom set_termios() callback implemented in the vendor-specific
      8250-port glue-driver. Currently that is how it's done for the most of
      the vendor-specific 8250 ports, but for some reason for Mediatek a
      solution has been spread out to both the glue-driver and to the generic
      8250-port code. Due to that a bug has been introduced, which permitted the
      extended baud rate limit for all even for standard 8250-ports. The bug
      has been fixed by the commit 7b668c06 ("serial: 8250: Fix max baud
      limit in generic 8250 port") by narrowing the baud rates limit back down to
      the normal bounds. Unfortunately by doing so we also broke the
      Mediatek-specific extended bauds feature.
      
      A fix of the problem described above is twofold. First since we can't get
      back the extended baud rate limits feature to the generic set_termios()
      function and that method supports only a standard baud rates range, the
      requested baud rate must be locally stored before calling it and then
      restored back to the new termios structure after the generic set_termios()
      finished its magic business. By doing so we still use the
      serial8250_do_set_termios() method to set the LCR/MCR/FCR/etc. registers,
      while the extended baud rate setting procedure will be performed later in
      the custom Mediatek-specific set_termios() callback. Second since a true
      baud rate is now fully calculated in the custom set_termios() method we
      need to locally update the port timeout by calling the
      uart_update_timeout() function. After the fixes described above are
      implemented in the 8250_mtk.c driver, the Mediatek 8250-port should
      get back to normally working with extended baud rates.
      
      Link: https://lore.kernel.org/linux-serial/20200701211337.3027448-1-danielwinkler@google.com
      
      Fixes: 7b668c06 ("serial: 8250: Fix max baud limit in generic 8250 port")
      Reported-by: default avatarDaniel Winkler <danielwinkler@google.com>
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: stable <stable@vger.kernel.org>
      Tested-by: default avatarClaire Chang <tientzu@chromium.org>
      Link: https://lore.kernel.org/r/20200714124113.20918-1-Sergey.Semin@baikalelectronics.ruSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bce9a1f2
    • Yang Yingliang's avatar
      serial: 8250: fix null-ptr-deref in serial8250_start_tx() · 81e57039
      Yang Yingliang authored
      commit f4c23a14 upstream.
      
      I got null-ptr-deref in serial8250_start_tx():
      
      [   78.114630] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
      [   78.123778] Mem abort info:
      [   78.126560]   ESR = 0x86000007
      [   78.129603]   EC = 0x21: IABT (current EL), IL = 32 bits
      [   78.134891]   SET = 0, FnV = 0
      [   78.137933]   EA = 0, S1PTW = 0
      [   78.141064] user pgtable: 64k pages, 48-bit VAs, pgdp=00000027d41a8600
      [   78.147562] [0000000000000000] pgd=00000027893f0003, p4d=00000027893f0003, pud=00000027893f0003, pmd=00000027c9a20003, pte=0000000000000000
      [   78.160029] Internal error: Oops: 86000007 [#1] SMP
      [   78.164886] Modules linked in: sunrpc vfat fat aes_ce_blk crypto_simd cryptd aes_ce_cipher crct10dif_ce ghash_ce sha2_ce sha256_arm64 sha1_ce ses enclosure sg sbsa_gwdt ipmi_ssif spi_dw_mmio sch_fq_codel vhost_net tun vhost vhost_iotlb tap ip_tables ext4 mbcache jbd2 ahci hisi_sas_v3_hw libahci hisi_sas_main libsas hns3 scsi_transport_sas hclge libata megaraid_sas ipmi_si hnae3 ipmi_devintf ipmi_msghandler br_netfilter bridge stp llc nvme nvme_core xt_sctp sctp libcrc32c dm_mod nbd
      [   78.207383] CPU: 11 PID: 23258 Comm: null-ptr Not tainted 5.8.0-rc6+ #48
      [   78.214056] Hardware name: Huawei TaiShan 2280 V2/BC82AMDC, BIOS 2280-V2 CS V3.B210.01 03/12/2020
      [   78.222888] pstate: 80400089 (Nzcv daIf +PAN -UAO BTYPE=--)
      [   78.228435] pc : 0x0
      [   78.230618] lr : serial8250_start_tx+0x160/0x260
      [   78.235215] sp : ffff800062eefb80
      [   78.238517] x29: ffff800062eefb80 x28: 0000000000000fff
      [   78.243807] x27: ffff800062eefd80 x26: ffff202fd83b3000
      [   78.249098] x25: ffff800062eefd80 x24: ffff202fd83b3000
      [   78.254388] x23: ffff002fc5e50be8 x22: 0000000000000002
      [   78.259679] x21: 0000000000000001 x20: 0000000000000000
      [   78.264969] x19: ffffa688827eecc8 x18: 0000000000000000
      [   78.270259] x17: 0000000000000000 x16: 0000000000000000
      [   78.275550] x15: ffffa68881bc67a8 x14: 00000000000002e6
      [   78.280841] x13: ffffa68881bc67a8 x12: 000000000000c539
      [   78.286131] x11: d37a6f4de9bd37a7 x10: ffffa68881cccff0
      [   78.291421] x9 : ffffa68881bc6000 x8 : ffffa688819daa88
      [   78.296711] x7 : ffffa688822a0f20 x6 : ffffa688819e0000
      [   78.302002] x5 : ffff800062eef9d0 x4 : ffffa68881e707a8
      [   78.307292] x3 : 0000000000000000 x2 : 0000000000000002
      [   78.312582] x1 : 0000000000000001 x0 : ffffa688827eecc8
      [   78.317873] Call trace:
      [   78.320312]  0x0
      [   78.322147]  __uart_start.isra.9+0x64/0x78
      [   78.326229]  uart_start+0xb8/0x1c8
      [   78.329620]  uart_flush_chars+0x24/0x30
      [   78.333442]  n_tty_receive_buf_common+0x7b0/0xc30
      [   78.338128]  n_tty_receive_buf+0x44/0x2c8
      [   78.342122]  tty_ioctl+0x348/0x11f8
      [   78.345599]  ksys_ioctl+0xd8/0xf8
      [   78.348903]  __arm64_sys_ioctl+0x2c/0xc8
      [   78.352812]  el0_svc_common.constprop.2+0x88/0x1b0
      [   78.357583]  do_el0_svc+0x44/0xd0
      [   78.360887]  el0_sync_handler+0x14c/0x1d0
      [   78.364880]  el0_sync+0x140/0x180
      [   78.368185] Code: bad PC value
      
      SERIAL_PORT_DFNS is not defined on each arch, if it's not defined,
      serial8250_set_defaults() won't be called in serial8250_isa_init_ports(),
      so the p->serial_in pointer won't be initialized, and it leads a null-ptr-deref.
      Fix this problem by calling serial8250_set_defaults() after init uart port.
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200721143852.4058352-1-yangyingliang@huawei.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      81e57039
    • Ian Abbott's avatar
      staging: comedi: addi_apci_1564: check INSN_CONFIG_DIGITAL_TRIG shift · 75a0cbaa
      Ian Abbott authored
      commit 926234f1 upstream.
      
      The `INSN_CONFIG` comedi instruction with sub-instruction code
      `INSN_CONFIG_DIGITAL_TRIG` includes a base channel in `data[3]`. This is
      used as a right shift amount for other bitmask values without being
      checked.  Shift amounts greater than or equal to 32 will result in
      undefined behavior.  Add code to deal with this.
      
      Fixes: 1e15687e ("staging: comedi: addi_apci_1564: add Change-of-State interrupt subdevice and required functions")
      Cc: <stable@vger.kernel.org> #3.17+
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Link: https://lore.kernel.org/r/20200717145257.112660-4-abbotti@mev.co.ukSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75a0cbaa
    • Ian Abbott's avatar
      staging: comedi: addi_apci_1500: check INSN_CONFIG_DIGITAL_TRIG shift · ecceea19
      Ian Abbott authored
      commit fc846e9d upstream.
      
      The `INSN_CONFIG` comedi instruction with sub-instruction code
      `INSN_CONFIG_DIGITAL_TRIG` includes a base channel in `data[3]`. This is
      used as a right shift amount for other bitmask values without being
      checked.  Shift amounts greater than or equal to 32 will result in
      undefined behavior.  Add code to deal with this, adjusting the checks
      for invalid channels so that enabled channel bits that would have been
      lost by shifting are also checked for validity.  Only channels 0 to 15
      are valid.
      
      Fixes: a8c66b68 ("staging: comedi: addi_apci_1500: rewrite the subdevice support functions")
      Cc: <stable@vger.kernel.org> #4.0+: ef75e14a: staging: comedi: verify array index is correct before using it
      Cc: <stable@vger.kernel.org> #4.0+
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Link: https://lore.kernel.org/r/20200717145257.112660-5-abbotti@mev.co.ukSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ecceea19
    • Ian Abbott's avatar
      staging: comedi: ni_6527: fix INSN_CONFIG_DIGITAL_TRIG support · 63fe8c96
      Ian Abbott authored
      commit f07804ec upstream.
      
      `ni6527_intr_insn_config()` processes `INSN_CONFIG` comedi instructions
      for the "interrupt" subdevice.  When `data[0]` is
      `INSN_CONFIG_DIGITAL_TRIG` it is configuring the digital trigger.  When
      `data[2]` is `COMEDI_DIGITAL_TRIG_ENABLE_EDGES` it is configuring rising
      and falling edge detection for the digital trigger, using a base channel
      number (or shift amount) in `data[3]`, a rising edge bitmask in
      `data[4]` and falling edge bitmask in `data[5]`.
      
      If the base channel number (shift amount) is greater than or equal to
      the number of channels (24) of the digital input subdevice, there are no
      changes to the rising and falling edges, so the mask of channels to be
      changed can be set to 0, otherwise the mask of channels to be changed,
      and the rising and falling edge bitmasks are shifted by the base channel
      number before calling `ni6527_set_edge_detection()` to change the
      appropriate registers.  Unfortunately, the code is comparing the base
      channel (shift amount) to the interrupt subdevice's number of channels
      (1) instead of the digital input subdevice's number of channels (24).
      Fix it by comparing to 32 because all shift amounts for an `unsigned
      int` must be less than that and everything from bit 24 upwards is
      ignored by `ni6527_set_edge_detection()` anyway.
      
      Fixes: 110f9e68 ("staging: comedi: ni_6527: support INSN_CONFIG_DIGITAL_TRIG")
      Cc: <stable@vger.kernel.org> # 3.17+
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Link: https://lore.kernel.org/r/20200717145257.112660-2-abbotti@mev.co.ukSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      63fe8c96
    • Ian Abbott's avatar
      staging: comedi: addi_apci_1032: check INSN_CONFIG_DIGITAL_TRIG shift · bfe0aac5
      Ian Abbott authored
      commit 0bd0db42 upstream.
      
      The `INSN_CONFIG` comedi instruction with sub-instruction code
      `INSN_CONFIG_DIGITAL_TRIG` includes a base channel in `data[3]`. This is
      used as a right shift amount for other bitmask values without being
      checked.  Shift amounts greater than or equal to 32 will result in
      undefined behavior.  Add code to deal with this.
      
      Fixes: 33cdce62 ("staging: comedi: addi_apci_1032: conform to new INSN_CONFIG_DIGITAL_TRIG")
      Cc: <stable@vger.kernel.org> #3.8+
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Link: https://lore.kernel.org/r/20200717145257.112660-3-abbotti@mev.co.ukSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bfe0aac5
    • Rustam Kovhaev's avatar
      staging: wlan-ng: properly check endpoint types · c2646b96
      Rustam Kovhaev authored
      commit faaff976 upstream.
      
      As syzkaller detected, wlan-ng driver does not do sanity check of
      endpoints in prism2sta_probe_usb(), add check for xfer direction and type
      
      Reported-and-tested-by: syzbot+c2a1fa67c02faa0de723@syzkaller.appspotmail.com
      Link: https://syzkaller.appspot.com/bug?extid=c2a1fa67c02faa0de723Signed-off-by: default avatarRustam Kovhaev <rkovhaev@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200722161052.999754-1-rkovhaev@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c2646b96
    • Steve French's avatar
      Revert "cifs: Fix the target file was deleted when rename failed." · 13b502bb
      Steve French authored
      commit 0e670518 upstream.
      
      This reverts commit 9ffad926.
      
      Upon additional testing with older servers, it was found that
      the original commit introduced a regression when using the old SMB1
      dialect and rsyncing over an existing file.
      
      The patch will need to be respun to address this, likely including
      a larger refactoring of the SMB1 and SMB3 rename code paths to make
      it less confusing and also to address some additional rename error
      cases that SMB3 may be able to workaround.
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Reported-by: default avatarPatrick Fernie <patrick.fernie@gmail.com>
      CC: Stable <stable@vger.kernel.org>
      Acked-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Acked-by: default avatarPavel Shilovsky <pshilov@microsoft.com>
      Acked-by: default avatarZhang Xiaoxu <zhangxiaoxu5@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      13b502bb
    • Forest Crossman's avatar
      usb: xhci: Fix ASM2142/ASM3142 DMA addressing · 41f5f86a
      Forest Crossman authored
      commit dbb0897e upstream.
      
      The ASM2142/ASM3142 (same PCI IDs) does not support full 64-bit DMA
      addresses, which can cause silent memory corruption or IOMMU errors on
      platforms that use the upper bits. Add the XHCI_NO_64BIT_SUPPORT quirk
      to fix this issue.
      Signed-off-by: default avatarForest Crossman <cyrozap@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200717112734.328432-1-cyrozap@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      41f5f86a
    • Chunfeng Yun's avatar
      usb: xhci-mtk: fix the failure of bandwidth allocation · a9423d50
      Chunfeng Yun authored
      commit 5ce1a24d upstream.
      
      The wMaxPacketSize field of endpoint descriptor may be zero
      as default value in alternate interface, and they are not
      actually selected when start stream, so skip them when try to
      allocate bandwidth.
      
      Cc: stable <stable@vger.kernel.org>
      Fixes: 0cbd4b34 ("xhci: mediatek: support MTK xHCI host controller")
      Signed-off-by: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
      Link: https://lore.kernel.org/r/1594360672-2076-1-git-send-email-chunfeng.yun@mediatek.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a9423d50
    • Arnd Bergmann's avatar
      x86: math-emu: Fix up 'cmp' insn for clang ias · 8844e170
      Arnd Bergmann authored
      [ Upstream commit 81e96851 ]
      
      The clang integrated assembler requires the 'cmp' instruction to
      have a length prefix here:
      
      arch/x86/math-emu/wm_sqrt.S:212:2: error: ambiguous instructions require an explicit suffix (could be 'cmpb', 'cmpw', or 'cmpl')
       cmp $0xffffffff,-24(%ebp)
       ^
      
      Make this a 32-bit comparison, which it was clearly meant to be.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://lkml.kernel.org/r/20200527135352.1198078-1-arnd@arndb.deSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      8844e170
    • Will Deacon's avatar
      arm64: Use test_tsk_thread_flag() for checking TIF_SINGLESTEP · 998c0852
      Will Deacon authored
      [ Upstream commit 5afc7855 ]
      
      Rather than open-code test_tsk_thread_flag() at each callsite, simply
      replace the couple of offenders with calls to test_tsk_thread_flag()
      directly.
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      998c0852
    • Evgeny Novikov's avatar
      usb: gadget: udc: gr_udc: fix memleak on error handling path in gr_ep_init() · f038d105
      Evgeny Novikov authored
      [ Upstream commit c8f8529e ]
      
      gr_ep_init() does not assign the allocated request anywhere if allocation
      of memory for the buffer fails. This is a memory leak fixed by the given
      patch.
      
      Found by Linux Driver Verification project (linuxtesting.org).
      Signed-off-by: default avatarEvgeny Novikov <novikov@ispras.ru>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f038d105
    • Leonid Ravich's avatar
      dmaengine: ioat setting ioat timeout as module parameter · 9ef02621
      Leonid Ravich authored
      [ Upstream commit 87730ccb ]
      
      DMA transaction time to completion is a function of PCI bandwidth,
      transaction size and a queue depth.  So hard coded value for timeouts
      might be wrong for some scenarios.
      Signed-off-by: default avatarLeonid Ravich <Leonid.Ravich@emc.com>
      Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
      Link: https://lore.kernel.org/r/20200701184816.29138-1-leonid.ravich@dell.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9ef02621
    • Marc Kleine-Budde's avatar
      regmap: dev_get_regmap_match(): fix string comparison · 05f479dc
      Marc Kleine-Budde authored
      [ Upstream commit e84861fe ]
      
      This function is used by dev_get_regmap() to retrieve a regmap for the
      specified device. If the device has more than one regmap, the name parameter
      can be used to specify one.
      
      The code here uses a pointer comparison to check for equal strings. This
      however will probably always fail, as the regmap->name is allocated via
      kstrdup_const() from the regmap's config->name.
      
      Fix this by using strcmp() instead.
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Link: https://lore.kernel.org/r/20200703103315.267996-1-mkl@pengutronix.deSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      05f479dc
    • Dinghao Liu's avatar
      dmaengine: tegra210-adma: Fix runtime PM imbalance on error · 8830292d
      Dinghao Liu authored
      [ Upstream commit 5b78fac4 ]
      
      pm_runtime_get_sync() increments the runtime PM usage counter even
      when it returns an error code. Thus a pairing decrement is needed on
      the error handling path to keep the counter balanced.
      Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
      Reviewed-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Link: https://lore.kernel.org/r/20200624064626.19855-1-dinghao.liu@zju.edu.cnSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8830292d
    • Hans de Goede's avatar
      HID: apple: Disable Fn-key key-re-mapping on clone keyboards · d1893610
      Hans de Goede authored
      [ Upstream commit a5d81646 ]
      
      The Maxxter KB-BT-001 Bluetooth keyboard, which looks somewhat like the
      Apple Wireless Keyboard, is using the vendor and product IDs (05AC:0239)
      of the Apple Wireless Keyboard (2009 ANSI version) <sigh>.
      
      But its F1 - F10 keys are marked as sending F1 - F10, not the special
      functions hid-apple.c maps them too; and since its descriptors do not
      contain the HID_UP_CUSTOM | 0x0003 usage apple-hid looks for for the
      Fn-key, apple_setup_input() never gets called, so F1 - F6 are mapped
      to key-codes which have not been set in the keybit array causing them
      to not send any events at all.
      
      The lack of a usage code matching the Fn key in the clone is actually
      useful as this allows solving this problem in a generic way.
      
      This commits adds a fn_found flag and it adds a input_configured
      callback which checks if this flag is set once all usages have been
      mapped. If it is not set, then assume this is a clone and clear the
      quirks bitmap so that the hid-apple code does not add any special
      handling to this keyboard.
      
      This fixes F1 - F6 not sending anything at all and F7 - F12 sending
      the wrong codes on the Maxxter KB-BT-001 Bluetooth keyboard and on
      similar clones.
      
      Cc: Joao Moreno <mail@joaomoreno.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d1893610
    • Federico Ricchiuto's avatar
      HID: i2c-hid: add Mediacom FlexBook edge13 to descriptor override · 95c0fa1e
      Federico Ricchiuto authored
      [ Upstream commit 43e666ac ]
      
      The Mediacom FlexBook edge13 uses the SIPODEV SP1064 touchpad, which does not
      supply descriptors, so it has to be added to the override list.
      Signed-off-by: default avatarFederico Ricchiuto <fed.ricchiuto@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      95c0fa1e
    • Pi-Hsun Shih's avatar
      scripts/decode_stacktrace: strip basepath from all paths · 5e085f2f
      Pi-Hsun Shih authored
      [ Upstream commit d178770d ]
      
      Currently the basepath is removed only from the beginning of the string.
      When the symbol is inlined and there's multiple line outputs of
      addr2line, only the first line would have basepath removed.
      
      Change to remove the basepath prefix from all lines.
      
      Fixes: 31013836 ("scripts/decode_stacktrace: match basepath using shell prefix operator, not regex")
      Co-developed-by: default avatarShik Chen <shik@chromium.org>
      Signed-off-by: default avatarPi-Hsun Shih <pihsun@chromium.org>
      Signed-off-by: default avatarShik Chen <shik@chromium.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Cc: Sasha Levin <sashal@kernel.org>
      Cc: Nicolas Boichat <drinkcat@chromium.org>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Link: http://lkml.kernel.org/r/20200720082709.252805-1-pihsun@chromium.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5e085f2f
    • Wang Hai's avatar
      net: smc91x: Fix possible memory leak in smc_drv_probe() · 49c4d850
      Wang Hai authored
      [ Upstream commit bca9749b ]
      
      If try_toggle_control_gpio() failed in smc_drv_probe(), free_netdev(ndev)
      should be called to free the ndev created earlier. Otherwise, a memleak
      will occur.
      
      Fixes: 7d2911c4 ("net: smc91x: Fix gpios for device tree based booting")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      49c4d850
    • Sergey Organov's avatar
      net: dp83640: fix SIOCSHWTSTAMP to update the struct with actual configuration · 059e2392
      Sergey Organov authored
      [ Upstream commit 473309fb ]
      
      From Documentation/networking/timestamping.txt:
      
        A driver which supports hardware time stamping shall update the
        struct with the actual, possibly more permissive configuration.
      
      Do update the struct passed when we upscale the requested time
      stamping mode.
      
      Fixes: cb646e2b ("ptp: Added a clock driver for the National Semiconductor PHYTER.")
      Signed-off-by: default avatarSergey Organov <sorganov@gmail.com>
      Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      059e2392
    • George Kennedy's avatar
      ax88172a: fix ax88172a_unbind() failures · 041aff4a
      George Kennedy authored
      [ Upstream commit c28d9a28 ]
      
      If ax88172a_unbind() fails, make sure that the return code is
      less than zero so that cleanup is done properly and avoid UAF.
      
      Fixes: a9a51bd7 ("ax88172a: fix information leak on short answers")
      Signed-off-by: default avatarGeorge Kennedy <george.kennedy@oracle.com>
      Reported-by: syzbot+4cd84f527bf4a10fc9c1@syzkaller.appspotmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      041aff4a
    • Christophe JAILLET's avatar
      hippi: Fix a size used in a 'pci_free_consistent()' in an error handling path · 7a1d03de
      Christophe JAILLET authored
      [ Upstream commit 3195c470 ]
      
      The size used when calling 'pci_alloc_consistent()' and
      'pci_free_consistent()' should match.
      
      Fix it and have it consistent with the corresponding call in 'rr_close()'.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7a1d03de
    • Vasundhara Volam's avatar
      bnxt_en: Fix race when modifying pause settings. · 1ff463b6
      Vasundhara Volam authored
      [ Upstream commit 163e9ef6 ]
      
      The driver was modified to not rely on rtnl lock to protect link
      settings about 2 years ago.  The pause setting was missed when
      making that change.  Fix it by acquiring link_lock mutex before
      calling bnxt_hwrm_set_pause().
      
      Fixes: e2dc9b6e ("bnxt_en: Don't use rtnl lock to protect link change logic in workqueue.")
      Signed-off-by: default avatarVasundhara Volam <vasundhara-v.volam@broadcom.com>
      Reviewed-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1ff463b6
    • Boris Burkov's avatar
      btrfs: fix mount failure caused by race with umount · 59b6d221
      Boris Burkov authored
      [ Upstream commit 48cfa61b ]
      
      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>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      59b6d221
    • Filipe Manana's avatar
      btrfs: fix double free on ulist after backref resolution failure · c6ff26b1
      Filipe Manana authored
      commit 580c079b upstream.
      
      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>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c6ff26b1
    • Hans de Goede's avatar
      ASoC: rt5670: Correct RT5670_LDO_SEL_MASK · f9162054
      Hans de Goede authored
      commit 5cacc6f5 upstream.
      
      The RT5670_PWR_ANLG1 register has 3 bits to select the LDO voltage,
      so the correct mask is 0x7 not 0x3.
      
      Because of this wrong mask we were programming the ldo bits
      to a setting of binary 001 (0x05 & 0x03) instead of binary 101
      when moving to SND_SOC_BIAS_PREPARE.
      
      According to the datasheet 001 is a reserved value, so no idea
      what it did, since the driver was working fine before I guess we
      got lucky and it does something which is ok.
      
      Fixes: 5e8351de ("ASoC: add RT5670 CODEC driver")
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200628155231.71089-3-hdegoede@redhat.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f9162054
    • Takashi Iwai's avatar
      ALSA: info: Drop WARN_ON() from buffer NULL sanity check · 4881d9b6
      Takashi Iwai authored
      commit 60379ba0 upstream.
      
      snd_info_get_line() has a sanity check of NULL buffer -- both buffer
      itself being NULL and buffer->buffer being NULL.  Basically both
      checks are valid and necessary, but the problem is that it's with
      snd_BUG_ON() macro that triggers WARN_ON().  The latter condition
      (NULL buffer->buffer) can be met arbitrarily by user since the buffer
      is allocated at the first write, so it means that user can trigger
      WARN_ON() at will.
      
      This patch addresses it by simply moving buffer->buffer NULL check out
      of snd_BUG_ON() so that spurious WARNING is no longer triggered.
      
      Reported-by: syzbot+e42d0746c3c3699b6061@syzkaller.appspotmail.com
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200717084023.5928-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4881d9b6
    • Oleg Nesterov's avatar
      uprobes: Change handle_swbp() to send SIGTRAP with si_code=SI_KERNEL, to fix GDB regression · fe6ba50d
      Oleg Nesterov authored
      commit fe5ed7ab upstream.
      
      If a tracee is uprobed and it hits int3 inserted by debugger, handle_swbp()
      does send_sig(SIGTRAP, current, 0) which means si_code == SI_USER. This used
      to work when this code was written, but then GDB started to validate si_code
      and now it simply can't use breakpoints if the tracee has an active uprobe:
      
      	# cat test.c
      	void unused_func(void)
      	{
      	}
      	int main(void)
      	{
      		return 0;
      	}
      
      	# gcc -g test.c -o test
      	# perf probe -x ./test -a unused_func
      	# perf record -e probe_test:unused_func gdb ./test -ex run
      	GNU gdb (GDB) 10.0.50.20200714-git
      	...
      	Program received signal SIGTRAP, Trace/breakpoint trap.
      	0x00007ffff7ddf909 in dl_main () from /lib64/ld-linux-x86-64.so.2
      	(gdb)
      
      The tracee hits the internal breakpoint inserted by GDB to monitor shared
      library events but GDB misinterprets this SIGTRAP and reports a signal.
      
      Change handle_swbp() to use force_sig(SIGTRAP), this matches do_int3_user()
      and fixes the problem.
      
      This is the minimal fix for -stable, arch/x86/kernel/uprobes.c is equally
      wrong; it should use send_sigtrap(TRAP_TRACE) instead of send_sig(SIGTRAP),
      but this doesn't confuse GDB and needs another x86-specific patch.
      Reported-by: default avatarAaron Merey <amerey@redhat.com>
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Reviewed-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200723154420.GA32043@redhat.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fe6ba50d
    • Olga Kornievskaia's avatar
      SUNRPC reverting d03727b2 ("NFSv4 fix CLOSE not waiting for direct IO compeletion") · 968bef60
      Olga Kornievskaia authored
      commit 65caafd0 upstream.
      
      Reverting commit d03727b2 "NFSv4 fix CLOSE not waiting for
      direct IO compeletion". This patch made it so that fput() by calling
      inode_dio_done() in nfs_file_release() would wait uninterruptably
      for any outstanding directIO to the file (but that wait on IO should
      be killable).
      
      The problem the patch was also trying to address was REMOVE returning
      ERR_ACCESS because the file is still opened, is supposed to be resolved
      by server returning ERR_FILE_OPEN and not ERR_ACCESS.
      Signed-off-by: default avatarOlga Kornievskaia <kolga@netapp.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      968bef60
    • Ben Skeggs's avatar
      drm/nouveau/i2c/g94-: increase NV_PMGR_DP_AUXCTL_TRANSACTREQ timeout · 237169c0
      Ben Skeggs authored
      [ Upstream commit 0156e76d ]
      
      Tegra TRM says worst-case reply time is 1216us, and this should fix some
      spurious timeouts that have been popping up.
      Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      237169c0
    • Tom Rix's avatar
      net: sky2: initialize return of gm_phy_read · 31b10f2c
      Tom Rix authored
      [ Upstream commit 28b18e4e ]
      
      clang static analysis flags this garbage return
      
      drivers/net/ethernet/marvell/sky2.c:208:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
              return v;
              ^~~~~~~~
      
      static inline u16 gm_phy_read( ...
      {
      	u16 v;
      	__gm_phy_read(hw, port, reg, &v);
      	return v;
      }
      
      __gm_phy_read can return without setting v.
      
      So handle similar to skge.c's gm_phy_read, initialize v.
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      31b10f2c
    • Xie He's avatar
      drivers/net/wan/lapbether: Fixed the value of hard_header_len · 4d565f46
      Xie He authored
      [ Upstream commit 9dc829a1 ]
      
      When this driver transmits data,
        first this driver will remove a pseudo header of 1 byte,
        then the lapb module will prepend the LAPB header of 2 or 3 bytes,
        then this driver will prepend a length field of 2 bytes,
        then the underlying Ethernet device will prepend its own header.
      
      So, the header length required should be:
        -1 + 3 + 2 + "the header length needed by the underlying device".
      
      This patch fixes kernel panic when this driver is used with AF_PACKET
      SOCK_DGRAM sockets.
      Signed-off-by: default avatarXie He <xie.he.0141@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4d565f46
    • Max Filippov's avatar
      xtensa: update *pos in cpuinfo_op.next · 55ba6c92
      Max Filippov authored
      [ Upstream commit 0d5ab144 ]
      
      Increment *pos in the cpuinfo_op.next to fix the following warning
      triggered by cat /proc/cpuinfo:
      
        seq_file: buggy .next function c_next did not update position index
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      55ba6c92
    • Max Filippov's avatar
      xtensa: fix __sync_fetch_and_{and,or}_4 declarations · 068dae90
      Max Filippov authored
      [ Upstream commit 73f99413 ]
      
      Building xtensa kernel with gcc-10 produces the following warnings:
        arch/xtensa/kernel/xtensa_ksyms.c:90:15: warning: conflicting types
          for built-in function ‘__sync_fetch_and_and_4’;
          expected ‘unsigned int(volatile void *, unsigned int)’
          [-Wbuiltin-declaration-mismatch]
        arch/xtensa/kernel/xtensa_ksyms.c:96:15: warning: conflicting types
          for built-in function ‘__sync_fetch_and_or_4’;
          expected ‘unsigned int(volatile void *, unsigned int)’
          [-Wbuiltin-declaration-mismatch]
      
      Fix declarations of these functions to avoid the warning.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      068dae90