Skip to content
  1. May 04, 2020
    • Yonatan Cohen's avatar
      IB/umad: Fix kernel crash while unloading ib_umad · edf3168e
      Yonatan Cohen authored
      commit 9ea04d0d upstream.
      
      When disassociating a device from umad we must ensure that the sysfs
      access is prevented before blocking the fops, otherwise assumptions in
      syfs don't hold:
      
      	    CPU0            	        CPU1
      	 ib_umad_kill_port()        ibdev_show()
      	    port->ib_dev = NULL
                                            dev_name(port->ib_dev)
      
      The prior patch made an error in moving the device_destroy(), it should
      have been split into device_del() (above) and put_device() (below). At
      this point we already have the split, so move the device_del() back to its
      original place.
      
        kernel stack
        PF: error_code(0x0000) - not-present page
        Oops: 0000 [#1] SMP DEBUG_PAGEALLOC PTI
        RIP: 0010:ibdev_show+0x18/0x50 [ib_umad]
        RSP: 0018:ffffc9000097fe40 EFLAGS: 00010282
        RAX: 0000000000000000 RBX: ffffffffa0441120 RCX: ffff8881df514000
        RDX: ffff8881df514000 RSI: ffffffffa0441120 RDI: ffff8881df1e8870
        RBP: ffffffff81caf000 R08: ffff8881df1e8870 R09: 0000000000000000
        R10: 0000000000001000 R11: 0000000000000003 R12: ffff88822f550b40
        R13: 0000000000000001 R14: ffffc9000097ff08 R15: ffff8882238bad58
        FS:  00007f1437ff3740(0000) GS:ffff888236940000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00000000000004e8 CR3: 00000001e0dfc001 CR4: 00000000001606e0
        Call Trace:
         dev_attr_show+0x15/0x50
         sysfs_kf_seq_show+0xb8/0x1a0
         seq_read+0x12d/0x350
         vfs_read+0x89/0x140
         ksys_read+0x55/0xd0
         do_syscall_64+0x55/0x1b0
         entry_SYSCALL_64_after_hwframe+0x44/0xa9:
      
      Fixes: cf7ad303
      
       ("IB/umad: Avoid destroying device while it is accessed")
      Link: https://lore.kernel.org/r/20200212072635.682689-9-leon@kernel.org
      Signed-off-by: default avatarYonatan Cohen <yonatanc@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Reviewed-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      edf3168e
    • Kaike Wan's avatar
      IB/rdmavt: Reset all QPs when the device is shut down · 6b674cfe
      Kaike Wan authored
      commit f92e4871 upstream.
      
      When the hfi1 device is shut down during a system reboot, it is possible
      that some QPs might have not not freed by ULPs. More requests could be
      post sent and a lingering timer could be triggered to schedule more packet
      sends, leading to a crash:
      
        BUG: unable to handle kernel NULL pointer dereference at 0000000000000102
        IP: [ffffffff810a65f2] __queue_work+0x32/0x3c0
        PGD 0
        Oops: 0000 1 SMP
        Modules linked in: nvmet_rdma(OE) nvmet(OE) nvme(OE) dm_round_robin nvme_rdma(OE) nvme_fabrics(OE) nvme_core(OE) pal_raw(POE) pal_pmt(POE) pal_cache(POE) pal_pile(POE) pal(POE) pal_compatible(OE) rpcrdma sunrpc ib_isert iscsi_target_mod target_core_mod ib_iser libiscsi scsi_transport_iscsi ib_ipoib rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm mlx4_ib sb_edac edac_core intel_powerclamp coretemp intel_rapl iosf_mbi kvm irqbypass crc32_pclmul ghash_clmulni_intel aesni_intel lrw gf128mul glue_helper ablk_helper cryptd iTCO_wdt iTCO_vendor_support mxm_wmi ipmi_ssif pcspkr ses enclosure joydev scsi_transport_sas i2c_i801 sg mei_me lpc_ich mei ioatdma shpchp ipmi_si ipmi_devintf ipmi_msghandler wmi acpi_power_meter acpi_pad dm_multipath hangcheck_timer ip_tables ext4 mbcache jbd2 mlx4_en
        sd_mod crc_t10dif crct10dif_generic mgag200 drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm drm mlx4_core crct10dif_pclmul crct10dif_common hfi1(OE) igb crc32c_intel rdmavt(OE) ahci ib_core libahci libata ptp megaraid_sas pps_core dca i2c_algo_bit i2c_core devlink dm_mirror dm_region_hash dm_log dm_mod
        CPU: 23 PID: 0 Comm: swapper/23 Tainted: P OE ------------ 3.10.0-693.el7.x86_64 #1
        Hardware name: Intel Corporation S2600CWR/S2600CWR, BIOS SE5C610.86B.01.01.0028.121720182203 12/17/2018
        task: ffff8808f4ec4f10 ti: ffff8808f4ed8000 task.ti: ffff8808f4ed8000
        RIP: 0010:[ffffffff810a65f2] [ffffffff810a65f2] __queue_work+0x32/0x3c0
        RSP: 0018:ffff88105df43d48 EFLAGS: 00010046
        RAX: 0000000000000086 RBX: 0000000000000086 RCX: 0000000000000000
        RDX: ffff880f74e758b0 RSI: 0000000000000000 RDI: 000000000000001f
        RBP: ffff88105df43d80 R08: ffff8808f3c583c8 R09: ffff8808f3c58000
        R10: 0000000000000002 R11: ffff88105df43da8 R12: ffff880f74e758b0
        R13: 000000000000001f R14: 0000000000000000 R15: ffff88105a300000
        FS: 0000000000000000(0000) GS:ffff88105df40000(0000) knlGS:0000000000000000
        CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000000102 CR3: 00000000019f2000 CR4: 00000000001407e0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
        Stack:
        ffff88105b6dd708 0000001f00000286 0000000000000086 ffff88105a300000
        ffff880f74e75800 0000000000000000 ffff88105a300000 ffff88105df43d98
        ffffffff810a6b85 ffff88105a301e80 ffff88105df43dc8 ffffffffc0224cde
        Call Trace:
        IRQ
      
        [ffffffff810a6b85] queue_work_on+0x45/0x50
        [ffffffffc0224cde] _hfi1_schedule_send+0x6e/0xc0 [hfi1]
        [ffffffffc0170570] ? get_map_page+0x60/0x60 [rdmavt]
        [ffffffffc0224d62] hfi1_schedule_send+0x32/0x70 [hfi1]
        [ffffffffc0170644] rvt_rc_timeout+0xd4/0x120 [rdmavt]
        [ffffffffc0170570] ? get_map_page+0x60/0x60 [rdmavt]
        [ffffffff81097316] call_timer_fn+0x36/0x110
        [ffffffffc0170570] ? get_map_page+0x60/0x60 [rdmavt]
        [ffffffff8109982d] run_timer_softirq+0x22d/0x310
        [ffffffff81090b3f] __do_softirq+0xef/0x280
        [ffffffff816b6a5c] call_softirq+0x1c/0x30
        [ffffffff8102d3c5] do_softirq+0x65/0xa0
        [ffffffff81090ec5] irq_exit+0x105/0x110
        [ffffffff816b76c2] smp_apic_timer_interrupt+0x42/0x50
        [ffffffff816b5c1d] apic_timer_interrupt+0x6d/0x80
        EOI
      
        [ffffffff81527a02] ? cpuidle_enter_state+0x52/0xc0
        [ffffffff81527b48] cpuidle_idle_call+0xd8/0x210
        [ffffffff81034fee] arch_cpu_idle+0xe/0x30
        [ffffffff810e7bca] cpu_startup_entry+0x14a/0x1c0
        [ffffffff81051af6] start_secondary+0x1b6/0x230
        Code: 89 e5 41 57 41 56 49 89 f6 41 55 41 89 fd 41 54 49 89 d4 53 48 83 ec 10 89 7d d4 9c 58 0f 1f 44 00 00 f6 c4 02 0f 85 be 02 00 00 41 f6 86 02 01 00 00 01 0f 85 58 02 00 00 49 c7 c7 28 19 01 00
        RIP [ffffffff810a65f2] __queue_work+0x32/0x3c0
        RSP ffff88105df43d48
        CR2: 0000000000000102
      
      The solution is to reset the QPs before the device resources are freed.
      This reset will change the QP state to prevent post sends and delete
      timers to prevent callbacks.
      
      Fixes: 0acb0cc7
      
       ("IB/rdmavt: Initialize and teardown of qpn table")
      Link: https://lore.kernel.org/r/20200210131040.87408.38161.stgit@awfm-01.aw.intel.com
      Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
      Signed-off-by: default avatarKaike Wan <kaike.wan@intel.com>
      Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      6b674cfe
    • Mike Marciniszyn's avatar
      IB/hfi1: Close window for pq and request coliding · 9f913895
      Mike Marciniszyn authored
      commit be863834 upstream.
      
      Cleaning up a pq can result in the following warning and panic:
      
        WARNING: CPU: 52 PID: 77418 at lib/list_debug.c:53 __list_del_entry+0x63/0xd0
        list_del corruption, ffff88cb2c6ac068->next is LIST_POISON1 (dead000000000100)
        Modules linked in: mmfs26(OE) mmfslinux(OE) tracedev(OE) 8021q garp mrp ib_isert iscsi_target_mod target_core_mod crc_t10dif crct10dif_generic opa_vnic rpcrdma ib_iser libiscsi scsi_transport_iscsi ib_ipoib(OE) bridge stp llc iTCO_wdt iTCO_vendor_support intel_powerclamp coretemp intel_rapl iosf_mbi kvm_intel kvm irqbypass crct10dif_pclmul crct10dif_common crc32_pclmul ghash_clmulni_intel ast aesni_intel ttm lrw gf128mul glue_helper ablk_helper drm_kms_helper cryptd syscopyarea sysfillrect sysimgblt fb_sys_fops drm pcspkr joydev lpc_ich mei_me drm_panel_orientation_quirks i2c_i801 mei wmi ipmi_si ipmi_devintf ipmi_msghandler nfit libnvdimm acpi_power_meter acpi_pad hfi1(OE) rdmavt(OE) rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm ib_core binfmt_misc numatools(OE) xpmem(OE) ip_tables
         nfsv3 nfs_acl nfs lockd grace sunrpc fscache igb ahci i2c_algo_bit libahci dca ptp libata pps_core crc32c_intel [last unloaded: i2c_algo_bit]
        CPU: 52 PID: 77418 Comm: pvbatch Kdump: loaded Tainted: G           OE  ------------   3.10.0-957.38.3.el7.x86_64 #1
        Hardware name: HPE.COM HPE SGI 8600-XA730i Gen10/X11DPT-SB-SG007, BIOS SBED1229 01/22/2019
        Call Trace:
         [<ffffffff90365ac0>] dump_stack+0x19/0x1b
         [<ffffffff8fc98b78>] __warn+0xd8/0x100
         [<ffffffff8fc98bff>] warn_slowpath_fmt+0x5f/0x80
         [<ffffffff8ff970c3>] __list_del_entry+0x63/0xd0
         [<ffffffff8ff9713d>] list_del+0xd/0x30
         [<ffffffff8fddda70>] kmem_cache_destroy+0x50/0x110
         [<ffffffffc0328130>] hfi1_user_sdma_free_queues+0xf0/0x200 [hfi1]
         [<ffffffffc02e2350>] hfi1_file_close+0x70/0x1e0 [hfi1]
         [<ffffffff8fe4519c>] __fput+0xec/0x260
         [<ffffffff8fe453fe>] ____fput+0xe/0x10
         [<ffffffff8fcbfd1b>] task_work_run+0xbb/0xe0
         [<ffffffff8fc2bc65>] do_notify_resume+0xa5/0xc0
         [<ffffffff90379134>] int_signal+0x12/0x17
        BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
        IP: [<ffffffff8fe1f93e>] kmem_cache_close+0x7e/0x300
        PGD 2cdab19067 PUD 2f7bfdb067 PMD 0
        Oops: 0000 [#1] SMP
        Modules linked in: mmfs26(OE) mmfslinux(OE) tracedev(OE) 8021q garp mrp ib_isert iscsi_target_mod target_core_mod crc_t10dif crct10dif_generic opa_vnic rpcrdma ib_iser libiscsi scsi_transport_iscsi ib_ipoib(OE) bridge stp llc iTCO_wdt iTCO_vendor_support intel_powerclamp coretemp intel_rapl iosf_mbi kvm_intel kvm irqbypass crct10dif_pclmul crct10dif_common crc32_pclmul ghash_clmulni_intel ast aesni_intel ttm lrw gf128mul glue_helper ablk_helper drm_kms_helper cryptd syscopyarea sysfillrect sysimgblt fb_sys_fops drm pcspkr joydev lpc_ich mei_me drm_panel_orientation_quirks i2c_i801 mei wmi ipmi_si ipmi_devintf ipmi_msghandler nfit libnvdimm acpi_power_meter acpi_pad hfi1(OE) rdmavt(OE) rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm ib_core binfmt_misc numatools(OE) xpmem(OE) ip_tables
         nfsv3 nfs_acl nfs lockd grace sunrpc fscache igb ahci i2c_algo_bit libahci dca ptp libata pps_core crc32c_intel [last unloaded: i2c_algo_bit]
        CPU: 52 PID: 77418 Comm: pvbatch Kdump: loaded Tainted: G        W  OE  ------------   3.10.0-957.38.3.el7.x86_64 #1
        Hardware name: HPE.COM HPE SGI 8600-XA730i Gen10/X11DPT-SB-SG007, BIOS SBED1229 01/22/2019
        task: ffff88cc26db9040 ti: ffff88b5393a8000 task.ti: ffff88b5393a8000
        RIP: 0010:[<ffffffff8fe1f93e>]  [<ffffffff8fe1f93e>] kmem_cache_close+0x7e/0x300
        RSP: 0018:ffff88b5393abd60  EFLAGS: 00010287
        RAX: 0000000000000000 RBX: ffff88cb2c6ac000 RCX: 0000000000000003
        RDX: 0000000000000400 RSI: 0000000000000400 RDI: ffffffff9095b800
        RBP: ffff88b5393abdb0 R08: ffffffff9095b808 R09: ffffffff8ff77c19
        R10: ffff88b73ce1f160 R11: ffffddecddde9800 R12: ffff88cb2c6ac000
        R13: 000000000000000c R14: ffff88cf3fdca780 R15: 0000000000000000
        FS:  00002aaaaab52500(0000) GS:ffff88b73ce00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000000010 CR3: 0000002d27664000 CR4: 00000000007607e0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        PKRU: 55555554
        Call Trace:
         [<ffffffff8fe20d44>] __kmem_cache_shutdown+0x14/0x80
         [<ffffffff8fddda78>] kmem_cache_destroy+0x58/0x110
         [<ffffffffc0328130>] hfi1_user_sdma_free_queues+0xf0/0x200 [hfi1]
         [<ffffffffc02e2350>] hfi1_file_close+0x70/0x1e0 [hfi1]
         [<ffffffff8fe4519c>] __fput+0xec/0x260
         [<ffffffff8fe453fe>] ____fput+0xe/0x10
         [<ffffffff8fcbfd1b>] task_work_run+0xbb/0xe0
         [<ffffffff8fc2bc65>] do_notify_resume+0xa5/0xc0
         [<ffffffff90379134>] int_signal+0x12/0x17
        Code: 00 00 ba 00 04 00 00 0f 4f c2 3d 00 04 00 00 89 45 bc 0f 84 e7 01 00 00 48 63 45 bc 49 8d 04 c4 48 89 45 b0 48 8b 80 c8 00 00 00 <48> 8b 78 10 48 89 45 c0 48 83 c0 10 48 89 45 d0 48 8b 17 48 39
        RIP  [<ffffffff8fe1f93e>] kmem_cache_close+0x7e/0x300
         RSP <ffff88b5393abd60>
        CR2: 0000000000000010
      
      The panic is the result of slab entries being freed during the destruction
      of the pq slab.
      
      The code attempts to quiesce the pq, but looking for n_req == 0 doesn't
      account for new requests.
      
      Fix the issue by using SRCU to get a pq pointer and adjust the pq free
      logic to NULL the fd pq pointer prior to the quiesce.
      
      Fixes: e87473bc
      
       ("IB/hfi1: Only set fd pointer when base context is completely initialized")
      Link: https://lore.kernel.org/r/20200210131033.87408.81174.stgit@awfm-01.aw.intel.com
      Reviewed-by: default avatarKaike Wan <kaike.wan@intel.com>
      Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
      Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      9f913895
    • Kaike Wan's avatar
      IB/hfi1: Acquire lock to release TID entries when user file is closed · 59b2fdd7
      Kaike Wan authored
      commit a70ed0f2 upstream.
      
      Each user context is allocated a certain number of RcvArray (TID)
      entries and these entries are managed through TID groups. These groups
      are put into one of three lists in each user context: tid_group_list,
      tid_used_list, and tid_full_list, depending on the number of used TID
      entries within each group. When TID packets are expected, one or more
      TID groups will be allocated. After the packets are received, the TID
      groups will be freed. Since multiple user threads may access the TID
      groups simultaneously, a mutex exp_mutex is used to synchronize the
      access. However, when the user file is closed, it tries to release
      all TID groups without acquiring the mutex first, which risks a race
      condition with another thread that may be releasing its TID groups,
      leading to data corruption.
      
      This patch addresses the issue by acquiring the mutex first before
      releasing the TID groups when the file is closed.
      
      Fixes: 3abb33ac
      
       ("staging/hfi1: Add TID cache receive init and free funcs")
      Link: https://lore.kernel.org/r/20200210131026.87408.86853.stgit@awfm-01.aw.intel.com
      Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
      Signed-off-by: default avatarKaike Wan <kaike.wan@intel.com>
      Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      59b2fdd7
    • Yi Zhang's avatar
      nvme: fix the parameter order for nvme_get_log in nvme_get_fw_slot_info · 2c368396
      Yi Zhang authored
      commit f25372ff upstream.
      
      nvme fw-activate operation will get bellow warning log,
      fix it by update the parameter order
      
      [  113.231513] nvme nvme0: Get FW SLOT INFO log error
      
      Fixes: 0e98719b
      
       ("nvme: simplify the API for getting log pages")
      Reported-by: default avatarSujith Pandel <sujith_pandel@dell.com>
      Reviewed-by: default avatarDavid Milburn <dmilburn@redhat.com>
      Signed-off-by: default avatarYi Zhang <yi.zhang@redhat.com>
      Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      2c368396
    • Daniel Vetter's avatar
      drm/vgem: Close use-after-free race in vgem_gem_create · 2cdb2204
      Daniel Vetter authored
      commit 4b848f20
      
       upstream.
      
      There's two references floating around here (for the object reference,
      not the handle_count reference, that's a different thing):
      
      - The temporary reference held by vgem_gem_create, acquired by
        creating the object and released by calling
        drm_gem_object_put_unlocked.
      
      - The reference held by the object handle, created by
        drm_gem_handle_create. This one generally outlives the function,
        except if a 2nd thread races with a GEM_CLOSE ioctl call.
      
      So usually everything is correct, except in that race case, where the
      access to gem_object->size could be looking at freed data already.
      Which again isn't a real problem (userspace shot its feet off already
      with the race, we could return garbage), but maybe someone can exploit
      this as an information leak.
      
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Reported-by: default avatar <syzbot+0dc4444774d419e916c8@syzkaller.appspotmail.com>
      Cc: stable@vger.kernel.org
      Cc: Emil Velikov <emil.velikov@collabora.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Sean Paul <seanpaul@chromium.org>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Eric Anholt <eric@anholt.net>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Rob Clark <robdclark@chromium.org>
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200202132133.1891846-1-daniel.vetter@ffwll.ch
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      2cdb2204
    • Christian Borntraeger's avatar
      s390/uv: Fix handling of length extensions · 8fdf83c1
      Christian Borntraeger authored
      commit 27dc0700
      
       upstream.
      
      The query parameter block might contain additional information and can
      be extended in the future. If the size of the block does not suffice we
      get an error code of rc=0x100.  The buffer will contain all information
      up to the specified size and the hypervisor/guest simply do not need the
      additional information as they do not know about the new data.  That
      means that we can (and must) accept rc=0x100 as success.
      
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      Fixes: 5abb9351
      
       ("s390/uv: introduce guest side ultravisor code")
      Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      8fdf83c1
    • Kim Phillips's avatar
      perf/x86/amd: Add missing L2 misses event spec to AMD Family 17h's event map · 38c882c2
      Kim Phillips authored
      commit 25d38728 upstream.
      
      Commit 3fe3331b ("perf/x86/amd: Add event map for AMD Family 17h"),
      claimed L2 misses were unsupported, due to them not being found in its
      referenced documentation, whose link has now moved [1].
      
      That old documentation listed PMCx064 unit mask bit 3 as:
      
          "LsRdBlkC: LS Read Block C S L X Change to X Miss."
      
      and bit 0 as:
      
          "IcFillMiss: IC Fill Miss"
      
      We now have new public documentation [2] with improved descriptions, that
      clearly indicate what events those unit mask bits represent:
      
      Bit 3 now clearly states:
      
          "LsRdBlkC: Data Cache Req Miss in L2 (all types)"
      
      and bit 0 is:
      
          "IcFillMiss: Instruction Cache Req Miss in L2."
      
      So we can now add support for L2 misses in perf's genericised events as
      PMCx064 with both the above unit masks.
      
      [1] The commit's original documentation reference, "Processor Programming
          Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors",
          originally available here:
      
              https://www.amd.com/system/files/TechDocs/54945_PPR_Family_17h_Models_00h-0Fh.pdf
      
          is now available here:
      
              https://developer.amd.com/wordpress/media/2017/11/54945_PPR_Family_17h_Models_00h-0Fh.pdf
      
      [2] "Processor Programming Reference (PPR) for Family 17h Model 31h,
          Revision B0 Processors", available here:
      
      	https://developer.amd.com/wp-content/resources/55803_0.54-PUB.pdf
      
      Fixes: 3fe3331b
      
       ("perf/x86/amd: Add event map for AMD Family 17h")
      Reported-by: default avatarBabu Moger <babu.moger@amd.com>
      Signed-off-by: default avatarKim Phillips <kim.phillips@amd.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Tested-by: default avatarBabu Moger <babu.moger@amd.com>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200121171232.28839-1-kim.phillips@amd.com
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      38c882c2
    • Sean Christopherson's avatar
      KVM: nVMX: Use correct root level for nested EPT shadow page tables · b82147ac
      Sean Christopherson authored
      commit 148d735e upstream.
      
      Hardcode the EPT page-walk level for L2 to be 4 levels, as KVM's MMU
      currently also hardcodes the page walk level for nested EPT to be 4
      levels.  The L2 guest is all but guaranteed to soft hang on its first
      instruction when L1 is using EPT, as KVM will construct 4-level page
      tables and then tell hardware to use 5-level page tables.
      
      Fixes: 855feb67
      
       ("KVM: MMU: Add 5 level EPT & Shadow page table support.")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      b82147ac
    • Ronnie Sahlberg's avatar
      cifs: make sure we do not overflow the max EA buffer size · 2d747317
      Ronnie Sahlberg authored
      commit 85db6b7a
      
       upstream.
      
      RHBZ: 1752437
      
      Before we add a new EA we should check that this will not overflow
      the maximum buffer we have available to read the EAs back.
      Otherwise we can get into a situation where the EAs are so big that
      we can not read them back to the client and thus we can not list EAs
      anymore or delete them.
      
      Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      2d747317
    • Chuck Lever's avatar
      xprtrdma: Fix DMA scatter-gather list mapping imbalance · 794c0df5
      Chuck Lever authored
      commit ca1c6713 upstream.
      
      The @nents value that was passed to ib_dma_map_sg() has to be passed
      to the matching ib_dma_unmap_sg() call. If ib_dma_map_sg() choses to
      concatenate sg entries, it will return a different nents value than
      it was passed.
      
      The bug was exposed by recent changes to the AMD IOMMU driver, which
      enabled sg entry concatenation.
      
      Looking all the way back to commit 4143f34e
      
       ("xprtrdma: Port to
      new memory registration API") and reviewing other kernel ULPs, it's
      not clear that the frwr_map() logic was ever correct for this case.
      
      Reported-by: default avatarAndre Tomt <andre@tomt.net>
      Suggested-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      794c0df5
    • Paul Thomas's avatar
      gpio: xilinx: Fix bug where the wrong GPIO register is written to · 0861e61e
      Paul Thomas authored
      commit c3afa804
      
       upstream.
      
      Care is taken with "index", however with the current version
      the actual xgpio_writereg is using index for data but
      xgpio_regoffset(chip, i) for the offset. And since i is already
      incremented it is incorrect. This patch fixes it so that index
      is used for the offset too.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaul Thomas <pthomas8589@gmail.com>
      Link: https://lore.kernel.org/r/20200125221410.8022-1-pthomas8589@gmail.com
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      0861e61e
    • Krzysztof Kozlowski's avatar
      ARM: npcm: Bring back GPIOLIB support · 308f0c73
      Krzysztof Kozlowski authored
      commit e383e871 upstream.
      
      The CONFIG_ARCH_REQUIRE_GPIOLIB is gone since commit 65053e1a
      ("gpio: delete ARCH_[WANTS_OPTIONAL|REQUIRE]_GPIOLIB") and all platforms
      should explicitly select GPIOLIB to have it.
      
      Link: https://lore.kernel.org/r/20200130195525.4525-1-krzk@kernel.org
      Cc: <stable@vger.kernel.org>
      Fixes: 65053e1a
      
       ("gpio: delete ARCH_[WANTS_OPTIONAL|REQUIRE]_GPIOLIB")
      Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      308f0c73
    • David Sterba's avatar
      btrfs: log message when rw remount is attempted with unclean tree-log · 12c832db
      David Sterba authored
      commit 10a3a3ed
      
       upstream.
      
      A remount to a read-write filesystem is not safe when there's tree-log
      to be replayed. Files that could be opened until now might be affected
      by the changes in the tree-log.
      
      A regular mount is needed to replay the log so the filesystem presents
      the consistent view with the pending changes included.
      
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      12c832db
    • David Sterba's avatar
      btrfs: print message when tree-log replay starts · d7272fc9
      David Sterba authored
      commit e8294f2f
      
       upstream.
      
      There's no logged information about tree-log replay although this is
      something that points to previous unclean unmount. Other filesystems
      report that as well.
      
      Suggested-by: default avatarChris Murphy <lists@colorremedies.com>
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      d7272fc9
    • Wenwen Wang's avatar
      btrfs: ref-verify: fix memory leaks · 9050721a
      Wenwen Wang authored
      commit f311ade3
      
       upstream.
      
      In btrfs_ref_tree_mod(), 'ref' and 'ra' are allocated through kzalloc() and
      kmalloc(), respectively. In the following code, if an error occurs, the
      execution will be redirected to 'out' or 'out_unlock' and the function will
      be exited. However, on some of the paths, 'ref' and 'ra' are not
      deallocated, leading to memory leaks. For example, if 'action' is
      BTRFS_ADD_DELAYED_EXTENT, add_block_entry() will be invoked. If the return
      value indicates an error, the execution will be redirected to 'out'. But,
      'ref' is not deallocated on this path, causing a memory leak.
      
      To fix the above issues, deallocate both 'ref' and 'ra' before exiting from
      the function when an error is encountered.
      
      CC: stable@vger.kernel.org # 4.15+
      Signed-off-by: default avatarWenwen Wang <wenwen@cs.uga.edu>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      9050721a
    • Filipe Manana's avatar
      Btrfs: fix race between using extent maps and merging them · 4c6832f4
      Filipe Manana authored
      commit ac05ca91
      
       upstream.
      
      We have a few cases where we allow an extent map that is in an extent map
      tree to be merged with other extents in the tree. Such cases include the
      unpinning of an extent after the respective ordered extent completed or
      after logging an extent during a fast fsync. This can lead to subtle and
      dangerous problems because when doing the merge some other task might be
      using the same extent map and as consequence see an inconsistent state of
      the extent map - for example sees the new length but has seen the old start
      offset.
      
      With luck this triggers a BUG_ON(), and not some silent bug, such as the
      following one in __do_readpage():
      
        $ cat -n fs/btrfs/extent_io.c
        3061  static int __do_readpage(struct extent_io_tree *tree,
        3062                           struct page *page,
        (...)
        3127                  em = __get_extent_map(inode, page, pg_offset, cur,
        3128                                        end - cur + 1, get_extent, em_cached);
        3129                  if (IS_ERR_OR_NULL(em)) {
        3130                          SetPageError(page);
        3131                          unlock_extent(tree, cur, end);
        3132                          break;
        3133                  }
        3134                  extent_offset = cur - em->start;
        3135                  BUG_ON(extent_map_end(em) <= cur);
        (...)
      
      Consider the following example scenario, where we end up hitting the
      BUG_ON() in __do_readpage().
      
      We have an inode with a size of 8KiB and 2 extent maps:
      
        extent A: file offset 0, length 4KiB, disk_bytenr = X, persisted on disk by
                  a previous transaction
      
        extent B: file offset 4KiB, length 4KiB, disk_bytenr = X + 4KiB, not yet
                  persisted but writeback started for it already. The extent map
      	    is pinned since there's writeback and an ordered extent in
      	    progress, so it can not be merged with extent map A yet
      
      The following sequence of steps leads to the BUG_ON():
      
      1) The ordered extent for extent B completes, the respective page gets its
         writeback bit cleared and the extent map is unpinned, at that point it
         is not yet merged with extent map A because it's in the list of modified
         extents;
      
      2) Due to memory pressure, or some other reason, the MM subsystem releases
         the page corresponding to extent B - btrfs_releasepage() is called and
         returns 1, meaning the page can be released as it's not dirty, not under
         writeback anymore and the extent range is not locked in the inode's
         iotree. However the extent map is not released, either because we are
         not in a context that allows memory allocations to block or because the
         inode's size is smaller than 16MiB - in this case our inode has a size
         of 8KiB;
      
      3) Task B needs to read extent B and ends up __do_readpage() through the
         btrfs_readpage() callback. At __do_readpage() it gets a reference to
         extent map B;
      
      4) Task A, doing a fast fsync, calls clear_em_loggin() against extent map B
         while holding the write lock on the inode's extent map tree - this
         results in try_merge_map() being called and since it's possible to merge
         extent map B with extent map A now (the extent map B was removed from
         the list of modified extents), the merging begins - it sets extent map
         B's start offset to 0 (was 4KiB), but before it increments the map's
         length to 8KiB (4kb + 4KiB), task A is at:
      
         BUG_ON(extent_map_end(em) <= cur);
      
         The call to extent_map_end() sees the extent map has a start of 0
         and a length still at 4KiB, so it returns 4KiB and 'cur' is 4KiB, so
         the BUG_ON() is triggered.
      
      So it's dangerous to modify an extent map that is in the tree, because some
      other task might have got a reference to it before and still using it, and
      needs to see a consistent map while using it. Generally this is very rare
      since most paths that lookup and use extent maps also have the file range
      locked in the inode's iotree. The fsync path is pretty much the only
      exception where we don't do it to avoid serialization with concurrent
      reads.
      
      Fix this by not allowing an extent map do be merged if if it's being used
      by tasks other then the one attempting to merge the extent map (when the
      reference count of the extent map is greater than 2).
      
      Reported-by: default avatarryusuke1925 <st13s20@gm.ibaraki-ct.ac.jp>
      Reported-by: default avatarKoki Mitani <koki.mitani.xg@hco.ntt.co.jp>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=206211
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      4c6832f4
    • Theodore Ts'o's avatar
      ext4: improve explanation of a mount failure caused by a misconfigured kernel · cee2504c
      Theodore Ts'o authored
      commit d65d87a0 upstream.
      
      If CONFIG_QFMT_V2 is not enabled, but CONFIG_QUOTA is enabled, when a
      user tries to mount a file system with the quota or project quota
      enabled, the kernel will emit a very confusing messsage:
      
          EXT4-fs warning (device vdc): ext4_enable_quotas:5914: Failed to enable quota tracking (type=0, err=-3). Please run e2fsck to fix.
          EXT4-fs (vdc): mount failed
      
      We will now report an explanatory message indicating which kernel
      configuration options have to be enabled, to avoid customer/sysadmin
      confusion.
      
      Link: https://lore.kernel.org/r/20200215012738.565735-1-tytso@mit.edu
      Google-Bug-Id: 149093531
      Fixes: 7c319d32
      
       ("ext4: make quota as first class supported feature")
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      cee2504c
    • Jan Kara's avatar
      ext4: fix checksum errors with indexed dirs · f82c2407
      Jan Kara authored
      commit 48a34311 upstream.
      
      DIR_INDEX has been introduced as a compat ext4 feature. That means that
      even kernels / tools that don't understand the feature may modify the
      filesystem. This works because for kernels not understanding indexed dir
      format, internal htree nodes appear just as empty directory entries.
      Index dir aware kernels then check the htree structure is still
      consistent before using the data. This all worked reasonably well until
      metadata checksums were introduced. The problem is that these
      effectively made DIR_INDEX only ro-compatible because internal htree
      nodes store checksums in a different place than normal directory blocks.
      Thus any modification ignorant to DIR_INDEX (or just clearing
      EXT4_INDEX_FL from the inode) will effectively cause checksum mismatch
      and trigger kernel errors. So we have to be more careful when dealing
      with indexed directories on filesystems with checksumming enabled.
      
      1) We just disallow loading any directory inodes with EXT4_INDEX_FL when
      DIR_INDEX is not enabled. This is harsh but it should be very rare (it
      means someone disabled DIR_INDEX on existing filesystem and didn't run
      e2fsck), e2fsck can fix the problem, and we don't want to answer the
      difficult question: "Should we rather corrupt the directory more or
      should we ignore that DIR_INDEX feature is not set?"
      
      2) When we find out htree structure is corrupted (but the filesystem and
      the directory should in support htrees), we continue just ignoring htree
      information for reading but we refuse to add new entries to the
      directory to avoid corrupting it more.
      
      Link: https://lore.kernel.org/r/20200210144316.22081-1-jack@suse.cz
      Fixes: dbe89444
      
       ("ext4: Calculate and verify checksums for htree nodes")
      Reviewed-by: default avatarAndreas Dilger <adilger@dilger.ca>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      f82c2407
    • Andreas Dilger's avatar
      ext4: don't assume that mmp_nodename/bdevname have NUL · 12ae3582
      Andreas Dilger authored
      commit 14c9ca05
      
       upstream.
      
      Don't assume that the mmp_nodename and mmp_bdevname strings are NUL
      terminated, since they are filled in by snprintf(), which is not
      guaranteed to do so.
      
      Link: https://lore.kernel.org/r/1580076215-1048-1-git-send-email-adilger@dilger.ca
      Signed-off-by: default avatarAndreas Dilger <adilger@dilger.ca>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      12ae3582
    • Alexander Tsoy's avatar
      ALSA: usb-audio: Add clock validity quirk for Denon MC7000/MCX8000 · c2f1f2f9
      Alexander Tsoy authored
      commit 9f35a312
      
       upstream.
      
      It should be safe to ignore clock validity check result if the following
      conditions are met:
       - only one single sample rate is supported;
       - the terminal is directly connected to the clock source;
       - the clock type is internal.
      
      This is to deal with some Denon DJ controllers that always reports that
      clock is invalid.
      
      Tested-by: default avatarTobias Oszlanyi <toszlanyi@yahoo.de>
      Signed-off-by: default avatarAlexander Tsoy <alexander@tsoy.me>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200212235450.697348-1-alexander@tsoy.me
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      c2f1f2f9
    • Saurav Girepunje's avatar
      ALSA: usb-audio: sound: usb: usb true/false for bool return type · 03bb436e
      Saurav Girepunje authored
      commit 1d4961d9
      
       upstream.
      
      Use true/false for bool type return in uac_clock_source_is_valid().
      
      Signed-off-by: default avatarSaurav Girepunje <saurav.girepunje@gmail.com>
      Link: https://lore.kernel.org/r/20191029175200.GA7320@saurav
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      03bb436e
    • Arvind Sankar's avatar
      ALSA: usb-audio: Apply sample rate quirk for Audioengine D1 · 6a541aee
      Arvind Sankar authored
      commit 93f9d1a4
      
       upstream.
      
      The Audioengine D1 (0x2912:0x30c8) does support reading the sample rate,
      but it returns the rate in byte-reversed order.
      
      When setting sampling rate, the driver produces these warning messages:
      [168840.944226] usb 3-2.2: current rate 4500480 is different from the runtime rate 44100
      [168854.930414] usb 3-2.2: current rate 8436480 is different from the runtime rate 48000
      [168905.185825] usb 3-2.1.2: current rate 30465 is different from the runtime rate 96000
      
      As can be seen from the hexadecimal conversion, the current rate read
      back is byte-reversed from the rate that was set.
      
      44100 == 0x00ac44, 4500480 == 0x44ac00
      48000 == 0x00bb80, 8436480 == 0x80bb00
      96000 == 0x017700,   30465 == 0x007701
      
      Rather than implementing a new quirk to reverse the order, just skip
      checking the rate to avoid spamming the log.
      
      Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200211162235.1639889-1-nivedita@alum.mit.edu
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      6a541aee
    • Takashi Iwai's avatar
      ALSA: hda/realtek - Fix silent output on MSI-GL73 · 7a89d4b9
      Takashi Iwai authored
      commit 7dafba37
      
       upstream.
      
      MSI-GL73 laptop with ALC1220 codec requires a similar workaround for
      Clevo laptops to enforce the DAC/mixer connection path.  Set up a
      quirk entry for that.
      
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204159
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200212081047.27727-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      7a89d4b9
    • Kailang Yang's avatar
      ALSA: hda/realtek - Add more codec supported Headset Button · 8bf5fabf
      Kailang Yang authored
      commit 2b3b6497
      
       upstream.
      
      Add supported Headset Button for ALC215/ALC285/ALC289.
      
      Signed-off-by: default avatarKailang Yang <kailang@realtek.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/948f70b4488f4cc2b629a39ce4e4be33@realtek.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      8bf5fabf
    • Benjamin Tissoires's avatar
      Input: synaptics - remove the LEN0049 dmi id from topbuttonpad list · 7acb5bec
      Benjamin Tissoires authored
      commit 5179a9df
      
       upstream.
      
      The Yoga 11e is using LEN0049, but it doesn't have a trackstick.
      
      Thus, there is no need to create a software top buttons row.
      
      However, it seems that the device works under SMBus, so keep it as part
      of the smbus_pnp_ids.
      
      Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200115013023.9710-1-benjamin.tissoires@redhat.com
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      7acb5bec
    • Gaurav Agrawal's avatar
      Input: synaptics - enable SMBus on ThinkPad L470 · 212e0a2d
      Gaurav Agrawal authored
      commit b8a3d819
      
       upstream.
      
      Add touchpad LEN2044 to the list, as it is capable of working with
      psmouse.synaptics_intertouch=1
      
      Signed-off-by: default avatarGaurav Agrawal <agrawalgaurav@gnome.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/CADdtggVzVJq5gGNmFhKSz2MBwjTpdN5YVOdr4D3Hkkv=KZRc9g@mail.gmail.com
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      212e0a2d
    • Lyude Paul's avatar
      Input: synaptics - switch T470s to RMI4 by default · c8b3f729
      Lyude Paul authored
      commit bf502391
      
       upstream.
      
      This supports RMI4 and everything seems to work, including the touchpad
      buttons. So, let's enable this by default.
      
      Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200204194322.112638-1-lyude@redhat.com
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      c8b3f729
    • Stephen Smalley's avatar
      selinux: fall back to ref-walk if audit is required · 651fda4c
      Stephen Smalley authored
      commit 0188d5c0 upstream.
      
      commit bda0be7a ("security: make inode_follow_link RCU-walk aware")
      passed down the rcu flag to the SELinux AVC, but failed to adjust the
      test in slow_avc_audit() to also return -ECHILD on LSM_AUDIT_DATA_DENTRY.
      Previously, we only returned -ECHILD if generating an audit record with
      LSM_AUDIT_DATA_INODE since this was only relevant from inode_permission.
      Move the handling of MAY_NOT_BLOCK to avc_audit() and its inlined
      equivalent in selinux_inode_permission() immediately after we determine
      that audit is required, and always fall back to ref-walk in this case.
      
      Fixes: bda0be7a
      
       ("security: make inode_follow_link RCU-walk aware")
      Reported-by: default avatarWill Deacon <will@kernel.org>
      Suggested-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      651fda4c
    • Qing Xu's avatar
      mwifiex: Fix possible buffer overflows in mwifiex_cmd_append_vsie_tlv() · 8c3c00ca
      Qing Xu authored
      commit b70261a2
      
       upstream.
      
      mwifiex_cmd_append_vsie_tlv() calls memcpy() without checking
      the destination size may trigger a buffer overflower,
      which a local user could use to cause denial of service
      or the execution of arbitrary code.
      Fix it by putting the length check before calling memcpy().
      
      Signed-off-by: default avatarQing Xu <m1s5p6688@gmail.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      8c3c00ca
    • Qing Xu's avatar
      mwifiex: Fix possible buffer overflows in mwifiex_ret_wmm_get_status() · a99f8f9b
      Qing Xu authored
      commit 3a9b153c
      
       upstream.
      
      mwifiex_ret_wmm_get_status() calls memcpy() without checking the
      destination size.Since the source is given from remote AP which
      contains illegal wmm elements , this may trigger a heap buffer
      overflow.
      Fix it by putting the length check before calling memcpy().
      
      Signed-off-by: default avatarQing Xu <m1s5p6688@gmail.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      a99f8f9b
    • Jerome Brunet's avatar
      clk: meson: g12a: fix missing uart2 in regmap table · 9d008125
      Jerome Brunet authored
      commit b1b3f062 upstream.
      
      UART2 peripheral is missing from the regmap fixup table of the g12a family
      clock controller. As it is, any access to this clock would Oops, which is
      not great.
      
      Add the clock to the table to fix the problem.
      
      Fixes: 085a4ea9
      
       ("clk: meson: g12a: add peripheral clock controller")
      Reported-by: default avatarDmitry Shmidt <dimitrysh@google.com>
      Tested-by: default avatarDmitry Shmidt <dimitrysh@google.com>
      Acked-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
      Tested-by: default avatarKevin Hilman <khilman@baylibre.com>
      Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      9d008125
    • Bartosz Golaszewski's avatar
      mfd: max77650: Select REGMAP_IRQ in Kconfig · 9f447bca
      Bartosz Golaszewski authored
      commit cb7a374a upstream.
      
      MAX77650 MFD driver uses regmap_irq API but doesn't select the required
      REGMAP_IRQ option in Kconfig. This can cause the following build error
      if regmap irq is not enabled implicitly by someone else:
      
          ld: drivers/mfd/max77650.o: in function `max77650_i2c_probe':
          max77650.c:(.text+0xcb): undefined reference to `devm_regmap_add_irq_chip'
          ld: max77650.c:(.text+0xdb): undefined reference to `regmap_irq_get_domain'
          make: *** [Makefile:1079: vmlinux] Error 1
      
      Fix it by adding the missing option.
      
      Fixes: d0f60334
      
       ("mfd: Add new driver for MAX77650 PMIC")
      Reported-by: default avatarPaul Gazzillo <paul@pgazz.com>
      Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      9f447bca
    • Ben Whitten's avatar
      regmap: fix writes to non incrementing registers · 39d4ade8
      Ben Whitten authored
      commit 2e31aab0 upstream.
      
      When checking if a register block is writable we must ensure that the
      block does not start with or contain a non incrementing register.
      
      Fixes: 8b9f9d4d
      
       ("regmap: verify if register is writeable before writing operations")
      Signed-off-by: default avatarBen Whitten <ben.whitten@gmail.com>
      Link: https://lore.kernel.org/r/20200118205625.14532-1-ben.whitten@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      39d4ade8
    • Geert Uytterhoeven's avatar
      pinctrl: sh-pfc: r8a7778: Fix duplicate SDSELF_B and SD1_CLK_B · a488a2a7
      Geert Uytterhoeven authored
      commit 805f6357 upstream.
      
      The FN_SDSELF_B and FN_SD1_CLK_B enum IDs are used twice, which means
      one set of users must be wrong.  Replace them by the correct enum IDs.
      
      Fixes: 87f8c988
      
       ("sh-pfc: Add r8a7778 pinmux support")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Link: https://lore.kernel.org/r/20191218194812.12741-2-geert+renesas@glider.be
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      a488a2a7
    • Geert Uytterhoeven's avatar
      pinctrl: sh-pfc: r8a77965: Fix DU_DOTCLKIN3 drive/bias control · 65ee453b
      Geert Uytterhoeven authored
      commit a34cd9df upstream.
      
      R-Car Gen3 Hardware Manual Errata for Rev. 2.00 of October 24, 2019
      changed the configuration bits for drive and bias control for the
      DU_DOTCLKIN3 pin on R-Car M3-N, to match the same pin on R-Car H3.
      Update the driver to reflect this.
      
      After this, the handling of drive and bias control for the various
      DU_DOTCLKINx pins is consistent across all of the R-Car H3, M3-W,
      M3-W+, and M3-N SoCs.
      
      Fixes: 86c045c2
      
       ("pinctrl: sh-pfc: r8a77965: Replace DU_DOTCLKIN2 by DU_DOTCLKIN3")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Link: https://lore.kernel.org/r/20191113101653.28428-1-geert+renesas@glider.be
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      65ee453b
    • Stephen Smalley's avatar
      selinux: fix regression introduced by move_mount(2) syscall · 4808a89b
      Stephen Smalley authored
      commit 98aa0034 upstream.
      
      commit 2db154b3 ("vfs: syscall: Add move_mount(2) to move mounts around")
      introduced a new move_mount(2) system call and a corresponding new LSM
      security_move_mount hook but did not implement this hook for any existing
      LSM.  This creates a regression for SELinux with respect to consistent
      checking of mounts; the existing selinux_mount hook checks mounton
      permission to the mount point path.  Provide a SELinux hook
      implementation for move_mount that applies this same check for
      consistency.  In the future we may wish to add a new move_mount
      filesystem permission and check as well, but this addresses
      the immediate regression.
      
      Fixes: 2db154b3
      
       ("vfs: syscall: Add move_mount(2) to move mounts around")
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      Reviewed-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      4808a89b
    • Stephen Smalley's avatar
      selinux: revert "stop passing MAY_NOT_BLOCK to the AVC upon follow_link" · c994d8d4
      Stephen Smalley authored
      commit 1a37079c upstream.
      
      This reverts commit e46e01ee ("selinux: stop passing MAY_NOT_BLOCK
      to the AVC upon follow_link"). The correct fix is to instead fall
      back to ref-walk if audit is required irrespective of the specific
      audit data type.  This is done in the next commit.
      
      Fixes: e46e01ee
      
       ("selinux: stop passing MAY_NOT_BLOCK to the AVC upon follow_link")
      Reported-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      c994d8d4
    • Gustavo A. R. Silva's avatar
      media: i2c: adv748x: Fix unsafe macros · b74db57e
      Gustavo A. R. Silva authored
      commit 0d962e06 upstream.
      
      Enclose multiple macro parameters in parentheses in order to
      make such macros safer and fix the Clang warning below:
      
      drivers/media/i2c/adv748x/adv748x-afe.c:452:12: warning: operator '?:'
      has lower precedence than '|'; '|' will be evaluated first
      [-Wbitwise-conditional-parentheses]
      
      ret = sdp_clrset(state, ADV748X_SDP_FRP, ADV748X_SDP_FRP_MASK, enable
      ? ctrl->val - 1 : 0);
      
      Fixes: 3e89586a
      
       ("media: i2c: adv748x: add adv748x driver")
      Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      b74db57e
    • Christophe Roullier's avatar
      drivers: watchdog: stm32_iwdg: set WDOG_HW_RUNNING at probe · 09819ac5
      Christophe Roullier authored
      commit 85fdc63f upstream.
      
      If the watchdog hardware is already enabled during the boot process,
      when the Linux watchdog driver loads, it should start/reset the watchdog
      and tell the watchdog framework. As a result, ping can be generated from
      the watchdog framework (if CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED is set),
      until the userspace watchdog daemon takes over control
      
      Fixes:4332d113
      
       ("watchdog: Add STM32 IWDG driver")
      
      Signed-off-by: default avatarChristophe Roullier <christophe.roullier@st.com>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20191122132246.8473-1-christophe.roullier@st.com
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      09819ac5