1. 31 May, 2019 40 commits
    • Guenter Roeck's avatar
      hwmon: (vt1211) Use request_muxed_region for Super-IO accesses · e2cab965
      Guenter Roeck authored
      [ Upstream commit 14b97ba5 ]
      
      Super-IO accesses may fail on a system with no or unmapped LPC bus.
      
      Also, other drivers may attempt to access the LPC bus at the same time,
      resulting in undefined behavior.
      
      Use request_muxed_region() to ensure that IO access on the requested
      address space is supported, and to ensure that access by multiple drivers
      is synchronized.
      
      Fixes: 2219cd81 ("hwmon/vt1211: Add probing of alternate config index port")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e2cab965
    • Enric Balletbo i Serra's avatar
      PM / devfreq: Fix static checker warning in try_then_request_governor · 6b110830
      Enric Balletbo i Serra authored
      [ Upstream commit b53b0128 ]
      
      The patch 23c7b54c: "PM / devfreq: Fix devfreq_add_device() when
      drivers are built as modules." leads to the following static checker
      warning:
      
          drivers/devfreq/devfreq.c:1043 governor_store()
          warn: 'governor' can also be NULL
      
      The reason is that the try_then_request_governor() function returns both
      error pointers and NULL. It should just return error pointers, so fix
      this by returning a ERR_PTR to the error intead of returning NULL.
      
      Fixes: 23c7b54c ("PM / devfreq: Fix devfreq_add_device() when drivers are built as modules.")
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
      Reviewed-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      Signed-off-by: default avatarMyungJoo Ham <myungjoo.ham@samsung.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6b110830
    • Kan Liang's avatar
      perf/x86/intel/cstate: Add Icelake support · d1546745
      Kan Liang authored
      [ Upstream commit f08c47d1 ]
      
      Icelake uses the same C-state residency events as Sandy Bridge.
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: acme@kernel.org
      Cc: jolsa@kernel.org
      Link: https://lkml.kernel.org/r/20190402194509.2832-10-kan.liang@linux.intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d1546745
    • Kan Liang's avatar
      perf/x86/intel/rapl: Add Icelake support · d2b4a1c7
      Kan Liang authored
      [ Upstream commit b3377c3a ]
      
      Icelake support the same RAPL counters as Skylake.
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: acme@kernel.org
      Cc: jolsa@kernel.org
      Link: https://lkml.kernel.org/r/20190402194509.2832-11-kan.liang@linux.intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d2b4a1c7
    • Kan Liang's avatar
      perf/x86/msr: Add Icelake support · dcec07cd
      Kan Liang authored
      [ Upstream commit cf50d79a ]
      
      Icelake is the same as the existing Skylake parts.
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: acme@kernel.org
      Cc: jolsa@kernel.org
      Link: https://lkml.kernel.org/r/20190402194509.2832-12-kan.liang@linux.intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dcec07cd
    • Eric Biggers's avatar
      fscrypt: use READ_ONCE() to access ->i_crypt_info · 8bcc53fb
      Eric Biggers authored
      [ Upstream commit e37a784d ]
      
      ->i_crypt_info starts out NULL and may later be locklessly set to a
      non-NULL value by the cmpxchg() in fscrypt_get_encryption_info().
      
      But ->i_crypt_info is used directly, which technically is incorrect.
      It's a data race, and it doesn't include the data dependency barrier
      needed to safely dereference the pointer on at least one architecture.
      
      Fix this by using READ_ONCE() instead.  Note: we don't need to use
      smp_load_acquire(), since dereferencing the pointer only requires a data
      dependency barrier, which is already included in READ_ONCE().  We also
      don't need READ_ONCE() in places where ->i_crypt_info is unconditionally
      dereferenced, since it must have already been checked.
      
      Also downgrade the cmpxchg() to cmpxchg_release(), since RELEASE
      semantics are sufficient on the write side.
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8bcc53fb
    • Colin Ian King's avatar
      RDMA/cxgb4: Fix null pointer dereference on alloc_skb failure · d66a2891
      Colin Ian King authored
      [ Upstream commit a6d2a5a9 ]
      
      Currently if alloc_skb fails to allocate the skb a null skb is passed to
      t4_set_arp_err_handler and this ends up dereferencing the null skb.  Avoid
      the NULL pointer dereference by checking for a NULL skb and returning
      early.
      
      Addresses-Coverity: ("Dereference null return")
      Fixes: b38a0ad8 ("RDMA/cxgb4: Set arp error handler for PASS_ACCEPT_RPL messages")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Acked-by: default avatarPotnuri Bharat Teja <bharat@chelsio.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d66a2891
    • Vincenzo Frascino's avatar
      arm64: vdso: Fix clock_getres() for CLOCK_REALTIME · cb9552b9
      Vincenzo Frascino authored
      [ Upstream commit 81fb8736 ]
      
      clock_getres() in the vDSO library has to preserve the same behaviour
      of posix_get_hrtimer_res().
      
      In particular, posix_get_hrtimer_res() does:
      
          sec = 0;
          ns = hrtimer_resolution;
      
      where 'hrtimer_resolution' depends on whether or not high resolution
      timers are enabled, which is a runtime decision.
      
      The vDSO incorrectly returns the constant CLOCK_REALTIME_RES. Fix this
      by exposing 'hrtimer_resolution' in the vDSO datapage and returning that
      instead.
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarVincenzo Frascino <vincenzo.frascino@arm.com>
      [will: Use WRITE_ONCE(), move adr off COARSE path, renumber labels, use 'w' reg]
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cb9552b9
    • Kefeng Wang's avatar
      ACPI/IORT: Reject platform device creation on NUMA node mapping failure · 6388d9ec
      Kefeng Wang authored
      [ Upstream commit 36a2ba07 ]
      
      In a system where, through IORT firmware mappings, the SMMU device is
      mapped to a NUMA node that is not online, the kernel bootstrap results
      in the following crash:
      
        Unable to handle kernel paging request at virtual address 0000000000001388
        Mem abort info:
          ESR = 0x96000004
          Exception class = DABT (current EL), IL = 32 bits
          SET = 0, FnV = 0
          EA = 0, S1PTW = 0
        Data abort info:
          ISV = 0, ISS = 0x00000004
          CM = 0, WnR = 0
        [0000000000001388] user address but active_mm is swapper
        Internal error: Oops: 96000004 [#1] SMP
        Modules linked in:
        CPU: 5 PID: 1 Comm: swapper/0 Not tainted 5.0.0 #15
        pstate: 80c00009 (Nzcv daif +PAN +UAO)
        pc : __alloc_pages_nodemask+0x13c/0x1068
        lr : __alloc_pages_nodemask+0xdc/0x1068
        ...
        Process swapper/0 (pid: 1, stack limit = 0x(____ptrval____))
        Call trace:
         __alloc_pages_nodemask+0x13c/0x1068
         new_slab+0xec/0x570
         ___slab_alloc+0x3e0/0x4f8
         __slab_alloc+0x60/0x80
         __kmalloc_node_track_caller+0x10c/0x478
         devm_kmalloc+0x44/0xb0
         pinctrl_bind_pins+0x4c/0x188
         really_probe+0x78/0x2b8
         driver_probe_device+0x64/0x110
         device_driver_attach+0x74/0x98
         __driver_attach+0x9c/0xe8
         bus_for_each_dev+0x84/0xd8
         driver_attach+0x30/0x40
         bus_add_driver+0x170/0x218
         driver_register+0x64/0x118
         __platform_driver_register+0x54/0x60
         arm_smmu_driver_init+0x24/0x2c
         do_one_initcall+0xbc/0x328
         kernel_init_freeable+0x304/0x3ac
         kernel_init+0x18/0x110
         ret_from_fork+0x10/0x1c
        Code: f90013b5 b9410fa1 1a9f0694 b50014c2 (b9400804)
        ---[ end trace dfeaed4c373a32da ]--
      
      Change the dev_set_proximity() hook prototype so that it returns a
      value and make it return failure if the PXM->NUMA-node mapping
      corresponds to an offline node, fixing the crash.
      Acked-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Link: https://lore.kernel.org/linux-arm-kernel/20190315021940.86905-1-wangkefeng.wang@huawei.com/Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6388d9ec
    • Nicholas Nunley's avatar
      i40e: don't allow changes to HW VLAN stripping on active port VLANs · f7b0c61d
      Nicholas Nunley authored
      [ Upstream commit bfb0ebed ]
      
      Modifying the VLAN stripping options when a port VLAN is configured
      will break traffic for the VSI, and conceptually doesn't make sense,
      so don't allow this.
      Signed-off-by: default avatarNicholas Nunley <nicholas.d.nunley@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f7b0c61d
    • Adam Ludkiewicz's avatar
      i40e: Able to add up to 16 MAC filters on an untrusted VF · decaf301
      Adam Ludkiewicz authored
      [ Upstream commit 06b6e2a2 ]
      
      This patch fixes the problem with the driver being able to add only 7
      multicast MAC address filters instead of 16. The problem is fixed by
      changing the maximum number of MAC address filters to 16+1+1 (two extra
      are needed because the driver uses 1 for unicast MAC address and 1 for
      broadcast).
      Signed-off-by: default avatarAdam Ludkiewicz <adam.ludkiewicz@intel.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      decaf301
    • Ioana Ciocoi Radulescu's avatar
      dpaa2-eth: Fix Rx classification status · 9ea0adc4
      Ioana Ciocoi Radulescu authored
      [ Upstream commit df8e249b ]
      
      Set the Rx flow classification enable flag only if key config
      operation is successful.
      
      Fixes 3f9b5c9 ("dpaa2-eth: Configure Rx flow classification key")
      Signed-off-by: default avatarIoana Radulescu <ruxandra.radulescu@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9ea0adc4
    • Arnd Bergmann's avatar
      phy: ti: usb2: fix OMAP_CONTROL_PHY dependency · 3a416e20
      Arnd Bergmann authored
      [ Upstream commit d41ce98a ]
      
      With randconfig build testing on arm64, we can run into a configuration
      that has CONFIG_OMAP_CONTROL_PHY=m and CONFIG_OMAP_USB2=y, which in turn
      causes a link failure:
      
      drivers/phy/ti/phy-omap-usb2.o: In function `omap_usb_phy_power':
      phy-omap-usb2.c:(.text+0x17c): undefined reference to `omap_control_phy_power'
      
      I could not come up with a good way to correctly describe the relation
      of the two symbols, but if we just select CONFIG_OMAP_CONTROL_PHY
      during compile testing, we can no longer run into the broken configuration.
      
      Fixes: 6777cee3 ("phy: ti: usb2: Add support for AM654 USB2 PHY")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3a416e20
    • Arnd Bergmann's avatar
      phy: mapphone-mdm6600: add gpiolib dependency · 03b812ea
      Arnd Bergmann authored
      [ Upstream commit 208d3423 ]
      
      gcc points out that when CONFIG_GPIOLIB is disabled,
      gpiod_get_array_value_cansleep() returns 0 but fails to set its output:
      
      drivers/phy/motorola/phy-mapphone-mdm6600.c: In function 'phy_mdm6600_status':
      drivers/phy/motorola/phy-mapphone-mdm6600.c:220:24: error: 'values[0]' is used uninitialized in this function [-Werror=uninitialized]
      
      This could be fixed more generally in gpiolib by returning a failure
      code, but for this specific case, the easier workaround is to add a
      gpiolib dependency.
      
      Fixes: 5d1ebbda ("phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      03b812ea
    • Paul Kocialkowski's avatar
      phy: sun4i-usb: Make sure to disable PHY0 passby for peripheral mode · bb4b60cd
      Paul Kocialkowski authored
      [ Upstream commit e6f32efb ]
      
      On platforms where the MUSB and HCI controllers share PHY0, PHY passby
      is required when using the HCI controller with the PHY, but it must be
      disabled when the MUSB controller is used instead.
      
      Without this, PHY0 passby is always enabled, which results in broken
      peripheral mode on such platforms (e.g. H3/H5).
      
      Fixes: ba4bdc9e ("PHY: sunxi: Add driver for sunxi usb phy")
      Signed-off-by: default avatarPaul Kocialkowski <paul.kocialkowski@bootlin.com>
      Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bb4b60cd
    • Evan Green's avatar
      dt-bindings: phy-qcom-qmp: Add UFS PHY reset · bf0280e5
      Evan Green authored
      [ Upstream commit 95cee0b4 ]
      
      Add a required reset to the SDM845 UFS phy to express the PHY reset
      bit inside the UFS controller register space. Before this change, this
      reset was not expressed in the DT, and the driver utilized two different
      callbacks (phy_init and phy_poweron) to implement a two-phase
      initialization procedure that involved deasserting this reset between
      init and poweron. This abused the two callbacks and diluted their
      purpose.
      
      That scheme does not work as regulators cannot be turned off in
      phy_poweroff because they were turned on in init, rather than poweron.
      The net result is that regulators are left on in suspend that shouldn't
      be.
      
      This new scheme gives the UFS reset to the PHY, so that it can fully
      initialize itself in a single callback. We can then turn regulators on
      during poweron and off during poweroff.
      Signed-off-by: default avatarEvan Green <evgreen@chromium.org>
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bf0280e5
    • Russell King's avatar
      drm: etnaviv: avoid DMA API warning when importing buffers · bf18396d
      Russell King authored
      [ Upstream commit 1262cc88 ]
      
      During boot, I get this kernel warning:
      
      WARNING: CPU: 0 PID: 19001 at kernel/dma/debug.c:1301 debug_dma_map_sg+0x284/0x3dc
      etnaviv etnaviv: DMA-API: mapping sg segment longer than device claims to support [len=3145728] [max=65536]
      Modules linked in: ip6t_REJECT nf_reject_ipv6 ip6t_rpfilter xt_tcpudp ipt_REJECT nf_reject_ipv4 xt_conntrack ip_set nfnetlink ebtable_broute ebtable_nat ip6table_raw ip6table_nat nf_nat_ipv6 ip6table_mangle iptable_raw iptable_nat nf_nat_ipv4 nf_nat nf_conntrack nf_defrag_ipv4 nf_defrag_ipv6 libcrc32c iptable_mangle ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter caam_jr error snd_soc_imx_spdif imx_thermal snd_soc_imx_audmux nvmem_imx_ocotp snd_soc_sgtl5000
      caam imx_sdma virt_dma coda rc_cec v4l2_mem2mem snd_soc_fsl_ssi snd_soc_fsl_spdif imx_vdoa imx_pcm_dma videobuf2_dma_contig etnaviv dw_hdmi_cec gpu_sched dw_hdmi_ahb_audio imx6q_cpufreq nfsd sch_fq_codel ip_tables x_tables
      CPU: 0 PID: 19001 Comm: Xorg Not tainted 4.20.0+ #307
      Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
      [<c0019658>] (unwind_backtrace) from [<c001489c>] (show_stack+0x10/0x14)
      [<c001489c>] (show_stack) from [<c07fb420>] (dump_stack+0x9c/0xd4)
      [<c07fb420>] (dump_stack) from [<c00312dc>] (__warn+0xf8/0x124)
      [<c00312dc>] (__warn) from [<c00313d0>] (warn_slowpath_fmt+0x38/0x48)
      [<c00313d0>] (warn_slowpath_fmt) from [<c00b14e8>] (debug_dma_map_sg+0x284/0x3dc)
      [<c00b14e8>] (debug_dma_map_sg) from [<c046eb40>] (drm_gem_map_dma_buf+0xc4/0x13c)
      [<c046eb40>] (drm_gem_map_dma_buf) from [<c04c3314>] (dma_buf_map_attachment+0x38/0x5c)
      [<c04c3314>] (dma_buf_map_attachment) from [<c046e728>] (drm_gem_prime_import_dev+0x74/0x104)
      [<c046e728>] (drm_gem_prime_import_dev) from [<c046e5bc>] (drm_gem_prime_fd_to_handle+0x84/0x17c)
      [<c046e5bc>] (drm_gem_prime_fd_to_handle) from [<c046edd0>] (drm_prime_fd_to_handle_ioctl+0x38/0x4c)
      [<c046edd0>] (drm_prime_fd_to_handle_ioctl) from [<c0460efc>] (drm_ioctl_kernel+0x90/0xc8)
      [<c0460efc>] (drm_ioctl_kernel) from [<c0461114>] (drm_ioctl+0x1e0/0x3b0)
      [<c0461114>] (drm_ioctl) from [<c01cae20>] (do_vfs_ioctl+0x90/0xa48)
      [<c01cae20>] (do_vfs_ioctl) from [<c01cb80c>] (ksys_ioctl+0x34/0x60)
      [<c01cb80c>] (ksys_ioctl) from [<c0009000>] (ret_fast_syscall+0x0/0x28)
      Exception stack(0xd81a9fa8 to 0xd81a9ff0)
      9fa0:                   b6c69c88 bec613f8 00000009 c00c642e bec613f8 b86c4600
      9fc0: b6c69c88 bec613f8 c00c642e 00000036 012762e0 01276348 00000300 012d91f8
      9fe0: b6989f18 bec613dc b697185c b667be5c
      irq event stamp: 47905
      hardirqs last  enabled at (47913): [<c0098824>] console_unlock+0x46c/0x680
      hardirqs last disabled at (47922): [<c0098470>] console_unlock+0xb8/0x680
      softirqs last  enabled at (47754): [<c000a484>] __do_softirq+0x344/0x540
      softirqs last disabled at (47701): [<c0038700>] irq_exit+0x124/0x144
      ---[ end trace af477747acbcc642 ]---
      
      The reason is the contiguous buffer exceeds the default maximum segment
      size of 64K as specified by dma_get_max_seg_size() in
      linux/dma-mapping.h.  Fix this by providing our own segment size, which
      is set to 2GiB to cover the window found in MMUv1 GPUs.
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bf18396d
    • Thomas Gleixner's avatar
      x86/irq/64: Limit IST stack overflow check to #DB stack · 5c907df8
      Thomas Gleixner authored
      [ Upstream commit 7dbcf2b0 ]
      
      Commit
      
        37fe6a42 ("x86: Check stack overflow in detail")
      
      added a broad check for the full exception stack area, i.e. it considers
      the full exception stack area as valid.
      
      That's wrong in two aspects:
      
       1) It does not check the individual areas one by one
      
       2) #DF, NMI and #MCE are not enabling interrupts which means that a
          regular device interrupt cannot happen in their context. In fact if a
          device interrupt hits one of those IST stacks that's a bug because some
          code path enabled interrupts while handling the exception.
      
      Limit the check to the #DB stack and consider all other IST stacks as
      'overflow' or invalid.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
      Cc: Nicolai Stange <nstange@suse.de>
      Cc: Sean Christopherson <sean.j.christopherson@intel.com>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20190414160143.682135110@linutronix.deSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      5c907df8
    • Alan Stern's avatar
      USB: core: Don't unbind interfaces following device reset failure · abda5289
      Alan Stern authored
      [ Upstream commit 381419fa ]
      
      The SCSI core does not like to have devices or hosts unregistered
      while error recovery is in progress.  Trying to do so can lead to
      self-deadlock: Part of the removal code tries to obtain a lock already
      held by the error handler.
      
      This can cause problems for the usb-storage and uas drivers, because
      their error handler routines perform a USB reset, and if the reset
      fails then the USB core automatically goes on to unbind all drivers
      from the device's interfaces -- all while still in the context of the
      SCSI error handler.
      
      As it turns out, practically all the scenarios leading to a USB reset
      failure end up causing a device disconnect (the main error pathway in
      usb_reset_and_verify_device(), at the end of the routine, calls
      hub_port_logical_disconnect() before returning).  As a result, the
      hub_wq thread will soon become aware of the problem and will unbind
      all the device's drivers in its own context, not in the
      error-handler's context.
      
      This means that usb_reset_device() does not need to call
      usb_unbind_and_rebind_marked_interfaces() in cases where
      usb_reset_and_verify_device() has returned an error, because hub_wq
      will take care of everything anyway.
      
      This particular problem was observed in somewhat artificial
      circumstances, by using usbfs to tell a hub to power-down a port
      connected to a USB-3 mass storage device using the UAS protocol.  With
      the port turned off, the currently executing command timed out and the
      error handler started running.  The USB reset naturally failed,
      because the hub port was off, and the error handler deadlocked as
      described above.  Not carrying out the call to
      usb_unbind_and_rebind_marked_interfaces() fixes this issue.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-by: default avatarKento Kobayashi <Kento.A.Kobayashi@sony.com>
      Tested-by: default avatarKento Kobayashi <Kento.A.Kobayashi@sony.com>
      CC: Bart Van Assche <bvanassche@acm.org>
      CC: Martin K. Petersen <martin.petersen@oracle.com>
      CC: Jacky Cao <Jacky.Cao@sony.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      abda5289
    • Julian Wiedmann's avatar
      s390/qeth: handle error from qeth_update_from_chp_desc() · dfb23004
      Julian Wiedmann authored
      [ Upstream commit a4cdc9ba ]
      
      Subsequent code relies on the values that qeth_update_from_chp_desc()
      reads from the CHP descriptor. Rather than dealing with weird errors
      later on, just handle it properly here.
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dfb23004
    • Mika Westerberg's avatar
      thunderbolt: Take domain lock in switch sysfs attribute callbacks · 6a3d844b
      Mika Westerberg authored
      [ Upstream commit 09f11b6c ]
      
      switch_lock was introduced because it allowed serialization of device
      authorization requests from userspace without need to take the big
      domain lock (tb->lock). This was fine because device authorization with
      ICM is just one command that is sent to the firmware. Now that we start
      to handle all tunneling in the driver switch_lock is not enough because
      we need to walk over the topology to establish paths.
      
      For this reason drop switch_lock from the driver completely in favour of
      big domain lock.
      
      There is one complication, though. If userspace is waiting for the lock
      in tb_switch_set_authorized(), it keeps the device_del() from removing
      the sysfs attribute because it waits for active users to release the
      attribute first which leads into following splat:
      
          INFO: task kworker/u8:3:73 blocked for more than 61 seconds.
                Tainted: G        W         5.1.0-rc1+ #244
          "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
          kworker/u8:3    D12976    73      2 0x80000000
          Workqueue: thunderbolt0 tb_handle_hotplug [thunderbolt]
          Call Trace:
           ? __schedule+0x2e5/0x740
           ? _raw_spin_lock_irqsave+0x12/0x40
           ? prepare_to_wait_event+0xc5/0x160
           schedule+0x2d/0x80
           __kernfs_remove.part.17+0x183/0x1f0
           ? finish_wait+0x80/0x80
           kernfs_remove_by_name_ns+0x4a/0x90
           remove_files.isra.1+0x2b/0x60
           sysfs_remove_group+0x38/0x80
           sysfs_remove_groups+0x24/0x40
           device_remove_attrs+0x3d/0x70
           device_del+0x14c/0x360
           device_unregister+0x15/0x50
           tb_switch_remove+0x9e/0x1d0 [thunderbolt]
           tb_handle_hotplug+0x119/0x5a0 [thunderbolt]
           ? process_one_work+0x1b7/0x420
           process_one_work+0x1b7/0x420
           worker_thread+0x37/0x380
           ? _raw_spin_unlock_irqrestore+0xf/0x30
           ? process_one_work+0x420/0x420
           kthread+0x118/0x130
           ? kthread_create_on_node+0x60/0x60
           ret_from_fork+0x35/0x40
      
      We deal this by following what network stack did for some of their
      attributes and use mutex_trylock() with restart_syscall(). This makes
      userspace release the attribute allowing sysfs attribute removal to
      progress before the write is restarted and eventually fail when the
      attribute is removed.
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6a3d844b
    • Nicholas Piggin's avatar
      irq_work: Do not raise an IPI when queueing work on the local CPU · 5f335f7c
      Nicholas Piggin authored
      [ Upstream commit 471ba0e6 ]
      
      The QEMU PowerPC/PSeries machine model was not expecting a self-IPI,
      and it may be a bit surprising thing to do, so have irq_work_queue_on
      do local queueing when target is the current CPU.
      Suggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Reported-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Tested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarFrederic Weisbecker <frederic@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= <clg@kaod.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/20190409093403.20994-1-npiggin@gmail.com
      [ Simplified the preprocessor comments.
        Fixed unbalanced curly brackets pointed out by Thomas. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5f335f7c
    • Luca Weiss's avatar
      drm/msm: Fix NULL pointer dereference · a02a8367
      Luca Weiss authored
      [ Upstream commit 7603df38 ]
      
      [    3.707412] Unable to handle kernel NULL pointer dereference at virtual address 0000009c
      [    3.714511] pgd = (ptrval)
      [    3.722742] [0000009c] *pgd=00000000
      [    3.725238] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
      [    3.728968] Modules linked in:
      [    3.734265] CPU: 3 PID: 112 Comm: kworker/3:2 Tainted: G        W         5.0.0-rc7-00183-g06a1c31df9eb #4
      [    3.737142] Hardware name: Generic DT based system
      [    3.746778] Workqueue: events deferred_probe_work_func
      [    3.751542] PC is at msm_gem_map_vma+0x3c/0xac
      [    3.756669] LR is at msm_gem_get_and_pin_iova+0xd8/0x134
      [    3.761086] pc : [<c07d3b7c>]    lr : [<c07d14f8>]    psr: 60000013
      [    3.766560] sp : ee297be8  ip : ed9ab1c0  fp : ed93b800
      [    3.772546] r10: ee35e180  r9 : 00000000  r8 : ee297c80
      [    3.777752] r7 : 00000000  r6 : 7c100000  r5 : 00000000  r4 : ee35e180
      [    3.782968] r3 : 00000001  r2 : 00000003  r1 : ee35e180  r0 : 00000000
      [    3.789562] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
      [    3.796079] Control: 10c5787d  Table: 2e3a806a  DAC: 00000051
      [    3.803282] Process kworker/3:2 (pid: 112, stack limit = 0x(ptrval))
      [    3.809006] Stack: (0xee297be8 to 0xee298000)
      [    3.815445] 7be0:                   00000000 c1108c48 eda8c000 00000003 eda8c0fc c1108c48
      [    3.819715] 7c00: eda8c000 00000003 eda8c0fc c07d14f8 00000001 c07d1100 7c100000 00000000
      [    3.827873] 7c20: eda8c000 bb7ffb78 00000000 eda8c000 00000000 00000000 c0c8b1d4 ee3bfa00
      [    3.836037] 7c40: ee3b9800 c07d1684 00000000 c1108c48 ee0d7810 ee3b9800 c0c8b1d4 c07d222c
      [    3.844193] 7c60: ee3bfd84 ee297c80 00000000 c0b1d5b0 ee3bfc40 c07dcfd8 ee3bfd84 ee297c80
      [    3.852357] 7c80: 0000006d ee3bfc40 ee0d7810 bb7ffb78 c0c8b1d4 00000000 ee3bfc40 c07ddb48
      [    3.860516] 7ca0: 00002004 c0eba384 ee3bfc40 c079eba0 ee3bd040 ee3b9800 00000001 ed93b800
      [    3.868673] 7cc0: ed9aa100 c07db7e8 ee3bf240 ed9a6500 00000001 ee3b9800 ee3bf2d4 c07a0a30
      [    3.876834] 7ce0: ed93b800 7d100000 c1108c48 ee0d7610 ee3b9800 ed93b800 c1108c48 00000000
      [    3.884991] 7d00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      [    3.893151] 7d20: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 bb7ffb78
      [    3.901310] 7d40: c12113c4 ed93b800 ee3b9800 c1108c48 ee9eec10 00000000 ed93b800 7d100000
      [    3.909472] 7d60: eff7b000 c07cf748 7d100000 00000000 c0e9a350 c0b1d5b0 c12113c4 c0961e40
      [    3.917633] 7d80: c12113c4 40000113 eeff4bec c0ebe004 00000019 c0b1d230 ee9eeda8 60000113
      [    3.925791] 7da0: ee35d300 ee9eeda8 c07ce260 bb7ffb78 c07ce260 ee35d2c0 00000028 00000002
      [    3.933950] 7dc0: eeb76280 c118f884 ee0be640 c11c6128 c07ce260 c07ea4ac 00000000 c0962b48
      [    3.942108] 7de0: c118f868 00000001 c0ebbc98 ee35d2c0 00000000 eeb76280 00000000 c118f87c
      [    3.950270] 7e00: ee35d2c0 00000000 c11c63e0 c118f694 00000019 c07ea5d0 ee0d7810 00000000
      [    3.958430] 7e20: c118f694 00000000 00000000 c07f2b0c c120f55c ee0d7810 c120f560 00000000
      [    3.966590] 7e40: 00000000 c07f08c4 c07f0e8c ee0d7810 c11ba3d0 ee0d7810 c118f694 c07f0e8c
      [    3.974748] 7e60: c1108c48 00000001 c0ebc3cc c11c63f8 c11ba3d0 c07f0c08 00000001 c07f2f8c
      [    3.982908] 7e80: c118f694 00000000 ee297ed4 c07f0e8c c1108c48 00000001 c0ebc3cc c11c63f8
      [    3.991068] 7ea0: c11ba3d0 c07ee8a0 c11ba3d0 ee82686c ee0baf38 bb7ffb78 ee0d7810 ee0d7810
      [    3.999227] 7ec0: c1108c48 ee0d7844 c118faac c07f05b0 ee0d7810 ee0d7810 00000001 bb7ffb78
      [    4.007389] 7ee0: ee0d7810 ee0d7810 c118fd18 c118faac c11c63e0 c07ef7d0 ee0d7810 c118fa90
      [    4.015548] 7f00: c118fa90 c07efd68 c118fac8 ee27fe00 eefd9c80 eefdcd00 00000000 c118facc
      [    4.023708] 7f20: 00000000 c033c038 eefd9c80 eefd9c80 00000008 ee27fe00 ee27fe14 eefd9c80
      [    4.031866] 7f40: 00000008 c1103d00 eefd9c98 ee296000 eefd9c80 c033ce54 ee907eac c0b1d230
      [    4.040026] 7f60: ee907eac eea24440 ee285000 00000000 ee296000 ee27fe00 c033ce24 eea2445c
      [    4.048188] 7f80: ee907eac c0341db0 00000000 ee285000 c0341c8c 00000000 00000000 00000000
      [    4.056346] 7fa0: 00000000 00000000 00000000 c03010e8 00000000 00000000 00000000 00000000
      [    4.064505] 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      [    4.072665] 7fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
      [    4.080828] [<c07d3b7c>] (msm_gem_map_vma) from [<c07d14f8>] (msm_gem_get_and_pin_iova+0xd8/0x134)
      [    4.088983] [<c07d14f8>] (msm_gem_get_and_pin_iova) from [<c07d1684>] (_msm_gem_kernel_new+0x38/0xac)
      [    4.097839] [<c07d1684>] (_msm_gem_kernel_new) from [<c07d222c>] (msm_gem_kernel_new+0x24/0x2c)
      [    4.107130] [<c07d222c>] (msm_gem_kernel_new) from [<c07dcfd8>] (dsi_tx_buf_alloc_6g+0x44/0x90)
      [    4.115631] [<c07dcfd8>] (dsi_tx_buf_alloc_6g) from [<c07ddb48>] (msm_dsi_host_modeset_init+0x80/0x104)
      [    4.124313] [<c07ddb48>] (msm_dsi_host_modeset_init) from [<c07db7e8>] (msm_dsi_modeset_init+0x34/0x1c0)
      [    4.133691] [<c07db7e8>] (msm_dsi_modeset_init) from [<c07a0a30>] (mdp5_kms_init+0x764/0x7e0)
      [    4.143409] [<c07a0a30>] (mdp5_kms_init) from [<c07cf748>] (msm_drm_bind+0x56c/0x740)
      [    4.151824] [<c07cf748>] (msm_drm_bind) from [<c07ea4ac>] (try_to_bring_up_master+0x238/0x2b4)
      [    4.159636] [<c07ea4ac>] (try_to_bring_up_master) from [<c07ea5d0>] (component_add+0xa8/0x170)
      [    4.168146] [<c07ea5d0>] (component_add) from [<c07f2b0c>] (platform_drv_probe+0x48/0x9c)
      [    4.176737] [<c07f2b0c>] (platform_drv_probe) from [<c07f08c4>] (really_probe+0x278/0x404)
      [    4.184981] [<c07f08c4>] (really_probe) from [<c07f0c08>] (driver_probe_device+0x78/0x1c0)
      [    4.193147] [<c07f0c08>] (driver_probe_device) from [<c07ee8a0>] (bus_for_each_drv+0x74/0xb8)
      [    4.201389] [<c07ee8a0>] (bus_for_each_drv) from [<c07f05b0>] (__device_attach+0xd0/0x164)
      [    4.209984] [<c07f05b0>] (__device_attach) from [<c07ef7d0>] (bus_probe_device+0x84/0x8c)
      [    4.218143] [<c07ef7d0>] (bus_probe_device) from [<c07efd68>] (deferred_probe_work_func+0x48/0xc4)
      [    4.226398] [<c07efd68>] (deferred_probe_work_func) from [<c033c038>] (process_one_work+0x204/0x574)
      [    4.235254] [<c033c038>] (process_one_work) from [<c033ce54>] (worker_thread+0x30/0x560)
      [    4.244534] [<c033ce54>] (worker_thread) from [<c0341db0>] (kthread+0x124/0x154)
      [    4.252606] [<c0341db0>] (kthread) from [<c03010e8>] (ret_from_fork+0x14/0x2c)
      [    4.259966] Exception stack(0xee297fb0 to 0xee297ff8)
      [    4.266998] 7fa0:                                     00000000 00000000 00000000 00000000
      [    4.272143] 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      [    4.280297] 7fe0: 00000000 00000000 00000000 00000000 00000013 00000000
      [    4.288451] Code: e5813080 1a000013 e3a03001 e5c4307c (e590009c)
      [    4.294933] ---[ end trace 18729cc2bca2b4b3 ]---
      Signed-off-by: default avatarLuca Weiss <luca@z3ntu.xyz>
      Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a02a8367
    • Sean Paul's avatar
      drm/msm: dpu: Don't set frame_busy_mask for async updates · 48f41424
      Sean Paul authored
      [ Upstream commit f98baa31 ]
      
      The frame_busy mask is used in frame_done event handling, which is not
      invoked for async commits. So an async commit will leave the
      frame_busy mask populated after it completes and future commits will start
      with the busy mask incorrect.
      
      This showed up on disable after cursor move. I was hitting the "this should
      not happen" comment in the frame event worker since frame_busy was set,
      we queued the event, but there were no frames pending (since async
      also doesn't set that).
      Reviewed-by: default avatarFritz Koenig <frkoenig@google.com>
      Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190130163220.138637-1-sean@poorly.runSigned-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      48f41424
    • Wen Yang's avatar
      drm/msm: a5xx: fix possible object reference leak · 15180fd9
      Wen Yang authored
      [ Upstream commit 6cd5235c ]
      
      The call to of_get_child_by_name returns a node pointer with refcount
      incremented thus it must be explicitly decremented after the last
      usage.
      
      Detected by coccinelle with the following warnings:
      drivers/gpu/drm/msm/adreno/a5xx_gpu.c:57:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 47, but without a corresponding object release within this function.
      drivers/gpu/drm/msm/adreno/a5xx_gpu.c:66:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 47, but without a corresponding object release within this function.
      drivers/gpu/drm/msm/adreno/a5xx_gpu.c:118:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 47, but without a corresponding object release within this function.
      drivers/gpu/drm/msm/adreno/a5xx_gpu.c:57:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 51, but without a corresponding object release within this function.
      drivers/gpu/drm/msm/adreno/a5xx_gpu.c:66:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 51, but without a corresponding object release within this function.
      drivers/gpu/drm/msm/adreno/a5xx_gpu.c:118:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 51, but without a corresponding object release within this function.
      Signed-off-by: default avatarWen Yang <wen.yang99@zte.com.cn>
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: Sean Paul <sean@poorly.run>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Jordan Crouse <jcrouse@codeaurora.org>
      Cc: Mamta Shukla <mamtashukla555@gmail.com>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: Sharat Masetty <smasetty@codeaurora.org>
      Cc: linux-arm-msm@vger.kernel.org
      Cc: dri-devel@lists.freedesktop.org
      Cc: freedreno@lists.freedesktop.org
      Cc: linux-kernel@vger.kernel.org (open list)
      Reviewed-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
      Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      15180fd9
    • Jeykumar Sankaran's avatar
      drm/msm/dpu: release resources on modeset failure · aa6b53c2
      Jeykumar Sankaran authored
      [ Upstream commit a7fcc323 ]
      
      release resources allocated in mode_set if any of
      the hw check fails. Most of these checks are not
      necessary and they will be removed in the follow up
      patches with state based resource allocations.
      Signed-off-by: default avatarJeykumar Sankaran <jsanka@codeaurora.org>
      Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/1550107156-17625-4-git-send-email-jsanka@codeaurora.orgSigned-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aa6b53c2
    • Nicholas Mc Guire's avatar
      staging: vc04_services: handle kzalloc failure · 216fb3cc
      Nicholas Mc Guire authored
      [ Upstream commit a5112277 ]
      
      The kzalloc here was being used without checking the return - if the
      kzalloc fails return VCHIQ_ERROR. The call-site of
      vchiq_platform_init_state() vchiq_init_state() was not responding
      to an allocation failure so checks for != VCHIQ_SUCCESS
      and pass VCHIQ_ERROR up to vchiq_platform_init() which then
      will fail with -EINVAL.
      Signed-off-by: default avatarNicholas Mc Guire <hofrat@osadl.org>
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Acked-By: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      216fb3cc
    • Konstantin Khlebnikov's avatar
      sched/core: Handle overflow in cpu_shares_write_u64 · 16e061eb
      Konstantin Khlebnikov authored
      [ Upstream commit 5b61d50a ]
      
      Bit shift in scale_load() could overflow shares. This patch saturates
      it to MAX_SHARES like following sched_group_set_shares().
      
      Example:
      
       # echo 9223372036854776832 > cpu.shares
       # cat cpu.shares
      
      Before patch: 1024
      After pattch: 262144
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/155125501891.293431.3345233332801109696.stgit@buzzSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      16e061eb
    • Konstantin Khlebnikov's avatar
      sched/rt: Check integer overflow at usec to nsec conversion · b698e991
      Konstantin Khlebnikov authored
      [ Upstream commit 1a010e29 ]
      
      Example of unhandled overflows:
      
       # echo 18446744073709651 > cpu.rt_runtime_us
       # cat cpu.rt_runtime_us
       99
      
       # echo 18446744073709900 > cpu.rt_period_us
       # cat cpu.rt_period_us
       348
      
      After this patch they will fail with -EINVAL.
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/155125501739.293431.5252197504404771496.stgit@buzzSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b698e991
    • Konstantin Khlebnikov's avatar
      sched/core: Check quota and period overflow at usec to nsec conversion · dcfdbf77
      Konstantin Khlebnikov authored
      [ Upstream commit 1a8b4540 ]
      
      Large values could overflow u64 and pass following sanity checks.
      
       # echo 18446744073750000 > cpu.cfs_period_us
       # cat cpu.cfs_period_us
       40448
      
       # echo 18446744073750000 > cpu.cfs_quota_us
       # cat cpu.cfs_quota_us
       40448
      
      After this patch they will fail with -EINVAL.
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/155125502079.293431.3947497929372138600.stgit@buzzSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dcfdbf77
    • Roman Gushchin's avatar
      cgroup: protect cgroup->nr_(dying_)descendants by css_set_lock · fa317078
      Roman Gushchin authored
      [ Upstream commit 4dcabece ]
      
      The number of descendant cgroups and the number of dying
      descendant cgroups are currently synchronized using the cgroup_mutex.
      
      The number of descendant cgroups will be required by the cgroup v2
      freezer, which will use it to determine if a cgroup is frozen
      (depending on total number of descendants and number of frozen
      descendants). It's not always acceptable to grab the cgroup_mutex,
      especially from quite hot paths (e.g. exit()).
      
      To avoid this, let's additionally synchronize these counters using
      the css_set_lock.
      
      So, it's safe to read these counters with either cgroup_mutex or
      css_set_lock locked, and for changing both locks should be acquired.
      Signed-off-by: default avatarRoman Gushchin <guro@fb.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: kernel-team@fb.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fa317078
    • Sebastian Andrzej Siewior's avatar
      random: add a spinlock_t to struct batched_entropy · 50a41f60
      Sebastian Andrzej Siewior authored
      [ Upstream commit b7d5dc21 ]
      
      The per-CPU variable batched_entropy_uXX is protected by get_cpu_var().
      This is just a preempt_disable() which ensures that the variable is only
      from the local CPU. It does not protect against users on the same CPU
      from another context. It is possible that a preemptible context reads
      slot 0 and then an interrupt occurs and the same value is read again.
      
      The above scenario is confirmed by lockdep if we add a spinlock:
      | ================================
      | WARNING: inconsistent lock state
      | 5.1.0-rc3+ #42 Not tainted
      | --------------------------------
      | inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
      | ksoftirqd/9/56 [HC0[0]:SC1[1]:HE0:SE0] takes:
      | (____ptrval____) (batched_entropy_u32.lock){+.?.}, at: get_random_u32+0x3e/0xe0
      | {SOFTIRQ-ON-W} state was registered at:
      |   _raw_spin_lock+0x2a/0x40
      |   get_random_u32+0x3e/0xe0
      |   new_slab+0x15c/0x7b0
      |   ___slab_alloc+0x492/0x620
      |   __slab_alloc.isra.73+0x53/0xa0
      |   kmem_cache_alloc_node+0xaf/0x2a0
      |   copy_process.part.41+0x1e1/0x2370
      |   _do_fork+0xdb/0x6d0
      |   kernel_thread+0x20/0x30
      |   kthreadd+0x1ba/0x220
      |   ret_from_fork+0x3a/0x50
      …
      | other info that might help us debug this:
      |  Possible unsafe locking scenario:
      |
      |        CPU0
      |        ----
      |   lock(batched_entropy_u32.lock);
      |   <Interrupt>
      |     lock(batched_entropy_u32.lock);
      |
      |  *** DEADLOCK ***
      |
      | stack backtrace:
      | Call Trace:
      …
      |  kmem_cache_alloc_trace+0x20e/0x270
      |  ipmi_alloc_recv_msg+0x16/0x40
      …
      |  __do_softirq+0xec/0x48d
      |  run_ksoftirqd+0x37/0x60
      |  smpboot_thread_fn+0x191/0x290
      |  kthread+0xfe/0x130
      |  ret_from_fork+0x3a/0x50
      
      Add a spinlock_t to the batched_entropy data structure and acquire the
      lock while accessing it. Acquire the lock with disabled interrupts
      because this function may be used from interrupt context.
      
      Remove the batched_entropy_reset_lock lock. Now that we have a lock for
      the data scructure, we can access it from a remote CPU.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      50a41f60
    • Jon DeVree's avatar
      random: fix CRNG initialization when random.trust_cpu=1 · 6f9c63bc
      Jon DeVree authored
      [ Upstream commit fe6f1a6a ]
      
      When the system boots with random.trust_cpu=1 it doesn't initialize the
      per-NUMA CRNGs because it skips the rest of the CRNG startup code. This
      means that the code from 1e7f583a ("random: make /dev/urandom scalable
      for silly userspace programs") is not used when random.trust_cpu=1.
      
      crash> dmesg | grep random:
      [    0.000000] random: get_random_bytes called from start_kernel+0x94/0x530 with crng_init=0
      [    0.314029] random: crng done (trusting CPU's manufacturer)
      crash> print crng_node_pool
      $6 = (struct crng_state **) 0x0
      
      After adding the missing call to numa_crng_init() the per-NUMA CRNGs are
      initialized again:
      
      crash> dmesg | grep random:
      [    0.000000] random: get_random_bytes called from start_kernel+0x94/0x530 with crng_init=0
      [    0.314031] random: crng done (trusting CPU's manufacturer)
      crash> print crng_node_pool
      $1 = (struct crng_state **) 0xffff9a915f4014a0
      
      The call to invalidate_batched_entropy() was also missing. This is
      important for architectures like PPC and S390 which only have the
      arch_get_random_seed_* functions.
      
      Fixes: 39a8883a ("random: add a config option to trust the CPU's hwrng")
      Signed-off-by: default avatarJon DeVree <nuxi@vault24.org>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6f9c63bc
    • Russell Currey's avatar
      powerpc/64: Fix booting large kernels with STRICT_KERNEL_RWX · ee079354
      Russell Currey authored
      [ Upstream commit 56c46bba ]
      
      With STRICT_KERNEL_RWX enabled anything marked __init is placed at a 16M
      boundary.  This is necessary so that it can be repurposed later with
      different permissions.  However, in kernels with text larger than 16M,
      this pushes early_setup past 32M, incapable of being reached by the
      branch instruction.
      
      Fix this by setting the CTR and branching there instead.
      
      Fixes: 1e0fc9d1 ("powerpc/Kconfig: Enable STRICT_KERNEL_RWX for some configs")
      Signed-off-by: default avatarRussell Currey <ruscur@russell.cc>
      [mpe: Fix it to work on BE by using DOTSYM()]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ee079354
    • Nathan Lynch's avatar
      powerpc/numa: improve control of topology updates · c4fb49c7
      Nathan Lynch authored
      [ Upstream commit 2d4d9b30 ]
      
      When booted with "topology_updates=no", or when "off" is written to
      /proc/powerpc/topology_updates, NUMA reassignments are inhibited for
      PRRN and VPHN events. However, migration and suspend unconditionally
      re-enable reassignments via start_topology_update(). This is
      incoherent.
      
      Check the topology_updates_enabled flag in
      start/stop_topology_update() so that callers of those APIs need not be
      aware of whether reassignments are enabled. This allows the
      administrative decision on reassignments to remain in force across
      migrations and suspensions.
      Signed-off-by: default avatarNathan Lynch <nathanl@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c4fb49c7
    • Yufen Yu's avatar
      block: fix use-after-free on gendisk · 5090dd8f
      Yufen Yu authored
      [ Upstream commit 2c88e3c7 ]
      
      commit 2da78092 "block: Fix dev_t minor allocation lifetime"
      specifically moved blk_free_devt(dev->devt) call to part_release()
      to avoid reallocating device number before the device is fully
      shutdown.
      
      However, it can cause use-after-free on gendisk in get_gendisk().
      We use md device as example to show the race scenes:
      
      Process1		Worker			Process2
      md_free
      						blkdev_open
      del_gendisk
        add delete_partition_work_fn() to wq
        						__blkdev_get
      						get_gendisk
      put_disk
        disk_release
          kfree(disk)
          						find part from ext_devt_idr
      						get_disk_and_module(disk)
          					  	cause use after free
      
          			delete_partition_work_fn
      			put_device(part)
          		  	part_release
      		    	remove part from ext_devt_idr
      
      Before <devt, hd_struct pointer> is removed from ext_devt_idr by
      delete_partition_work_fn(), we can find the devt and then access
      gendisk by hd_struct pointer. But, if we access the gendisk after
      it have been freed, it can cause in use-after-freeon gendisk in
      get_gendisk().
      
      We fix this by adding a new helper blk_invalidate_devt() in
      delete_partition() and del_gendisk(). It replaces hd_struct
      pointer in idr with value 'NULL', and deletes the entry from
      idr in part_release() as we do now.
      
      Thanks to Jan Kara for providing the solution and more clear comments
      for the code.
      
      Fixes: 2da78092 ("block: Fix dev_t minor allocation lifetime")
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Reviewed-by: default avatarKeith Busch <keith.busch@intel.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Suggested-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarYufen Yu <yuyufen@huawei.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5090dd8f
    • Fabrice Gasnier's avatar
      iio: adc: stm32-dfsdm: fix unmet direct dependencies detected · 3404d705
      Fabrice Gasnier authored
      [ Upstream commit ba7ecfe4 ]
      
      This fixes unmet direct dependencies seen when CONFIG_STM32_DFSDM_ADC
      is selected:
      
      WARNING: unmet direct dependencies detected for IIO_BUFFER_HW_CONSUMER
        Depends on [n]: IIO [=y] && IIO_BUFFER [=n]
        Selected by [y]:
        - STM32_DFSDM_ADC [=y] && IIO [=y] && (ARCH_STM32 [=y] && OF [=y] ||
          COMPILE_TEST [=n])
      
      Fixes: e2e6771c ("IIO: ADC: add STM32 DFSDM sigma delta ADC support")
      Signed-off-by: default avatarFabrice Gasnier <fabrice.gasnier@st.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3404d705
    • Dan Carpenter's avatar
      media: pvrusb2: Prevent a buffer overflow · 5ffb30e6
      Dan Carpenter authored
      [ Upstream commit c1ced46c ]
      
      The ctrl_check_input() function is called from pvr2_ctrl_range_check().
      It's supposed to validate user supplied input and return true or false
      depending on whether the input is valid or not.  The problem is that
      negative shifts or shifts greater than 31 are undefined in C.  In
      practice with GCC they result in shift wrapping so this function returns
      true for some inputs which are not valid and this could result in a
      buffer overflow:
      
          drivers/media/usb/pvrusb2/pvrusb2-ctrl.c:205 pvr2_ctrl_get_valname()
          warn: uncapped user index 'names[val]'
      
      The cptr->hdw->input_allowed_mask mask is configured in pvr2_hdw_create()
      and the highest valid bit is BIT(4).
      
      Fixes: 7fb20fa3 ("V4L/DVB (7299): pvrusb2: Improve logic which handles input choice availability")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5ffb30e6
    • Shuah Khan's avatar
      media: au0828: Fix NULL pointer dereference in au0828_analog_stream_enable() · 02dce75a
      Shuah Khan authored
      [ Upstream commit 898bc40b ]
      
      Fix au0828_analog_stream_enable() to check if device is in the right
      state first. When unbind happens while bind is in progress, usbdev
      pointer could be invalid in au0828_analog_stream_enable() and a call
      to usb_ifnum_to_if() will result in the null pointer dereference.
      
      This problem is found with the new media_dev_allocator.sh test.
      
      kernel: [  590.359623] BUG: unable to handle kernel NULL pointer dereference at 00000000000004e8
      kernel: [  590.359627] #PF error: [normal kernel read fault]
      kernel: [  590.359629] PGD 0 P4D 0
      kernel: [  590.359632] Oops: 0000 [#1] SMP PTI
      kernel: [  590.359634] CPU: 3 PID: 1458 Comm: v4l_id Not tainted 5.1.0-rc2+ #30
      kernel: [  590.359636] Hardware name: Dell Inc. OptiPlex 7 90/0HY9JP, BIOS A18 09/24/2013
      kernel: [  590.359641] RIP: 0010:usb_ifnum_to_if+0x6/0x60
      kernel: [  590.359643] Code: 5d 41 5e 41 5f 5d c3 48 83 c4
       10 b8 fa ff ff ff 5b 41 5c 41 5d 41 5e 41 5f 5d c3 b8 fa ff ff ff c3 0f 1f 00 6
      6 66 66 66 90 55 <48> 8b 97 e8 04 00 00 48 89 e5 48 85 d2 74 41 0f b6 4a 04 84 c
      9 74
      kernel: [  590.359645] RSP: 0018:ffffad3cc3c1fc00 EFLAGS: 00010246
      kernel: [  590.359646] RAX: 0000000000000000 RBX: ffff8ded b1f3c000 RCX: 1f377e4500000000
      kernel: [  590.359648] RDX: ffff8dedfa3a6b50 RSI: 00000000 00000000 RDI: 0000000000000000
      kernel: [  590.359649] RBP: ffffad3cc3c1fc28 R08: 00000000 8574acc2 R09: ffff8dedfa3a6b50
      kernel: [  590.359650] R10: 0000000000000001 R11: 00000000 00000000 R12: 0000000000000000
      kernel: [  590.359652] R13: ffff8dedb1f3f0f0 R14: ffffffff adcf7ec0 R15: 0000000000000000
      kernel: [  590.359654] FS:  00007f7917198540(0000) GS:ffff 8dee258c0000(0000) knlGS:0000000000000000
      kernel: [  590.359655] CS:  0010 DS: 0000 ES: 0000 CR0: 00 00000080050033
      kernel: [  590.359657] CR2: 00000000000004e8 CR3: 00000001 a388e002 CR4: 00000000000606e0
      kernel: [  590.359658] Call Trace:
      kernel: [  590.359664]  ? au0828_analog_stream_enable+0x2c/0x180
      kernel: [  590.359666]  au0828_v4l2_open+0xa4/0x110
      kernel: [  590.359670]  v4l2_open+0x8b/0x120
      kernel: [  590.359674]  chrdev_open+0xa6/0x1c0
      kernel: [  590.359676]  ? cdev_put.part.3+0x20/0x20
      kernel: [  590.359678]  do_dentry_open+0x1f6/0x360
      kernel: [  590.359681]  vfs_open+0x2f/0x40
      kernel: [  590.359684]  path_openat+0x299/0xc20
      kernel: [  590.359688]  do_filp_open+0x9b/0x110
      kernel: [  590.359695]  ? _raw_spin_unlock+0x27/0x40
      kernel: [  590.359697]  ? __alloc_fd+0xb2/0x160
      kernel: [  590.359700]  do_sys_open+0x1ba/0x260
      kernel: [  590.359702]  ? do_sys_open+0x1ba/0x260
      kernel: [  590.359712]  __x64_sys_openat+0x20/0x30
      kernel: [  590.359715]  do_syscall_64+0x5a/0x120
      kernel: [  590.359718]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      Signed-off-by: default avatarShuah Khan <shuah@kernel.org>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      02dce75a
    • Hugues Fruchet's avatar
      media: stm32-dcmi: fix crash when subdev do not expose any formats · 74a8b114
      Hugues Fruchet authored
      [ Upstream commit 33dfeb62 ]
      
      Do not access sd_formats[] if num_of_sd_formats is zero, ie
      subdev sensor didn't expose any formats.
      Signed-off-by: default avatarHugues Fruchet <hugues.fruchet@st.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      74a8b114