Skip to content
  1. Sep 08, 2022
    • Mika Westerberg's avatar
      thunderbolt: Use the actual buffer in tb_async_error() · 9fe0e993
      Mika Westerberg authored
      commit eb100b8f upstream.
      
      The received notification packet is held in pkg->buffer and not in pkg
      itself. Fix this by using the correct buffer.
      
      Fixes: 81a54b5e
      
       ("thunderbolt: Let the connection manager handle all notifications")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9fe0e993
    • SeongJae Park's avatar
      xen-blkfront: Cache feature_persistent value before advertisement · 06cb0542
      SeongJae Park authored
      commit fe8f65b0 upstream.
      
      Xen blkfront advertises its support of the persistent grants feature
      when it first setting up and when resuming in 'talk_to_blkback()'.
      Then, blkback reads the advertised value when it connects with blkfront
      and decides if it will use the persistent grants feature or not, and
      advertises its decision to blkfront.  Blkfront reads the blkback's
      decision and it also makes the decision for the use of the feature.
      
      Commit 402c43ea ("xen-blkfront: Apply 'feature_persistent' parameter
      when connect"), however, made the blkfront's read of the parameter for
      disabling the advertisement, namely 'feature_persistent', to be done
      when it negotiate, not when advertise.  Therefore blkfront advertises
      without reading the parameter.  As the field for caching the parameter
      value is zero-initialized, it always advertises as the feature is
      disabled, so that the persistent grants feature becomes always disabled.
      
      This commit fixes the issue by making the blkfront does parmeter caching
      just before the advertisement.
      
      Fixes: 402c43ea
      
       ("xen-blkfront: Apply 'feature_persistent' parameter when connect")
      Cc: <stable@vger.kernel.org> # 5.10.x
      Reported-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Tested-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/20220831165824.94815-4-sj@kernel.org
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      06cb0542
    • SeongJae Park's avatar
      xen-blkfront: Advertise feature-persistent as user requested · 6d4ee444
      SeongJae Park authored
      commit 9f5e0fe5 upstream.
      
      The advertisement of the persistent grants feature (writing
      'feature-persistent' to xenbus) should mean not the decision for using
      the feature but only the availability of the feature.  However, commit
      74a85247 ("xen-blkfront: add a parameter for disabling of persistent
      grants") made a field of blkfront, which was a place for saving only the
      negotiation result, to be used for yet another purpose: caching of the
      'feature_persistent' parameter value.  As a result, the advertisement,
      which should follow only the parameter value, becomes inconsistent.
      
      This commit fixes the misuse of the semantic by making blkfront saves
      the parameter value in a separate place and advertises the support based
      on only the saved value.
      
      Fixes: 74a85247
      
       ("xen-blkfront: add a parameter for disabling of persistent grants")
      Cc: <stable@vger.kernel.org> # 5.10.x
      Suggested-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Tested-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/20220831165824.94815-3-sj@kernel.org
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6d4ee444
    • SeongJae Park's avatar
      xen-blkback: Advertise feature-persistent as user requested · d925c3bf
      SeongJae Park authored
      commit 06ba5d2e upstream.
      
      The advertisement of the persistent grants feature (writing
      'feature-persistent' to xenbus) should mean not the decision for using
      the feature but only the availability of the feature.  However, commit
      aac8a70d ("xen-blkback: add a parameter for disabling of persistent
      grants") made a field of blkback, which was a place for saving only the
      negotiation result, to be used for yet another purpose: caching of the
      'feature_persistent' parameter value.  As a result, the advertisement,
      which should follow only the parameter value, becomes inconsistent.
      
      This commit fixes the misuse of the semantic by making blkback saves the
      parameter value in a separate place and advertises the support based on
      only the saved value.
      
      Fixes: aac8a70d
      
       ("xen-blkback: add a parameter for disabling of persistent grants")
      Cc: <stable@vger.kernel.org> # 5.10.x
      Suggested-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Tested-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/20220831165824.94815-2-sj@kernel.org
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d925c3bf
    • Steven Price's avatar
      mm: pagewalk: Fix race between unmap and page walker · 9a108bd6
      Steven Price authored
      [ Upstream commit 8782fb61 ]
      
      The mmap lock protects the page walker from changes to the page tables
      during the walk.  However a read lock is insufficient to protect those
      areas which don't have a VMA as munmap() detaches the VMAs before
      downgrading to a read lock and actually tearing down PTEs/page tables.
      
      For users of walk_page_range() the solution is to simply call pte_hole()
      immediately without checking the actual page tables when a VMA is not
      present. We now never call __walk_page_range() without a valid vma.
      
      For walk_page_range_novma() the locking requirements are tightened to
      require the mmap write lock to be taken, and then walking the pgd
      directly with 'no_vma' set.
      
      This in turn means that all page walkers either have a valid vma, or
      it's that special 'novma' case for page table debugging.  As a result,
      all the odd '(!walk->vma && !walk->no_vma)' tests can be removed.
      
      Fixes: dd2283f2
      
       ("mm: mmap: zap pages with read mmap_sem in munmap")
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarSteven Price <steven.price@arm.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
      Cc: Konstantin Khlebnikov <koct9i@gmail.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9a108bd6
    • Dan Carpenter's avatar
      xen/grants: prevent integer overflow in gnttab_dma_alloc_pages() · 3aa6a9f8
      Dan Carpenter authored
      [ Upstream commit e9ea0b30 ]
      
      The change from kcalloc() to kvmalloc() means that arg->nr_pages
      might now be large enough that the "args->nr_pages << PAGE_SHIFT" can
      result in an integer overflow.
      
      Fixes: b3f7931f
      
       ("xen/gntdev: switch from kcalloc() to kvcalloc()")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/YxDROJqu/RPvR0bi@kili
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3aa6a9f8
    • Nathan Chancellor's avatar
      powerpc/papr_scm: Ensure rc is always initialized in papr_scm_pmu_register() · 4e2eecb9
      Nathan Chancellor authored
      [ Upstream commit 6cf07810 ]
      
      Clang warns:
      
        arch/powerpc/platforms/pseries/papr_scm.c:492:6: warning: variable 'rc' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
                if (!p->stat_buffer_len)
                    ^~~~~~~~~~~~~~~~~~~
        arch/powerpc/platforms/pseries/papr_scm.c:523:64: note: uninitialized use occurs here
                dev_info(&p->pdev->dev, "nvdimm pmu didn't register rc=%d\n", rc);
                                                                              ^~
        include/linux/dev_printk.h:150:67: note: expanded from macro 'dev_info'
                dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
                                                                                ^~~~~~~~~~~
        include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
                        _p_func(dev, fmt, ##__VA_ARGS__);                       \
                                            ^~~~~~~~~~~
        arch/powerpc/platforms/pseries/papr_scm.c:492:2: note: remove the 'if' if its condition is always false
                if (!p->stat_buffer_len)
                ^~~~~~~~~~~~~~~~~~~~~~~~
        arch/powerpc/platforms/pseries/papr_scm.c:484:8: note: initialize the variable 'rc' to silence this warning
                int rc, nodeid;
                      ^
                      = 0
        1 warning generated.
      
      The call to papr_scm_pmu_check_events() was eliminated but a return code
      was not added to the if statement. Add the same return code from
      papr_scm_pmu_check_events() for this condition so there is no more
      warning.
      
      Fixes: 9b1ac046
      
       ("powerpc/papr_scm: Fix nvdimm event mappings")
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://github.com/ClangBuiltLinux/linux/issues/1701
      Link: https://lore.kernel.org/r/20220830151256.1473169-1-nathan@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4e2eecb9
    • Jim Mattson's avatar
      KVM: x86: Mask off unsupported and unknown bits of IA32_ARCH_CAPABILITIES · 3d92ba26
      Jim Mattson authored
      [ Upstream commit 0204750b ]
      
      KVM should not claim to virtualize unknown IA32_ARCH_CAPABILITIES
      bits. When kvm_get_arch_capabilities() was originally written, there
      were only a few bits defined in this MSR, and KVM could virtualize all
      of them. However, over the years, several bits have been defined that
      KVM cannot just blindly pass through to the guest without additional
      work (such as virtualizing an MSR promised by the
      IA32_ARCH_CAPABILITES feature bit).
      
      Define a mask of supported IA32_ARCH_CAPABILITIES bits, and mask off
      any other bits that are set in the hardware MSR.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Fixes: 5b76a3cf
      
       ("KVM: VMX: Tell the nested hypervisor to skip L1D flush on vmentry")
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Reviewed-by: default avatarVipin Sharma <vipinsh@google.com>
      Reviewed-by: default avatarXiaoyao Li <xiaoyao.li@intel.com>
      Message-Id: <20220830174947.2182144-1-jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3d92ba26
    • Sander Vanheule's avatar
      gpio: realtek-otto: switch to 32-bit I/O · e13ef600
      Sander Vanheule authored
      [ Upstream commit ee0175b3 ]
      
      By using 16-bit I/O on the GPIO peripheral, which is apparently not safe
      on MIPS, the IMR can end up containing garbage. This then results in
      interrupt triggers for lines that don't have an interrupt handler
      associated. The irq_desc lookup fails, and the ISR will not be cleared,
      keeping the CPU busy until reboot, or until another IMR operation
      restores the correct value. This situation appears to happen very
      rarely, for < 0.5% of IMR writes.
      
      Instead of using 8-bit or 16-bit I/O operations on the 32-bit memory
      mapped peripheral registers, switch to using 32-bit I/O only, operating
      on the entire bank for all single bit line settings. For 2-bit line
      settings, with 16-bit port values, stick to manual (un)packing.
      
      This issue has been seen on RTL8382M (HPE 1920-16G), RTL8391M (Netgear
      GS728TP v2), and RTL8393M (D-Link DGS-1210-52 F3, Zyxel GS1900-48).
      
      Reported-by: Luiz Angelo Daros de Luca <luizluca@gmail.com> # DGS-1210-52
      Reported-by: Birger Koblitz <mail@birger-koblitz.de> # GS728TP
      Reported-by: Jan Hoffmann <jan@3e8.eu> # 1920-16G
      Fixes: 0d82fb11
      
       ("gpio: Add Realtek Otto GPIO support")
      Signed-off-by: default avatarSander Vanheule <sander@svanheule.net>
      Cc: Paul Cercueil <paul@crapouillou.net>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e13ef600
    • Haibo Chen's avatar
      gpio: pca953x: Add mutex_lock for regcache sync in PM · 97ca48ec
      Haibo Chen authored
      [ Upstream commit 518e26f1 ]
      
      The regcache sync will set the cache_bypass = true, at that
      time, when there is regmap write operation, it will bypass
      the regmap cache, then the regcache sync will write back the
      value from cache to register, which is not as our expectation.
      
      Though regmap already use its internal lock to avoid such issue,
      but this driver force disable the regmap internal lock in its
      regmap config: disable_locking = true
      
      To avoid this issue, use the driver's own lock to do the protect
      in system PM.
      
      Fixes: b7657430
      
       ("gpio: pca953x: Restore registers after suspend/resume cycle")
      Signed-off-by: default avatarHaibo Chen <haibo.chen@nxp.com>
      Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      97ca48ec
    • Armin Wolf's avatar
      hwmon: (gpio-fan) Fix array out of bounds access · 3263984c
      Armin Wolf authored
      [ Upstream commit f233d2be ]
      
      The driver does not check if the cooling state passed to
      gpio_fan_set_cur_state() exceeds the maximum cooling state as
      stored in fan_data->num_speeds. Since the cooling state is later
      used as an array index in set_fan_speed(), an array out of bounds
      access can occur.
      This can be exploited by setting the state of the thermal cooling device
      to arbitrary values, causing for example a kernel oops when unavailable
      memory is accessed this way.
      
      Example kernel oops:
      [  807.987276] Unable to handle kernel paging request at virtual address ffffff80d0588064
      [  807.987369] Mem abort info:
      [  807.987398]   ESR = 0x96000005
      [  807.987428]   EC = 0x25: DABT (current EL), IL = 32 bits
      [  807.987477]   SET = 0, FnV = 0
      [  807.987507]   EA = 0, S1PTW = 0
      [  807.987536]   FSC = 0x05: level 1 translation fault
      [  807.987570] Data abort info:
      [  807.987763]   ISV = 0, ISS = 0x00000005
      [  807.987801]   CM = 0, WnR = 0
      [  807.987832] swapper pgtable: 4k pages, 39-bit VAs, pgdp=0000000001165000
      [  807.987872] [ffffff80d0588064] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000
      [  807.987961] Internal error: Oops: 96000005 [#1] PREEMPT SMP
      [  807.987992] Modules linked in: cmac algif_hash aes_arm64 algif_skcipher af_alg bnep hci_uart btbcm bluetooth ecdh_generic ecc 8021q garp stp llc snd_soc_hdmi_codec brcmfmac vc4 brcmutil cec drm_kms_helper snd_soc_core cfg80211 snd_compress bcm2835_codec(C) snd_pcm_dmaengine syscopyarea bcm2835_isp(C) bcm2835_v4l2(C) sysfillrect v4l2_mem2mem bcm2835_mmal_vchiq(C) raspberrypi_hwmon sysimgblt videobuf2_dma_contig videobuf2_vmalloc fb_sys_fops videobuf2_memops rfkill videobuf2_v4l2 videobuf2_common i2c_bcm2835 snd_bcm2835(C) videodev snd_pcm snd_timer snd mc vc_sm_cma(C) gpio_fan uio_pdrv_genirq uio drm fuse drm_panel_orientation_quirks backlight ip_tables x_tables ipv6
      [  807.988508] CPU: 0 PID: 1321 Comm: bash Tainted: G         C        5.15.56-v8+ #1575
      [  807.988548] Hardware name: Raspberry Pi 3 Model B Rev 1.2 (DT)
      [  807.988574] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      [  807.988608] pc : set_fan_speed.part.5+0x34/0x80 [gpio_fan]
      [  807.988654] lr : gpio_fan_set_cur_state+0x34/0x50 [gpio_fan]
      [  807.988691] sp : ffffffc008cf3bd0
      [  807.988710] x29: ffffffc008cf3bd0 x28: ffffff80019edac0 x27: 0000000000000000
      [  807.988762] x26: 0000000000000000 x25: 0000000000000000 x24: ffffff800747c920
      [  807.988787] x23: 000000000000000a x22: ffffff800369f000 x21: 000000001999997c
      [  807.988854] x20: ffffff800369f2e8 x19: ffffff8002ae8080 x18: 0000000000000000
      [  807.988877] x17: 0000000000000000 x16: 0000000000000000 x15: 000000559e271b70
      [  807.988938] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000
      [  807.988960] x11: 0000000000000000 x10: ffffffc008cf3c20 x9 : ffffffcfb60c741c
      [  807.989018] x8 : 000000000000000a x7 : 00000000ffffffc9 x6 : 0000000000000009
      [  807.989040] x5 : 000000000000002a x4 : 0000000000000000 x3 : ffffff800369f2e8
      [  807.989062] x2 : 000000000000e780 x1 : 0000000000000001 x0 : ffffff80d0588060
      [  807.989084] Call trace:
      [  807.989091]  set_fan_speed.part.5+0x34/0x80 [gpio_fan]
      [  807.989113]  gpio_fan_set_cur_state+0x34/0x50 [gpio_fan]
      [  807.989199]  cur_state_store+0x84/0xd0
      [  807.989221]  dev_attr_store+0x20/0x38
      [  807.989262]  sysfs_kf_write+0x4c/0x60
      [  807.989282]  kernfs_fop_write_iter+0x130/0x1c0
      [  807.989298]  new_sync_write+0x10c/0x190
      [  807.989315]  vfs_write+0x254/0x378
      [  807.989362]  ksys_write+0x70/0xf8
      [  807.989379]  __arm64_sys_write+0x24/0x30
      [  807.989424]  invoke_syscall+0x4c/0x110
      [  807.989442]  el0_svc_common.constprop.3+0xfc/0x120
      [  807.989458]  do_el0_svc+0x2c/0x90
      [  807.989473]  el0_svc+0x24/0x60
      [  807.989544]  el0t_64_sync_handler+0x90/0xb8
      [  807.989558]  el0t_64_sync+0x1a0/0x1a4
      [  807.989579] Code: b9403801 f9402800 7100003f 8b35cc00 (b9400416)
      [  807.989627] ---[ end trace 8ded4c918658445b ]---
      
      Fix this by checking the cooling state and return an error if it
      exceeds the maximum cooling state.
      
      Tested on a Raspberry Pi 3.
      
      Fixes: b5cf88e4
      
       ("(gpio-fan): Add thermal control hooks")
      Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
      Link: https://lore.kernel.org/r/20220830011101.178843-1-W_Armin@gmx.de
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3263984c
    • Stefan Wahren's avatar
      clk: bcm: rpi: Add missing newline · 7d54f19f
      Stefan Wahren authored
      [ Upstream commit 13b5cf8d ]
      
      Some log messages lacks the final newline. So add them.
      
      Fixes: 93d2725a
      
       ("clk: bcm: rpi: Discover the firmware clocks")
      Signed-off-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Link: https://lore.kernel.org/r/20220713154953.3336-3-stefan.wahren@i2se.com
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarIvan T. Ivanov <iivanov@suse.de>
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7d54f19f
    • Stefan Wahren's avatar
      clk: bcm: rpi: Prevent out-of-bounds access · c8b04b73
      Stefan Wahren authored
      [ Upstream commit bc163555 ]
      
      The while loop in raspberrypi_discover_clocks() relies on the assumption
      that the id of the last clock element is zero. Because this data comes
      from the Videocore firmware and it doesn't guarantuee such a behavior
      this could lead to out-of-bounds access. So fix this by providing
      a sentinel element.
      
      Fixes: 93d2725a
      
       ("clk: bcm: rpi: Discover the firmware clocks")
      Link: https://github.com/raspberrypi/firmware/issues/1688
      Suggested-by: default avatarPhil Elwell <phil@raspberrypi.com>
      Signed-off-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Link: https://lore.kernel.org/r/20220713154953.3336-2-stefan.wahren@i2se.com
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarIvan T. Ivanov <iivanov@suse.de>
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c8b04b73
    • Stefan Wahren's avatar
      clk: bcm: rpi: Fix error handling of raspberrypi_fw_get_rate · 838dff24
      Stefan Wahren authored
      [ Upstream commit 35f73cca
      
       ]
      
      The function raspberrypi_fw_get_rate (e.g. used for the recalc_rate
      hook) can fail to get the clock rate from the firmware. In this case
      we cannot return a signed error value, which would be casted to
      unsigned long. Fix this by returning 0 instead.
      
      Signed-off-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Link: https://lore.kernel.org/r/20220625083643.4012-1-stefan.wahren@i2se.com
      Fixes: 4e85e535
      
       ("clk: bcm283x: add driver interfacing with Raspberry Pi's firmware")
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      838dff24
    • Kajol Jain's avatar
      powerpc/papr_scm: Fix nvdimm event mappings · 3a58d2aa
      Kajol Jain authored
      [ Upstream commit 9b1ac046 ]
      
      Commit 4c08d4bb ("powerpc/papr_scm: Add perf interface support")
      added performance monitoring support for papr-scm nvdimm devices via
      perf interface. Commit also added an array in papr_scm_priv
      structure called "nvdimm_events_map", which got filled based on the
      result of H_SCM_PERFORMANCE_STATS hcall.
      
      Currently there is an assumption that the order of events in the
      stats buffer, returned by the hypervisor is same. And order also
      happens to matches with the events specified in nvdimm driver code.
      But this assumption is not documented in Power Architecture
      Platform Requirements (PAPR) document. Although the order
      of events happens to be same on current generation od system, but
      it might not be true in future generation systems. Fix the issue, by
      adding a static mapping for nvdimm events to corresponding stat-id,
      and removing the dynamic map from papr_scm_priv structure. Also
      remove the function papr_scm_pmu_check_events from papr_scm.c file,
      as we no longer need to copy stat-ids dynamically.
      
      Fixes: 4c08d4bb
      
       ("powerpc/papr_scm: Add perf interface support")
      Reported-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Reviewed-by: default avatarVaibhav Jain <vaibhav@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220804074852.55157-1-kjain@linux.ibm.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3a58d2aa
    • Peter Robinson's avatar
      Input: rk805-pwrkey - fix module autoloading · dd5ec541
      Peter Robinson authored
      [ Upstream commit 99077ad6 ]
      
      Add the module alias so the rk805-pwrkey driver will
      autoload when built as a module.
      
      Fixes: 5a35b85c
      
       ("Input: add power key driver for Rockchip RK805 PMIC")
      Signed-off-by: default avatarPeter Robinson <pbrobinson@gmail.com>
      Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
      Link: https://lore.kernel.org/r/20220612225437.3628788-1-pbrobinson@gmail.com
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dd5ec541
    • Chen-Yu Tsai's avatar
      clk: core: Fix runtime PM sequence in clk_core_unprepare() · 5e7ddb09
      Chen-Yu Tsai authored
      [ Upstream commit 4b592061 ]
      
      In the original commit 9a34b453 ("clk: Add support for runtime PM"),
      the commit message mentioned that pm_runtime_put_sync() would be done
      at the end of clk_core_unprepare(). This mirrors the operations in
      clk_core_prepare() in the opposite order.
      
      However, the actual code that was added wasn't in the order the commit
      message described. Move clk_pm_runtime_put() to the end of
      clk_core_unprepare() so that it is in the correct order.
      
      Fixes: 9a34b453
      
       ("clk: Add support for runtime PM")
      Signed-off-by: default avatarChen-Yu Tsai <wenst@chromium.org>
      Reviewed-by: default avatarNícolas F. R. A. Prado <nfraprado@collabora.com>
      Link: https://lore.kernel.org/r/20220822081424.1310926-3-wenst@chromium.org
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5e7ddb09
    • Stephen Boyd's avatar
      Revert "clk: core: Honor CLK_OPS_PARENT_ENABLE for clk gate ops" · 27c26c2a
      Stephen Boyd authored
      [ Upstream commit abb5f3f4 ]
      
      This reverts commit 35b0fac8
      
      . Alexander
      reports that it causes boot failures on i.MX8M Plus based boards
      (specifically imx8mp-tqma8mpql-mba8mpxl.dts).
      
      Reported-by: default avatarAlexander Stein <alexander.stein@ew.tq-group.com>
      Cc: Chen-Yu Tsai <wenst@chromium.org>
      Fixes: 35b0fac8
      
       ("clk: core: Honor CLK_OPS_PARENT_ENABLE for clk gate ops")
      Link: https://lore.kernel.org/r/12115951.O9o76ZdvQC@steina-w
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Link: https://lore.kernel.org/r/20220831175326.2523912-1-sboyd@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      27c26c2a
    • Chen-Yu Tsai's avatar
      clk: core: Honor CLK_OPS_PARENT_ENABLE for clk gate ops · c25e0ca0
      Chen-Yu Tsai authored
      [ Upstream commit 35b0fac8 ]
      
      In the previous commits that added CLK_OPS_PARENT_ENABLE, support for
      this flag was only added to rate change operations (rate setting and
      reparent) and disabling unused subtree. It was not added to the
      clock gate related operations. Any hardware driver that needs it for
      these operations will either see bogus results, or worse, hang.
      
      This has been seen on MT8192 and MT8195, where the imp_ii2_* clk
      drivers set this, but dumping debugfs clk_summary would cause it
      to hang.
      
      Fixes: fc8726a2 ("clk: core: support clocks which requires parents enable (part 2)")
      Fixes: a4b3518d
      
       ("clk: core: support clocks which requires parents enable (part 1)")
      Signed-off-by: default avatarChen-Yu Tsai <wenst@chromium.org>
      Reviewed-by: default avatarNícolas F. R. A. Prado <nfraprado@collabora.com>
      Tested-by: default avatarNícolas F. R. A. Prado <nfraprado@collabora.com>
      Link: https://lore.kernel.org/r/20220822081424.1310926-2-wenst@chromium.org
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c25e0ca0
    • Colin Ian King's avatar
      drm/i915/reg: Fix spelling mistake "Unsupport" -> "Unsupported" · 079ea01f
      Colin Ian King authored
      [ Upstream commit 233f5674 ]
      
      There is a spelling mistake in a gvt_vgpu_err error message. Fix it.
      
      Fixes: 695fbc08
      
       ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
      Signed-off-by: default avatarColin Ian King <colin.i.king@gmail.com>
      Signed-off-by: default avatarZhi Wang <zhi.a.wang@intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20220315202449.2952845-1-colin.i.king@gmail.com
      Reviewed-by: default avatarZhi Wang <zhi.a.wang@intel.com>
      Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      079ea01f
    • Tony Lindgren's avatar
      clk: ti: Fix missing of_node_get() ti_find_clock_provider() · d6c8cc2d
      Tony Lindgren authored
      [ Upstream commit 26f2da0d ]
      
      For ti_find_clock_provider() we want to return the np with refcount
      incremented. However we are missing of_node_get() for the
      clock-output-names case that causes refcount warnings.
      
      Fixes: 51f661ef
      
       ("clk: ti: Add ti_find_clock_provider() to use clock-output-names")
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Link: https://lore.kernel.org/r/20220621091118.33930-1-tony@atomide.com
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d6c8cc2d
    • Conor Dooley's avatar
      riscv: kvm: move extern sbi_ext declarations to a header · 26b03f80
      Conor Dooley authored
      [ Upstream commit 3e5e56c6 ]
      
      Sparse complains about missing statics in the declarations of several
      variables:
      arch/riscv/kvm/vcpu_sbi_replace.c:38:37: warning: symbol 'vcpu_sbi_ext_time' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_replace.c:73:37: warning: symbol 'vcpu_sbi_ext_ipi' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_replace.c:126:37: warning: symbol 'vcpu_sbi_ext_rfence' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_replace.c:170:37: warning: symbol 'vcpu_sbi_ext_srst' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_base.c:69:37: warning: symbol 'vcpu_sbi_ext_base' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_base.c:90:37: warning: symbol 'vcpu_sbi_ext_experimental' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_base.c:96:37: warning: symbol 'vcpu_sbi_ext_vendor' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_hsm.c:115:37: warning: symbol 'vcpu_sbi_ext_hsm' was not declared. Should it be static?
      
      These variables are however used in vcpu_sbi.c where they are declared
      as extern. Move them to kvm_vcpu_sbi.h which is handily already
      included by the three other files.
      
      Fixes: a046c2d8 ("RISC-V: KVM: Reorganize SBI code by moving SBI v0.1 to its own file")
      Fixes: 5f862df5 ("RISC-V: KVM: Add v0.1 replacement SBI extensions defined in v0.2")
      Fixes: 3e1d8656
      
       ("RISC-V: KVM: Add SBI HSM extension in KVM")
      Reviewed-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      26b03f80
    • Jim Mattson's avatar
      KVM: VMX: Heed the 'msr' argument in msr_write_intercepted() · 5424fd04
      Jim Mattson authored
      [ Upstream commit 020dac41 ]
      
      Regardless of the 'msr' argument passed to the VMX version of
      msr_write_intercepted(), the function always checks to see if a
      specific MSR (IA32_SPEC_CTRL) is intercepted for write.  This behavior
      seems unintentional and unexpected.
      
      Modify the function so that it checks to see if the provided 'msr'
      index is intercepted for write.
      
      Fixes: 67f4b996
      
       ("KVM: nVMX: Handle dynamic MSR intercept toggling")
      Cc: Sean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20220810213050.2655000-1-jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5424fd04
    • Enzo Matsumiya's avatar
      cifs: fix small mempool leak in SMB2_negotiate() · 38a6b469
      Enzo Matsumiya authored
      commit 27893dfc
      
       upstream.
      
      In some cases of failure (dialect mismatches) in SMB2_negotiate(), after
      the request is sent, the checks would return -EIO when they should be
      rather setting rc = -EIO and jumping to neg_exit to free the response
      buffer from mempool.
      
      Signed-off-by: default avatarEnzo Matsumiya <ematsumiya@suse.de>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      38a6b469
    • Carlos Llamas's avatar
      binder: fix alloc->vma_vm_mm null-ptr dereference · b2a97bab
      Carlos Llamas authored
      commit 1da52815 upstream.
      
      Syzbot reported a couple issues introduced by commit 44e602b4
      ("binder_alloc: add missing mmap_lock calls when using the VMA"), in
      which we attempt to acquire the mmap_lock when alloc->vma_vm_mm has not
      been initialized yet.
      
      This can happen if a binder_proc receives a transaction without having
      previously called mmap() to setup the binder_proc->alloc space in [1].
      Also, a similar issue occurs via binder_alloc_print_pages() when we try
      to dump the debugfs binder stats file in [2].
      
      Sample of syzbot's crash report:
        ==================================================================
        KASAN: null-ptr-deref in range [0x0000000000000128-0x000000000000012f]
        CPU: 0 PID: 3755 Comm: syz-executor229 Not tainted 6.0.0-rc1-next-20220819-syzkaller #0
        syz-executor229[3755] cmdline: ./syz-executor2294415195
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022
        RIP: 0010:__lock_acquire+0xd83/0x56d0 kernel/locking/lockdep.c:4923
        [...]
        Call Trace:
         <TASK>
         lock_acquire kernel/locking/lockdep.c:5666 [inline]
         lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
         down_read+0x98/0x450 kernel/locking/rwsem.c:1499
         mmap_read_lock include/linux/mmap_lock.h:117 [inline]
         binder_alloc_new_buf_locked drivers/android/binder_alloc.c:405 [inline]
         binder_alloc_new_buf+0xa5/0x19e0 drivers/android/binder_alloc.c:593
         binder_transaction+0x242e/0x9a80 drivers/android/binder.c:3199
         binder_thread_write+0x664/0x3220 drivers/android/binder.c:3986
         binder_ioctl_write_read drivers/android/binder.c:5036 [inline]
         binder_ioctl+0x3470/0x6d00 drivers/android/binder.c:5323
         vfs_ioctl fs/ioctl.c:51 [inline]
         __do_sys_ioctl fs/ioctl.c:870 [inline]
         __se_sys_ioctl fs/ioctl.c:856 [inline]
         __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
         do_syscall_x64 arch/x86/entry/common.c:50 [inline]
         do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
         entry_SYSCALL_64_after_hwframe+0x63/0xcd
         [...]
        ==================================================================
      
      Fix these issues by setting up alloc->vma_vm_mm pointer during open()
      and caching directly from current->mm. This guarantees we have a valid
      reference to take the mmap_lock during scenarios described above.
      
      [1] https://syzkaller.appspot.com/bug?extid=f7dc54e5be28950ac459
      [2] https://syzkaller.appspot.com/bug?extid=a75ebe0452711c9e56d9
      
      Fixes: 44e602b4
      
       ("binder_alloc: add missing mmap_lock calls when using the VMA")
      Cc: <stable@vger.kernel.org> # v5.15+
      Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
      Reported-by: default avatar <syzbot+f7dc54e5be28950ac459@syzkaller.appspotmail.com>
      Reported-by: default avatar <syzbot+a75ebe0452711c9e56d9@syzkaller.appspotmail.com>
      Reviewed-by: default avatarLiam R. Howlett <Liam.Howlett@oracle.com>
      Acked-by: default avatarTodd Kjos <tkjos@google.com>
      Signed-off-by: default avatarCarlos Llamas <cmllamas@google.com>
      Link: https://lore.kernel.org/r/20220829201254.1814484-2-cmllamas@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2a97bab
    • Carlos Llamas's avatar
      binder: fix UAF of ref->proc caused by race condition · 603a47f2
      Carlos Llamas authored
      commit a0e44c64
      
       upstream.
      
      A transaction of type BINDER_TYPE_WEAK_HANDLE can fail to increment the
      reference for a node. In this case, the target proc normally releases
      the failed reference upon close as expected. However, if the target is
      dying in parallel the call will race with binder_deferred_release(), so
      the target could have released all of its references by now leaving the
      cleanup of the new failed reference unhandled.
      
      The transaction then ends and the target proc gets released making the
      ref->proc now a dangling pointer. Later on, ref->node is closed and we
      attempt to take spin_lock(&ref->proc->inner_lock), which leads to the
      use-after-free bug reported below. Let's fix this by cleaning up the
      failed reference on the spot instead of relying on the target to do so.
      
        ==================================================================
        BUG: KASAN: use-after-free in _raw_spin_lock+0xa8/0x150
        Write of size 4 at addr ffff5ca207094238 by task kworker/1:0/590
      
        CPU: 1 PID: 590 Comm: kworker/1:0 Not tainted 5.19.0-rc8 #10
        Hardware name: linux,dummy-virt (DT)
        Workqueue: events binder_deferred_func
        Call trace:
         dump_backtrace.part.0+0x1d0/0x1e0
         show_stack+0x18/0x70
         dump_stack_lvl+0x68/0x84
         print_report+0x2e4/0x61c
         kasan_report+0xa4/0x110
         kasan_check_range+0xfc/0x1a4
         __kasan_check_write+0x3c/0x50
         _raw_spin_lock+0xa8/0x150
         binder_deferred_func+0x5e0/0x9b0
         process_one_work+0x38c/0x5f0
         worker_thread+0x9c/0x694
         kthread+0x188/0x190
         ret_from_fork+0x10/0x20
      
      Acked-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      Signed-off-by: default avatarCarlos Llamas <cmllamas@google.com>
      Cc: stable <stable@kernel.org> # 4.14+
      Link: https://lore.kernel.org/r/20220801182511.3371447-1-cmllamas@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      603a47f2
    • Adrian Hunter's avatar
      mmc: core: Fix inconsistent sd3_bus_mode at UHS-I SD voltage switch failure · 71f7644b
      Adrian Hunter authored
      commit 63f15609
      
       upstream.
      
      If re-initialization results is a different signal voltage, because the
      voltage switch failed previously, but not this time (or vice versa), then
      sd3_bus_mode will be inconsistent with the card because the SD_SWITCH
      command is done only upon first initialization.
      
      Fix by always reading SD_SWITCH information during re-initialization, which
      also means it does not need to be re-read later for the 1.8V fixup
      workaround.
      
      Note, brief testing showed SD_SWITCH took about 1.8ms to 2ms which added
      about 1% to 1.5% to the re-initialization time, so it's not particularly
      significant.
      
      Reported-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
      Tested-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20220815073321.63382-3-adrian.hunter@intel.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      71f7644b
    • Adrian Hunter's avatar
      mmc: core: Fix UHS-I SD 1.8V workaround branch · bb4be611
      Adrian Hunter authored
      commit 15c56208 upstream.
      
      When introduced, upon success, the 1.8V fixup workaround in
      mmc_sd_init_card() would branch to practically the end of the function, to
      a label named "done". Unfortunately, perhaps due to the label name, over
      time new code has been added that really should have come after "done" not
      before it. Let's fix the problem by moving the label to the correct place
      and rename it "cont".
      
      Fixes: 045d705d
      
       ("mmc: core: Enable the MMC host software queue for the SD card")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20220815073321.63382-2-adrian.hunter@intel.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb4be611
    • Mickaël Salaün's avatar
      landlock: Fix file reparenting without explicit LANDLOCK_ACCESS_FS_REFER · 9f78dda3
      Mickaël Salaün authored
      commit 55e55920 upstream.
      
      This change fixes a mis-handling of the LANDLOCK_ACCESS_FS_REFER right
      when multiple rulesets/domains are stacked. The expected behaviour was
      that an additional ruleset can only restrict the set of permitted
      operations, but in this particular case, it was potentially possible to
      re-gain the LANDLOCK_ACCESS_FS_REFER right.
      
      With the introduction of LANDLOCK_ACCESS_FS_REFER, we added the first
      globally denied-by-default access right.  Indeed, this lifted an initial
      Landlock limitation to rename and link files, which was initially always
      denied when the source or the destination were different directories.
      
      This led to an inconsistent backward compatibility behavior which was
      only taken into account if no domain layer were using the new
      LANDLOCK_ACCESS_FS_REFER right. However, when restricting a thread with
      a new ruleset handling LANDLOCK_ACCESS_FS_REFER, all inherited parent
      rulesets/layers not explicitly handling LANDLOCK_ACCESS_FS_REFER would
      behave as if they were handling this access right and with all their
      rules allowing it. This means that renaming and linking files could
      became allowed by these parent layers, but all the other required
      accesses must also be granted: all layers must allow file removal or
      creation, and renaming and linking operations cannot lead to privilege
      escalation according to the Landlock policy.  See detailed explanation
      in commit b91c3e4e ("landlock: Add support for file reparenting with
      LANDLOCK_ACCESS_FS_REFER").
      
      To say it another way, this bug may lift the renaming and linking
      limitations of the initial Landlock version, and a same ruleset can
      enforce different restrictions depending on previous or next enforced
      ruleset (i.e. inconsistent behavior). The LANDLOCK_ACCESS_FS_REFER right
      cannot give access to data not already allowed, but this doesn't follow
      the contract of the first Landlock ABI. This fix puts back the
      limitation for sandboxes that didn't opt-in for this additional right.
      
      For instance, if a first ruleset allows LANDLOCK_ACCESS_FS_MAKE_REG on
      /dst and LANDLOCK_ACCESS_FS_REMOVE_FILE on /src, renaming /src/file to
      /dst/file is denied. However, without this fix, stacking a new ruleset
      which allows LANDLOCK_ACCESS_FS_REFER on / would now permit the
      sandboxed thread to rename /src/file to /dst/file .
      
      This change fixes the (absolute) rule access rights, which now always
      forbid LANDLOCK_ACCESS_FS_REFER except when it is explicitly allowed
      when creating a rule.
      
      Making all domain handle LANDLOCK_ACCESS_FS_REFER was an initial
      approach but there is two downsides:
      * it makes the code more complex because we still want to check that a
        rule allowing LANDLOCK_ACCESS_FS_REFER is legitimate according to the
        ruleset's handled access rights (i.e. ABI v1 != ABI v2);
      * it would not allow to identify if the user created a ruleset
        explicitly handling LANDLOCK_ACCESS_FS_REFER or not, which will be an
        issue to audit Landlock.
      
      Instead, this change adds an ACCESS_INITIALLY_DENIED list of
      denied-by-default rights, which (only) contains
      LANDLOCK_ACCESS_FS_REFER.  All domains are treated as if they are also
      handling this list, but without modifying their fs_access_masks field.
      
      A side effect is that the errno code returned by rename(2) or link(2)
      *may* be changed from EXDEV to EACCES according to the enforced
      restrictions.  Indeed, we now have the mechanic to identify if an access
      is denied because of a required right (e.g. LANDLOCK_ACCESS_FS_MAKE_REG,
      LANDLOCK_ACCESS_FS_REMOVE_FILE) or if it is denied because of missing
      LANDLOCK_ACCESS_FS_REFER rights.  This may result in different errno
      codes than for the initial Landlock version, but this approach is more
      consistent and better for rename/link compatibility reasons, and it
      wasn't possible before (hence no backport to ABI v1).  The
      layout1.rename_file test reflects this change.
      
      Add 4 layout1.refer_denied_by_default* test suites to check that the
      behavior of a ruleset not handling LANDLOCK_ACCESS_FS_REFER (ABI v1) is
      unchanged even if another layer handles LANDLOCK_ACCESS_FS_REFER (i.e.
      ABI v1 precedence).  Make sure rule's absolute access rights are correct
      by testing with and without a matching path.  Add test_rename() and
      test_exchange() helpers.
      
      Extend layout1.inval tests to check that a denied-by-default access
      right is not necessarily part of a domain's handled access rights.
      
      Test coverage for security/landlock is 95.3% of 599 lines according to
      gcc/gcov-11.
      
      Fixes: b91c3e4e
      
       ("landlock: Add support for file reparenting with LANDLOCK_ACCESS_FS_REFER")
      Reviewed-by: default avatarPaul Moore <paul@paul-moore.com>
      Reviewed-by: default avatarGünther Noack <gnoack3000@gmail.com>
      Link: https://lore.kernel.org/r/20220831203840.1370732-1-mic@digikod.net
      Cc: stable@vger.kernel.org
      [mic: Constify and slightly simplify test helpers]
      Signed-off-by: default avatarMickaël Salaün <mic@digikod.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9f78dda3
    • Niek Nooijens's avatar
      USB: serial: ftdi_sio: add Omron CS1W-CIF31 device id · 23475d8e
      Niek Nooijens authored
      commit 001047ea
      
       upstream.
      
      works perfectly with:
      modprobe ftdi_sio
      echo "0590 00b2" | tee
      /sys/module/ftdi_sio/drivers/usb-serial\:ftdi_sio/new_id > /dev/null
      
      but doing this every reboot is a pain in the ass.
      
      Signed-off-by: default avatarNiek Nooijens <niek.nooijens@omron.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      23475d8e
    • Russ Weight's avatar
      firmware_loader: Fix memory leak in firmware upload · baf92485
      Russ Weight authored
      commit 789bba82 upstream.
      
      In the case of firmware-upload, an instance of struct fw_upload is
      allocated in firmware_upload_register(). This data needs to be freed
      in fw_dev_release(). Create a new fw_upload_free() function in
      sysfs_upload.c to handle the firmware-upload specific memory frees
      and incorporate the missing kfree call for the fw_upload structure.
      
      Fixes: 97730bbb
      
       ("firmware_loader: Add firmware-upload support")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarRuss Weight <russell.h.weight@intel.com>
      Link: https://lore.kernel.org/r/20220831002518.465274-1-russell.h.weight@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      baf92485
    • Russ Weight's avatar
      firmware_loader: Fix use-after-free during unregister · d380d409
      Russ Weight authored
      commit 8b40c38e upstream.
      
      In the following code within firmware_upload_unregister(), the call to
      device_unregister() could result in the dev_release function freeing the
      fw_upload_priv structure before it is dereferenced for the call to
      module_put(). This bug was found by the kernel test robot using
      CONFIG_KASAN while running the firmware selftests.
      
        device_unregister(&fw_sysfs->dev);
        module_put(fw_upload_priv->module);
      
      The problem is fixed by copying fw_upload_priv->module to a local variable
      for use when calling device_unregister().
      
      Fixes: 97730bbb
      
       ("firmware_loader: Add firmware-upload support")
      Cc: stable <stable@kernel.org>
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Reviewed-by: default avatarMatthew Gerlach <matthew.gerlach@linux.intel.com>
      Signed-off-by: default avatarRuss Weight <russell.h.weight@intel.com>
      Link: https://lore.kernel.org/r/20220829174557.437047-1-russell.h.weight@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d380d409
    • Johan Hovold's avatar
      misc: fastrpc: fix memory corruption on open · e0578e60
      Johan Hovold authored
      commit d245f43a upstream.
      
      The probe session-duplication overflow check incremented the session
      count also when there were no more available sessions so that memory
      beyond the fixed-size slab-allocated session array could be corrupted in
      fastrpc_session_alloc() on open().
      
      Fixes: f6f9279f
      
       ("misc: fastrpc: Add Qualcomm fastrpc basic driver model")
      Cc: stable@vger.kernel.org      # 5.1
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Link: https://lore.kernel.org/r/20220829080531.29681-3-johan+linaro@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e0578e60
    • Johan Hovold's avatar
      misc: fastrpc: fix memory corruption on probe · c0425c2f
      Johan Hovold authored
      commit 9baa1415 upstream.
      
      Add the missing sanity check on the probed-session count to avoid
      corrupting memory beyond the fixed-size slab-allocated session array
      when there are more than FASTRPC_MAX_SESSIONS sessions defined in the
      devicetree.
      
      Fixes: f6f9279f
      
       ("misc: fastrpc: Add Qualcomm fastrpc basic driver model")
      Cc: stable@vger.kernel.org      # 5.1
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Link: https://lore.kernel.org/r/20220829080531.29681-2-johan+linaro@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c0425c2f
    • Marcus Folkesson's avatar
      iio: adc: mcp3911: use correct formula for AD conversion · 5461b547
      Marcus Folkesson authored
      commit 9e2238e3 upstream.
      
      The ADC conversion is actually not rail-to-rail but with a factor 1.5.
      Make use of this factor when calculating actual voltage.
      
      Fixes: 3a89b289
      
       ("iio: adc: add support for mcp3911")
      Signed-off-by: default avatarMarcus Folkesson <marcus.folkesson@gmail.com>
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Link: https://lore.kernel.org/r/20220722130726.7627-4-marcus.folkesson@gmail.com
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5461b547
    • Marcus Folkesson's avatar
      iio: adc: mcp3911: correct "microchip,device-addr" property · 2838fdab
      Marcus Folkesson authored
      commit cfbd76d5 upstream.
      
      Go for the right property name that is documented in the bindings.
      
      Fixes: 3a89b289
      
       ("iio: adc: add support for mcp3911")
      Signed-off-by: default avatarMarcus Folkesson <marcus.folkesson@gmail.com>
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Link: https://lore.kernel.org/r/20220722130726.7627-3-marcus.folkesson@gmail.com
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2838fdab
    • Matti Vaittinen's avatar
      iio: ad7292: Prevent regulator double disable · 76608a25
      Matti Vaittinen authored
      commit 22b42776 upstream.
      
      The ad7292 tries to add an devm_action for disabling a regulator at
      device detach using devm_add_action_or_reset(). The
      devm_add_action_or_reset() does call the release function should adding
      action fail. The driver inspects the value returned by
      devm_add_action_or_reset() and manually calls regulator_disable() if
      adding the action has failed. This leads to double disable and messes
      the enable count for regulator.
      
      Do not manually call disable if devm_add_action_or_reset() fails.
      
      Fixes: 506d2e31
      
       ("iio: adc: Add driver support for AD7292")
      Signed-off-by: default avatarMatti Vaittinen <mazziesaccount@gmail.com>
      Tested-by: default avatarMarcelo Schmitt <marcelo.schmitt1@gmail.com>
      Link: https://lore.kernel.org/r/Yv9O+9sxU7gAv3vM@fedora
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      76608a25
    • Christophe JAILLET's avatar
      iio: light: cm3605: Fix an error handling path in cm3605_probe() · 3f7f49d8
      Christophe JAILLET authored
      commit 16090554 upstream.
      
      The commit in Fixes also introduced a new error handling path which should
      goto the existing error handling path.
      Otherwise some resources leak.
      
      Fixes: 0d31d91e
      
       ("iio: light: cm3605: Make use of the helper function dev_err_probe()")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Link: https://lore.kernel.org/r/0e186de2c125b3e17476ebf9c54eae4a5d66f994.1659854238.git.christophe.jaillet@wanadoo.fr
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f7f49d8
    • Tetsuo Handa's avatar
      Input: iforce - wake up after clearing IFORCE_XMIT_RUNNING flag · b533b9d3
      Tetsuo Handa authored
      commit 98e01215 upstream.
      
      syzbot is reporting hung task at __input_unregister_device() [1], for
      iforce_close() waiting at wait_event_interruptible() with dev->mutex held
      is blocking input_disconnect_device() from __input_unregister_device().
      
      It seems that the cause is simply that commit c2b27ef6
      
       ("Input:
      iforce - wait for command completion when closing the device") forgot to
      call wake_up() after clear_bit().
      
      Fix this problem by introducing a helper that calls clear_bit() followed
      by wake_up_all().
      
      Reported-by: default avatarsyzbot <syzbot+deb6abc36aad4008f407@syzkaller.appspotmail.com>
      Fixes: c2b27ef6
      
       ("Input: iforce - wait for command completion when closing the device")
      Tested-by: default avatarsyzbot <syzbot+deb6abc36aad4008f407@syzkaller.appspotmail.com>
      Suggested-by: default avatarFabio M. De Francesco <fmdefrancesco@gmail.com>
      Co-developed-by: default avatarHillf Danton <hdanton@sina.com>
      Signed-off-by: default avatarHillf Danton <hdanton@sina.com>
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Link: https://lore.kernel.org/r/887021c3-4f13-40ce-c8b9-aa6e09faa3a7@I-love.SAKURA.ne.jp
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b533b9d3
    • Sherry Sun's avatar
      tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete · 3e05af2f
      Sherry Sun authored
      commit d5a2e083 upstream.
      
      When the user initializes the uart port, and waits for the transmit
      engine to complete in lpuart32_set_termios(), if the UART TX fifo has
      dirty data and the UARTMODIR enable the flow control, the TX fifo may
      never be empty. So here we should disable the flow control first to make
      sure the transmit engin can complete.
      
      Fixes: 380c966c
      
       ("tty: serial: fsl_lpuart: add 32-bit register interface support")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarSherry Sun <sherry.sun@nxp.com>
      Link: https://lore.kernel.org/r/20220821101527.10066-1-sherry.sun@nxp.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e05af2f