1. 30 Sep, 2016 40 commits
    • James Hogan's avatar
      MIPS: vDSO: Fix Malta EVA mapping to vDSO page structs · 66f93fb3
      James Hogan authored
      commit 554af0c3 upstream.
      
      The page structures associated with the vDSO pages in the kernel image
      are calculated using virt_to_page(), which uses __pa() under the hood to
      find the pfn associated with the virtual address. The vDSO data pointers
      however point to kernel symbols, so __pa_symbol() should really be used
      instead.
      
      Since there is no equivalent to virt_to_page() which uses __pa_symbol(),
      fix init_vdso_image() to work directly with pfns, calculated with
      __phys_to_pfn(__pa_symbol(...)).
      
      This issue broke the Malta Enhanced Virtual Addressing (EVA)
      configuration which has a non-default implementation of __pa_symbol().
      This is because it uses a physical alias so that the kernel executes
      from KSeg0 (VA 0x80000000 -> PA 0x00000000), while RAM is provided to
      the kernel in the KUSeg range (VA 0x00000000 -> PA 0x80000000) which
      uses the same underlying RAM.
      
      Since there are no page structures associated with the low physical
      address region, some arbitrary kernel memory would be interpreted as a
      page structure for the vDSO pages and badness ensues.
      
      Fixes: ebb5e78c ("MIPS: Initial implementation of a VDSO")
      Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Cc: Leonid Yegoshin <leonid.yegoshin@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14229/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      66f93fb3
    • Matt Redfearn's avatar
      MIPS: SMP: Fix possibility of deadlock when bringing CPUs online · 9ed2d4ac
      Matt Redfearn authored
      commit 8f46cca1 upstream.
      
      This patch fixes the possibility of a deadlock when bringing up
      secondary CPUs.
      The deadlock occurs because the set_cpu_online() is called before
      synchronise_count_slave(). This can cause a deadlock if the boot CPU,
      having scheduled another thread, attempts to send an IPI to the
      secondary CPU, which it sees has been marked online. The secondary is
      blocked in synchronise_count_slave() waiting for the boot CPU to enter
      synchronise_count_master(), but the boot cpu is blocked in
      smp_call_function_many() waiting for the secondary to respond to it's
      IPI request.
      
      Fix this by marking the CPU online in cpu_callin_map and synchronising
      counters before declaring the CPU online and calculating the maps for
      IPIs.
      Signed-off-by: default avatarMatt Redfearn <matt.redfearn@imgtec.com>
      Reported-by: default avatarJustin Chen <justinpopo6@gmail.com>
      Tested-by: default avatarJustin Chen <justinpopo6@gmail.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14302/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9ed2d4ac
    • Paul Burton's avatar
      MIPS: Fix pre-r6 emulation FPU initialisation · 24a465cc
      Paul Burton authored
      commit 7e956304 upstream.
      
      In the mipsr2_decoder() function, used to emulate pre-MIPSr6
      instructions that were removed in MIPSr6, the init_fpu() function is
      called if a removed pre-MIPSr6 floating point instruction is the first
      floating point instruction used by the task. However, init_fpu()
      performs varous actions that rely upon not being migrated. For example
      in the most basic case it sets the coprocessor 0 Status.CU1 bit to
      enable the FPU & then loads FP register context into the FPU registers.
      If the task were to migrate during this time, it may end up attempting
      to load FP register context on a different CPU where it hasn't set the
      CU1 bit, leading to errors such as:
      
          do_cpu invoked from kernel context![#2]:
          CPU: 2 PID: 7338 Comm: fp-prctl Tainted: G      D         4.7.0-00424-g49b0c82 #2
          task: 838e4000 ti: 88d38000 task.ti: 88d38000
          $ 0   : 00000000 00000001 ffffffff 88d3fef8
          $ 4   : 838e4000 88d38004 00000000 00000001
          $ 8   : 3400fc01 801f8020 808e9100 24000000
          $12   : dbffffff 807b69d8 807b0000 00000000
          $16   : 00000000 80786150 00400fc4 809c0398
          $20   : 809c0338 0040273c 88d3ff28 808e9d30
          $24   : 808e9d30 00400fb4
          $28   : 88d38000 88d3fe88 00000000 8011a2ac
          Hi    : 0040273c
          Lo    : 88d3ff28
          epc   : 80114178 _restore_fp+0x10/0xa0
          ra    : 8011a2ac mipsr2_decoder+0xd5c/0x1660
          Status: 1400fc03	KERNEL EXL IE
          Cause : 1080002c (ExcCode 0b)
          PrId  : 0001a920 (MIPS I6400)
          Modules linked in:
          Process fp-prctl (pid: 7338, threadinfo=88d38000, task=838e4000, tls=766527d0)
          Stack : 00000000 00000000 00000000 88d3fe98 00000000 00000000 809c0398 809c0338
          	  808e9100 00000000 88d3ff28 00400fc4 00400fc4 0040273c 7fb69e18 004a0000
          	  004a0000 004a0000 7664add0 8010de18 00000000 00000000 88d3fef8 88d3ff28
          	  808e9100 00000000 766527d0 8010e534 000c0000 85755000 8181d580 00000000
          	  00000000 00000000 004a0000 00000000 766527d0 7fb69e18 004a0000 80105c20
          	  ...
          Call Trace:
          [<80114178>] _restore_fp+0x10/0xa0
          [<8011a2ac>] mipsr2_decoder+0xd5c/0x1660
          [<8010de18>] do_ri+0x90/0x6b8
          [<80105c20>] ret_from_exception+0x0/0x10
      
      Fix this by disabling preemption around the call to init_fpu(), ensuring
      that it starts & completes on one CPU.
      Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
      Fixes: b0a668fb ("MIPS: kernel: mips-r2-to-r6-emul: Add R2 emulator for MIPS R6")
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14305/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      24a465cc
    • Sudeep Holla's avatar
      i2c: qup: skip qup_i2c_suspend if the device is already runtime suspended · 4b37b0ca
      Sudeep Holla authored
      commit 331dcf42 upstream.
      
      If the i2c device is already runtime suspended, if qup_i2c_suspend is
      executed during suspend-to-idle or suspend-to-ram it will result in the
      following splat:
      
      WARNING: CPU: 3 PID: 1593 at drivers/clk/clk.c:476 clk_core_unprepare+0x80/0x90
      Modules linked in:
      
      CPU: 3 PID: 1593 Comm: bash Tainted: G        W       4.8.0-rc3 #14
      Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT)
      PC is at clk_core_unprepare+0x80/0x90
      LR is at clk_unprepare+0x28/0x40
      pc : [<ffff0000086eecf0>] lr : [<ffff0000086f0c58>] pstate: 60000145
      Call trace:
       clk_core_unprepare+0x80/0x90
       qup_i2c_disable_clocks+0x2c/0x68
       qup_i2c_suspend+0x10/0x20
       platform_pm_suspend+0x24/0x68
       ...
      
      This patch fixes the issue by executing qup_i2c_pm_suspend_runtime
      conditionally in qup_i2c_suspend.
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Reviewed-by: default avatarAndy Gross <andy.gross@linaro.org>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4b37b0ca
    • Peter Rosin's avatar
      i2c: mux: pca954x: retry updating the mux selection on failure · 9bdb254d
      Peter Rosin authored
      commit 463e8f84 upstream.
      
      The cached value of the last selected channel prevents retries on the
      next call, even on failure to update the selected channel. Fix that.
      Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9bdb254d
    • Yadi.hu's avatar
      i2c-eg20t: fix race between i2c init and interrupt enable · 90cc7b41
      Yadi.hu authored
      commit 371a0153 upstream.
      
      the eg20t driver call request_irq() function before the pch_base_address,
      base address of i2c controller's register, is assigned an effective value.
      
      there is one possible scenario that an interrupt which isn't inside eg20t
      arrives immediately after request_irq() is executed when i2c controller
      shares an interrupt number with others. since the interrupt handler
      pch_i2c_handler() has already active as shared action, it will be called
      and read its own register to determine if this interrupt is from itself.
      
      At that moment, since base address of i2c registers is not remapped
      in kernel space yet,so the INT handler will access an illegal address
      and then a error occurs.
      Signed-off-by: default avatarYadi.hu <yadi.hu@windriver.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      90cc7b41
    • Paul Burton's avatar
      irqchip/mips-gic: Fix local interrupts · f8fea9dc
      Paul Burton authored
      commit e875bd66 upstream.
      
      Since the device hierarchy domain was added by commit c98c1822
      ("irqchip/mips-gic: Add device hierarchy domain"), GIC local interrupts
      have been broken.
      
      Users attempting to setup a per-cpu local IRQ, for example the GIC timer
      clock events code in drivers/clocksource/mips-gic-timer.c, the
      setup_percpu_irq function would refuse with -EINVAL because the GIC
      irqchip driver never called irq_set_percpu_devid so the
      IRQ_PER_CPU_DEVID flag was never set for the IRQ. This happens because
      irq_set_percpu_devid was being called from the gic_irq_domain_map
      function which is no longer called.
      
      Doing only that runs into further problems because gic_dev_domain_alloc
      set the struct irq_chip for all interrupts, local or shared, to
      gic_level_irq_controller despite that only being suitable for shared
      interrupts. The typical outcome of this is that gic_level_irq_controller
      callback functions are called for local interrupts, and then hwirq
      number calculations overflow & the driver ends up attempting to access
      some invalid register with an address calculated from an invalid hwirq
      number. Best case scenario is that this then leads to a bus error. This
      is fixed by abstracting the setup of the hwirq & chip to a new function
      gic_setup_dev_chip which is used by both the root GIC IRQ domain & the
      device domain.
      
      Finally, decoding local interrupts failed because gic_dev_domain_alloc
      only called irq_domain_alloc_irqs_parent for shared interrupts. Local
      ones were therefore never associated with hwirqs in the root GIC IRQ
      domain and the virq in gic_handle_local_int would always be 0. This is
      fixed by calling irq_domain_alloc_irqs_parent unconditionally & having
      gic_irq_domain_alloc handle both local & shared interrupts, which is
      easy due to the aforementioned abstraction of chip setup into
      gic_setup_dev_chip.
      
      This fixes use of the MIPS GIC timer for clock events, which has been
      broken since c98c1822 ("irqchip/mips-gic: Add device hierarchy
      domain") but hadn't been noticed due to a silent fallback to the MIPS
      coprocessor 0 count/compare clock events device.
      
      Fixes: c98c1822 ("irqchip/mips-gic: Add device hierarchy domain")
      Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Jason Cooper <jason@lakedaemon.net>
      Cc: Qais Yousef <qsyousef@gmail.com>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Link: http://lkml.kernel.org/r/20160913165335.31389-1-paul.burton@imgtec.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f8fea9dc
    • Matt Fleming's avatar
      x86/efi: Only map RAM into EFI page tables if in mixed-mode · 39b47d37
      Matt Fleming authored
      commit 12976670 upstream.
      
      Waiman reported that booting with CONFIG_EFI_MIXED enabled on his
      multi-terabyte HP machine results in boot crashes, because the EFI
      region mapping functions loop forever while trying to map those
      regions describing RAM.
      
      While this patch doesn't fix the underlying hang, there's really no
      reason to map EFI_CONVENTIONAL_MEMORY regions into the EFI page tables
      when mixed-mode is not in use at runtime.
      Reported-by: default avatarWaiman Long <waiman.long@hpe.com>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      CC: Theodore Ts'o <tytso@mit.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Scott J Norton <scott.norton@hpe.com>
      Cc: Douglas Hatch <doug.hatch@hpe.com>
      Signed-off-by: default avatarMatt Fleming <matt@codeblueprint.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      39b47d37
    • Jeff Mahoney's avatar
      btrfs: ensure that file descriptor used with subvol ioctls is a dir · eb06045e
      Jeff Mahoney authored
      commit 325c50e3 upstream.
      
      If the subvol/snapshot create/destroy ioctls are passed a regular file
      with execute permissions set, we'll eventually Oops while trying to do
      inode->i_op->lookup via lookup_one_len.
      
      This patch ensures that the file descriptor refers to a directory.
      
      Fixes: cb8e7090 (Btrfs: Fix subvolume creation locking rules)
      Fixes: 76dda93c (Btrfs: add snapshot/subvolume destroy ioctl)
      Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eb06045e
    • Johannes Berg's avatar
      nl80211: validate number of probe response CSA counters · e402ffde
      Johannes Berg authored
      commit ad5987b4 upstream.
      
      Due to an apparent copy/paste bug, the number of counters for the
      beacon configuration were checked twice, instead of checking the
      number of probe response counters. Fix this to check the number of
      probe response counters before parsing those.
      
      Fixes: 9a774c78 ("cfg80211: Support multiple CSA counters")
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e402ffde
    • Beni Lev's avatar
      iwlwifi: mvm: update TX queue before making a copy of the skb · 29adc609
      Beni Lev authored
      commit 54c5ef2e upstream.
      
      Off-channel action frames (such as ANQP frames) must be sent either on
      the AUX queue or on the offchannel queue, otherwise the firmware will
      cause a SYSASSERT.
      
      In the current implementation, the queue to be used is correctly set in
      the original skb, but this is done after it is copied.  Thus the copy
      remains with the original, incorrect queue.
      
      Fix this by setting the queue in the original skb before copying it.
      
      Fixes: commit 5c08b0f5 ("iwlwifi: mvm: don't override the rate with the AMSDU len")
      Signed-off-by: default avatarBeni Lev <beni.lev@intel.com>
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      29adc609
    • Marek Vasut's avatar
      net: can: ifi: Configure transmitter delay · 8c48d21d
      Marek Vasut authored
      commit 8d58790b upstream.
      
      Configure the transmitter delay register at +0x1c to correctly handle
      the CAN FD bitrate switch (BRS). This moves the SSP (secondary sample
      point) to a proper offset, so that the TDC mechanism works and won't
      generate error frames on the CAN link.
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: Marc Kleine-Budde <mkl@pengutronix.de>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Oliver Hartkopp <socketcan@hartkopp.net>
      Cc: Wolfgang Grandegger <wg@grandegger.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c48d21d
    • Fabio Estevam's avatar
      can: flexcan: fix resume function · 68e864b4
      Fabio Estevam authored
      commit 4de349e7 upstream.
      
      On a imx6ul-pico board the following error is seen during system suspend:
      
      dpm_run_callback(): platform_pm_resume+0x0/0x54 returns -110
      PM: Device 2090000.flexcan failed to resume: error -110
      
      The reason for this suspend error is because when the CAN interface is not
      active the clocks are disabled and then flexcan_chip_enable() will
      always fail due to a timeout error.
      
      In order to fix this issue, only call flexcan_chip_enable/disable()
      when the CAN interface is active.
      
      Based on a patch from Dong Aisheng in the NXP kernel.
      Signed-off-by: default avatarFabio Estevam <fabio.estevam@nxp.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      68e864b4
    • Hugh Dickins's avatar
      mm: delete unnecessary and unsafe init_tlb_ubc() · 1d5617bf
      Hugh Dickins authored
      commit b385d21f upstream.
      
      init_tlb_ubc() looked unnecessary to me: tlb_ubc is statically
      initialized with zeroes in the init_task, and copied from parent to
      child while it is quiescent in arch_dup_task_struct(); so I went to
      delete it.
      
      But inserted temporary debug WARN_ONs in place of init_tlb_ubc() to
      check that it was always empty at that point, and found them firing:
      because memcg reclaim can recurse into global reclaim (when allocating
      biosets for swapout in my case), and arrive back at the init_tlb_ubc()
      in shrink_node_memcg().
      
      Resetting tlb_ubc.flush_required at that point is wrong: if the upper
      level needs a deferred TLB flush, but the lower level turns out not to,
      we miss a TLB flush.  But fortunately, that's the only part of the
      protocol that does not nest: with the initialization removed, cpumask
      collects bits from upper and lower levels, and flushes TLB when needed.
      
      Fixes: 72b252ae ("mm: send one IPI per CPU to TLB flush all entries after unmapping pages")
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Acked-by: default avatarMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1d5617bf
    • Steven Rostedt (Red Hat)'s avatar
      tracing: Move mutex to protect against resetting of seq data · 9092c241
      Steven Rostedt (Red Hat) authored
      commit 1245800c upstream.
      
      The iter->seq can be reset outside the protection of the mutex. So can
      reading of user data. Move the mutex up to the beginning of the function.
      
      Fixes: d7350c3f ("tracing/core: make the read callbacks reentrants")
      Reported-by: default avatarAl Viro <viro@ZenIV.linux.org.uk>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9092c241
    • Al Viro's avatar
      fix memory leaks in tracing_buffers_splice_read() · 09ae540c
      Al Viro authored
      commit 1ae2293d upstream.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09ae540c
    • Johannes Berg's avatar
      mac80211: reject TSPEC TIDs (TSIDs) for aggregation · 22f591e2
      Johannes Berg authored
      commit 85d5313e upstream.
      
      Since mac80211 doesn't currently support TSIDs 8-15 which can
      only be used after QoS TSPEC negotiation (and not even after
      WMM negotiation), reject attempts to set up aggregation
      sessions for them, which might confuse drivers. In mac80211
      we do correctly handle that, but the TSIDs should never get
      used anyway, and drivers might not be able to handle it.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      22f591e2
    • Arvind Yadav's avatar
      power: reset: hisi-reboot: Unmap region obtained by of_iomap · c11aadb9
      Arvind Yadav authored
      commit bae170ef upstream.
      
      Free memory mapping, if probe is not successful.
      
      Fixes: 4a9b3737 ("power: reset: move hisilicon reboot code")
      Signed-off-by: default avatarArvind Yadav <arvind.yadav.cs@gmail.com>
      Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c11aadb9
    • Keerthy's avatar
      rtc: ds1307: Fix relying on reset value for weekday · 1c79cde5
      Keerthy authored
      commit e29385fa upstream.
      
      The reset value of weekday is 0x1. This is wrong since
      the reset values of the day/month/year make up to Jan 1 2001.
      When computed weekday comes out to be Monday. On a scale
      of 1-7(Sunday - Saturday) it should be 0x2. So we should not
      be relying on the reset value.
      
      Hence compute the wday using the current date/month/year values.
      Check if reset wday is any different from the computed wday,
      If different then set the wday which we computed using
      date/month/year values.
      
      Document Referred:
      http://ww1.microchip.com/downloads/en/DeviceDoc/20002266F.pdf
      
      Fixes: 1d1945d2 "drivers/rtc/rtc-ds1307.c: add alarm support for mcp7941x chips"
      Signed-off-by: default avatarKeerthy <j-keerthy@ti.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c79cde5
    • John Youn's avatar
      reset: Return -ENOTSUPP when not configured · e7c5a957
      John Youn authored
      commit 168d7c4e upstream.
      
      Prior to commit 6c96f05c ("reset: Make [of_]reset_control_get[_foo]
      functions wrappers"), the "optional" functions returned -ENOTSUPP when
      CONFIG_RESET_CONTROLLER was not set.
      
      Revert back to the old behavior by changing the new
      __devm_reset_control_get() and __of_reset_control_get() functions to
      return ERR_PTR(-ENOTSUPP) when compiled without CONFIG_RESET_CONTROLLER.
      
      Otherwise they will return -EINVAL causing users to think that an error
      occurred when CONFIG_RESET_CONTROLLER is not set.
      
      Fixes: 6c96f05c ("reset: Make [of_]reset_control_get[_foo] functions wrappers")
      Signed-off-by: default avatarJohn Youn <johnyoun@synopsys.com>
      Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e7c5a957
    • Brian Norris's avatar
      mtd: spi-nor: fix wrong "fully unlocked" test · 16964b31
      Brian Norris authored
      commit 06586204 upstream.
      
      In stm_unlock(), the test to determine whether we've fully unlocked the
      flash checks for the lock length to be equal to the flash size. That is
      a typo/think-o -- the condition actually means the flash is completely
      *locked.* We should be using the inverse condition -- that the lock
      length is 0 (i.e., no protection).
      
      The result of this bug is that we never actually turn off the Status
      Register Write Disable bit, even if the flash is completely unlocked.
      Now we can.
      
      Fixes: 47b8edbf ("mtd: spi-nor: disallow further writes to SR if WP# is low")
      Reported-by: default avatarGiorgio <giorgio.nicole@arcor.de>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      16964b31
    • Dan Carpenter's avatar
      mtd: pmcmsp-flash: Allocating too much in init_msp_flash() · dc4773f9
      Dan Carpenter authored
      commit 79ad07d4 upstream.
      
      There is a cut and paste issue here.  The bug is that we are allocating
      more memory than necessary for msp_maps.  We should be allocating enough
      space for a map_info struct (144 bytes) but we instead allocate enough
      for an mtd_info struct (1840 bytes).  It's a small waste.
      
      The other part of this is not harmful but when we allocated msp_flash
      then we allocated enough space fro a map_info pointer instead of an
      mtd_info pointer.  But since pointers are the same size it works out
      fine.
      
      Anyway, I decided to clean up all three allocations a bit to make them
      a bit more consistent and clear.
      
      Fixes: 68aa0fa8 ('[MTD] PMC MSP71xx flash/rootfs mappings')
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dc4773f9
    • Dan Carpenter's avatar
      mtd: maps: sa1100-flash: potential NULL dereference · 3f98badc
      Dan Carpenter authored
      commit dc01a28d upstream.
      
      We check for NULL but then dereference "info->mtd" on the next line.
      
      Fixes: 72169755 ('mtd: maps: sa1100-flash: show parent device in sysfs')
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f98badc
    • Lothar Waßmann's avatar
      mtd: nand: mxc: fix obiwan error in mxc_nand_v[12]_ooblayout_free() functions · 753de51f
      Lothar Waßmann authored
      commit 38178e7b upstream.
      
      commit a894cf6c ("mtd: nand: mxc: switch to mtd_ooblayout_ops")
      introduced a regression accessing the OOB area from the mxc_nand
      driver due to an Obiwan error in the mxc_nand_v[12]_ooblayout_free()
      functions. They report a bogus oobregion { 64, 7 } which leads to
      errors accessing bogus data when reading the oob area.
      
      Prior to the commit the mtd-oobtest module could be run without any
      errors. With the offending commit, this test fails with results like:
      |Running mtd-oobtest
      |
      |=================================================
      |mtd_oobtest: MTD device: 5
      |mtd_oobtest: MTD device size 524288, eraseblock size 131072, page size 2048, count of eraseblocks 4, pages per eraseblock 64, OOB size 64
      |mtd_test: scanning for bad eraseblocks
      |mtd_test: scanned 4 eraseblocks, 0 are bad
      |mtd_oobtest: test 1 of 5
      |mtd_oobtest: writing OOBs of whole device
      |mtd_oobtest: written up to eraseblock 0
      |mtd_oobtest: written 4 eraseblocks
      |mtd_oobtest: verifying all eraseblocks
      |mtd_oobtest: error @addr[0x0:0x19] 0x9a -> 0x78 diff 0xe2
      |mtd_oobtest: error @addr[0x0:0x1a] 0xcc -> 0x0 diff 0xcc
      |mtd_oobtest: error @addr[0x0:0x1b] 0xe0 -> 0x85 diff 0x65
      |mtd_oobtest: error @addr[0x0:0x1c] 0x60 -> 0x62 diff 0x2
      |mtd_oobtest: error @addr[0x0:0x1d] 0x69 -> 0x45 diff 0x2c
      |mtd_oobtest: error @addr[0x0:0x1e] 0xcd -> 0xa0 diff 0x6d
      |mtd_oobtest: error @addr[0x0:0x1f] 0xf2 -> 0x60 diff 0x92
      |mtd_oobtest: error: verify failed at 0x0
      [...]
      Signed-off-by: default avatarLothar Waßmann <LW@KARO-electronics.de>
      Fixes: a894cf6c ("mtd: nand: mxc: switch to mtd_ooblayout_ops")
      Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      753de51f
    • Phil Turnbull's avatar
      configfs: Return -EFBIG from configfs_write_bin_file. · 71b4a3c0
      Phil Turnbull authored
      commit 42857cf5 upstream.
      
      The check for writing more than cb_max_size bytes does not 'goto out' so
      it is a no-op which allows users to vmalloc an arbitrary amount.
      
      Fixes: 03607ace ("configfs: implement binary attributes")
      Signed-off-by: default avatarPhil Turnbull <phil.turnbull@oracle.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      71b4a3c0
    • David Daney's avatar
      arm64: Call numa_store_cpu_info() earlier. · 84bba4be
      David Daney authored
      commit c18df0ad upstream.
      
      The wq_numa_init() function makes a private CPU to node map by calling
      cpu_to_node() early in the boot process, before the non-boot CPUs are
      brought online.  Since the default implementation of cpu_to_node()
      returns zero for CPUs that have never been brought online, the
      workqueue system's view is that *all* CPUs are on node zero.
      
      When the unbound workqueue for a non-zero node is created, the
      tsk_cpus_allowed() for the worker threads is the empty set because
      there are, in the view of the workqueue system, no CPUs on non-zero
      nodes.  The code in try_to_wake_up() using this empty cpumask ends up
      using the cpumask empty set value of NR_CPUS as an index into the
      per-CPU area pointer array, and gets garbage as it is one past the end
      of the array.  This results in:
      
      [    0.881970] Unable to handle kernel paging request at virtual address fffffb1008b926a4
      [    1.970095] pgd = fffffc00094b0000
      [    1.973530] [fffffb1008b926a4] *pgd=0000000000000000, *pud=0000000000000000, *pmd=0000000000000000
      [    1.982610] Internal error: Oops: 96000004 [#1] SMP
      [    1.987541] Modules linked in:
      [    1.990631] CPU: 48 PID: 295 Comm: cpuhp/48 Tainted: G        W       4.8.0-rc6-preempt-vol+ #9
      [    1.999435] Hardware name: Cavium ThunderX CN88XX board (DT)
      [    2.005159] task: fffffe0fe89cc300 task.stack: fffffe0fe8b8c000
      [    2.011158] PC is at try_to_wake_up+0x194/0x34c
      [    2.015737] LR is at try_to_wake_up+0x150/0x34c
      [    2.020318] pc : [<fffffc00080e7468>] lr : [<fffffc00080e7424>] pstate: 600000c5
      [    2.027803] sp : fffffe0fe8b8fb10
      [    2.031149] x29: fffffe0fe8b8fb10 x28: 0000000000000000
      [    2.036522] x27: fffffc0008c63bc8 x26: 0000000000001000
      [    2.041896] x25: fffffc0008c63c80 x24: fffffc0008bfb200
      [    2.047270] x23: 00000000000000c0 x22: 0000000000000004
      [    2.052642] x21: fffffe0fe89d25bc x20: 0000000000001000
      [    2.058014] x19: fffffe0fe89d1d00 x18: 0000000000000000
      [    2.063386] x17: 0000000000000000 x16: 0000000000000000
      [    2.068760] x15: 0000000000000018 x14: 0000000000000000
      [    2.074133] x13: 0000000000000000 x12: 0000000000000000
      [    2.079505] x11: 0000000000000000 x10: 0000000000000000
      [    2.084879] x9 : 0000000000000000 x8 : 0000000000000000
      [    2.090251] x7 : 0000000000000040 x6 : 0000000000000000
      [    2.095621] x5 : ffffffffffffffff x4 : 0000000000000000
      [    2.100991] x3 : 0000000000000000 x2 : 0000000000000000
      [    2.106364] x1 : fffffc0008be4c24 x0 : ffffff0ffffada80
      [    2.111737]
      [    2.113236] Process cpuhp/48 (pid: 295, stack limit = 0xfffffe0fe8b8c020)
      [    2.120102] Stack: (0xfffffe0fe8b8fb10 to 0xfffffe0fe8b90000)
      [    2.125914] fb00:                                   fffffe0fe8b8fb80 fffffc00080e7648
      .
      .
      .
      [    2.442859] Call trace:
      [    2.445327] Exception stack(0xfffffe0fe8b8f940 to 0xfffffe0fe8b8fa70)
      [    2.451843] f940: fffffe0fe89d1d00 0000040000000000 fffffe0fe8b8fb10 fffffc00080e7468
      [    2.459767] f960: fffffe0fe8b8f980 fffffc00080e4958 ffffff0ff91ab200 fffffc00080e4b64
      [    2.467690] f980: fffffe0fe8b8f9d0 fffffc00080e515c fffffe0fe8b8fa80 0000000000000000
      [    2.475614] f9a0: fffffe0fe8b8f9d0 fffffc00080e58e4 fffffe0fe8b8fa80 0000000000000000
      [    2.483540] f9c0: fffffe0fe8d10000 0000000000000040 fffffe0fe8b8fa50 fffffc00080e5ac4
      [    2.491465] f9e0: ffffff0ffffada80 fffffc0008be4c24 0000000000000000 0000000000000000
      [    2.499387] fa00: 0000000000000000 ffffffffffffffff 0000000000000000 0000000000000040
      [    2.507309] fa20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      [    2.515233] fa40: 0000000000000000 0000000000000000 0000000000000000 0000000000000018
      [    2.523156] fa60: 0000000000000000 0000000000000000
      [    2.528089] [<fffffc00080e7468>] try_to_wake_up+0x194/0x34c
      [    2.533723] [<fffffc00080e7648>] wake_up_process+0x28/0x34
      [    2.539275] [<fffffc00080d3764>] create_worker+0x110/0x19c
      [    2.544824] [<fffffc00080d69dc>] alloc_unbound_pwq+0x3cc/0x4b0
      [    2.550724] [<fffffc00080d6bcc>] wq_update_unbound_numa+0x10c/0x1e4
      [    2.557066] [<fffffc00080d7d78>] workqueue_online_cpu+0x220/0x28c
      [    2.563234] [<fffffc00080bd288>] cpuhp_invoke_callback+0x6c/0x168
      [    2.569398] [<fffffc00080bdf74>] cpuhp_up_callbacks+0x44/0xe4
      [    2.575210] [<fffffc00080be194>] cpuhp_thread_fun+0x13c/0x148
      [    2.581027] [<fffffc00080dfbac>] smpboot_thread_fn+0x19c/0x1a8
      [    2.586929] [<fffffc00080dbd64>] kthread+0xdc/0xf0
      [    2.591776] [<fffffc0008083380>] ret_from_fork+0x10/0x50
      [    2.597147] Code: b00057e1 91304021 91005021 b8626822 (b8606821)
      [    2.603464] ---[ end trace 58c0cd36b88802bc ]---
      [    2.608138] Kernel panic - not syncing: Fatal exception
      
      Fix by moving call to numa_store_cpu_info() for all CPUs into
      smp_prepare_cpus(), which happens before wq_numa_init().  Since
      smp_store_cpu_info() now contains only a single function call,
      simplify by removing the function and out-lining its contents.
      Suggested-by: default avatarRobert Richter <rric@kernel.org>
      Fixes: 1a2db300 ("arm64, numa: Add NUMA support for arm64 platforms.")
      Signed-off-by: default avatarDavid Daney <david.daney@cavium.com>
      Reviewed-by: default avatarRobert Richter <rrichter@cavium.com>
      Tested-by: default avatarYisheng Xie <xieyisheng1@huawei.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      84bba4be
    • Herbert Xu's avatar
      KEYS: Fix skcipher IV clobbering · f3edd9b2
      Herbert Xu authored
      commit 456bee98 upstream.
      
      The IV must not be modified by the skcipher operation so we need
      to duplicate it.
      
      Fixes: c3917fd9 ("KEYS: Use skcipher")
      Reported-by: default avatarMimi Zohar <zohar@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>
      f3edd9b2
    • Al Viro's avatar
      fix fault_in_multipages_...() on architectures with no-op access_ok() · 206d4c6c
      Al Viro authored
      commit e23d4159 upstream.
      
      Switching iov_iter fault-in to multipages variants has exposed an old
      bug in underlying fault_in_multipages_...(); they break if the range
      passed to them wraps around.  Normally access_ok() done by callers will
      prevent such (and it's a guaranteed EFAULT - ERR_PTR() values fall into
      such a range and they should not point to any valid objects).
      
      However, on architectures where userland and kernel live in different
      MMU contexts (e.g. s390) access_ok() is a no-op and on those a range
      with a wraparound can reach fault_in_multipages_...().
      
      Since any wraparound means EFAULT there, the fix is trivial - turn
      those
      
          while (uaddr <= end)
      	    ...
      into
      
          if (unlikely(uaddr > end))
      	    return -EFAULT;
          do
      	    ...
          while (uaddr <= end);
      Reported-by: default avatarJan Stancek <jstancek@redhat.com>
      Tested-by: default avatarJan Stancek <jstancek@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      206d4c6c
    • Johannes Weiner's avatar
      cgroup: duplicate cgroup reference when cloning sockets · 02d35700
      Johannes Weiner authored
      commit d979a39d upstream.
      
      When a socket is cloned, the associated sock_cgroup_data is duplicated
      but not its reference on the cgroup.  As a result, the cgroup reference
      count will underflow when both sockets are destroyed later on.
      
      Fixes: bd1060a1 ("sock, cgroup: add sock->sk_cgroup")
      Link: http://lkml.kernel.org/r/20160914194846.11153-2-hannes@cmpxchg.orgSigned-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Michal Hocko <mhocko@suse.cz>
      Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      02d35700
    • Johannes Weiner's avatar
      mm: memcontrol: make per-cpu charge cache IRQ-safe for socket accounting · 0d91b17b
      Johannes Weiner authored
      commit db2ba40c upstream.
      
      During cgroup2 rollout into production, we started encountering css
      refcount underflows and css access crashes in the memory controller.
      Splitting the heavily shared css reference counter into logical users
      narrowed the imbalance down to the cgroup2 socket memory accounting.
      
      The problem turns out to be the per-cpu charge cache.  Cgroup1 had a
      separate socket counter, but the new cgroup2 socket accounting goes
      through the common charge path that uses a shared per-cpu cache for all
      memory that is being tracked.  Those caches are safe against scheduling
      preemption, but not against interrupts - such as the newly added packet
      receive path.  When cache draining is interrupted by network RX taking
      pages out of the cache, the resuming drain operation will put references
      of in-use pages, thus causing the imbalance.
      
      Disable IRQs during all per-cpu charge cache operations.
      
      Fixes: f7e1cb6e ("mm: memcontrol: account socket memory in unified hierarchy memory controller")
      Link: http://lkml.kernel.org/r/20160914194846.11153-1-hannes@cmpxchg.orgSigned-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: default avatarTejun Heo <tj@kernel.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Michal Hocko <mhocko@suse.cz>
      Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0d91b17b
    • Jan Kara's avatar
      fanotify: fix list corruption in fanotify_get_response() · 45d4c535
      Jan Kara authored
      commit 96d41019 upstream.
      
      fanotify_get_response() calls fsnotify_remove_event() when it finds that
      group is being released from fanotify_release() (bypass_perm is set).
      
      However the event it removes need not be only in the group's notification
      queue but it can have already moved to access_list (userspace read the
      event before closing the fanotify instance fd) which is protected by a
      different lock.  Thus when fsnotify_remove_event() races with
      fanotify_release() operating on access_list, the list can get corrupted.
      
      Fix the problem by moving all the logic removing permission events from
      the lists to one place - fanotify_release().
      
      Fixes: 5838d444 ("fanotify: fix double free of pending permission events")
      Link: http://lkml.kernel.org/r/1473797711-14111-3-git-send-email-jack@suse.czSigned-off-by: default avatarJan Kara <jack@suse.cz>
      Reported-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Tested-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Reviewed-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45d4c535
    • Jan Kara's avatar
      fsnotify: add a way to stop queueing events on group shutdown · e0d4517c
      Jan Kara authored
      commit 12703dbf upstream.
      
      Implement a function that can be called when a group is being shutdown
      to stop queueing new events to the group.  Fanotify will use this.
      
      Fixes: 5838d444 ("fanotify: fix double free of pending permission events")
      Link: http://lkml.kernel.org/r/1473797711-14111-2-git-send-email-jack@suse.czSigned-off-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e0d4517c
    • Santosh Shilimkar's avatar
      mm: fix the page_swap_info() BUG_ON check · 364020ae
      Santosh Shilimkar authored
      commit c8de641b upstream.
      
      Commit 62c230bc ("mm: add support for a filesystem to activate
      swap files and use direct_IO for writing swap pages") replaced the
      swap_aops dirty hook from __set_page_dirty_no_writeback() with
      swap_set_page_dirty().
      
      For normal cases without these special SWP flags code path falls back to
      __set_page_dirty_no_writeback() so the behaviour is expected to be the
      same as before.
      
      But swap_set_page_dirty() makes use of the page_swap_info() helper to
      get the swap_info_struct to check for the flags like SWP_FILE,
      SWP_BLKDEV etc as desired for those features.  This helper has
      BUG_ON(!PageSwapCache(page)) which is racy and safe only for the
      set_page_dirty_lock() path.
      
      For the set_page_dirty() path which is often needed for cases to be
      called from irq context, kswapd() can toggle the flag behind the back
      while the call is getting executed when system is low on memory and
      heavy swapping is ongoing.
      
      This ends up with undesired kernel panic.
      
      This patch just moves the check outside the helper to its users
      appropriately to fix kernel panic for the described path.  Couple of
      users of helpers already take care of SwapCache condition so I skipped
      them.
      
      Link: http://lkml.kernel.org/r/1473460718-31013-1-git-send-email-santosh.shilimkar@oracle.comSigned-off-by: default avatarSantosh Shilimkar <santosh.shilimkar@oracle.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Joe Perches <joe@perches.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Jens Axboe <axboe@fb.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      364020ae
    • Brian Foster's avatar
      xfs: prevent dropping ioend completions during buftarg wait · 7027a358
      Brian Foster authored
      commit 800b2694 upstream.
      
      xfs_wait_buftarg() waits for all pending I/O, drains the ioend
      completion workqueue and walks the LRU until all buffers in the cache
      have been released. This is traditionally an unmount operation` but the
      mechanism is also reused during filesystem freeze.
      
      xfs_wait_buftarg() invokes drain_workqueue() as part of the quiesce,
      which is intended more for a shutdown sequence in that it indicates to
      the queue that new operations are not expected once the drain has begun.
      New work jobs after this point result in a WARN_ON_ONCE() and are
      otherwise dropped.
      
      With filesystem freeze, however, read operations are allowed and can
      proceed during or after the workqueue drain. If such a read occurs
      during the drain sequence, the workqueue infrastructure complains about
      the queued ioend completion work item and drops it on the floor. As a
      result, the buffer remains on the LRU and the freeze never completes.
      
      Despite the fact that the overall buffer cache cleanup is not necessary
      during freeze, fix up this operation such that it is safe to invoke
      during non-unmount quiesce operations. Replace the drain_workqueue()
      call with flush_workqueue(), which runs a similar serialization on
      pending workqueue jobs without causing new jobs to be dropped. This is
      safe for unmount as unmount independently locks out new operations by
      the time xfs_wait_buftarg() is invoked.
      
      cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7027a358
    • Steven Rostedt's avatar
      Makefile: Mute warning for __builtin_return_address(>0) for tracing only · 93200d68
      Steven Rostedt authored
      commit 377ccbb4 upstream.
      
      With the latest gcc compilers, they give a warning if
      __builtin_return_address() parameter is greater than 0. That is because if
      it is used by a function called by a top level function (or in the case of
      the kernel, by assembly), it can try to access stack frames outside the
      stack and crash the system.
      
      The tracing system uses __builtin_return_address() of up to 2! But it is
      well aware of the dangers that it may have, and has even added precautions
      to protect against it (see the thunk code in arch/x86/entry/thunk*.S)
      
      Linus originally added KBUILD_CFLAGS that would suppress the warning for the
      entire kernel, as simply adding KBUILD_CFLAGS to the tracing directory
      wouldn't work. The tracing directory plays a bit with the CFLAGS and
      requires a little more logic.
      
      This adds that special logic to only suppress the warning for the tracing
      directory. If it is used anywhere else outside of tracing, the warning will
      still be triggered.
      
      Link: http://lkml.kernel.org/r/20160728223043.51996267@grimm.local.homeTested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93200d68
    • Linus Torvalds's avatar
      Disable "frame-address" warning · 90d2d8f3
      Linus Torvalds authored
      commit 124a3d88 upstream.
      
      Newer versions of gcc warn about the use of __builtin_return_address()
      with a non-zero argument when "-Wall" is specified:
      
        kernel/trace/trace_irqsoff.c: In function ‘stop_critical_timings’:
        kernel/trace/trace_irqsoff.c:433:86: warning: calling ‘__builtin_return_address’ with a nonzero argument is unsafe [-Wframe-address]
           stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
        [ .. repeats a few times for other similar cases .. ]
      
      It is true that a non-zero argument is somewhat dangerous, and we do not
      actually have very many uses of that in the kernel - but the ftrace code
      does use it, and as Stephen Rostedt says:
      
       "We are well aware of the danger of using __builtin_return_address() of
        > 0.  In fact that's part of the reason for having the "thunk" code in
        x86 (See arch/x86/entry/thunk_{64,32}.S).  [..] it adds extra frames
        when tracking irqs off sections, to prevent __builtin_return_address()
        from accessing bad areas.  In fact the thunk_32.S states: 'Trampoline to
        trace irqs off.  (otherwise CALLER_ADDR1 might crash)'."
      
      For now, __builtin_return_address() with a non-zero argument is the best
      we can do, and the warning is not helpful and can end up making people
      miss other warnings for real problems.
      
      So disable the frame-address warning on compilers that need it.
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      90d2d8f3
    • Linus Torvalds's avatar
      Disable "maybe-uninitialized" warning globally · 63f4bb7d
      Linus Torvalds authored
      commit 6e8d666e upstream.
      
      Several build configurations had already disabled this warning because
      it generates a lot of false positives.  But some had not, and it was
      still enabled for "allmodconfig" builds, for example.
      
      Looking at the warnings produced, every single one I looked at was a
      false positive, and the warnings are frequent enough (and big enough)
      that they can easily hide real problems that you don't notice in the
      noise generated by -Wmaybe-uninitialized.
      
      The warning is good in theory, but this is a classic case of a warning
      that causes more problems than the warning can solve.
      
      If gcc gets better at avoiding false positives, we may be able to
      re-enable this warning.  But as is, we're better off without it, and I
      want to be able to see the *real* warnings.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      63f4bb7d
    • Ian Kent's avatar
      autofs: use dentry flags to block walks during expire · c911e412
      Ian Kent authored
      commit 7cbdb4a2 upstream.
      
      Somewhere along the way the autofs expire operation has changed to hold
      a spin lock over expired dentry selection.  The autofs indirect mount
      expired dentry selection is complicated and quite lengthy so it isn't
      appropriate to hold a spin lock over the operation.
      
      Commit 47be6184 ("fs/dcache.c: avoid soft-lockup in dput()") added a
      might_sleep() to dput() causing a WARN_ONCE() about this usage to be
      issued.
      
      But the spin lock doesn't need to be held over this check, the autofs
      dentry info.  flags are enough to block walks into dentrys during the
      expire.
      
      I've left the direct mount expire as it is (for now) because it is much
      simpler and quicker than the indirect mount expire and adding spin lock
      release and re-aquires would do nothing more than add overhead.
      
      Fixes: 47be6184 ("fs/dcache.c: avoid soft-lockup in dput()")
      Link: http://lkml.kernel.org/r/20160912014017.1773.73060.stgit@pluto.themaw.netSigned-off-by: default avatarIan Kent <raven@themaw.net>
      Reported-by: default avatarTakashi Iwai <tiwai@suse.de>
      Tested-by: default avatarTakashi Iwai <tiwai@suse.de>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: NeilBrown <neilb@suse.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c911e412
    • Junxiao Bi's avatar
      Revert "ocfs2: bump up o2cb network protocol version" · 223248f6
      Junxiao Bi authored
      commit 63b52c49 upstream.
      
      This reverts commit 38b52efd ("ocfs2: bump up o2cb network protocol
      version").
      
      This commit made rolling upgrade fail.  When one node is upgraded to new
      version with this commit, the remaining nodes will fail to establish
      connections to it, then the application like VMs on the remaining nodes
      can't be live migrated to the upgraded one.  This will cause an outage.
      Since negotiate hb timeout behavior didn't change without this commit,
      so revert it.
      
      Fixes: 38b52efd ("ocfs2: bump up o2cb network protocol version")
      Link: http://lkml.kernel.org/r/1471396924-10375-1-git-send-email-junxiao.bi@oracle.comSigned-off-by: default avatarJunxiao Bi <junxiao.bi@oracle.com>
      Cc: Mark Fasheh <mfasheh@suse.de>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joseph Qi <joseph.qi@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      223248f6
    • Ashish Samant's avatar
      ocfs2: fix start offset to ocfs2_zero_range_for_truncate() · e29576aa
      Ashish Samant authored
      commit d21c353d upstream.
      
      If we punch a hole on a reflink such that following conditions are met:
      
      1. start offset is on a cluster boundary
      2. end offset is not on a cluster boundary
      3. (end offset is somewhere in another extent) or
         (hole range > MAX_CONTIG_BYTES(1MB)),
      
      we dont COW the first cluster starting at the start offset.  But in this
      case, we were wrongly passing this cluster to
      ocfs2_zero_range_for_truncate() to zero out.  This will modify the
      cluster in place and zero it in the source too.
      
      Fix this by skipping this cluster in such a scenario.
      
      To reproduce:
      
      1. Create a random file of say 10 MB
           xfs_io -c 'pwrite -b 4k 0 10M' -f 10MBfile
      2. Reflink  it
           reflink -f 10MBfile reflnktest
      3. Punch a hole at starting at cluster boundary  with range greater that
      1MB. You can also use a range that will put the end offset in another
      extent.
           fallocate -p -o 0 -l 1048615 reflnktest
      4. sync
      5. Check the  first cluster in the source file. (It will be zeroed out).
          dd if=10MBfile iflag=direct bs=<cluster size> count=1 | hexdump -C
      
      Link: http://lkml.kernel.org/r/1470957147-14185-1-git-send-email-ashish.samant@oracle.comSigned-off-by: default avatarAshish Samant <ashish.samant@oracle.com>
      Reported-by: default avatarSaar Maoz <saar.maoz@oracle.com>
      Reviewed-by: default avatarSrinivas Eeda <srinivas.eeda@oracle.com>
      Cc: Mark Fasheh <mfasheh@suse.de>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Joseph Qi <joseph.qi@huawei.com>
      Cc: Eric Ren <zren@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e29576aa