1. 23 Jan, 2020 40 commits
    • Jagan Teki's avatar
      ARM: dts: imx6q-icore-mipi: Use 1.5 version of i.Core MX6DL · e37de852
      Jagan Teki authored
      commit 4a132f60 upstream.
      
      The EDIMM STARTER KIT i.Core 1.5 MIPI Evaluation is based on
      the 1.5 version of the i.Core MX6 cpu module. The 1.5 version
      differs from the original one for a few details, including the
      ethernet PHY interface clock provider.
      
      With this commit, the ethernet interface works properly:
      SMSC LAN8710/LAN8720 2188000.ethernet-1:00: attached PHY driver
      
      While before using the 1.5 version, ethernet failed to startup
      do to un-clocked PHY interface:
      fec 2188000.ethernet eth0: could not attach to PHY
      
      Similar fix has merged for i.Core MX6Q but missed to update for DL.
      
      Fixes: a8039f2d ("ARM: dts: imx6dl: Add Engicam i.CoreM6 1.5 Quad/Dual MIPI starter kit support")
      Cc: Jacopo Mondi <jacopo@jmondi.org>
      Signed-off-by: default avatarMichael Trimarchi <michael@amarulasolutions.com>
      Signed-off-by: default avatarJagan Teki <jagan@amarulasolutions.com>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e37de852
    • Jacopo Mondi's avatar
      ARM: dts: imx6qdl: Add Engicam i.Core 1.5 MX6 · 16ba1ad0
      Jacopo Mondi authored
      commit 37c045d2 upstream.
      
      The 1.5 version of Engicam's i.Core MX6 CPU module features a different clock
      provider for the ethernet's PHY interface. Adjust the FEC ptp clock to
      reference CLK_ENET_REF clock source, and set SION bit of
      MX6QDL_PAD_GPIO_16__ENET_REF_CLK to adjust the input path of that pin.
      
      The newly introduced imx6ql-icore-1.5.dtsi allows to collect in a single
      place differences between version '1.0' and '1.5' of the module.
      Reviewed-by: default avatarFabio Estevam <fabio.estevam@nxp.com>
      Signed-off-by: default avatarJacopo Mondi <jacopo@jmondi.org>
      Cc: Daniel Díaz <daniel.diaz@linaro.org>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      16ba1ad0
    • Wen Yang's avatar
      mm/page-writeback.c: avoid potential division by zero in wb_min_max_ratio() · ff86c5b6
      Wen Yang authored
      commit 6d9e8c65 upstream.
      
      Patch series "use div64_ul() instead of div_u64() if the divisor is
      unsigned long".
      
      We were first inspired by commit b0ab99e7 ("sched: Fix possible divide
      by zero in avg_atom () calculation"), then refer to the recently analyzed
      mm code, we found this suspicious place.
      
       201                 if (min) {
       202                         min *= this_bw;
       203                         do_div(min, tot_bw);
       204                 }
      
      And we also disassembled and confirmed it:
      
        /usr/src/debug/kernel-4.9.168-016.ali3000/linux-4.9.168-016.ali3000.alios7.x86_64/mm/page-writeback.c: 201
        0xffffffff811c37da <__wb_calc_thresh+234>:      xor    %r10d,%r10d
        0xffffffff811c37dd <__wb_calc_thresh+237>:      test   %rax,%rax
        0xffffffff811c37e0 <__wb_calc_thresh+240>:      je 0xffffffff811c3800 <__wb_calc_thresh+272>
        /usr/src/debug/kernel-4.9.168-016.ali3000/linux-4.9.168-016.ali3000.alios7.x86_64/mm/page-writeback.c: 202
        0xffffffff811c37e2 <__wb_calc_thresh+242>:      imul   %r8,%rax
        /usr/src/debug/kernel-4.9.168-016.ali3000/linux-4.9.168-016.ali3000.alios7.x86_64/mm/page-writeback.c: 203
        0xffffffff811c37e6 <__wb_calc_thresh+246>:      mov    %r9d,%r10d    ---> truncates it to 32 bits here
        0xffffffff811c37e9 <__wb_calc_thresh+249>:      xor    %edx,%edx
        0xffffffff811c37eb <__wb_calc_thresh+251>:      div    %r10
        0xffffffff811c37ee <__wb_calc_thresh+254>:      imul   %rbx,%rax
        0xffffffff811c37f2 <__wb_calc_thresh+258>:      shr    $0x2,%rax
        0xffffffff811c37f6 <__wb_calc_thresh+262>:      mul    %rcx
        0xffffffff811c37f9 <__wb_calc_thresh+265>:      shr    $0x2,%rdx
        0xffffffff811c37fd <__wb_calc_thresh+269>:      mov    %rdx,%r10
      
      This series uses div64_ul() instead of div_u64() if the divisor is
      unsigned long, to avoid truncation to 32-bit on 64-bit platforms.
      
      This patch (of 3):
      
      The variables 'min' and 'max' are unsigned long and do_div truncates
      them to 32 bits, which means it can test non-zero and be truncated to
      zero for division.  Fix this issue by using div64_ul() instead.
      
      Link: http://lkml.kernel.org/r/20200102081442.8273-2-wenyang@linux.alibaba.com
      Fixes: 693108a8 ("writeback: make bdi->min/max_ratio handling cgroup writeback aware")
      Signed-off-by: default avatarWen Yang <wenyang@linux.alibaba.com>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Qian Cai <cai@lca.pw>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ff86c5b6
    • Johannes Thumshirn's avatar
      btrfs: fix memory leak in qgroup accounting · 5bff4167
      Johannes Thumshirn authored
      commit 26ef8493 upstream.
      
      When running xfstests on the current btrfs I get the following splat from
      kmemleak:
      
      unreferenced object 0xffff88821b2404e0 (size 32):
        comm "kworker/u4:7", pid 26663, jiffies 4295283698 (age 8.776s)
        hex dump (first 32 bytes):
          01 00 00 00 00 00 00 00 10 ff fd 26 82 88 ff ff  ...........&....
          10 ff fd 26 82 88 ff ff 20 ff fd 26 82 88 ff ff  ...&.... ..&....
        backtrace:
          [<00000000f94fd43f>] ulist_alloc+0x25/0x60 [btrfs]
          [<00000000fd023d99>] btrfs_find_all_roots_safe+0x41/0x100 [btrfs]
          [<000000008f17bd32>] btrfs_find_all_roots+0x52/0x70 [btrfs]
          [<00000000b7660afb>] btrfs_qgroup_rescan_worker+0x343/0x680 [btrfs]
          [<0000000058e66778>] btrfs_work_helper+0xac/0x1e0 [btrfs]
          [<00000000f0188930>] process_one_work+0x1cf/0x350
          [<00000000af5f2f8e>] worker_thread+0x28/0x3c0
          [<00000000b55a1add>] kthread+0x109/0x120
          [<00000000f88cbd17>] ret_from_fork+0x35/0x40
      
      This corresponds to:
      
        (gdb) l *(btrfs_find_all_roots_safe+0x41)
        0x8d7e1 is in btrfs_find_all_roots_safe (fs/btrfs/backref.c:1413).
        1408
        1409            tmp = ulist_alloc(GFP_NOFS);
        1410            if (!tmp)
        1411                    return -ENOMEM;
        1412            *roots = ulist_alloc(GFP_NOFS);
        1413            if (!*roots) {
        1414                    ulist_free(tmp);
        1415                    return -ENOMEM;
        1416            }
        1417
      
      Following the lifetime of the allocated 'roots' ulist, it gets freed
      again in btrfs_qgroup_account_extent().
      
      But this does not happen if the function is called with the
      'BTRFS_FS_QUOTA_ENABLED' flag cleared, then btrfs_qgroup_account_extent()
      does a short leave and directly returns.
      
      Instead of directly returning we should jump to the 'out_free' in order to
      free all resources as expected.
      
      CC: stable@vger.kernel.org # 4.14+
      Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
      Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      [ add comment ]
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5bff4167
    • Josef Bacik's avatar
      btrfs: do not delete mismatched root refs · 3b5a4a18
      Josef Bacik authored
      commit 423a716c upstream.
      
      btrfs_del_root_ref() will simply WARN_ON() if the ref doesn't match in
      any way, and then continue to delete the reference.  This shouldn't
      happen, we have these values because there's more to the reference than
      the original root and the sub root.  If any of these checks fail, return
      -ENOENT.
      
      CC: stable@vger.kernel.org # 4.4+
      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 avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3b5a4a18
    • Josef Bacik's avatar
      btrfs: fix invalid removal of root ref · d110e93b
      Josef Bacik authored
      commit d49d3287 upstream.
      
      If we have the following sequence of events
      
        btrfs sub create A
        btrfs sub create A/B
        btrfs sub snap A C
        mkdir C/foo
        mv A/B C/foo
        rm -rf *
      
      We will end up with a transaction abort.
      
      The reason for this is because we create a root ref for B pointing to A.
      When we create a snapshot of C we still have B in our tree, but because
      the root ref points to A and not C we will make it appear to be empty.
      
      The problem happens when we move B into C.  This removes the root ref
      for B pointing to A and adds a ref of B pointing to C.  When we rmdir C
      we'll see that we have a ref to our root and remove the root ref,
      despite not actually matching our reference name.
      
      Now btrfs_del_root_ref() allowing this to work is a bug as well, however
      we know that this inode does not actually point to a root ref in the
      first place, so we shouldn't be calling btrfs_del_root_ref() in the
      first place and instead simply look up our dir index for this item and
      do the rest of the removal.
      
      CC: stable@vger.kernel.org # 4.4+
      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 avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d110e93b
    • Josef Bacik's avatar
      btrfs: rework arguments of btrfs_unlink_subvol · dab7dd71
      Josef Bacik authored
      [ Upstream commit 045d3967 ]
      
      btrfs_unlink_subvol takes the name of the dentry and the root objectid
      based on what kind of inode this is, either a real subvolume link or a
      empty one that we inherited as a snapshot.  We need to fix how we unlink
      in the case for BTRFS_EMPTY_SUBVOL_DIR_OBJECTID in the future, so rework
      btrfs_unlink_subvol to just take the dentry and handle getting the right
      objectid given the type of inode this is.  There is no functional change
      here, simply pushing the work into btrfs_unlink_subvol() proper.
      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 avatarSasha Levin <sashal@kernel.org>
      dab7dd71
    • Adrian Huang's avatar
      mm: memcg/slab: call flush_memcg_workqueue() only if memcg workqueue is valid · bc603056
      Adrian Huang authored
      commit 2fe20210 upstream.
      
      When booting with amd_iommu=off, the following WARNING message
      appears:
      
        AMD-Vi: AMD IOMMU disabled on kernel command-line
        ------------[ cut here ]------------
        WARNING: CPU: 0 PID: 0 at kernel/workqueue.c:2772 flush_workqueue+0x42e/0x450
        Modules linked in:
        CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.5.0-rc3-amd-iommu #6
        Hardware name: Lenovo ThinkSystem SR655-2S/7D2WRCZ000, BIOS D8E101L-1.00 12/05/2019
        RIP: 0010:flush_workqueue+0x42e/0x450
        Code: ff 0f 0b e9 7a fd ff ff 4d 89 ef e9 33 fe ff ff 0f 0b e9 7f fd ff ff 0f 0b e9 bc fd ff ff 0f 0b e9 a8 fd ff ff e8 52 2c fe ff <0f> 0b 31 d2 48 c7 c6 e0 88 c5 95 48 c7 c7 d8 ad f0 95 e8 19 f5 04
        Call Trace:
         kmem_cache_destroy+0x69/0x260
         iommu_go_to_state+0x40c/0x5ab
         amd_iommu_prepare+0x16/0x2a
         irq_remapping_prepare+0x36/0x5f
         enable_IR_x2apic+0x21/0x172
         default_setup_apic_routing+0x12/0x6f
         apic_intr_mode_init+0x1a1/0x1f1
         x86_late_time_init+0x17/0x1c
         start_kernel+0x480/0x53f
         secondary_startup_64+0xb6/0xc0
        ---[ end trace 30894107c3749449 ]---
        x2apic: IRQ remapping doesn't support X2APIC mode
        x2apic disabled
      
      The warning is caused by the calling of 'kmem_cache_destroy()'
      in free_iommu_resources(). Here is the call path:
      
        free_iommu_resources
          kmem_cache_destroy
            flush_memcg_workqueue
              flush_workqueue
      
      The root cause is that the IOMMU subsystem runs before the workqueue
      subsystem, which the variable 'wq_online' is still 'false'.  This leads
      to the statement 'if (WARN_ON(!wq_online))' in flush_workqueue() is
      'true'.
      
      Since the variable 'memcg_kmem_cache_wq' is not allocated during the
      time, it is unnecessary to call flush_memcg_workqueue().  This prevents
      the WARNING message triggered by flush_workqueue().
      
      Link: http://lkml.kernel.org/r/20200103085503.1665-1-ahuang12@lenovo.com
      Fixes: 92ee383f ("mm: fix race between kmem_cache destroy, create and deactivate")
      Signed-off-by: default avatarAdrian Huang <ahuang12@lenovo.com>
      Reported-by: default avatarXiaochun Lee <lixc17@lenovo.com>
      Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
      Cc: Joerg Roedel <jroedel@suse.de>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc603056
    • Kirill A. Shutemov's avatar
      mm/shmem.c: thp, shmem: fix conflict of above-47bit hint address and PMD alignment · a3071de2
      Kirill A. Shutemov authored
      commit 99158997 upstream.
      
      Shmem/tmpfs tries to provide THP-friendly mappings if huge pages are
      enabled.  But it doesn't work well with above-47bit hint address.
      
      Normally, the kernel doesn't create userspace mappings above 47-bit,
      even if the machine allows this (such as with 5-level paging on x86-64).
      Not all user space is ready to handle wide addresses.  It's known that
      at least some JIT compilers use higher bits in pointers to encode their
      information.
      
      Userspace can ask for allocation from full address space by specifying
      hint address (with or without MAP_FIXED) above 47-bits.  If the
      application doesn't need a particular address, but wants to allocate
      from whole address space it can specify -1 as a hint address.
      
      Unfortunately, this trick breaks THP alignment in shmem/tmp:
      shmem_get_unmapped_area() would not try to allocate PMD-aligned area if
      *any* hint address specified.
      
      This can be fixed by requesting the aligned area if the we failed to
      allocated at user-specified hint address.  The request with inflated
      length will also take the user-specified hint address.  This way we will
      not lose an allocation request from the full address space.
      
      [kirill@shutemov.name: fold in a fixup]
        Link: http://lkml.kernel.org/r/20191223231309.t6bh5hkbmokihpfu@box
      Link: http://lkml.kernel.org/r/20191220142548.7118-3-kirill.shutemov@linux.intel.com
      Fixes: b569bab7 ("x86/mm: Prepare to expose larger address space to userspace")
      Signed-off-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: "Willhalm, Thomas" <thomas.willhalm@intel.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: "Bruggeman, Otto G" <otto.g.bruggeman@intel.com>
      Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.vnet.ibm.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a3071de2
    • Jin Yao's avatar
      perf report: Fix incorrectly added dimensions as switch perf data file · 8caa8b36
      Jin Yao authored
      commit 0feba17b upstream.
      
      We observed an issue that was some extra columns displayed after switching
      perf data file in browser. The steps to reproduce:
      
      1. perf record -a -e cycles,instructions -- sleep 3
      2. perf report --group
      3. In browser, we use hotkey 's' to switch to another perf.data
      4. Now in browser, the extra columns 'Self' and 'Children' are displayed.
      
      The issue is setup_sorting() executed again after repeat path, so dimensions
      are added again.
      
      This patch checks the last key returned from __cmd_report(). If it's
      K_SWITCH_INPUT_DATA, skips the setup_sorting().
      
      Fixes: ad0de097 ("perf report: Enable the runtime switching of perf data file")
      Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Feng Tang <feng.tang@intel.com>
      Cc: Jin Yao <yao.jin@intel.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20191220013722.20592-1-yao.jin@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8caa8b36
    • Yuya Fujita's avatar
      perf hists: Fix variable name's inconsistency in hists__for_each() macro · 7e4d65de
      Yuya Fujita authored
      commit 55347ec3 upstream.
      
      Variable names are inconsistent in hists__for_each macro().
      
      Due to this inconsistency, the macro replaces its second argument with
      "fmt" regardless of its original name.
      
      So far it works because only "fmt" is passed to the second argument.
      However, this behavior is not expected and should be fixed.
      
      Fixes: f0786af5 ("perf hists: Introduce hists__for_each_format macro")
      Fixes: aa6f50af ("perf hists: Introduce hists__for_each_sort_list macro")
      Signed-off-by: default avatarYuya Fujita <fujita.yuya@fujitsu.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/OSAPR01MB1588E1C47AC22043175DE1B2E8520@OSAPR01MB1588.jpnprd01.prod.outlook.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7e4d65de
    • Shakeel Butt's avatar
      x86/resctrl: Fix potential memory leak · bb8e8f42
      Shakeel Butt authored
      commit ab6a2114 upstream.
      
      set_cache_qos_cfg() is leaking memory when the given level is not
      RDT_RESOURCE_L3 or RDT_RESOURCE_L2. At the moment, this function is
      called with only valid levels but move the allocation after the valid
      level checks in order to make it more robust and future proof.
      
       [ bp: Massage commit message. ]
      
      Fixes: 99adde9b ("x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG")
      Signed-off-by: default avatarShakeel Butt <shakeelb@google.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Reinette Chatre <reinette.chatre@intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20200102165844.133133-1-shakeelb@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb8e8f42
    • YueHaibing's avatar
      drm/i915: Add missing include file <linux/math64.h> · 107fb290
      YueHaibing authored
      commit ea38aa2e upstream.
      
      Fix build error:
      ./drivers/gpu/drm/i915/selftests/i915_random.h: In function i915_prandom_u32_max_state:
      ./drivers/gpu/drm/i915/selftests/i915_random.h:48:23: error:
       implicit declaration of function mul_u32_u32; did you mean mul_u64_u32_div? [-Werror=implicit-function-declaration]
        return upper_32_bits(mul_u32_u32(prandom_u32_state(state), ep_ro));
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Fixes: 7ce5b685 ("drm/i915/selftests: Use mul_u32_u32() for 32b x 32b -> 64b result")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200107135014.36472-1-yuehaibing@huawei.com
      (cherry picked from commit 62bf5465)
      Signed-off-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      107fb290
    • Ard Biesheuvel's avatar
      x86/efistub: Disable paging at mixed mode entry · 820ea0e5
      Ard Biesheuvel authored
      commit 4911ee40 upstream.
      
      The EFI mixed mode entry code goes through the ordinary startup_32()
      routine before jumping into the kernel's EFI boot code in 64-bit
      mode. The 32-bit startup code must be entered with paging disabled,
      but this is not documented as a requirement for the EFI handover
      protocol, and so we should disable paging explicitly when entering
      the kernel from 32-bit EFI firmware.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: <stable@vger.kernel.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20191224132909.102540-4-ardb@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      820ea0e5
    • Tom Lendacky's avatar
      x86/CPU/AMD: Ensure clearing of SME/SEV features is maintained · 4d839755
      Tom Lendacky authored
      commit a006483b upstream.
      
      If the SME and SEV features are present via CPUID, but memory encryption
      support is not enabled (MSR 0xC001_0010[23]), the feature flags are cleared
      using clear_cpu_cap(). However, if get_cpu_cap() is later called, these
      feature flags will be reset back to present, which is not desired.
      
      Change from using clear_cpu_cap() to setup_clear_cpu_cap() so that the
      clearing of the flags is maintained.
      Signed-off-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: <stable@vger.kernel.org> # 4.16.x-
      Link: https://lkml.kernel.org/r/226de90a703c3c0be5a49565047905ac4e94e8f3.1579125915.git.thomas.lendacky@amd.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d839755
    • Qian Cai's avatar
      x86/resctrl: Fix an imbalance in domain_remove_cpu() · 7e22f494
      Qian Cai authored
      commit e278af89 upstream.
      
      A system that supports resource monitoring may have multiple resources
      while not all of these resources are capable of monitoring. Monitoring
      related state is initialized only for resources that are capable of
      monitoring and correspondingly this state should subsequently only be
      removed from these resources that are capable of monitoring.
      
      domain_add_cpu() calls domain_setup_mon_state() only when r->mon_capable
      is true where it will initialize d->mbm_over. However,
      domain_remove_cpu() calls cancel_delayed_work(&d->mbm_over) without
      checking r->mon_capable resulting in an attempt to cancel d->mbm_over on
      all resources, even those that never initialized d->mbm_over because
      they are not capable of monitoring. Hence, it triggers a debugobjects
      warning when offlining CPUs because those timer debugobjects are never
      initialized:
      
        ODEBUG: assert_init not available (active state 0) object type:
        timer_list hint: 0x0
        WARNING: CPU: 143 PID: 789 at lib/debugobjects.c:484
        debug_print_object
        Hardware name: HP Synergy 680 Gen9/Synergy 680 Gen9 Compute Module, BIOS I40 05/23/2018
        RIP: 0010:debug_print_object
        Call Trace:
        debug_object_assert_init
        del_timer
        try_to_grab_pending
        cancel_delayed_work
        resctrl_offline_cpu
        cpuhp_invoke_callback
        cpuhp_thread_fun
        smpboot_thread_fn
        kthread
        ret_from_fork
      
      Fixes: e3302683 ("x86/intel_rdt/mbm: Handle counter overflow")
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarReinette Chatre <reinette.chatre@intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: john.stultz@linaro.org
      Cc: sboyd@kernel.org
      Cc: <stable@vger.kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: tj@kernel.org
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Vikas Shivappa <vikas.shivappa@linux.intel.com>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20191211033042.2188-1-cai@lca.pwSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7e22f494
    • Keiya Nobuta's avatar
      usb: core: hub: Improved device recognition on remote wakeup · ecd8db99
      Keiya Nobuta authored
      commit 9c06ac4c upstream.
      
      If hub_activate() is called before D+ has stabilized after remote
      wakeup, the following situation might occur:
      
               __      ___________________
              /  \    /
      D+   __/    \__/
      
      Hub  _______________________________
                |  ^   ^           ^
                |  |   |           |
      Host _____v__|___|___________|______
                |  |   |           |
                |  |   |           \-- Interrupt Transfer (*3)
                |  |    \-- ClearPortFeature (*2)
                |   \-- GetPortStatus (*1)
                \-- Host detects remote wakeup
      
      - D+ goes high, Host starts running by remote wakeup
      - D+ is not stable, goes low
      - Host requests GetPortStatus at (*1) and gets the following hub status:
        - Current Connect Status bit is 0
        - Connect Status Change bit is 1
      - D+ stabilizes, goes high
      - Host requests ClearPortFeature and thus Connect Status Change bit is
        cleared at (*2)
      - After waiting 100 ms, Host starts the Interrupt Transfer at (*3)
      - Since the Connect Status Change bit is 0, Hub returns NAK.
      
      In this case, port_event() is not called in hub_event() and Host cannot
      recognize device. To solve this issue, flag change_bits even if only
      Connect Status Change bit is 1 when got in the first GetPortStatus.
      
      This issue occurs rarely because it only if D+ changes during a very
      short time between GetPortStatus and ClearPortFeature. However, it is
      fatal if it occurs in embedded system.
      Signed-off-by: default avatarKeiya Nobuta <nobuta.keiya@fujitsu.com>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/20200109051448.28150-1-nobuta.keiya@fujitsu.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ecd8db99
    • Christian Brauner's avatar
      ptrace: reintroduce usage of subjective credentials in ptrace_has_cap() · 21cd79a2
      Christian Brauner authored
      commit 6b3ad664 upstream.
      
      Commit 69f594a3 ("ptrace: do not audit capability check when outputing /proc/pid/stat")
      introduced the ability to opt out of audit messages for accesses to various
      proc files since they are not violations of policy.  While doing so it
      somehow switched the check from ns_capable() to
      has_ns_capability{_noaudit}(). That means it switched from checking the
      subjective credentials of the task to using the objective credentials. This
      is wrong since. ptrace_has_cap() is currently only used in
      ptrace_may_access() And is used to check whether the calling task (subject)
      has the CAP_SYS_PTRACE capability in the provided user namespace to operate
      on the target task (object). According to the cred.h comments this would
      mean the subjective credentials of the calling task need to be used.
      This switches ptrace_has_cap() to use security_capable(). Because we only
      call ptrace_has_cap() in ptrace_may_access() and in there we already have a
      stable reference to the calling task's creds under rcu_read_lock() there's
      no need to go through another series of dereferences and rcu locking done
      in ns_capable{_noaudit}().
      
      As one example where this might be particularly problematic, Jann pointed
      out that in combination with the upcoming IORING_OP_OPENAT feature, this
      bug might allow unprivileged users to bypass the capability checks while
      asynchronously opening files like /proc/*/mem, because the capability
      checks for this would be performed against kernel credentials.
      
      To illustrate on the former point about this being exploitable: When
      io_uring creates a new context it records the subjective credentials of the
      caller. Later on, when it starts to do work it creates a kernel thread and
      registers a callback. The callback runs with kernel creds for
      ktask->real_cred and ktask->cred. To prevent this from becoming a
      full-blown 0-day io_uring will call override_cred() and override
      ktask->cred with the subjective credentials of the creator of the io_uring
      instance. With ptrace_has_cap() currently looking at ktask->real_cred this
      override will be ineffective and the caller will be able to open arbitray
      proc files as mentioned above.
      Luckily, this is currently not exploitable but will turn into a 0-day once
      IORING_OP_OPENAT{2} land in v5.6. Fix it now!
      
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Eric Paris <eparis@redhat.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarSerge Hallyn <serge@hallyn.com>
      Reviewed-by: default avatarJann Horn <jannh@google.com>
      Fixes: 69f594a3 ("ptrace: do not audit capability check when outputing /proc/pid/stat")
      Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21cd79a2
    • Micah Morton's avatar
      LSM: generalize flag passing to security_capable · 87ca9aaf
      Micah Morton authored
      [ Upstream commit c1a85a00 ]
      
      This patch provides a general mechanism for passing flags to the
      security_capable LSM hook. It replaces the specific 'audit' flag that is
      used to tell security_capable whether it should log an audit message for
      the given capability check. The reason for generalizing this flag
      passing is so we can add an additional flag that signifies whether
      security_capable is being called by a setid syscall (which is needed by
      the proposed SafeSetID LSM).
      Signed-off-by: default avatarMicah Morton <mortonm@chromium.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarJames Morris <james.morris@microsoft.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      87ca9aaf
    • Kishon Vijay Abraham I's avatar
      ARM: dts: am571x-idk: Fix gpios property to have the correct gpio number · 991d8c73
      Kishon Vijay Abraham I authored
      commit 0c4eb2a6 upstream.
      
      commit d23f3839 ("ARM: dts: DRA7: Add pcie1 dt node for
      EP mode") while adding the dt node for EP mode for DRA7 platform,
      added rc node for am571x-idk and populated gpios property with
      "gpio3 23". However the GPIO_PCIE_SWRST line is actually connected
      to "gpio5 18". Fix it here. (The patch adding "gpio3 23" was tested
      with another am57x board in EP mode which doesn't rely on reset from
      host).
      
      Cc: stable <stable@vger.kernel.org> # 4.14+
      Fixes: d23f3839 ("ARM: dts: DRA7: Add pcie1 dt node for EP mode")
      Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      991d8c73
    • Mikulas Patocka's avatar
      block: fix an integer overflow in logical block size · a7f79052
      Mikulas Patocka authored
      commit ad6bf88a upstream.
      
      Logical block size has type unsigned short. That means that it can be at
      most 32768. However, there are architectures that can run with 64k pages
      (for example arm64) and on these architectures, it may be possible to
      create block devices with 64k block size.
      
      For exmaple (run this on an architecture with 64k pages):
      
      Mount will fail with this error because it tries to read the superblock using 2-sector
      access:
        device-mapper: writecache: I/O is not aligned, sector 2, size 1024, block size 65536
        EXT4-fs (dm-0): unable to read superblock
      
      This patch changes the logical block size from unsigned short to unsigned
      int to avoid the overflow.
      
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7f79052
    • Jari Ruusu's avatar
      Fix built-in early-load Intel microcode alignment · 8d9fd1f4
      Jari Ruusu authored
      commit f5ae2ea6 upstream.
      
      Intel Software Developer's Manual, volume 3, chapter 9.11.6 says:
      
       "Note that the microcode update must be aligned on a 16-byte boundary
        and the size of the microcode update must be 1-KByte granular"
      
      When early-load Intel microcode is loaded from initramfs, userspace tool
      'iucode_tool' has already 16-byte aligned those microcode bits in that
      initramfs image.  Image that was created something like this:
      
       iucode_tool --write-earlyfw=FOO.cpio microcode-files...
      
      However, when early-load Intel microcode is loaded from built-in
      firmware BLOB using CONFIG_EXTRA_FIRMWARE= kernel config option, that
      16-byte alignment is not guaranteed.
      
      Fix this by forcing all built-in firmware BLOBs to 16-byte alignment.
      
      [ If we end up having other firmware with much bigger alignment
        requirements, we might need to introduce some method for the firmware
        to specify it, this is the minimal "just increase the alignment a bit
        to account for this one special case" patch    - Linus ]
      Signed-off-by: default avatarJari Ruusu <jari.ruusu@gmail.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Luis Chamberlain <mcgrof@kernel.org>
      Cc: stable@kernel.org
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8d9fd1f4
    • Stefan Mavrodiev's avatar
      arm64: dts: allwinner: a64: olinuxino: Fix SDIO supply regulator · c7d4d1ad
      Stefan Mavrodiev authored
      commit 3d615c2f upstream.
      
      A64-OLinuXino uses DCDC1 (VCC-IO) for MMC1 supply. In commit 916b68cf
      ("arm64: dts: a64-olinuxino: Enable RTL8723BS WiFi") ALDO2 is set, which is
      VCC-PL. Since DCDC1 is always present, the boards are working without a
      problem.
      
      This patch sets the correct regulator.
      
      Fixes: 916b68cf ("arm64: dts: a64-olinuxino: Enable RTL8723BS WiFi")
      Cc: stable@vger.kernel.org # v4.16+
      Signed-off-by: default avatarStefan Mavrodiev <stefan@olimex.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c7d4d1ad
    • Johan Hovold's avatar
      ALSA: usb-audio: fix sync-ep altsetting sanity check · aa7e8db2
      Johan Hovold authored
      commit 5d1b7122 upstream.
      
      The altsetting sanity check in set_sync_ep_implicit_fb_quirk() was
      checking for there to be at least one altsetting but then went on to
      access the second one, which may not exist.
      
      This could lead to random slab data being used to initialise the sync
      endpoint in snd_usb_add_endpoint().
      
      Fixes: c75a8a7a ("ALSA: snd-usb: add support for implicit feedback")
      Fixes: ca10a7eb ("ALSA: usb-audio: FT C400 sync playback EP to capture EP")
      Fixes: 5e35dc03 ("ALSA: usb-audio: add implicit fb quirk for Behringer UFX1204")
      Fixes: 17f08b0d ("ALSA: usb-audio: add implicit fb quirk for Axe-Fx II")
      Fixes: 103e9625 ("ALSA: usb-audio: simplify set_sync_ep_implicit_fb_quirk")
      Cc: stable <stable@vger.kernel.org>     # 3.5
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20200114083953.1106-1-johan@kernel.orgSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aa7e8db2
    • Takashi Iwai's avatar
      ALSA: seq: Fix racy access for queue timer in proc read · 20f2e4c2
      Takashi Iwai authored
      commit 60adcfde upstream.
      
      snd_seq_info_timer_read() reads the information of the timer assigned
      for each queue, but it's done in a racy way which may lead to UAF as
      spotted by syzkaller.
      
      This patch applies the missing q->timer_mutex lock while accessing the
      timer object as well as a slight code change to adapt the standard
      coding style.
      
      Reported-by: syzbot+2b2ef983f973e5c40943@syzkaller.appspotmail.com
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200115203733.26530-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      20f2e4c2
    • Takashi Sakamoto's avatar
      ALSA: dice: fix fallback from protocol extension into limited functionality · e68bc5ef
      Takashi Sakamoto authored
      commit 3e2dc6bd upstream.
      
      At failure of attempt to detect protocol extension, ALSA dice driver
      should be fallback to limited functionality. However it's not.
      
      This commit fixes it.
      
      Cc: <stable@vger.kernel.org> # v4.18+
      Fixes: 58579c05 ("ALSA: dice: use extended protocol to detect available stream formats")
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Link: https://lore.kernel.org/r/20200113084630.14305-2-o-takashi@sakamocchi.jpSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e68bc5ef
    • Marek Vasut's avatar
      ARM: dts: imx6q-dhcom: Fix SGTL5000 VDDIO regulator connection · 6a75df0c
      Marek Vasut authored
      commit fe6a6689 upstream.
      
      The SGTL5000 VDDIO is connected to the PMIC SW2 output, not to
      a fixed 3V3 rail. Describe this correctly in the DT.
      
      Fixes: 52c7a088 ("ARM: dts: imx6q: Add support for the DHCOM iMX6 SoM and PDK2")
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: Fabio Estevam <festevam@gmail.com>
      Cc: Ludwig Zenz <lzenz@dh-electronics.com>
      Cc: NXP Linux Team <linux-imx@nxp.com>
      To: linux-arm-kernel@lists.infradead.org
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a75df0c
    • Stephan Gerhold's avatar
      ASoC: msm8916-wcd-analog: Fix MIC BIAS Internal1 · 095fa892
      Stephan Gerhold authored
      commit 057efcf9 upstream.
      
      MIC BIAS Internal1 is broken at the moment because we always
      enable the internal rbias resistor to the TX2 line (connected to
      the headset microphone), rather than enabling the resistor connected
      to TX1.
      
      Move the RBIAS code to pm8916_wcd_analog_enable_micbias_int1/2()
      to fix this.
      
      Fixes: 585e881e ("ASoC: codecs: Add msm8916-wcd analog codec")
      Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Signed-off-by: default avatarStephan Gerhold <stephan@gerhold.net>
      Link: https://lore.kernel.org/r/20200111164006.43074-3-stephan@gerhold.netSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      095fa892
    • Stephan Gerhold's avatar
      ASoC: msm8916-wcd-analog: Fix selected events for MIC BIAS External1 · 0e3df2d7
      Stephan Gerhold authored
      commit e0beec88 upstream.
      
      MIC BIAS External1 sets pm8916_wcd_analog_enable_micbias_ext1()
      as event handler, which ends up in pm8916_wcd_analog_enable_micbias_ext().
      
      But pm8916_wcd_analog_enable_micbias_ext() only handles the POST_PMU
      event, which is not specified in the event flags for MIC BIAS External1.
      This means that the code in the event handler is never actually run.
      
      Set SND_SOC_DAPM_POST_PMU as the only event for the handler to fix this.
      
      Fixes: 585e881e ("ASoC: codecs: Add msm8916-wcd analog codec")
      Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Signed-off-by: default avatarStephan Gerhold <stephan@gerhold.net>
      Link: https://lore.kernel.org/r/20200111164006.43074-2-stephan@gerhold.netSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e3df2d7
    • Dan Carpenter's avatar
      scsi: mptfusion: Fix double fetch bug in ioctl · 3dae5041
      Dan Carpenter authored
      commit 28d76df1 upstream.
      
      Tom Hatskevich reported that we look up "iocp" then, in the called
      functions we do a second copy_from_user() and look it up again.
      The problem that could cause is:
      
      drivers/message/fusion/mptctl.c
         674          /* All of these commands require an interrupt or
         675           * are unknown/illegal.
         676           */
         677          if ((ret = mptctl_syscall_down(iocp, nonblock)) != 0)
                                                     ^^^^
      We take this lock.
      
         678                  return ret;
         679
         680          if (cmd == MPTFWDOWNLOAD)
         681                  ret = mptctl_fw_download(arg);
                                                       ^^^
      Then the user memory changes and we look up "iocp" again but a different
      one so now we are holding the incorrect lock and have a race condition.
      
         682          else if (cmd == MPTCOMMAND)
         683                  ret = mptctl_mpt_command(arg);
      
      The security impact of this bug is not as bad as it could have been
      because these operations are all privileged and root already has
      enormous destructive power.  But it's still worth fixing.
      
      This patch passes the "iocp" pointer to the functions to avoid the
      second lookup.  That deletes 100 lines of code from the driver so
      it's a nice clean up as well.
      
      Link: https://lore.kernel.org/r/20200114123414.GA7957@kadamReported-by: default avatarTom Hatskevich <tom2001tom.23@gmail.com>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3dae5041
    • Arnd Bergmann's avatar
      scsi: fnic: fix invalid stack access · ac13a00a
      Arnd Bergmann authored
      commit 42ec15ce upstream.
      
      gcc -O3 warns that some local variables are not properly initialized:
      
      drivers/scsi/fnic/vnic_dev.c: In function 'fnic_dev_hang_notify':
      drivers/scsi/fnic/vnic_dev.c:511:16: error: 'a0' is used uninitialized in this function [-Werror=uninitialized]
        vdev->args[0] = *a0;
        ~~~~~~~~~~~~~~^~~~~
      drivers/scsi/fnic/vnic_dev.c:691:6: note: 'a0' was declared here
        u64 a0, a1;
            ^~
      drivers/scsi/fnic/vnic_dev.c:512:16: error: 'a1' is used uninitialized in this function [-Werror=uninitialized]
        vdev->args[1] = *a1;
        ~~~~~~~~~~~~~~^~~~~
      drivers/scsi/fnic/vnic_dev.c:691:10: note: 'a1' was declared here
        u64 a0, a1;
                ^~
      drivers/scsi/fnic/vnic_dev.c: In function 'fnic_dev_mac_addr':
      drivers/scsi/fnic/vnic_dev.c:512:16: error: 'a1' is used uninitialized in this function [-Werror=uninitialized]
        vdev->args[1] = *a1;
        ~~~~~~~~~~~~~~^~~~~
      drivers/scsi/fnic/vnic_dev.c:698:10: note: 'a1' was declared here
        u64 a0, a1;
                ^~
      
      Apparently the code relies on the local variables occupying adjacent memory
      locations in the same order, but this is of course not guaranteed.
      
      Use an array of two u64 variables where needed to make it work correctly.
      
      I suspect there is also an endianness bug here, but have not digged in deep
      enough to be sure.
      
      Fixes: 5df6d737 ("[SCSI] fnic: Add new Cisco PCI-Express FCoE HBA")
      Fixes: mmtom ("init/Kconfig: enable -O3 for all arches")
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200107201602.4096790-1-arnd@arndb.deSigned-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac13a00a
    • Johan Hovold's avatar
      USB: serial: quatech2: handle unbound ports · 392950d7
      Johan Hovold authored
      commit 9715a43e upstream.
      
      Check for NULL port data in the modem- and line-status handlers to avoid
      dereferencing a NULL pointer in the unlikely case where a port device
      isn't bound to a driver (e.g. after an allocation failure on port
      probe).
      
      Note that the other (stubbed) event handlers qt2_process_xmit_empty()
      and qt2_process_flush() would need similar sanity checks in case they
      are ever implemented.
      
      Fixes: f7a33e60 ("USB: serial: add quatech2 usb to serial driver")
      Cc: stable <stable@vger.kernel.org>     # 3.5
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      392950d7
    • Johan Hovold's avatar
      USB: serial: keyspan: handle unbound ports · 655e0b39
      Johan Hovold authored
      commit 3018dd3f upstream.
      
      Check for NULL port data in the control URB completion handlers to avoid
      dereferencing a NULL pointer in the unlikely case where a port device
      isn't bound to a driver (e.g. after an allocation failure on port
      probe()).
      
      Fixes: 0ca1268e ("USB Serial Keyspan: add support for USA-49WG & USA-28XG")
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      655e0b39
    • Johan Hovold's avatar
      USB: serial: io_edgeport: add missing active-port sanity check · d5f7cbcd
      Johan Hovold authored
      commit 1568c58d upstream.
      
      The driver receives the active port number from the device, but never
      made sure that the port number was valid. This could lead to a
      NULL-pointer dereference or memory corruption in case a device sends
      data for an invalid port.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d5f7cbcd
    • Johan Hovold's avatar
      USB: serial: io_edgeport: handle unbound ports on URB completion · 8dbc5ed3
      Johan Hovold authored
      commit e37d1aed upstream.
      
      Check for NULL port data in the shared interrupt and bulk completion
      callbacks to avoid dereferencing a NULL pointer in case a device sends
      data for a port device which isn't bound to a driver (e.g. due to a
      malicious device having unexpected endpoints or after an allocation
      failure on port probe).
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8dbc5ed3
    • Johan Hovold's avatar
      USB: serial: ch341: handle unbound port at reset_resume · 9b057d12
      Johan Hovold authored
      commit 4d5ef53f upstream.
      
      Check for NULL port data in reset_resume() to avoid dereferencing a NULL
      pointer in case the port device isn't bound to a driver (e.g. after a
      failed control request at port probe).
      
      Fixes: 1ded7ea4 ("USB: ch341 serial: fix port number changed after resume")
      Cc: stable <stable@vger.kernel.org>     # 2.6.30
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9b057d12
    • Johan Hovold's avatar
      USB: serial: suppress driver bind attributes · 1b86caef
      Johan Hovold authored
      commit fdb838ef upstream.
      
      USB-serial drivers must not be unbound from their ports before the
      corresponding USB driver is unbound from the parent interface so
      suppress the bind and unbind attributes.
      
      Unbinding a serial driver while it's port is open is a sure way to
      trigger a crash as any driver state is released on unbind while port
      hangup is handled on the parent USB interface level. Drivers for
      multiport devices where ports share a resource such as an interrupt
      endpoint also generally cannot handle individual ports going away.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1b86caef
    • Reinhard Speyerer's avatar
      USB: serial: option: add support for Quectel RM500Q in QDL mode · 845c8f49
      Reinhard Speyerer authored
      commit f3eaabbf upstream.
      
      Add support for Quectel RM500Q in QDL mode.
      
      T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 24 Spd=480  MxCh= 0
      D:  Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
      P:  Vendor=2c7c ProdID=0800 Rev= 0.00
      S:  Manufacturer=Qualcomm CDMA Technologies MSM
      S:  Product=QUSB_BULK_SN:xxxxxxxx
      S:  SerialNumber=xxxxxxxx
      C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=  2mA
      I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=10 Driver=option
      E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      
      It is assumed that the ZLP flag required for other Qualcomm-based
      5G devices also applies to Quectel RM500Q.
      Signed-off-by: default avatarReinhard Speyerer <rspmn@arcor.de>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      845c8f49
    • Johan Hovold's avatar
      USB: serial: opticon: fix control-message timeouts · cfb62fbc
      Johan Hovold authored
      commit 5e28055f upstream.
      
      The driver was issuing synchronous uninterruptible control requests
      without using a timeout. This could lead to the driver hanging
      on open() or tiocmset() due to a malfunctioning (or malicious) device
      until the device is physically disconnected.
      
      The USB upper limit of five seconds per request should be more than
      enough.
      
      Fixes: 309a0579 ("USB: opticon: add rts and cts support")
      Cc: stable <stable@vger.kernel.org>     # 2.6.39
      Cc: Martin Jansen <martin.jansen@opticon.com>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cfb62fbc
    • Kristian Evensen's avatar
      USB: serial: option: Add support for Quectel RM500Q · 805083d1
      Kristian Evensen authored
      commit accf227d upstream.
      
      RM500Q is a 5G module from Quectel, supporting both standalone and
      non-standalone modes. Unlike other recent Quectel modems, it is possible
      to identify the diagnostic interface (bInterfaceProtocol is unique).
      Thus, there is no need to check for the number of endpoints or reserve
      interfaces. The interface number is still dynamic though, so matching on
      interface number is not possible and two entries have to be added to the
      table.
      
      Output from usb-devices with all interfaces enabled (order is diag,
      nmea, at_port, modem, rmnet and adb):
      
      Bus 004 Device 007: ID 2c7c:0800 Quectel Wireless Solutions Co., Ltd.
      Device Descriptor:
        bLength                18
        bDescriptorType         1
        bcdUSB               3.20
        bDeviceClass            0 (Defined at Interface level)
        bDeviceSubClass         0
        bDeviceProtocol         0
        bMaxPacketSize0         9
        idVendor           0x2c7c Quectel Wireless Solutions Co., Ltd.
        idProduct          0x0800
        bcdDevice            4.14
        iManufacturer           1 Quectel
        iProduct                2 LTE-A Module
        iSerial                 3 40046d60
        bNumConfigurations      1
        Configuration Descriptor:
          bLength                 9
          bDescriptorType         2
          wTotalLength          328
          bNumInterfaces          6
          bConfigurationValue     1
          iConfiguration          4 DIAG_SER_RMNET
          bmAttributes         0xa0
            (Bus Powered)
            Remote Wakeup
          MaxPower              224mA
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        0
            bAlternateSetting       0
            bNumEndpoints           2
            bInterfaceClass       255 Vendor Specific Class
            bInterfaceSubClass    255 Vendor Specific Subclass
            bInterfaceProtocol     48
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x81  EP 1 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0400  1x 1024 bytes
              bInterval               0
              bMaxBurst               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x01  EP 1 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0400  1x 1024 bytes
              bInterval               0
              bMaxBurst               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        1
            bAlternateSetting       0
            bNumEndpoints           3
            bInterfaceClass       255 Vendor Specific Class
            bInterfaceSubClass      0
            bInterfaceProtocol      0
            iInterface              0
            ** UNRECOGNIZED:  05 24 00 10 01
            ** UNRECOGNIZED:  05 24 01 00 00
            ** UNRECOGNIZED:  04 24 02 02
            ** UNRECOGNIZED:  05 24 06 00 00
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x83  EP 3 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x000a  1x 10 bytes
              bInterval               9
              bMaxBurst               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x82  EP 2 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0400  1x 1024 bytes
              bInterval               0
              bMaxBurst               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x02  EP 2 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0400  1x 1024 bytes
              bInterval               0
              bMaxBurst               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        2
            bAlternateSetting       0
            bNumEndpoints           3
            bInterfaceClass       255 Vendor Specific Class
            bInterfaceSubClass      0
            bInterfaceProtocol      0
            iInterface              0
            ** UNRECOGNIZED:  05 24 00 10 01
            ** UNRECOGNIZED:  05 24 01 00 00
            ** UNRECOGNIZED:  04 24 02 02
            ** UNRECOGNIZED:  05 24 06 00 00
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x85  EP 5 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x000a  1x 10 bytes
              bInterval               9
              bMaxBurst               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x84  EP 4 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0400  1x 1024 bytes
              bInterval               0
              bMaxBurst               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x03  EP 3 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0400  1x 1024 bytes
              bInterval               0
              bMaxBurst               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        3
            bAlternateSetting       0
            bNumEndpoints           3
            bInterfaceClass       255 Vendor Specific Class
            bInterfaceSubClass      0
            bInterfaceProtocol      0
            iInterface              0
            ** UNRECOGNIZED:  05 24 00 10 01
            ** UNRECOGNIZED:  05 24 01 00 00
            ** UNRECOGNIZED:  04 24 02 02
            ** UNRECOGNIZED:  05 24 06 00 00
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x87  EP 7 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x000a  1x 10 bytes
              bInterval               9
              bMaxBurst               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x86  EP 6 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0400  1x 1024 bytes
              bInterval               0
              bMaxBurst               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x04  EP 4 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0400  1x 1024 bytes
              bInterval               0
              bMaxBurst               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        4
            bAlternateSetting       0
            bNumEndpoints           3
            bInterfaceClass       255 Vendor Specific Class
            bInterfaceSubClass    255 Vendor Specific Subclass
            bInterfaceProtocol    255 Vendor Specific Protocol
            iInterface              5 CDEV Serial
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x88  EP 8 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0008  1x 8 bytes
              bInterval               9
              bMaxBurst               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x8e  EP 14 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0400  1x 1024 bytes
              bInterval               0
              bMaxBurst               6
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x0f  EP 15 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0400  1x 1024 bytes
              bInterval               0
              bMaxBurst               2
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        5
            bAlternateSetting       0
            bNumEndpoints           2
            bInterfaceClass       255 Vendor Specific Class
            bInterfaceSubClass     66
            bInterfaceProtocol      1
            iInterface              6 ADB Interface
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x05  EP 5 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0400  1x 1024 bytes
              bInterval               0
              bMaxBurst               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x89  EP 9 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0400  1x 1024 bytes
              bInterval               0
              bMaxBurst               0
      Binary Object Store Descriptor:
        bLength                 5
        bDescriptorType        15
        wTotalLength           42
        bNumDeviceCaps          3
        USB 2.0 Extension Device Capability:
          bLength                 7
          bDescriptorType        16
          bDevCapabilityType      2
          bmAttributes   0x00000006
            Link Power Management (LPM) Supported
        SuperSpeed USB Device Capability:
          bLength                10
          bDescriptorType        16
          bDevCapabilityType      3
          bmAttributes         0x00
          wSpeedsSupported   0x000f
            Device can operate at Low Speed (1Mbps)
            Device can operate at Full Speed (12Mbps)
            Device can operate at High Speed (480Mbps)
            Device can operate at SuperSpeed (5Gbps)
          bFunctionalitySupport   1
            Lowest fully-functional device speed is Full Speed (12Mbps)
          bU1DevExitLat           1 micro seconds
          bU2DevExitLat         500 micro seconds
        ** UNRECOGNIZED:  14 10 0a 00 01 00 00 00 00 11 00 00 30 40 0a 00 b0 40 0a 00
      Device Status:     0x0000
        (Bus Powered)
      Signed-off-by: default avatarKristian Evensen <kristian.evensen@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      805083d1