1. 11 Jun, 2014 9 commits
  2. 07 Jun, 2014 31 commits
    • Greg Kroah-Hartman's avatar
      Linux 3.14.6 · a1bc295d
      Greg Kroah-Hartman authored
      a1bc295d
    • Thomas Gleixner's avatar
      futex: Make lookup_pi_state more robust · b1f9d594
      Thomas Gleixner authored
      commit 54a21788 upstream.
      
      The current implementation of lookup_pi_state has ambigous handling of
      the TID value 0 in the user space futex.  We can get into the kernel
      even if the TID value is 0, because either there is a stale waiters bit
      or the owner died bit is set or we are called from the requeue_pi path
      or from user space just for fun.
      
      The current code avoids an explicit sanity check for pid = 0 in case
      that kernel internal state (waiters) are found for the user space
      address.  This can lead to state leakage and worse under some
      circumstances.
      
      Handle the cases explicit:
      
             Waiter | pi_state | pi->owner | uTID      | uODIED | ?
      
        [1]  NULL   | ---      | ---       | 0         | 0/1    | Valid
        [2]  NULL   | ---      | ---       | >0        | 0/1    | Valid
      
        [3]  Found  | NULL     | --        | Any       | 0/1    | Invalid
      
        [4]  Found  | Found    | NULL      | 0         | 1      | Valid
        [5]  Found  | Found    | NULL      | >0        | 1      | Invalid
      
        [6]  Found  | Found    | task      | 0         | 1      | Valid
      
        [7]  Found  | Found    | NULL      | Any       | 0      | Invalid
      
        [8]  Found  | Found    | task      | ==taskTID | 0/1    | Valid
        [9]  Found  | Found    | task      | 0         | 0      | Invalid
        [10] Found  | Found    | task      | !=taskTID | 0/1    | Invalid
      
       [1] Indicates that the kernel can acquire the futex atomically. We
           came came here due to a stale FUTEX_WAITERS/FUTEX_OWNER_DIED bit.
      
       [2] Valid, if TID does not belong to a kernel thread. If no matching
           thread is found then it indicates that the owner TID has died.
      
       [3] Invalid. The waiter is queued on a non PI futex
      
       [4] Valid state after exit_robust_list(), which sets the user space
           value to FUTEX_WAITERS | FUTEX_OWNER_DIED.
      
       [5] The user space value got manipulated between exit_robust_list()
           and exit_pi_state_list()
      
       [6] Valid state after exit_pi_state_list() which sets the new owner in
           the pi_state but cannot access the user space value.
      
       [7] pi_state->owner can only be NULL when the OWNER_DIED bit is set.
      
       [8] Owner and user space value match
      
       [9] There is no transient state which sets the user space TID to 0
           except exit_robust_list(), but this is indicated by the
           FUTEX_OWNER_DIED bit. See [4]
      
      [10] There is no transient state which leaves owner and user space
           TID out of sync.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Will Drewry <wad@chromium.org>
      Cc: Darren Hart <dvhart@linux.intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b1f9d594
    • Thomas Gleixner's avatar
      futex: Always cleanup owner tid in unlock_pi · 19040c57
      Thomas Gleixner authored
      commit 13fbca4c upstream.
      
      If the owner died bit is set at futex_unlock_pi, we currently do not
      cleanup the user space futex.  So the owner TID of the current owner
      (the unlocker) persists.  That's observable inconsistant state,
      especially when the ownership of the pi state got transferred.
      
      Clean it up unconditionally.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Will Drewry <wad@chromium.org>
      Cc: Darren Hart <dvhart@linux.intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      19040c57
    • Thomas Gleixner's avatar
      futex: Validate atomic acquisition in futex_lock_pi_atomic() · cae300d1
      Thomas Gleixner authored
      commit b3eaa9fc upstream.
      
      We need to protect the atomic acquisition in the kernel against rogue
      user space which sets the user space futex to 0, so the kernel side
      acquisition succeeds while there is existing state in the kernel
      associated to the real owner.
      
      Verify whether the futex has waiters associated with kernel state.  If
      it has, return -EINVAL.  The state is corrupted already, so no point in
      cleaning it up.  Subsequent calls will fail as well.  Not our problem.
      
      [ tglx: Use futex_top_waiter() and explain why we do not need to try
        	restoring the already corrupted user space state. ]
      Signed-off-by: default avatarDarren Hart <dvhart@linux.intel.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Will Drewry <wad@chromium.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cae300d1
    • Thomas Gleixner's avatar
      futex-prevent-requeue-pi-on-same-futex.patch futex: Forbid uaddr == uaddr2 in... · 1ab0607b
      Thomas Gleixner authored
      futex-prevent-requeue-pi-on-same-futex.patch futex: Forbid uaddr == uaddr2 in futex_requeue(..., requeue_pi=1)
      
      commit e9c243a5 upstream.
      
      If uaddr == uaddr2, then we have broken the rule of only requeueing from
      a non-pi futex to a pi futex with this call.  If we attempt this, then
      dangling pointers may be left for rt_waiter resulting in an exploitable
      condition.
      
      This change brings futex_requeue() in line with futex_wait_requeue_pi()
      which performs the same check as per commit 6f7b0a2a ("futex: Forbid
      uaddr == uaddr2 in futex_wait_requeue_pi()")
      
      [ tglx: Compare the resulting keys as well, as uaddrs might be
        	different depending on the mapping ]
      
      Fixes CVE-2014-3153.
      
      Reported-by: Pinkie Pie
      Signed-off-by: default avatarWill Drewry <wad@chromium.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarDarren Hart <dvhart@linux.intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      1ab0607b
    • Sudeep Holla's avatar
      arm64: use cpu_online_mask when using forced irq_set_affinity · 3e32c277
      Sudeep Holla authored
      commit 601c9421 upstream.
      
      Commit 01f8fa4f("genirq: Allow forcing cpu affinity of interrupts")
      enabled the forced irq_set_affinity which previously refused to route an
      interrupt to an offline cpu.
      
      Commit ffde1de6("irqchip: Gic: Support forced affinity setting")
      implements this force logic and disables the cpu online check for GIC
      interrupt controller.
      
      When __cpu_disable calls migrate_irqs, it disables the current cpu in
      cpu_online_mask and uses forced irq_set_affinity to migrate the IRQs
      away from the cpu but passes affinity mask with the cpu being offlined
      also included in it.
      
      When calling irq_set_affinity with force == true in a cpu hotplug path,
      the caller must ensure that the cpu being offlined is not present in the
      affinity mask or it may be selected as the target CPU, leading to the
      interrupt not being migrated.
      
      This patch uses cpu_online_mask when using forced irq_set_affinity so
      that the IRQs are properly migrated away.
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e32c277
    • Guennadi Liakhovetski's avatar
      media: V4L2: fix VIDIOC_CREATE_BUFS in 64- / 32-bit compatibility mode · 3372ac6f
      Guennadi Liakhovetski authored
      commit 97d9d23d upstream.
      
      If a struct contains 64-bit fields, it is aligned on 64-bit boundaries
      within containing structs in 64-bit compilations. This is the case with
      struct v4l2_window, which contains pointers and is embedded into struct
      v4l2_format, and that one is embedded into struct v4l2_create_buffers.
      Unlike some other structs, used as a part of the kernel ABI as ioctl()
      arguments, that are packed, these structs aren't packed. This isn't a
      problem per se, but the ioctl-compat code for VIDIOC_CREATE_BUFS contains
      a bug, that triggers in such 64-bit builds. That code wrongly assumes,
      that in struct v4l2_create_buffers, struct v4l2_format immediately follows
      the __u32 memory field, which in fact isn't the case. This bug wasn't
      visible until now, because until recently hardly any applications used
      this ioctl() and mostly embedded 32-bit only drivers implemented it. This
      is changing now with addition of this ioctl() to some USB drivers, e.g.
      UVC. This patch fixes the bug by copying parts of struct
      v4l2_create_buffers separately.
      Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
      Acked-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3372ac6f
    • Guennadi Liakhovetski's avatar
      media: V4L2: ov7670: fix a wrong index, potentially Oopsing the kernel from user-space · d0c47e5d
      Guennadi Liakhovetski authored
      commit cfece585 upstream.
      
      Commit 75e2bdad "ov7670: allow
      configuration of image size, clock speed, and I/O method" uses a wrong
      index to iterate an array. Apart from being wrong, it also uses an
      unchecked value from user-space, which can cause access to unmapped
      memory in the kernel, triggered by a normal desktop user with rights to
      use V4L2 devices.
      Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
      Acked-by: default avatarJonathan Corbet <corbet@lwn.net>
      Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d0c47e5d
    • Eyal Shapira's avatar
      iwlwifi: mvm: rs: clear per rate stats when aggregation changes · ca4a4d64
      Eyal Shapira authored
      commit b804eeb6 upstream.
      
      The per rate stats should be cleared when aggregation state changes
      to avoid making rate scale decisions based on throughput figures which
      were collected prior to the aggregation state change and are now stale.
      While at it make sure any clearing of the per rate stats will get logged.
      Signed-off-by: default avatarEyal Shapira <eyalx.shapira@intel.com>
      Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ca4a4d64
    • Eliad Peller's avatar
      iwlwifi: add rs_rate_scale_clear_tbl_windows helper function · 424048eb
      Eliad Peller authored
      commit 3ca71f60 upstream.
      
      instead of duplicating the same loop multiple times,
      use a new function for it.
      
      this will be later used also for clearing other
      windows in the table.
      Signed-off-by: default avatarEliad Peller <eliadx.peller@intel.com>
      Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      424048eb
    • Emmanuel Grumbach's avatar
      iwlwifi: mvm: disable beacon filtering · f47fc3c1
      Emmanuel Grumbach authored
      commit 7bacc782 upstream.
      
      This feature has been causing trouble - disable it for now.
      Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f47fc3c1
    • Antti Palosaari's avatar
      media: fc2580: fix tuning failure on 32-bit arch · 24d0dd75
      Antti Palosaari authored
      commit 8845cc64 upstream.
      
      There was some frequency calculation overflows which caused tuning
      failure on 32-bit architecture. Use 64-bit numbers where needed in
      order to avoid calculation overflows.
      
      Thanks for the Finnish person, who asked remain anonymous, reporting,
      testing and suggesting the fix.
      Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
      Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      24d0dd75
    • Alex Williamson's avatar
      iommu/amd: Fix interrupt remapping for aliased devices · c1a763c4
      Alex Williamson authored
      commit e028a9e6 upstream.
      
      An apparent cut and paste error prevents the correct flags from being
      set on the alias device resulting in MSI on conventional PCI devices
      failing to work.  This also produces error events from the IOMMU like:
      
      AMD-Vi: Event logged [INVALID_DEVICE_REQUEST device=00:14.4 address=0x000000fdf8000000 flags=0x0a00]
      
      Where 14.4 is a PCIe-to-PCI bridge with a device behind it trying to
      use MSI interrupts.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarJoerg Roedel <joro@8bytes.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c1a763c4
    • Chunwei Chen's avatar
      libceph: fix corruption when using page_count 0 page in rbd · bcd5faf9
      Chunwei Chen authored
      commit 178eda29 upstream.
      
      It has been reported that using ZFSonLinux on rbd will result in memory
      corruption. The bug report can be found here:
      
      https://github.com/zfsonlinux/spl/issues/241
      http://tracker.ceph.com/issues/7790
      
      The reason is that ZFS will send pages with page_count 0 into rbd, which in
      turns send them to tcp_sendpage. However, tcp_sendpage cannot deal with
      page_count 0, as it will do get_page and put_page, and erroneously free the
      page.
      
      This type of issue has been noted before, and handled in iscsi, drbd,
      etc. So, rbd should also handle this. This fix address this issue by fall back
      to slower sendmsg when page_count 0 detected.
      
      Cc: Sage Weil <sage@inktank.com>
      Cc: Yehuda Sadeh <yehuda@inktank.com>
      Signed-off-by: default avatarChunwei Chen <tuxoko@gmail.com>
      Reviewed-by: default avatarIlya Dryomov <ilya.dryomov@inktank.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bcd5faf9
    • Geert Uytterhoeven's avatar
      spi: core: Ignore unsupported Dual/Quad Transfer Mode bits · a03443f5
      Geert Uytterhoeven authored
      commit 83596fbe upstream.
      
      The availability of SPI Dual or Quad Transfer Mode as indicated by the
      "spi-tx-bus-width" and "spi-rx-bus-width" properties in the device tree is
      a hardware property of the SPI master, SPI slave, and board wiring.  Hence
      the SPI core should not reject an SPI slave because an SPI master driver
      doesn't (yet) support Dual or Quad Transfer Mode.
      
      Change the lack of Dual or Quad Transfer Mode support in the SPI master
      driver from an error condition to a warning condition, and ignore the
      unsupported mode bits, falling back to Single Transfer Mode, to avoid
      breakages when running old kernels with new device trees.
      
      Fixes: f477b7fb (spi: DUAL and QUAD support)
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarMark Brown <broonie@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a03443f5
    • Srivatsa S. Bhat's avatar
      powerpc, kexec: Fix "Processor X is stuck" issue during kexec from ST mode · 26aa7dc4
      Srivatsa S. Bhat authored
      commit 011e4b02 upstream.
      
      If we try to perform a kexec when the machine is in ST (Single-Threaded) mode
      (ppc64_cpu --smt=off), the kexec operation doesn't succeed properly, and we
      get the following messages during boot:
      
      [    0.089866] POWER8 performance monitor hardware support registered
      [    0.089985] power8-pmu: PMAO restore workaround active.
      [    5.095419] Processor 1 is stuck.
      [   10.097933] Processor 2 is stuck.
      [   15.100480] Processor 3 is stuck.
      [   20.102982] Processor 4 is stuck.
      [   25.105489] Processor 5 is stuck.
      [   30.108005] Processor 6 is stuck.
      [   35.110518] Processor 7 is stuck.
      [   40.113369] Processor 9 is stuck.
      [   45.115879] Processor 10 is stuck.
      [   50.118389] Processor 11 is stuck.
      [   55.120904] Processor 12 is stuck.
      [   60.123425] Processor 13 is stuck.
      [   65.125970] Processor 14 is stuck.
      [   70.128495] Processor 15 is stuck.
      [   75.131316] Processor 17 is stuck.
      
      Note that only the sibling threads are stuck, while the primary threads (0, 8,
      16 etc) boot just fine. Looking closer at the previous step of kexec, we observe
      that kexec tries to wakeup (bring online) the sibling threads of all the cores,
      before performing kexec:
      
      [ 9464.131231] Starting new kernel
      [ 9464.148507] kexec: Waking offline cpu 1.
      [ 9464.148552] kexec: Waking offline cpu 2.
      [ 9464.148600] kexec: Waking offline cpu 3.
      [ 9464.148636] kexec: Waking offline cpu 4.
      [ 9464.148671] kexec: Waking offline cpu 5.
      [ 9464.148708] kexec: Waking offline cpu 6.
      [ 9464.148743] kexec: Waking offline cpu 7.
      [ 9464.148779] kexec: Waking offline cpu 9.
      [ 9464.148815] kexec: Waking offline cpu 10.
      [ 9464.148851] kexec: Waking offline cpu 11.
      [ 9464.148887] kexec: Waking offline cpu 12.
      [ 9464.148922] kexec: Waking offline cpu 13.
      [ 9464.148958] kexec: Waking offline cpu 14.
      [ 9464.148994] kexec: Waking offline cpu 15.
      [ 9464.149030] kexec: Waking offline cpu 17.
      
      Instrumenting this piece of code revealed that the cpu_up() operation actually
      fails with -EBUSY. Thus, only the primary threads of all the cores are online
      during kexec, and hence this is a sure-shot receipe for disaster, as explained
      in commit e8e5c215 (powerpc/kexec: Fix orphaned offline CPUs across kexec),
      as well as in the comment above wake_offline_cpus().
      
      It turns out that cpu_up() was returning -EBUSY because the variable
      'cpu_hotplug_disabled' was set to 1; and this disabling of CPU hotplug was done
      by migrate_to_reboot_cpu() inside kernel_kexec().
      
      Now, migrate_to_reboot_cpu() was originally written with the assumption that
      any further code will not need to perform CPU hotplug, since we are anyway in
      the reboot path. However, kexec is clearly not such a case, since we depend on
      onlining CPUs, atleast on powerpc.
      
      So re-enable cpu-hotplug after returning from migrate_to_reboot_cpu() in the
      kexec path, to fix this regression in kexec on powerpc.
      
      Also, wrap the cpu_up() in powerpc kexec code within a WARN_ON(), so that we
      can catch such issues more easily in the future.
      
      Fixes: c97102ba (kexec: migrate to reboot cpu)
      Signed-off-by: default avatarSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      26aa7dc4
    • Guenter Roeck's avatar
      powerpc: Fix 64 bit builds with binutils 2.24 · f7fb605a
      Guenter Roeck authored
      commit 7998eb3d upstream.
      
      With binutils 2.24, various 64 bit builds fail with relocation errors
      such as
      
      arch/powerpc/kernel/built-in.o: In function `exc_debug_crit_book3e':
      	(.text+0x165ee): relocation truncated to fit: R_PPC64_ADDR16_HI
      	against symbol `interrupt_base_book3e' defined in .text section
      	in arch/powerpc/kernel/built-in.o
      arch/powerpc/kernel/built-in.o: In function `exc_debug_crit_book3e':
      	(.text+0x16602): relocation truncated to fit: R_PPC64_ADDR16_HI
      	against symbol `interrupt_end_book3e' defined in .text section
      	in arch/powerpc/kernel/built-in.o
      
      The assembler maintainer says:
      
       I changed the ABI, something that had to be done but unfortunately
       happens to break the booke kernel code.  When building up a 64-bit
       value with lis, ori, shl, oris, ori or similar sequences, you now
       should use @high and @higha in place of @h and @ha.  @h and @ha
       (and their associated relocs R_PPC64_ADDR16_HI and R_PPC64_ADDR16_HA)
       now report overflow if the value is out of 32-bit signed range.
       ie. @h and @ha assume you're building a 32-bit value. This is needed
       to report out-of-range -mcmodel=medium toc pointer offsets in @toc@h
       and @toc@ha expressions, and for consistency I did the same for all
       other @h and @ha relocs.
      
      Replacing @h with @high in one strategic location fixes the relocation
      errors. This has to be done conditionally since the assembler either
      supports @h or @high but not both.
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f7fb605a
    • Anton Blanchard's avatar
      powerpc: irq work racing with timer interrupt can result in timer interrupt hang · 06059939
      Anton Blanchard authored
      commit 8050936c upstream.
      
      I am seeing an issue where a CPU running perf eventually hangs.
      Traces show timer interrupts happening every 4 seconds even
      when a userspace task is running on the CPU. /proc/timer_list
      also shows pending hrtimers have not run in over an hour,
      including the scheduler.
      
      Looking closer, decrementers_next_tb is getting set to
      0xffffffffffffffff, and at that point we will never take
      a timer interrupt again.
      
      In __timer_interrupt() we set decrementers_next_tb to
      0xffffffffffffffff and rely on ->event_handler to update it:
      
              *next_tb = ~(u64)0;
              if (evt->event_handler)
                      evt->event_handler(evt);
      
      In this case ->event_handler is hrtimer_interrupt. This will eventually
      call back through the clockevents code with the next event to be
      programmed:
      
      static int decrementer_set_next_event(unsigned long evt,
                                            struct clock_event_device *dev)
      {
              /* Don't adjust the decrementer if some irq work is pending */
              if (test_irq_work_pending())
                      return 0;
              __get_cpu_var(decrementers_next_tb) = get_tb_or_rtc() + evt;
      
      If irq work came in between these two points, we will return
      before updating decrementers_next_tb and we never process a timer
      interrupt again.
      
      This looks to have been introduced by 0215f7d8 (powerpc: Fix races
      with irq_work). Fix it by removing the early exit and relying on
      code later on in the function to force an early decrementer:
      
             /* We may have raced with new irq work */
             if (test_irq_work_pending())
                     set_dec(1);
      Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      06059939
    • Gavin Shan's avatar
      powerpc/powernv: Reset root port in firmware · 6f73026d
      Gavin Shan authored
      commit 372cf124 upstream.
      
      Resetting root port has more stuff to do than that for PCIe switch
      ports and we should have resetting root port done in firmware instead
      of the kernel itself. The problem was introduced by commit 5b2e198e
      ("powerpc/powernv: Rework EEH reset").
      Signed-off-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6f73026d
    • Stephen Boyd's avatar
      clk: Fix slab corruption in clk_unregister() · 2bf0e785
      Stephen Boyd authored
      commit 874f224c upstream.
      
      When a clock is unregsitered, we iterate over the list of
      children and reparent them to NULL (i.e. orphan list). While
      iterating the list, we should use the safe iterators because the
      children list for this clock is changing when we reparent the
      children to NULL. Failure to iterate safely can lead to slab
      corruption like this:
      
      =============================================================================
      BUG kmalloc-128 (Not tainted): Poison overwritten
      -----------------------------------------------------------------------------
      
      Disabling lock debugging due to kernel taint
      INFO: 0xed0c4900-0xed0c4903. First byte 0x0 instead of 0x6b
      INFO: Allocated in clk_register+0x20/0x1bc age=297 cpu=2 pid=70
       __slab_alloc.isra.39.constprop.42+0x410/0x454
       kmem_cache_alloc_trace+0x200/0x24c
       clk_register+0x20/0x1bc
       devm_clk_register+0x34/0x68
       0xbf0000f0
       platform_drv_probe+0x18/0x48
       driver_probe_device+0x94/0x360
       __driver_attach+0x94/0x98
       bus_for_each_dev+0x54/0x88
       bus_add_driver+0xe8/0x204
       driver_register+0x78/0xf4
       do_one_initcall+0xc4/0x17c
       load_module+0x19ac/0x2294
       SyS_init_module+0xa4/0x110
       ret_fast_syscall+0x0/0x48
      INFO: Freed in clk_unregister+0xd4/0x140 age=23 cpu=2 pid=73
       __slab_free+0x38/0x41c
       clk_unregister+0xd4/0x140
       release_nodes+0x164/0x1d8
       __device_release_driver+0x60/0xb0
       driver_detach+0xb4/0xb8
       bus_remove_driver+0x5c/0xc4
       SyS_delete_module+0x148/0x1d8
       ret_fast_syscall+0x0/0x48
      INFO: Slab 0xeec50b90 objects=25 used=0 fp=0xed0c5400 flags=0x4080
      INFO: Object 0xed0c48c0 @offset=2240 fp=0xed0c4a00
      
      Bytes b4 ed0c48b0: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a  ZZZZZZZZZZZZZZZZ
      Object ed0c48c0: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ed0c48d0: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ed0c48e0: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ed0c48f0: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ed0c4900: 00 00 00 00 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  ....kkkkkkkkkkkk
      Object ed0c4910: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ed0c4920: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ed0c4930: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5  kkkkkkkkkkkkkkk.
      Redzone ed0c4940: bb bb bb bb                                      ....
      Padding ed0c49e8: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a  ZZZZZZZZZZZZZZZZ
      Padding ed0c49f8: 5a 5a 5a 5a 5a 5a 5a 5a                          ZZZZZZZZ
      CPU: 3 PID: 75 Comm: mdev Tainted: G    B         3.14.0-11033-g2054ba5ca781 #35
      [<c0014be0>] (unwind_backtrace) from [<c0012240>] (show_stack+0x10/0x14)
      [<c0012240>] (show_stack) from [<c04b74a0>] (dump_stack+0x70/0xbc)
      [<c04b74a0>] (dump_stack) from [<c00f7a78>] (check_bytes_and_report+0xbc/0x100)
      [<c00f7a78>] (check_bytes_and_report) from [<c00f7c48>] (check_object+0x18c/0x218)
      [<c00f7c48>] (check_object) from [<c00f7efc>] (__free_slab+0x104/0x144)
      [<c00f7efc>] (__free_slab) from [<c04b6668>] (__slab_free+0x3dc/0x41c)
      [<c04b6668>] (__slab_free) from [<c014c008>] (load_elf_binary+0x88/0x12b4)
      [<c014c008>] (load_elf_binary) from [<c0105a44>] (search_binary_handler+0x78/0x18c)
      [<c0105a44>] (search_binary_handler) from [<c0106fc0>] (do_execve+0x490/0x5dc)
      [<c0106fc0>] (do_execve) from [<c0036b8c>] (____call_usermodehelper+0x134/0x168)
      [<c0036b8c>] (____call_usermodehelper) from [<c000f048>] (ret_from_fork+0x14/0x2c)
      FIX kmalloc-128: Restoring 0xed0c4900-0xed0c4903=0x6b
      
      Fixes: fcb0ee6a (clk: Implement clk_unregister)
      Cc: Jiada Wang <jiada_wang@mentor.com>
      Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
      Cc: Kyungmin Park <kyungmin.park@samsung.com>
      Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: default avatarMike Turquette <mturquette@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2bf0e785
    • Stephen Boyd's avatar
      clk: Fix double free due to devm_clk_register() · 798ad2ab
      Stephen Boyd authored
      commit 293ba3b4 upstream.
      
      Now that clk_unregister() frees the struct clk we're
      unregistering we'll free memory twice: first we'll call kfree()
      in __clk_release() with an address kmalloc doesn't know about and
      second we'll call kfree() in the devres layer. Remove the
      allocation of struct clk in devm_clk_register() and let
      clk_release() handle it. This fixes slab errors like:
      
      =============================================================================
      BUG kmalloc-128 (Not tainted): Invalid object pointer 0xed08e8d0
      -----------------------------------------------------------------------------
      
      Disabling lock debugging due to kernel taint
      INFO: Slab 0xeec503f8 objects=25 used=15 fp=0xed08ea00 flags=0x4081
      CPU: 2 PID: 73 Comm: rmmod Tainted: G    B         3.14.0-11032-g526e9c764381 #34
      [<c0014be0>] (unwind_backtrace) from [<c0012240>] (show_stack+0x10/0x14)
      [<c0012240>] (show_stack) from [<c04b74dc>] (dump_stack+0x70/0xbc)
      [<c04b74dc>] (dump_stack) from [<c00f6778>] (slab_err+0x74/0x84)
      [<c00f6778>] (slab_err) from [<c04b6278>] (free_debug_processing+0x2cc/0x31c)
      [<c04b6278>] (free_debug_processing) from [<c04b6300>] (__slab_free+0x38/0x41c)
      [<c04b6300>] (__slab_free) from [<c03931bc>] (clk_unregister+0xd4/0x140)
      [<c03931bc>] (clk_unregister) from [<c02fb774>] (release_nodes+0x164/0x1d8)
      [<c02fb774>] (release_nodes) from [<c02f8698>] (__device_release_driver+0x60/0xb0)
      [<c02f8698>] (__device_release_driver) from [<c02f9080>] (driver_detach+0xb4/0xb8)
      [<c02f9080>] (driver_detach) from [<c02f8480>] (bus_remove_driver+0x5c/0xc4)
      [<c02f8480>] (bus_remove_driver) from [<c008c9b8>] (SyS_delete_module+0x148/0x1d8)
      [<c008c9b8>] (SyS_delete_module) from [<c000ef80>] (ret_fast_syscall+0x0/0x48)
      FIX kmalloc-128: Object at 0xed08e8d0 not freed
      
      Fixes: fcb0ee6a (clk: Implement clk_unregister)
      Cc: Jiada Wang <jiada_wang@mentor.com>
      Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
      Cc: Kyungmin Park <kyungmin.park@samsung.com>
      Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: default avatarMike Turquette <mturquette@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      798ad2ab
    • Harald Freudenberger's avatar
      crypto: s390 - fix aes,des ctr mode concurrency finding. · 55494146
      Harald Freudenberger authored
      commit 3901c112 upstream.
      
      An additional testcase found an issue with the last
      series of patches applied: the fallback solution may
      not save the iv value after operation. This very small
      fix just makes sure the iv is copied back to the
      walk/desc struct.
      Signed-off-by: default avatarHarald Freudenberger <freude@linux.vnet.ibm.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      55494146
    • Horia Geanta's avatar
      crypto: caam - add allocation failure handling in SPRINTFCAT macro · c40da129
      Horia Geanta authored
      commit 27c5fb7a upstream.
      
      GFP_ATOMIC memory allocation could fail.
      In this case, avoid NULL pointer dereference and notify user.
      
      Cc: Kim Phillips <kim.phillips@freescale.com>
      Signed-off-by: default avatarHoria Geanta <horia.geanta@freescale.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c40da129
    • Dirk Brandewie's avatar
      intel_pstate: remove setting P state to MAX on init · 23de3167
      Dirk Brandewie authored
      commit d40a63c4 upstream.
      
      Setting the P state of the core to max at init time is a hold over
      from early implementation of intel_pstate where intel_pstate disabled
      cpufreq and loaded VERY early in the boot sequence.  This was to
      ensure that intel_pstate did not affect boot time. This in not needed
      now that intel_pstate is a cpufreq driver.
      
      Removing this covers the case where a CPU has gone through a manual
      CPU offline/online cycle and the P state is set to MAX on init and the
      CPU immediately goes idle.  Due to HW coordination the P state request
      on the idle CPU will drag all cores to MAX P state until the load is
      reevaluated when to core goes non-idle.
      Reported-by: default avatarPatrick Marlier <patrick.marlier@gmail.com>
      Signed-off-by: default avatarDirk Brandewie <dirk.j.brandewie@intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      23de3167
    • Dirk Brandewie's avatar
      intel_pstate: Set turbo VID for BayTrail · dd4c4afb
      Dirk Brandewie authored
      commit 21855ff5 upstream.
      
      A documentation update exposed that there is a separate set of VID
      values that must be used in the turbo/boost P state range.  Add
      enumerating and setting the correct VID for P states in the turbo
      range.
      Signed-off-by: default avatarDirk Brandewie <dirk.j.brandewie@intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd4c4afb
    • Olof Johansson's avatar
      i2c: s3c2410: resume race fix · 35493cad
      Olof Johansson authored
      commit ce78cc07 upstream.
      
      Don't unmark the device as suspended until after it's been re-setup.
      
      The main race would be w.r.t. an i2c driver that gets resumed at the same
      time (asyncronously), that is allowed to do a transfer since suspended
      is set to 0 before reinit, but really should have seen the -EIO return
      instead.
      Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
      Signed-off-by: default avatarDoug Anderson <dianders@chromium.org>
      Acked-by: default avatarKukjin Kim <kgene.kim@samsung.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35493cad
    • Du, Wenkai's avatar
      i2c: designware: Mask all interrupts during i2c controller enable · bd811c10
      Du, Wenkai authored
      commit 47bb27e7 upstream.
      
      There have been "i2c_designware 80860F41:00: controller timed out" errors
      on a number of Baytrail platforms. The issue is caused by incorrect value in
      Interrupt Mask Register (DW_IC_INTR_MASK)  when i2c core is being enabled.
      This causes call to __i2c_dw_enable() to immediately start the transfer which
      leads to timeout. There are 3 failure modes observed:
      
      1. Failure in S0 to S3 resume path
      
      The default value after reset for DW_IC_INTR_MASK is 0x8ff. When we start
      the first transaction after resuming from system sleep, TX_EMPTY interrupt
      is already unmasked because of the hardware default.
      
      2. Failure in normal operational path
      
      This failure happens rarely and is hard to reproduce. Debug trace showed that
      DW_IC_INTR_MASK had value of 0x254 when failure occurred, which meant
      TX_EMPTY was unmasked.
      
      3. Failure in S3 to S0 suspend path
      
      This failure also happens rarely and is hard to reproduce. Adding debug trace
      that read DW_IC_INTR_MASK made this failure not reproducible. But from ISR
      call trace we could conclude TX_EMPTY was unmasked when problem occurred.
      
      The patch masks all interrupts before the controller is enabled to resolve the
      faulty DW_IC_INTR_MASK conditions.
      Signed-off-by: default avatarWenkai Du <wenkai.du@intel.com>
      Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      [wsa: improved the comment and removed typo in commit msg]
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd811c10
    • Wolfram Sang's avatar
      i2c: rcar: bail out on zero length transfers · 6a870282
      Wolfram Sang authored
      commit d7653964 upstream.
      
      This hardware does not support zero length transfers. Instead, the
      driver does one (random) byte transfers currently with undefined results
      for the slaves. We now bail out.
      Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a870282
    • Hans de Goede's avatar
      ACPI / video: Revert native brightness quirk for ThinkPad T530 · 6dc7b7da
      Hans de Goede authored
      commit 07d1d29e upstream.
      
      Seems it helps some users, but causes issues for other users:
      https://bugzilla.redhat.com/show_bug.cgi?id=1089545
      
      So lets drop it for now until we've figured out a better fix.
      
      Fixes: 43d94902 (ACPI / video: Add use_native_backlight quirks for more systems)
      References: https://bugzilla.redhat.com/show_bug.cgi?id=1089545Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6dc7b7da
    • Aaron Lu's avatar
      ACPI / video: correct DMI tag for Dell Inspiron 7520 · 73561c30
      Aaron Lu authored
      commit 5ff365fb upstream.
      
      The DMI tag used to identify Dell Inspiron 7520 should be product name
      instead of product version.
      
      Fixes: 0e9f81d3 (ACPI / video: Add systems that should favour native backlight interface)
      Reported-and-tested-by: default avatarTéo Mazars <teomazars@gmail.com>
      References: https://bugzilla.redhat.com/show_bug.cgi?id=909552Signed-off-by: default avatarAaron Lu <aaron.lu@intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      73561c30
    • Rafael J. Wysocki's avatar
      ACPI / TPM: Fix resume regression on Chromebooks · fcbe7574
      Rafael J. Wysocki authored
      commit f7595464 upstream.
      
      Chromebooks (at least Acer C720 and Pixel) implement an ACPI object
      for TPM, but don't implement the _DSM method to support PPI.  As
      a result, the TPM driver fails to load on those machines after
      commit 1569a4c4 (ACPI / TPM: detect PPI features by checking
      availability of _DSM functions) which causes them to fail to
      resume from system suspend, becuase they require the TPM hardware
      to be put into the right state during resume and the TPM driver
      is necessary for that.
      
      Fix the problem by making tpm_add_ppi() return 0 when tpm_ppi_handle
      is still NULL after walking the ACPI namespace in search for the PPI
      _DSM, which allows the TPM driver to load and operate the hardware
      (during system resume in particular), but avoid creating the PPI
      sysfs group in that case.
      
      This change is based on a prototype patch from Jiang Liu.
      
      Fixes: 1569a4c4 (ACPI / TPM: detect PPI features by checking availability of _DSM functions)
      References: https://bugzilla.kernel.org/show_bug.cgi?id=74021Reported-by: default avatarJames Duley <jagduley@gmail.com>
      Reported-by: default avatarPhillip Dixon <phil@dixon.gen.nz>
      Tested-by: default avatarBrandon Casey <drafnel@gmail.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fcbe7574