1. 02 May, 2020 34 commits
  2. 29 Apr, 2020 6 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.19.119 · 76567537
      Greg Kroah-Hartman authored
      76567537
    • Christian Borntraeger's avatar
      s390/mm: fix page table upgrade vs 2ndary address mode accesses · 215d1f39
      Christian Borntraeger authored
      commit 316ec154 upstream.
      
      A page table upgrade in a kernel section that uses secondary address
      mode will mess up the kernel instructions as follows:
      
      Consider the following scenario: two threads are sharing memory.
      On CPU1 thread 1 does e.g. strnlen_user().  That gets to
              old_fs = enable_sacf_uaccess();
              len = strnlen_user_srst(src, size);
      and
                      "   la    %2,0(%1)\n"
                      "   la    %3,0(%0,%1)\n"
                      "   slgr  %0,%0\n"
                      "   sacf  256\n"
                      "0: srst  %3,%2\n"
      in strnlen_user_srst().  At that point we are in secondary space mode,
      control register 1 points to kernel page table and instruction fetching
      happens via c1, rather than usual c13.  Interrupts are not disabled, for
      obvious reasons.
      
      On CPU2 thread 2 does MAP_FIXED mmap(), forcing the upgrade of page table
      from 3-level to e.g. 4-level one.  We'd allocated new top-level table,
      set it up and now we hit this:
                      notify = 1;
                      spin_unlock_bh(&mm->page_table_lock);
              }
              if (notify)
                      on_each_cpu(__crst_table_upgrade, mm, 0);
      OK, we need to actually change over to use of new page table and we
      need that to happen in all threads that are currently running.  Which
      happens to include the thread 1.  IPI is delivered and we have
      static void __crst_table_upgrade(void *arg)
      {
              struct mm_struct *mm = arg;
      
              if (current->active_mm == mm)
                      set_user_asce(mm);
              __tlb_flush_local();
      }
      run on CPU1.  That does
      static inline void set_user_asce(struct mm_struct *mm)
      {
              S390_lowcore.user_asce = mm->context.asce;
      OK, user page table address updated...
              __ctl_load(S390_lowcore.user_asce, 1, 1);
      ... and control register 1 set to it.
              clear_cpu_flag(CIF_ASCE_PRIMARY);
      }
      
      IPI is run in home space mode, so it's fine - insns are fetched
      using c13, which always points to kernel page table.  But as soon
      as we return from the interrupt, previous PSW is restored, putting
      CPU1 back into secondary space mode, at which point we no longer
      get the kernel instructions from the kernel mapping.
      
      The fix is to only fixup the control registers that are currently in use
      for user processes during the page table update.  We must also disable
      interrupts in enable_sacf_uaccess to synchronize the cr and
      thread.mm_segment updates against the on_each-cpu.
      
      Fixes: 0aaba41b ("s390: remove all code using the access register mode")
      Cc: stable@vger.kernel.org # 4.15+
      Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Reviewed-by: default avatarGerald Schaefer <gerald.schaefer@de.ibm.com>
      References: CVE-2020-11884
      Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      215d1f39
    • kaixuxia's avatar
      xfs: Fix deadlock between AGI and AGF with RENAME_WHITEOUT · 6fb102dd
      kaixuxia authored
      commit bc56ad8c upstream.
      
      When performing rename operation with RENAME_WHITEOUT flag, we will
      hold AGF lock to allocate or free extents in manipulating the dirents
      firstly, and then doing the xfs_iunlink_remove() call last to hold
      AGI lock to modify the tmpfile info, so we the lock order AGI->AGF.
      
      The big problem here is that we have an ordering constraint on AGF
      and AGI locking - inode allocation locks the AGI, then can allocate
      a new extent for new inodes, locking the AGF after the AGI. Hence
      the ordering that is imposed by other parts of the code is AGI before
      AGF. So we get an ABBA deadlock between the AGI and AGF here.
      
      Process A:
      Call trace:
       ? __schedule+0x2bd/0x620
       schedule+0x33/0x90
       schedule_timeout+0x17d/0x290
       __down_common+0xef/0x125
       ? xfs_buf_find+0x215/0x6c0 [xfs]
       down+0x3b/0x50
       xfs_buf_lock+0x34/0xf0 [xfs]
       xfs_buf_find+0x215/0x6c0 [xfs]
       xfs_buf_get_map+0x37/0x230 [xfs]
       xfs_buf_read_map+0x29/0x190 [xfs]
       xfs_trans_read_buf_map+0x13d/0x520 [xfs]
       xfs_read_agf+0xa6/0x180 [xfs]
       ? schedule_timeout+0x17d/0x290
       xfs_alloc_read_agf+0x52/0x1f0 [xfs]
       xfs_alloc_fix_freelist+0x432/0x590 [xfs]
       ? down+0x3b/0x50
       ? xfs_buf_lock+0x34/0xf0 [xfs]
       ? xfs_buf_find+0x215/0x6c0 [xfs]
       xfs_alloc_vextent+0x301/0x6c0 [xfs]
       xfs_ialloc_ag_alloc+0x182/0x700 [xfs]
       ? _xfs_trans_bjoin+0x72/0xf0 [xfs]
       xfs_dialloc+0x116/0x290 [xfs]
       xfs_ialloc+0x6d/0x5e0 [xfs]
       ? xfs_log_reserve+0x165/0x280 [xfs]
       xfs_dir_ialloc+0x8c/0x240 [xfs]
       xfs_create+0x35a/0x610 [xfs]
       xfs_generic_create+0x1f1/0x2f0 [xfs]
       ...
      
      Process B:
      Call trace:
       ? __schedule+0x2bd/0x620
       ? xfs_bmapi_allocate+0x245/0x380 [xfs]
       schedule+0x33/0x90
       schedule_timeout+0x17d/0x290
       ? xfs_buf_find+0x1fd/0x6c0 [xfs]
       __down_common+0xef/0x125
       ? xfs_buf_get_map+0x37/0x230 [xfs]
       ? xfs_buf_find+0x215/0x6c0 [xfs]
       down+0x3b/0x50
       xfs_buf_lock+0x34/0xf0 [xfs]
       xfs_buf_find+0x215/0x6c0 [xfs]
       xfs_buf_get_map+0x37/0x230 [xfs]
       xfs_buf_read_map+0x29/0x190 [xfs]
       xfs_trans_read_buf_map+0x13d/0x520 [xfs]
       xfs_read_agi+0xa8/0x160 [xfs]
       xfs_iunlink_remove+0x6f/0x2a0 [xfs]
       ? current_time+0x46/0x80
       ? xfs_trans_ichgtime+0x39/0xb0 [xfs]
       xfs_rename+0x57a/0xae0 [xfs]
       xfs_vn_rename+0xe4/0x150 [xfs]
       ...
      
      In this patch we move the xfs_iunlink_remove() call to
      before acquiring the AGF lock to preserve correct AGI/AGF locking
      order.
      
      [Minor massage required due to upstream change making xfs_bumplink() a
      void function where as in the 4.19.y tree the return value is checked,
      even though it is always zero. Only change was to the last code block
      removed by the patch. Functionally equivalent to upstream.]
      Signed-off-by: default avatarkaixuxia <kaixuxia@tencent.com>
      Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
      Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: default avatarSuraj Jitindar Singh <surajjs@amazon.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6fb102dd
    • Kazuhiro Fujita's avatar
      serial: sh-sci: Make sure status register SCxSR is read in correct sequence · d407f7dc
      Kazuhiro Fujita authored
      commit 3dc4db36 upstream.
      
      For SCIF and HSCIF interfaces the SCxSR register holds the status of
      data that is to be read next from SCxRDR register, But where as for
      SCIFA and SCIFB interfaces SCxSR register holds status of data that is
      previously read from SCxRDR register.
      
      This patch makes sure the status register is read depending on the port
      types so that errors are caught accordingly.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarKazuhiro Fujita <kazuhiro.fujita.jg@renesas.com>
      Signed-off-by: default avatarHao Bui <hao.bui.yg@renesas.com>
      Signed-off-by: default avatarKAZUMI HARADA <kazumi.harada.rh@renesas.com>
      Signed-off-by: default avatarLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
      Tested-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Link: https://lore.kernel.org/r/1585333048-31828-1-git-send-email-kazuhiro.fujita.jg@renesas.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d407f7dc
    • Mathias Nyman's avatar
      xhci: prevent bus suspend if a roothub port detected a over-current condition · d3ee95de
      Mathias Nyman authored
      commit e9fb08d6 upstream.
      
      Suspending the bus and host controller while a port is in a over-current
      condition may halt the host.
      Also keep the roothub running if over-current is active.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Link: https://lore.kernel.org/r/20200421140822.28233-3-mathias.nyman@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d3ee95de
    • Udipto Goswami's avatar
      usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset() · b0a0ebfe
      Udipto Goswami authored
      commit 1c2e54fb upstream.
      
      For userspace functions using OS Descriptors, if a function also supplies
      Extended Property descriptors currently the counts and lengths stored in
      the ms_os_descs_ext_prop_{count,name_len,data_len} variables are not
      getting reset to 0 during an unbind or when the epfiles are closed. If
      the same function is re-bound and the descriptors are re-written, this
      results in those count/length variables to monotonically increase
      causing the VLA allocation in _ffs_func_bind() to grow larger and larger
      at each bind/unbind cycle and eventually fail to allocate.
      
      Fix this by clearing the ms_os_descs_ext_prop count & lengths to 0 in
      ffs_data_reset().
      
      Fixes: f0175ab5 ("usb: gadget: f_fs: OS descriptors support")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarUdipto Goswami <ugoswami@codeaurora.org>
      Signed-off-by: default avatarSriharsha Allenki <sallenki@codeaurora.org>
      Reviewed-by: default avatarManu Gautam <mgautam@codeaurora.org>
      Link: https://lore.kernel.org/r/20200402044521.9312-1-sallenki@codeaurora.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b0a0ebfe