linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review
@ 2015-10-26 13:41 Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 001/104] ARM: 8429/1: disable GCC SRA optimization Luis Henriques
                   ` (108 more replies)
  0 siblings, 109 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Luis Henriques

This is the start of the review cycle for the Linux 3.16.7-ckt19 stable kernel.

This version contains 104 new patches, summarized below.  The new patches are
posted as replies to this message and also available in this git branch:

http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-3.16.y-review

git://kernel.ubuntu.com/ubuntu/linux.git  linux-3.16.y-review

The review period for version 3.16.7-ckt19 will be open for the next three days.
To report a problem, please reply to the relevant follow-up patch message.

For more information about the Linux 3.16.y-ckt extended stable kernel version,
see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable .

 -Luis

--
 arch/arm/Kconfig                           |   1 -
 arch/arm/Makefile                          |   8 ++
 arch/arm/boot/dts/omap3-beagle.dts         |   2 +-
 arch/arm/boot/dts/omap5-uevm.dts           |   4 +-
 arch/arm/kernel/signal.c                   |  15 ++--
 arch/arm/kvm/interrupts_head.S             |   6 +-
 arch/arm/mach-orion5x/include/mach/irqs.h  |  64 +++++++--------
 arch/arm/mach-orion5x/irq.c                |   4 +-
 arch/arm64/Kconfig                         |  16 ++++
 arch/arm64/Makefile                        |   4 +
 arch/arm64/kernel/head.S                   |   5 ++
 arch/arm64/kernel/module.c                 |   2 +
 arch/arm64/kernel/signal32.c               |  47 ++++++++---
 arch/arm64/kvm/hyp.S                       |   5 +-
 arch/m68k/include/asm/linkage.h            |  30 +++++++
 arch/mips/kernel/cps-vec.S                 |  12 +--
 arch/mips/mm/dma-default.c                 |   2 +-
 arch/powerpc/boot/Makefile                 |   3 +
 arch/powerpc/mm/hugepage-hash64.c          |   3 +-
 arch/x86/include/uapi/asm/msr-index.h      |   1 +
 arch/x86/kernel/apic/apic.c                |   7 ++
 arch/x86/kernel/entry_64.S                 |  16 +++-
 arch/x86/kernel/paravirt.c                 |  16 +++-
 arch/x86/kernel/tsc.c                      |  17 ++--
 arch/x86/kvm/svm.c                         |   2 +-
 arch/x86/kvm/x86.c                         |   2 +
 arch/x86/mm/init_64.c                      |   2 +-
 arch/x86/platform/efi/efi.c                |  67 +++++++++++++++-
 drivers/block/zram/zcomp.c                 |  12 +--
 drivers/cpufreq/intel_pstate.c             |  10 +--
 drivers/dma/dw/core.c                      |   4 +-
 drivers/gpu/drm/i915/intel_bios.c          |  12 ++-
 drivers/gpu/drm/qxl/qxl_display.c          |  14 ++--
 drivers/gpu/drm/radeon/atombios_encoders.c |   8 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h        |   6 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c    |   6 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c    |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c   |  29 +++++--
 drivers/gpu/drm/vmwgfx/vmwgfx_shader.c     |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c    |  12 ++-
 drivers/hwmon/nct6775.c                    |  16 ++--
 drivers/infiniband/ulp/isert/ib_isert.c    |   9 ++-
 drivers/mtd/ubi/io.c                       |   5 ++
 drivers/mtd/ubi/vtbl.c                     |   1 +
 drivers/mtd/ubi/wl.c                       |   1 +
 drivers/net/ethernet/marvell/mvneta.c      |   4 +-
 drivers/net/ppp/pppoe.c                    |   1 -
 drivers/net/usb/asix_devices.c             |  16 +---
 drivers/net/vxlan.c                        |  10 +--
 drivers/net/xen-netfront.c                 |   3 +-
 drivers/pci/access.c                       |  27 +------
 drivers/pci/quirks.c                       |  20 ++++-
 drivers/platform/x86/hp-wmi.c              |  35 +++++---
 drivers/spi/spi-pxa2xx.c                   |   4 +
 drivers/spi/spi-xtensa-xtfpga.c            |   4 +-
 drivers/spi/spi.c                          |   3 +-
 drivers/staging/android/ion/ion.c          |   6 +-
 drivers/usb/chipidea/udc.c                 |  84 +++++++++----------
 drivers/usb/core/config.c                  |   5 +-
 drivers/usb/host/ehci-fsl.c                |  13 +++
 drivers/usb/host/ehci-hub.c                |   7 ++
 drivers/usb/host/ehci.h                    |  12 +++
 drivers/usb/host/fsl-mph-dr-of.c           |  10 +++
 drivers/usb/host/xhci-mem.c                |  23 +++---
 drivers/usb/host/xhci-ring.c               |  13 ++-
 drivers/usb/host/xhci.c                    |   9 +--
 drivers/usb/serial/option.c                |  24 ++++++
 drivers/usb/serial/whiteheat.c             |  31 ++++++++
 fs/btrfs/extent_io.c                       |  65 +++++++++++++--
 fs/btrfs/inode.c                           |   3 +-
 fs/cifs/cifsencrypt.c                      |  53 +++++++++++-
 fs/cifs/ioctl.c                            |   6 ++
 fs/cifs/smb2ops.c                          |   8 +-
 fs/coredump.c                              |  38 +++++++--
 fs/dcache.c                                |   7 ++
 fs/jbd2/checkpoint.c                       |  39 +++++++--
 fs/jbd2/commit.c                           |   2 +-
 fs/jbd2/journal.c                          |  11 ++-
 fs/namei.c                                 |  31 +++++++-
 fs/ocfs2/dlm/dlmmaster.c                   |   9 ++-
 fs/ocfs2/dlm/dlmrecovery.c                 |   8 +-
 include/linux/fsl_devices.h                |   2 +
 include/linux/jbd2.h                       |   3 +-
 include/linux/skbuff.h                     |   5 +-
 include/net/af_unix.h                      |   6 +-
 include/net/sock.h                         |   8 ++
 ipc/msg.c                                  |  14 ++--
 ipc/sem.c                                  |  15 ++--
 ipc/shm.c                                  |  12 +--
 ipc/util.c                                 |   8 +-
 kernel/irq/proc.c                          |  19 ++++-
 kernel/time/clocksource.c                  |   2 +-
 mm/hugetlb.c                               |   8 ++
 mm/slab.c                                  |  13 ++-
 net/core/datagram.c                        |   6 +-
 net/core/ethtool.c                         |   2 +-
 net/core/fib_rules.c                       |   2 +-
 net/core/skbuff.c                          |   9 ++-
 net/ipv4/tcp_input.c                       |   2 +-
 net/ipv4/udp.c                             |   2 +-
 net/ipv6/raw.c                             |   2 +-
 net/ipv6/udp.c                             |   3 +-
 net/l2tp/l2tp_core.c                       |  11 ++-
 net/netfilter/nft_compat.c                 |  24 ++++--
 net/netlink/af_netlink.c                   |  34 +++++---
 net/openvswitch/flow_table.c               |   3 +-
 net/sctp/sm_sideeffect.c                   |   2 +-
 net/unix/af_unix.c                         |  16 +++-
 sound/arm/Kconfig                          |  15 ++--
 sound/soc/pxa/Kconfig                      |   2 -
 sound/soc/pxa/pxa2xx-ac97.c                |   4 +-
 tools/lib/traceevent/event-parse.c         |  23 +++++-
 tools/perf/util/header.c                   |   4 +-
 tools/perf/util/symbol-elf.c               |  35 +++-----
 virt/kvm/eventfd.c                         | 124 +++++++++++++++++------------
 virt/kvm/kvm_main.c                        |  19 ++++-
 116 files changed, 1164 insertions(+), 451 deletions(-)

Aaron Conole (2):
      af_unix: Convert the unix_sk macro to an inline function for type safety
      af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag

Adrian Hunter (1):
      perf tools: Fix copying of /proc/kcore

Alex Williamson (2):
      PCI: Fix devfn for VPD access through function 0
      PCI: Use function 0 VPD for identical functions, regular VPD for others

Alexander Couzens (1):
      l2tp: protect tunnel->del_work by ref_count

Andreas Schwab (1):
      m68k: Define asmlinkage_protect

Andrey Vagin (1):
      net/unix: fix logic about sk_peek_offset

Andy Lutomirski (2):
      x86/paravirt: Replace the paravirt nop with a bona fide empty function
      x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code

Andy Shevchenko (1):
      dmaengine: dw: properly read DWC_PARAMS register

Aneesh Kumar K.V (1):
      powerpc/mm: Recompute hash value after a failed update

Arad, Ronen (1):
      netlink: Trim skb to alloc size to avoid MSG_TRUNC

Ard Biesheuvel (1):
      ARM: 8429/1: disable GCC SRA optimization

Arnaldo Carvalho de Melo (1):
      perf header: Fixup reading of HEADER_NRCPUS feature

Ben Hutchings (1):
      genirq: Fix race in register_irq_proc()

Benjamin Herrenschmidt (1):
      powerpc/boot: Specify ABI v2 when building an LE boot wrapper

Carl Frederik Werner (1):
      ARM: dts: omap3-beagle: make i2c3, ddc and tfp410 gpio work again

Charles Keepax (1):
      asix: Do full reset during ax88772_bind

Chas Williams (1):
      net/xen-netfront: only napi_synchronize() if running

Dave Airlie (1):
      drm/qxl: only report first monitor as connected if we have no state

David Woodhouse (1):
      x86/platform: Fix Geode LX timekeeping in the generic x86 build

Dirk Müller (1):
      Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS

Eric Dumazet (1):
      net: add pfmemalloc check in sk_add_backlog()

Eric W. Biederman (2):
      dcache: Handle escaped paths in prepend_path
      vfs: Test for and handle paths that are unreachable from their mnt_root

Fabiano Fidêncio (1):
      drm/qxl: recreate the primary surface when the bo is not primary

Filipe Manana (1):
      Btrfs: fix read corruption of compressed and shared extents

Grazvydas Ignotas (1):
      ARM: dts: omap5-uevm.dts: fix i2c5 pinctrl offsets

Guenter Roeck (2):
      hwmon: (nct6775) Swap STEP_UP_TIME and STEP_DOWN_TIME registers for most chips
      spi: Fix documentation of spi_alloc_master()

Guillaume Nault (1):
      ppp: don't override sk->sk_state in pppoe_flush_dev()

James Hogan (1):
      MIPS: dma-default: Fix 32-bit fall back to GFP_DMA

Jan Kara (1):
      jbd2: avoid infinite loop when destroying aborted journal

Jani Nikula (1):
      drm/i915/bios: handle MIPI Sequence Block v3+ gracefully

Jann Horn (2):
      CIFS: fix type confusion in copy offload ioctl
      fs: if a coredump already exists, unlink and recreate with O_EXCL

Jason Wang (4):
      kvm: don't try to register to KVM_FAST_MMIO_BUS for non mmio eventfd
      kvm: factor out core eventfd assign/deassign logic
      kvm: fix double free for fast mmio eventfd
      kvm: fix zero length mmio searching

Jeff Mahoney (1):
      btrfs: skip waiting on ordered range for special files

Jenny Derzhavetz (1):
      iser-target: remove command with state ISTATE_REMOVE

Jiri Benc (1):
      vxlan: set needed headroom correctly

Joe Perches (1):
      ethtool: Use kcalloc instead of kmalloc for ethtool_get_strings

Johan Hovold (1):
      USB: whiteheat: fix potential null-deref at probe

John Stultz (1):
      clocksource: Fix abs() usage w/ 64bit values

Joonsoo Kim (1):
      mm/slab: fix unexpected index mapping result of kmalloc_size(INDEX_NODE+1)

Joseph Qi (1):
      ocfs2/dlm: fix deadlock when dispatch assert master

Julia Lawall (1):
      xhci-mem: Use setup_timer

Kapileshwar Singh (1):
      tools lib traceevent: Fix string handling in heterogeneous arch environments

Konstantin Khlebnikov (1):
      ovs: do not allocate memory from offline numa node

Kyle Evans (1):
      hp-wmi: limit hotkey enable

Linus Torvalds (1):
      Initialize msg/shm IPC objects before doing ipc_addid()

Liu.Zhao (1):
      USB: option: add ZTE PIDs

Luis Henriques (2):
      zram: fix possible use after free in zcomp_create()
      Revert "ARM: orion5x: fix legacy orion5x IRQ numbers"

Manfred Spraul (1):
      ipc/sem.c: fully initialize sem_array before making it visible

Marc Zyngier (2):
      arm64: KVM: Disable virtual timer even if the guest is not using it
      arm: KVM: Disable virtual timer even if the guest is not using it

Mathias Krause (1):
      hp-wmi: Add missing __init annotations to initialization code

Mathias Nyman (4):
      usb: Use the USB_SS_MULT() macro to get the burst multiplier.
      xhci: give command abortion one more chance before killing xhci
      xhci: change xhci 1.0 only restrictions to support xhci 1.1
      xhci: init command timeout timer earlier to avoid deleting it uninitialized

Matt Fleming (1):
      x86/efi: Fix boot crash by mapping EFI memmap entries bottom-up at runtime, instead of top-down

Max Filippov (1):
      spi: xtensa-xtfpga: fix register endianness

Mel Gorman (1):
      mm: hugetlbfs: skip shared VMAs when unmapping private pages to satisfy a fault

Michel Dänzer (1):
      drm/radeon: Restore LCD backlight level on resume (>= R5xx)

Michel Stam (1):
      asix: Don't reset PHY on if_up for ASIX 88772

Nikhil Badola (2):
      drivers: usb :fsl: Implement Workaround for USB Erratum A007792
      drivers: usb: fsl: Workaround for USB erratum-A005275

Pablo Neira Ayuso (1):
      netfilter: nft_compat: skip family comparison in case of NFPROTO_UNSPEC

Paolo Bonzini (1):
      KVM: x86: trap AMD MSRs for the TSeg base and mask

Paul Burton (3):
      MIPS: CPS: Stop dangling delay slot from has_mt.
      MIPS: CPS: Don't include MT code in non-MT kernels.
      MIPS: CPS: #ifdef on CONFIG_MIPS_MT_SMP rather than CONFIG_MIPS_MT

Peter Chen (1):
      usb: chipidea: udc: using the correct stall implementation

Peter Seiderer (1):
      cifs: use server timestamp for ntlmv2 authentication

Prarit Bhargava (1):
      intel_pstate: Fix overflow in busy_scaled due to long delay

Pravin B Shelar (2):
      skbuff: Fix skb checksum flag on skb pull
      skbuff: Fix skb checksum partial check.

Richard Weinberger (1):
      UBI: Validate data_size

Robert Jarzmik (2):
      ASoC: pxa: pxa2xx-ac97: fix dma requestor lines
      ASoC: fix broken pxa SoC support

Roger Quadros (2):
      usb: xhci: Clear XHCI_STATE_DYING on start
      usb: xhci: Allow usb_add/remove_hcd() to be called repeatedly

Roland Dreier (1):
      fib_rules: Fix dump_rules() not to exit early

Russell King (1):
      ARM: fix Thumb2 signal handling when ARMv6 is enabled

Sabrina Dubroca (1):
      net: add length argument to skb_copy_and_csum_datagram_iovec

Shaohua Li (1):
      x86/apic: Serialize LVTT and TSC_DEADLINE writes

Shawn Lin (1):
      staging: ion: fix corruption of ion_import_dma_buf

Simon Guinot (1):
      net: mvneta: fix DMA buffer unmapping in mvneta_rx()

Stephen Smalley (1):
      x86/mm: Set NX on gap between __ex_table and rodata

Steve French (1):
      disabling oplocks/leases via module parm enable_oplocks broken for SMB3

Stratos Karafotis (1):
      cpufreq: intel_pstate: Remove unnecessary type casting in div_s64() call

Tan, Jui Nee (1):
      spi: spi-pxa2xx: Check status register to determine if SSSR_TINT is disabled

Thomas Hellstrom (2):
      drm/vmwgfx: Fix up user_dmabuf refcounting
      drm/vmwgfx: Fix kernel NULL pointer dereference on older hardware

Will Deacon (3):
      arm64: head.S: initialise mdcr_el2 in el2_setup
      arm64: compat: fix vfp save/restore across signal handlers in big-endian
      arm64: errata: add module build workaround for erratum #843419

lucien (1):
      sctp: donot reset the overall_error_count in SHUTDOWN_RECEIVE state

shengyong (1):
      UBI: return ENOSPC if no enough space available

^ permalink raw reply	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 001/104] ARM: 8429/1: disable GCC SRA optimization
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 002/104] CIFS: fix type confusion in copy offload ioctl Luis Henriques
                   ` (107 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Ard Biesheuvel, Russell King, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit a077224fd35b2f7fbc93f14cf67074fc792fbac2 upstream.

While working on the 32-bit ARM port of UEFI, I noticed a strange
corruption in the kernel log. The following snprintf() statement
(in drivers/firmware/efi/efi.c:efi_md_typeattr_format())

	snprintf(pos, size, "|%3s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]",

was producing the following output in the log:

	|    |   |   |   |    |WB|WT|WC|UC]
	|    |   |   |   |    |WB|WT|WC|UC]
	|    |   |   |   |    |WB|WT|WC|UC]
	|RUN|   |   |   |    |WB|WT|WC|UC]*
	|RUN|   |   |   |    |WB|WT|WC|UC]*
	|    |   |   |   |    |WB|WT|WC|UC]
	|RUN|   |   |   |    |WB|WT|WC|UC]*
	|    |   |   |   |    |WB|WT|WC|UC]
	|RUN|   |   |   |    |   |   |   |UC]
	|RUN|   |   |   |    |   |   |   |UC]

As it turns out, this is caused by incorrect code being emitted for
the string() function in lib/vsprintf.c. The following code

	if (!(spec.flags & LEFT)) {
		while (len < spec.field_width--) {
			if (buf < end)
				*buf = ' ';
			++buf;
		}
	}
	for (i = 0; i < len; ++i) {
		if (buf < end)
			*buf = *s;
		++buf; ++s;
	}
	while (len < spec.field_width--) {
		if (buf < end)
			*buf = ' ';
		++buf;
	}

when called with len == 0, triggers an issue in the GCC SRA optimization
pass (Scalar Replacement of Aggregates), which handles promotion of signed
struct members incorrectly. This is a known but as yet unresolved issue.
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65932). In this particular
case, it is causing the second while loop to be executed erroneously a
single time, causing the additional space characters to be printed.

So disable the optimization by passing -fno-ipa-sra.

Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/arm/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 6721fab13734..2c359d52f4b4 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -52,6 +52,14 @@ endif
 
 comma = ,
 
+#
+# The Scalar Replacement of Aggregates (SRA) optimization pass in GCC 4.9 and
+# later may result in code being generated that handles signed short and signed
+# char struct members incorrectly. So disable it.
+# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65932)
+#
+KBUILD_CFLAGS	+= $(call cc-option,-fno-ipa-sra)
+
 # This selects which instruction set is used.
 # Note that GCC does not numerically define an architecture version
 # macro, but instead defines a whole series of macros which makes

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 002/104] CIFS: fix type confusion in copy offload ioctl
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 001/104] ARM: 8429/1: disable GCC SRA optimization Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 003/104] hwmon: (nct6775) Swap STEP_UP_TIME and STEP_DOWN_TIME registers for most chips Luis Henriques
                   ` (106 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Jann Horn, Steve French, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jann Horn <jann@thejh.net>

commit 4c17a6d56bb0cad3066a714e94f7185a24b40f49 upstream.

This might lead to local privilege escalation (code execution as
kernel) for systems where the following conditions are met:

 - CONFIG_CIFS_SMB2 and CONFIG_CIFS_POSIX are enabled
 - a cifs filesystem is mounted where:
  - the mount option "vers" was used and set to a value >=2.0
  - the attacker has write access to at least one file on the filesystem

To attack this, an attacker would have to guess the target_tcon
pointer (but guessing wrong doesn't cause a crash, it just returns an
error code) and win a narrow race.

Signed-off-by: Jann Horn <jann@thejh.net>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 fs/cifs/ioctl.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index 8b7898b7670f..64a9bca976d0 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -67,6 +67,12 @@ static long cifs_ioctl_clone(unsigned int xid, struct file *dst_file,
 		goto out_drop_write;
 	}
 
+	if (src_file.file->f_op->unlocked_ioctl != cifs_ioctl) {
+		rc = -EBADF;
+		cifs_dbg(VFS, "src file seems to be from a different filesystem type\n");
+		goto out_fput;
+	}
+
 	if ((!src_file.file->private_data) || (!dst_file->private_data)) {
 		rc = -EBADF;
 		cifs_dbg(VFS, "missing cifsFileInfo on copy range src file\n");

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 003/104] hwmon: (nct6775) Swap STEP_UP_TIME and STEP_DOWN_TIME registers for most chips
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 001/104] ARM: 8429/1: disable GCC SRA optimization Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 002/104] CIFS: fix type confusion in copy offload ioctl Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 004/104] x86/apic: Serialize LVTT and TSC_DEADLINE writes Luis Henriques
                   ` (105 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Guenter Roeck, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Guenter Roeck <linux@roeck-us.net>

commit 728d29400488d54974d3317fe8a232b45fdb42ee upstream.

The STEP_UP_TIME and STEP_DOWN_TIME registers are swapped for all chips but
NCT6775.

Reported-by: Grazvydas Ignotas <notasas@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/hwmon/nct6775.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index a2e63b309fe6..5ce32bbc41eb 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -350,6 +350,10 @@ static const u16 NCT6775_REG_TEMP_CRIT[ARRAY_SIZE(nct6775_temp_label) - 1]
 
 /* NCT6776 specific data */
 
+/* STEP_UP_TIME and STEP_DOWN_TIME regs are swapped for all chips but NCT6775 */
+#define NCT6776_REG_FAN_STEP_UP_TIME NCT6775_REG_FAN_STEP_DOWN_TIME
+#define NCT6776_REG_FAN_STEP_DOWN_TIME NCT6775_REG_FAN_STEP_UP_TIME
+
 static const s8 NCT6776_ALARM_BITS[] = {
 	0, 1, 2, 3, 8, 21, 20, 16,	/* in0.. in7 */
 	17, -1, -1, -1, -1, -1, -1,	/* in8..in14 */
@@ -3476,8 +3480,8 @@ static int nct6775_probe(struct platform_device *pdev)
 		data->REG_FAN_PULSES = NCT6776_REG_FAN_PULSES;
 		data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT;
 		data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME;
-		data->REG_FAN_TIME[1] = NCT6775_REG_FAN_STEP_UP_TIME;
-		data->REG_FAN_TIME[2] = NCT6775_REG_FAN_STEP_DOWN_TIME;
+		data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME;
+		data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME;
 		data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H;
 		data->REG_PWM[0] = NCT6775_REG_PWM;
 		data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT;
@@ -3548,8 +3552,8 @@ static int nct6775_probe(struct platform_device *pdev)
 		data->REG_FAN_PULSES = NCT6779_REG_FAN_PULSES;
 		data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT;
 		data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME;
-		data->REG_FAN_TIME[1] = NCT6775_REG_FAN_STEP_UP_TIME;
-		data->REG_FAN_TIME[2] = NCT6775_REG_FAN_STEP_DOWN_TIME;
+		data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME;
+		data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME;
 		data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H;
 		data->REG_PWM[0] = NCT6775_REG_PWM;
 		data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT;
@@ -3624,8 +3628,8 @@ static int nct6775_probe(struct platform_device *pdev)
 		data->REG_FAN_PULSES = NCT6779_REG_FAN_PULSES;
 		data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT;
 		data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME;
-		data->REG_FAN_TIME[1] = NCT6775_REG_FAN_STEP_UP_TIME;
-		data->REG_FAN_TIME[2] = NCT6775_REG_FAN_STEP_DOWN_TIME;
+		data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME;
+		data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME;
 		data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H;
 		data->REG_PWM[0] = NCT6775_REG_PWM;
 		data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 004/104] x86/apic: Serialize LVTT and TSC_DEADLINE writes
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (2 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 003/104] hwmon: (nct6775) Swap STEP_UP_TIME and STEP_DOWN_TIME registers for most chips Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 005/104] arm64: head.S: initialise mdcr_el2 in el2_setup Luis Henriques
                   ` (104 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Shaohua Li, Kernel-team, lenb, fenghua.yu, Andi Kleen,
	H. Peter Anvin, Thomas Gleixner, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shaohua Li <shli@fb.com>

commit 5d7c631d926b59aa16f3c56eaeb83f1036c81dc7 upstream.

The APIC LVTT register is MMIO mapped but the TSC_DEADLINE register is an
MSR. The write to the TSC_DEADLINE MSR is not serializing, so it's not
guaranteed that the write to LVTT has reached the APIC before the
TSC_DEADLINE MSR is written. In such a case the write to the MSR is
ignored and as a consequence the local timer interrupt never fires.

The SDM decribes this issue for xAPIC and x2APIC modes. The
serialization methods recommended by the SDM differ.

xAPIC:
 "1. Memory-mapped write to LVT Timer Register, setting bits 18:17 to 10b.
  2. WRMSR to the IA32_TSC_DEADLINE MSR a value much larger than current time-stamp counter.
  3. If RDMSR of the IA32_TSC_DEADLINE MSR returns zero, go to step 2.
  4. WRMSR to the IA32_TSC_DEADLINE MSR the desired deadline."

x2APIC:
 "To allow for efficient access to the APIC registers in x2APIC mode,
  the serializing semantics of WRMSR are relaxed when writing to the
  APIC registers. Thus, system software should not use 'WRMSR to APIC
  registers in x2APIC mode' as a serializing instruction. Read and write
  accesses to the APIC registers will occur in program order. A WRMSR to
  an APIC register may complete before all preceding stores are globally
  visible; software can prevent this by inserting a serializing
  instruction, an SFENCE, or an MFENCE before the WRMSR."

The xAPIC method is to just wait for the memory mapped write to hit
the LVTT by checking whether the MSR write has reached the hardware.
There is no reason why a proper MFENCE after the memory mapped write would
not do the same. Andi Kleen confirmed that MFENCE is sufficient for the
xAPIC case as well.

Issue MFENCE before writing to the TSC_DEADLINE MSR. This can be done
unconditionally as all CPUs which have TSC_DEADLINE also have MFENCE
support.

[ tglx: Massaged the changelog ]

Signed-off-by: Shaohua Li <shli@fb.com>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Cc: <Kernel-team@fb.com>
Cc: <lenb@kernel.org>
Cc: <fenghua.yu@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Link: http://lkml.kernel.org/r/20150909041352.GA2059853@devbig257.prn2.facebook.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/x86/kernel/apic/apic.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 62d8c4a944c0..c385d14dadc3 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -366,6 +366,13 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
 	apic_write(APIC_LVTT, lvtt_value);
 
 	if (lvtt_value & APIC_LVT_TIMER_TSCDEADLINE) {
+		/*
+		 * See Intel SDM: TSC-Deadline Mode chapter. In xAPIC mode,
+		 * writing to the APIC LVTT and TSC_DEADLINE MSR isn't serialized.
+		 * According to Intel, MFENCE can do the serialization here.
+		 */
+		asm volatile("mfence" : : : "memory");
+
 		printk_once(KERN_DEBUG "TSC deadline timer enabled\n");
 		return;
 	}

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 005/104] arm64: head.S: initialise mdcr_el2 in el2_setup
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (3 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 004/104] x86/apic: Serialize LVTT and TSC_DEADLINE writes Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 006/104] kvm: don't try to register to KVM_FAST_MMIO_BUS for non mmio eventfd Luis Henriques
                   ` (103 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Will Deacon, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Will Deacon <will.deacon@arm.com>

commit d10bcd473301888f957ec4b6b12aa3621be78d59 upstream.

When entering the kernel at EL2, we fail to initialise the MDCR_EL2
register which controls debug access and PMU capabilities at EL1.

This patch ensures that the register is initialised so that all traps
are disabled and all the PMU counters are available to the host. When a
guest is scheduled, KVM takes care to configure trapping appropriately.

Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/arm64/kernel/head.S | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 1cd11e73058f..a089ce8d52b3 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -315,6 +315,11 @@ CPU_LE(	movk	x0, #0x30d0, lsl #16	)	// Clear EE and E0E on LE systems
 	msr	hstr_el2, xzr			// Disable CP15 traps to EL2
 #endif
 
+	/* EL2 debug */
+	mrs	x0, pmcr_el0			// Disable debug access traps
+	ubfx	x0, x0, #11, #5			// to EL2 and allow access to
+	msr	mdcr_el2, x0			// all PMU counters from EL1
+
 	/* Stage-2 translation */
 	msr	vttbr_el2, xzr
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 006/104] kvm: don't try to register to KVM_FAST_MMIO_BUS for non mmio eventfd
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (4 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 005/104] arm64: head.S: initialise mdcr_el2 in el2_setup Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 007/104] kvm: factor out core eventfd assign/deassign logic Luis Henriques
                   ` (102 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Gleb Natapov, Paolo Bonzini, Jason Wang, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jason Wang <jasowang@redhat.com>

commit 8453fecbecae26edb3f278627376caab05d9a88d upstream.

We only want zero length mmio eventfd to be registered on
KVM_FAST_MMIO_BUS. So check this explicitly when arg->len is zero to
make sure this.

Cc: Gleb Natapov <gleb@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 virt/kvm/eventfd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 20c3af7692c5..47e48e2c7d1a 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -778,7 +778,7 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
 	/* When length is ignored, MMIO is also put on a separate bus, for
 	 * faster lookups.
 	 */
-	if (!args->len && !(args->flags & KVM_IOEVENTFD_FLAG_PIO)) {
+	if (!args->len && bus_idx == KVM_MMIO_BUS) {
 		ret = kvm_io_bus_register_dev(kvm, KVM_FAST_MMIO_BUS,
 					      p->addr, 0, &p->dev);
 		if (ret < 0)
@@ -833,7 +833,7 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
 			continue;
 
 		kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev);
-		if (!p->length) {
+		if (!p->length && p->bus_idx == KVM_MMIO_BUS) {
 			kvm_io_bus_unregister_dev(kvm, KVM_FAST_MMIO_BUS,
 						  &p->dev);
 		}

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 007/104] kvm: factor out core eventfd assign/deassign logic
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (5 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 006/104] kvm: don't try to register to KVM_FAST_MMIO_BUS for non mmio eventfd Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 008/104] kvm: fix double free for fast mmio eventfd Luis Henriques
                   ` (101 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Gleb Natapov, Paolo Bonzini, Jason Wang, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jason Wang <jasowang@redhat.com>

commit 85da11ca587c8eb73993a1b503052391a73586f9 upstream.

This patch factors out core eventfd assign/deassign logic and leaves
the argument checking and bus index selection to callers.

Cc: Gleb Natapov <gleb@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 virt/kvm/eventfd.c | 85 ++++++++++++++++++++++++++++++++----------------------
 1 file changed, 50 insertions(+), 35 deletions(-)

diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 47e48e2c7d1a..5a62748c49b9 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -703,40 +703,14 @@ static enum kvm_bus ioeventfd_bus_from_flags(__u32 flags)
 	return KVM_MMIO_BUS;
 }
 
-static int
-kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
+static int kvm_assign_ioeventfd_idx(struct kvm *kvm,
+				enum kvm_bus bus_idx,
+				struct kvm_ioeventfd *args)
 {
-	enum kvm_bus              bus_idx;
-	struct _ioeventfd        *p;
-	struct eventfd_ctx       *eventfd;
-	int                       ret;
-
-	bus_idx = ioeventfd_bus_from_flags(args->flags);
-	/* must be natural-word sized, or 0 to ignore length */
-	switch (args->len) {
-	case 0:
-	case 1:
-	case 2:
-	case 4:
-	case 8:
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	/* check for range overflow */
-	if (args->addr + args->len < args->addr)
-		return -EINVAL;
 
-	/* check for extra flags that we don't understand */
-	if (args->flags & ~KVM_IOEVENTFD_VALID_FLAG_MASK)
-		return -EINVAL;
-
-	/* ioeventfd with no length can't be combined with DATAMATCH */
-	if (!args->len &&
-	    args->flags & (KVM_IOEVENTFD_FLAG_PIO |
-			   KVM_IOEVENTFD_FLAG_DATAMATCH))
-		return -EINVAL;
+	struct eventfd_ctx *eventfd;
+	struct _ioeventfd *p;
+	int ret;
 
 	eventfd = eventfd_ctx_fdget(args->fd);
 	if (IS_ERR(eventfd))
@@ -805,14 +779,13 @@ fail:
 }
 
 static int
-kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
+kvm_deassign_ioeventfd_idx(struct kvm *kvm, enum kvm_bus bus_idx,
+			   struct kvm_ioeventfd *args)
 {
-	enum kvm_bus              bus_idx;
 	struct _ioeventfd        *p, *tmp;
 	struct eventfd_ctx       *eventfd;
 	int                       ret = -ENOENT;
 
-	bus_idx = ioeventfd_bus_from_flags(args->flags);
 	eventfd = eventfd_ctx_fdget(args->fd);
 	if (IS_ERR(eventfd))
 		return PTR_ERR(eventfd);
@@ -850,6 +823,48 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
 	return ret;
 }
 
+static int kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
+{
+	enum kvm_bus bus_idx = ioeventfd_bus_from_flags(args->flags);
+
+	return kvm_deassign_ioeventfd_idx(kvm, bus_idx, args);
+}
+
+static int
+kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
+{
+	enum kvm_bus              bus_idx;
+
+	bus_idx = ioeventfd_bus_from_flags(args->flags);
+	/* must be natural-word sized, or 0 to ignore length */
+	switch (args->len) {
+	case 0:
+	case 1:
+	case 2:
+	case 4:
+	case 8:
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	/* check for range overflow */
+	if (args->addr + args->len < args->addr)
+		return -EINVAL;
+
+	/* check for extra flags that we don't understand */
+	if (args->flags & ~KVM_IOEVENTFD_VALID_FLAG_MASK)
+		return -EINVAL;
+
+	/* ioeventfd with no length can't be combined with DATAMATCH */
+	if (!args->len &&
+	    args->flags & (KVM_IOEVENTFD_FLAG_PIO |
+			   KVM_IOEVENTFD_FLAG_DATAMATCH))
+		return -EINVAL;
+
+	return kvm_assign_ioeventfd_idx(kvm, bus_idx, args);
+}
+
 int
 kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
 {

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 008/104] kvm: fix double free for fast mmio eventfd
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (6 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 007/104] kvm: factor out core eventfd assign/deassign logic Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 009/104] kvm: fix zero length mmio searching Luis Henriques
                   ` (100 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Gleb Natapov, Paolo Bonzini, Jason Wang, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jason Wang <jasowang@redhat.com>

commit eefd6b06b17c5478e7c24bea6f64beaa2c431ca6 upstream.

We register wildcard mmio eventfd on two buses, once for KVM_MMIO_BUS
and once on KVM_FAST_MMIO_BUS but with a single iodev
instance. This will lead to an issue: kvm_io_bus_destroy() knows
nothing about the devices on two buses pointing to a single dev. Which
will lead to double free[1] during exit. Fix this by allocating two
instances of iodevs then registering one on KVM_MMIO_BUS and another
on KVM_FAST_MMIO_BUS.

CPU: 1 PID: 2894 Comm: qemu-system-x86 Not tainted 3.19.0-26-generic #28-Ubuntu
Hardware name: LENOVO 2356BG6/2356BG6, BIOS G7ET96WW (2.56 ) 09/12/2013
task: ffff88009ae0c4b0 ti: ffff88020e7f0000 task.ti: ffff88020e7f0000
RIP: 0010:[<ffffffffc07e25d8>]  [<ffffffffc07e25d8>] ioeventfd_release+0x28/0x60 [kvm]
RSP: 0018:ffff88020e7f3bc8  EFLAGS: 00010292
RAX: dead000000200200 RBX: ffff8801ec19c900 RCX: 000000018200016d
RDX: ffff8801ec19cf80 RSI: ffffea0008bf1d40 RDI: ffff8801ec19c900
RBP: ffff88020e7f3bd8 R08: 000000002fc75a01 R09: 000000018200016d
R10: ffffffffc07df6ae R11: ffff88022fc75a98 R12: ffff88021e7cc000
R13: ffff88021e7cca48 R14: ffff88021e7cca50 R15: ffff8801ec19c880
FS:  00007fc1ee3e6700(0000) GS:ffff88023e240000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f8f389d8000 CR3: 000000023dc13000 CR4: 00000000001427e0
Stack:
ffff88021e7cc000 0000000000000000 ffff88020e7f3be8 ffffffffc07e2622
ffff88020e7f3c38 ffffffffc07df69a ffff880232524160 ffff88020e792d80
 0000000000000000 ffff880219b78c00 0000000000000008 ffff8802321686a8
Call Trace:
[<ffffffffc07e2622>] ioeventfd_destructor+0x12/0x20 [kvm]
[<ffffffffc07df69a>] kvm_put_kvm+0xca/0x210 [kvm]
[<ffffffffc07df818>] kvm_vcpu_release+0x18/0x20 [kvm]
[<ffffffff811f69f7>] __fput+0xe7/0x250
[<ffffffff811f6bae>] ____fput+0xe/0x10
[<ffffffff81093f04>] task_work_run+0xd4/0xf0
[<ffffffff81079358>] do_exit+0x368/0xa50
[<ffffffff81082c8f>] ? recalc_sigpending+0x1f/0x60
[<ffffffff81079ad5>] do_group_exit+0x45/0xb0
[<ffffffff81085c71>] get_signal+0x291/0x750
[<ffffffff810144d8>] do_signal+0x28/0xab0
[<ffffffff810f3a3b>] ? do_futex+0xdb/0x5d0
[<ffffffff810b7028>] ? __wake_up_locked_key+0x18/0x20
[<ffffffff810f3fa6>] ? SyS_futex+0x76/0x170
[<ffffffff81014fc9>] do_notify_resume+0x69/0xb0
[<ffffffff817cb9af>] int_signal+0x12/0x17
Code: 5d c3 90 0f 1f 44 00 00 55 48 89 e5 53 48 89 fb 48 83 ec 08 48 8b 7f 20 e8 06 d6 a5 c0 48 8b 43 08 48 8b 13 48 89 df 48 89 42 08 <48> 89 10 48 b8 00 01 10 00 00
 RIP  [<ffffffffc07e25d8>] ioeventfd_release+0x28/0x60 [kvm]
 RSP <ffff88020e7f3bc8>

Cc: Gleb Natapov <gleb@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 virt/kvm/eventfd.c | 43 +++++++++++++++++++++++++------------------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 5a62748c49b9..2d4291b87792 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -749,16 +749,6 @@ static int kvm_assign_ioeventfd_idx(struct kvm *kvm,
 	if (ret < 0)
 		goto unlock_fail;
 
-	/* When length is ignored, MMIO is also put on a separate bus, for
-	 * faster lookups.
-	 */
-	if (!args->len && bus_idx == KVM_MMIO_BUS) {
-		ret = kvm_io_bus_register_dev(kvm, KVM_FAST_MMIO_BUS,
-					      p->addr, 0, &p->dev);
-		if (ret < 0)
-			goto register_fail;
-	}
-
 	kvm->buses[bus_idx]->ioeventfd_count++;
 	list_add_tail(&p->list, &kvm->ioeventfds);
 
@@ -766,8 +756,6 @@ static int kvm_assign_ioeventfd_idx(struct kvm *kvm,
 
 	return 0;
 
-register_fail:
-	kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev);
 unlock_fail:
 	mutex_unlock(&kvm->slots_lock);
 
@@ -806,10 +794,6 @@ kvm_deassign_ioeventfd_idx(struct kvm *kvm, enum kvm_bus bus_idx,
 			continue;
 
 		kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev);
-		if (!p->length && p->bus_idx == KVM_MMIO_BUS) {
-			kvm_io_bus_unregister_dev(kvm, KVM_FAST_MMIO_BUS,
-						  &p->dev);
-		}
 		kvm->buses[bus_idx]->ioeventfd_count--;
 		ioeventfd_release(p);
 		ret = 0;
@@ -826,14 +810,19 @@ kvm_deassign_ioeventfd_idx(struct kvm *kvm, enum kvm_bus bus_idx,
 static int kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
 {
 	enum kvm_bus bus_idx = ioeventfd_bus_from_flags(args->flags);
+	int ret = kvm_deassign_ioeventfd_idx(kvm, bus_idx, args);
+
+	if (!args->len && bus_idx == KVM_MMIO_BUS)
+		kvm_deassign_ioeventfd_idx(kvm, KVM_FAST_MMIO_BUS, args);
 
-	return kvm_deassign_ioeventfd_idx(kvm, bus_idx, args);
+	return ret;
 }
 
 static int
 kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
 {
 	enum kvm_bus              bus_idx;
+	int ret;
 
 	bus_idx = ioeventfd_bus_from_flags(args->flags);
 	/* must be natural-word sized, or 0 to ignore length */
@@ -862,7 +851,25 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
 			   KVM_IOEVENTFD_FLAG_DATAMATCH))
 		return -EINVAL;
 
-	return kvm_assign_ioeventfd_idx(kvm, bus_idx, args);
+	ret = kvm_assign_ioeventfd_idx(kvm, bus_idx, args);
+	if (ret)
+		goto fail;
+
+	/* When length is ignored, MMIO is also put on a separate bus, for
+	 * faster lookups.
+	 */
+	if (!args->len && bus_idx == KVM_MMIO_BUS) {
+		ret = kvm_assign_ioeventfd_idx(kvm, KVM_FAST_MMIO_BUS, args);
+		if (ret < 0)
+			goto fast_fail;
+	}
+
+	return 0;
+
+fast_fail:
+	kvm_deassign_ioeventfd_idx(kvm, bus_idx, args);
+fail:
+	return ret;
 }
 
 int

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 009/104] kvm: fix zero length mmio searching
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (7 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 008/104] kvm: fix double free for fast mmio eventfd Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 010/104] ARM: fix Thumb2 signal handling when ARMv6 is enabled Luis Henriques
                   ` (99 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Gleb Natapov, Paolo Bonzini, Jason Wang, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jason Wang <jasowang@redhat.com>

commit 8f4216c7d28976f7ec1b2bcbfa0a9f787133c45e upstream.

Currently, if we had a zero length mmio eventfd assigned on
KVM_MMIO_BUS. It will never be found by kvm_io_bus_cmp() since it
always compares the kvm_io_range() with the length that guest
wrote. This will cause e.g for vhost, kick will be trapped by qemu
userspace instead of vhost. Fixing this by using zero length if an
iodevice is zero length.

Cc: Gleb Natapov <gleb@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 virt/kvm/kvm_main.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 032150ca597d..12f7bd58da37 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2803,10 +2803,25 @@ static void kvm_io_bus_destroy(struct kvm_io_bus *bus)
 static inline int kvm_io_bus_cmp(const struct kvm_io_range *r1,
                                  const struct kvm_io_range *r2)
 {
-	if (r1->addr < r2->addr)
+	gpa_t addr1 = r1->addr;
+	gpa_t addr2 = r2->addr;
+
+	if (addr1 < addr2)
 		return -1;
-	if (r1->addr + r1->len > r2->addr + r2->len)
+
+	/* If r2->len == 0, match the exact address.  If r2->len != 0,
+	 * accept any overlapping write.  Any order is acceptable for
+	 * overlapping ranges, because kvm_io_bus_get_first_dev ensures
+	 * we process all of them.
+	 */
+	if (r2->len) {
+		addr1 += r1->len;
+		addr2 += r2->len;
+	}
+
+	if (addr1 > addr2)
 		return 1;
+
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 010/104] ARM: fix Thumb2 signal handling when ARMv6 is enabled
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (8 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 009/104] kvm: fix zero length mmio searching Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 011/104] powerpc/boot: Specify ABI v2 when building an LE boot wrapper Luis Henriques
                   ` (98 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Russell King, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Russell King <rmk+kernel@arm.linux.org.uk>

commit 9b55613f42e8d40d5c9ccb8970bde6af4764b2ab upstream.

When a kernel is built covering ARMv6 to ARMv7, we omit to clear the
IT state when entering a signal handler.  This can cause the first
few instructions to be conditionally executed depending on the parent
context.

In any case, the original test for >= ARMv7 is broken - ARMv6 can have
Thumb-2 support as well, and an ARMv6T2 specific build would omit this
code too.

Relax the test back to ARMv6 or greater.  This results in us always
clearing the IT state bits in the PSR, even on CPUs where these bits
are reserved.  However, they're reserved for the IT state, so this
should cause no harm.

Fixes: d71e1352e240 ("Clear the IT state when invoking a Thumb-2 signal handler")
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: H. Nikolaus Schaller <hns@goldelico.com>
Tested-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/arm/kernel/signal.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index bd1983437205..ea6d69125dde 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -354,12 +354,17 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
 		 */
 		thumb = handler & 1;
 
-#if __LINUX_ARM_ARCH__ >= 7
+#if __LINUX_ARM_ARCH__ >= 6
 		/*
-		 * Clear the If-Then Thumb-2 execution state
-		 * ARM spec requires this to be all 000s in ARM mode
-		 * Snapdragon S4/Krait misbehaves on a Thumb=>ARM
-		 * signal transition without this.
+		 * Clear the If-Then Thumb-2 execution state.  ARM spec
+		 * requires this to be all 000s in ARM mode.  Snapdragon
+		 * S4/Krait misbehaves on a Thumb=>ARM signal transition
+		 * without this.
+		 *
+		 * We must do this whenever we are running on a Thumb-2
+		 * capable CPU, which includes ARMv6T2.  However, we elect
+		 * to do this whenever we're on an ARMv6 or later CPU for
+		 * simplicity.
 		 */
 		cpsr &= ~PSR_IT_MASK;
 #endif

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 011/104] powerpc/boot: Specify ABI v2 when building an LE boot wrapper
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (9 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 010/104] ARM: fix Thumb2 signal handling when ARMv6 is enabled Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 012/104] powerpc/mm: Recompute hash value after a failed update Luis Henriques
                   ` (97 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Benjamin Herrenschmidt, Michael Ellerman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

commit 655471f54c2e395ba29ae4156ba0f49928177cc1 upstream.

The kernel does it, not the boot wrapper, which breaks with some
cross compilers that still default to ABI v1.

Fixes: 147c05168fc8 ("powerpc/boot: Add support for 64bit little endian wrapper")
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/powerpc/boot/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index ccc25eddbcb8..f5443645ffca 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -28,6 +28,9 @@ BOOTCFLAGS	+= -m64
 endif
 ifdef CONFIG_CPU_BIG_ENDIAN
 BOOTCFLAGS	+= -mbig-endian
+else
+BOOTCFLAGS	+= -mlittle-endian
+BOOTCFLAGS	+= $(call cc-option,-mabi=elfv2)
 endif
 
 BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 012/104] powerpc/mm: Recompute hash value after a failed update
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (10 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 011/104] powerpc/boot: Specify ABI v2 when building an LE boot wrapper Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 013/104] x86/platform: Fix Geode LX timekeeping in the generic x86 build Luis Henriques
                   ` (96 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Aneesh Kumar K.V, Michael Ellerman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>

commit 36b35d5d807b7e57aff7d08e63de8b17731ee211 upstream.

If we had secondary hash flag set, we ended up modifying hash value in
the updatepp code path. Hence with a failed updatepp we will be using
a wrong hash value for the following hash insert. Fix this by
recomputing hash before insert.

Without this patch we can end up with using wrong slot number in linux
pte. That can result in us missing an hash pte update or invalidate
which can cause memory corruption or even machine check.

Fixes: 6d492ecc6489 ("powerpc/THP: Add code to handle HPTE faults for hugepages")
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Reviewed-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/powerpc/mm/hugepage-hash64.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/mm/hugepage-hash64.c b/arch/powerpc/mm/hugepage-hash64.c
index 5f5e6328c21c..5061c6f676da 100644
--- a/arch/powerpc/mm/hugepage-hash64.c
+++ b/arch/powerpc/mm/hugepage-hash64.c
@@ -136,7 +136,6 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
 	BUG_ON(index >= 4096);
 
 	vpn = hpt_vpn(ea, vsid, ssize);
-	hash = hpt_hash(vpn, shift, ssize);
 	hpte_slot_array = get_hpte_slot_array(pmdp);
 	if (psize == MMU_PAGE_4K) {
 		/*
@@ -151,6 +150,7 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
 	valid = hpte_valid(hpte_slot_array, index);
 	if (valid) {
 		/* update the hpte bits */
+		hash = hpt_hash(vpn, shift, ssize);
 		hidx =  hpte_hash_index(hpte_slot_array, index);
 		if (hidx & _PTEIDX_SECONDARY)
 			hash = ~hash;
@@ -176,6 +176,7 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
 	if (!valid) {
 		unsigned long hpte_group;
 
+		hash = hpt_hash(vpn, shift, ssize);
 		/* insert new entry */
 		pa = pmd_pfn(__pmd(old_pmd)) << PAGE_SHIFT;
 		new_pmd |= _PAGE_HASHPTE;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 013/104] x86/platform: Fix Geode LX timekeeping in the generic x86 build
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (11 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 012/104] powerpc/mm: Recompute hash value after a failed update Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 014/104] arm64: compat: fix vfp save/restore across signal handlers in big-endian Luis Henriques
                   ` (95 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: David Woodhouse, Andres Salomon, Linus Torvalds, Marcelo Tosatti,
	Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Woodhouse <dwmw2@infradead.org>

commit 03da3ff1cfcd7774c8780d2547ba0d995f7dc03d upstream.

In 2007, commit 07190a08eef36 ("Mark TSC on GeodeLX reliable")
bypassed verification of the TSC on Geode LX. However, this code
(now in the check_system_tsc_reliable() function in
arch/x86/kernel/tsc.c) was only present if CONFIG_MGEODE_LX was
set.

OpenWRT has recently started building its generic Geode target
for Geode GX, not LX, to include support for additional
platforms. This broke the timekeeping on LX-based devices,
because the TSC wasn't marked as reliable:
https://dev.openwrt.org/ticket/20531

By adding a runtime check on is_geode_lx(), we can also include
the fix if CONFIG_MGEODEGX1 or CONFIG_X86_GENERIC are set, thus
fixing the problem.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Cc: Andres Salomon <dilinger@queued.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marcelo Tosatti <marcelo@kvack.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1442409003.131189.87.camel@infradead.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/x86/kernel/tsc.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index cafa1fa1586b..541bb5fc9d7e 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -21,6 +21,7 @@
 #include <asm/hypervisor.h>
 #include <asm/nmi.h>
 #include <asm/x86_init.h>
+#include <asm/geode.h>
 
 unsigned int __read_mostly cpu_khz;	/* TSC clocks / usec, not used here */
 EXPORT_SYMBOL(cpu_khz);
@@ -1008,15 +1009,17 @@ EXPORT_SYMBOL_GPL(mark_tsc_unstable);
 
 static void __init check_system_tsc_reliable(void)
 {
-#ifdef CONFIG_MGEODE_LX
-	/* RTSC counts during suspend */
+#if defined(CONFIG_MGEODEGX1) || defined(CONFIG_MGEODE_LX) || defined(CONFIG_X86_GENERIC)
+	if (is_geode_lx()) {
+		/* RTSC counts during suspend */
 #define RTSC_SUSP 0x100
-	unsigned long res_low, res_high;
+		unsigned long res_low, res_high;
 
-	rdmsr_safe(MSR_GEODE_BUSCONT_CONF0, &res_low, &res_high);
-	/* Geode_LX - the OLPC CPU has a very reliable TSC */
-	if (res_low & RTSC_SUSP)
-		tsc_clocksource_reliable = 1;
+		rdmsr_safe(MSR_GEODE_BUSCONT_CONF0, &res_low, &res_high);
+		/* Geode_LX - the OLPC CPU has a very reliable TSC */
+		if (res_low & RTSC_SUSP)
+			tsc_clocksource_reliable = 1;
+	}
 #endif
 	if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE))
 		tsc_clocksource_reliable = 1;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 014/104] arm64: compat: fix vfp save/restore across signal handlers in big-endian
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (12 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 013/104] x86/platform: Fix Geode LX timekeeping in the generic x86 build Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 015/104] arm64: errata: add module build workaround for erratum #843419 Luis Henriques
                   ` (94 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Will Deacon, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Will Deacon <will.deacon@arm.com>

commit bdec97a855ef1e239f130f7a11584721c9a1bf04 upstream.

When saving/restoring the VFP registers from a compat (AArch32)
signal frame, we rely on the compat registers forming a prefix of the
native register file and therefore make use of copy_{to,from}_user to
transfer between the native fpsimd_state and the compat_vfp_sigframe.

Unfortunately, this doesn't work so well in a big-endian environment.
Our fpsimd save/restore code operates directly on 128-bit quantities
(Q registers) whereas the compat_vfp_sigframe represents the registers
as an array of 64-bit (D) registers. The architecture packs the compat D
registers into the Q registers, with the least significant bytes holding
the lower register. Consequently, we need to swap the 64-bit halves when
converting between these two representations on a big-endian machine.

This patch replaces the __copy_{to,from}_user invocations in our
compat VFP signal handling code with explicit __put_user loops that
operate on 64-bit values and swap them accordingly.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/arm64/kernel/signal32.c | 47 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 36 insertions(+), 11 deletions(-)

diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
index 3e6ea07a0b0f..e3ac8f0c0fc7 100644
--- a/arch/arm64/kernel/signal32.c
+++ b/arch/arm64/kernel/signal32.c
@@ -206,14 +206,32 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
 
 /*
  * VFP save/restore code.
+ *
+ * We have to be careful with endianness, since the fpsimd context-switch
+ * code operates on 128-bit (Q) register values whereas the compat ABI
+ * uses an array of 64-bit (D) registers. Consequently, we need to swap
+ * the two halves of each Q register when running on a big-endian CPU.
  */
+union __fpsimd_vreg {
+	__uint128_t	raw;
+	struct {
+#ifdef __AARCH64EB__
+		u64	hi;
+		u64	lo;
+#else
+		u64	lo;
+		u64	hi;
+#endif
+	};
+};
+
 static int compat_preserve_vfp_context(struct compat_vfp_sigframe __user *frame)
 {
 	struct fpsimd_state *fpsimd = &current->thread.fpsimd_state;
 	compat_ulong_t magic = VFP_MAGIC;
 	compat_ulong_t size = VFP_STORAGE_SIZE;
 	compat_ulong_t fpscr, fpexc;
-	int err = 0;
+	int i, err = 0;
 
 	/*
 	 * Save the hardware registers to the fpsimd_state structure.
@@ -229,10 +247,15 @@ static int compat_preserve_vfp_context(struct compat_vfp_sigframe __user *frame)
 	/*
 	 * Now copy the FP registers. Since the registers are packed,
 	 * we can copy the prefix we want (V0-V15) as it is.
-	 * FIXME: Won't work if big endian.
 	 */
-	err |= __copy_to_user(&frame->ufp.fpregs, fpsimd->vregs,
-			      sizeof(frame->ufp.fpregs));
+	for (i = 0; i < ARRAY_SIZE(frame->ufp.fpregs); i += 2) {
+		union __fpsimd_vreg vreg = {
+			.raw = fpsimd->vregs[i >> 1],
+		};
+
+		__put_user_error(vreg.lo, &frame->ufp.fpregs[i], err);
+		__put_user_error(vreg.hi, &frame->ufp.fpregs[i + 1], err);
+	}
 
 	/* Create an AArch32 fpscr from the fpsr and the fpcr. */
 	fpscr = (fpsimd->fpsr & VFP_FPSCR_STAT_MASK) |
@@ -257,7 +280,7 @@ static int compat_restore_vfp_context(struct compat_vfp_sigframe __user *frame)
 	compat_ulong_t magic = VFP_MAGIC;
 	compat_ulong_t size = VFP_STORAGE_SIZE;
 	compat_ulong_t fpscr;
-	int err = 0;
+	int i, err = 0;
 
 	__get_user_error(magic, &frame->magic, err);
 	__get_user_error(size, &frame->size, err);
@@ -267,12 +290,14 @@ static int compat_restore_vfp_context(struct compat_vfp_sigframe __user *frame)
 	if (magic != VFP_MAGIC || size != VFP_STORAGE_SIZE)
 		return -EINVAL;
 
-	/*
-	 * Copy the FP registers into the start of the fpsimd_state.
-	 * FIXME: Won't work if big endian.
-	 */
-	err |= __copy_from_user(fpsimd.vregs, frame->ufp.fpregs,
-				sizeof(frame->ufp.fpregs));
+	/* Copy the FP registers into the start of the fpsimd_state. */
+	for (i = 0; i < ARRAY_SIZE(frame->ufp.fpregs); i += 2) {
+		union __fpsimd_vreg vreg;
+
+		__get_user_error(vreg.lo, &frame->ufp.fpregs[i], err);
+		__get_user_error(vreg.hi, &frame->ufp.fpregs[i + 1], err);
+		fpsimd.vregs[i >> 1] = vreg.raw;
+	}
 
 	/* Extract the fpsr and the fpcr from the fpscr */
 	__get_user_error(fpscr, &frame->ufp.fpscr, err);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 015/104] arm64: errata: add module build workaround for erratum #843419
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (13 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 014/104] arm64: compat: fix vfp save/restore across signal handlers in big-endian Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 016/104] arm64: KVM: Disable virtual timer even if the guest is not using it Luis Henriques
                   ` (93 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Will Deacon, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Will Deacon <will.deacon@arm.com>

commit df057cc7b4fa59e9b55f07ffdb6c62bf02e99a00 upstream.

Cortex-A53 processors <= r0p4 are affected by erratum #843419 which can
lead to a memory access using an incorrect address in certain sequences
headed by an ADRP instruction.

There is a linker fix to generate veneers for ADRP instructions, but
this doesn't work for kernel modules which are built as unlinked ELF
objects.

This patch adds a new config option for the erratum which, when enabled,
builds kernel modules with the mcmodel=large flag. This uses absolute
addressing for all kernel symbols, thereby removing the use of ADRP as
a PC-relative form of addressing. The ADRP relocs are removed from the
module loader so that we fail to load any potentially affected modules.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/arm64/Kconfig         | 16 ++++++++++++++++
 arch/arm64/Makefile        |  4 ++++
 arch/arm64/kernel/module.c |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 316ed8cf5bc0..2e882e5174ab 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -155,6 +155,22 @@ menu "Bus support"
 config ARM_AMBA
 	bool
 
+config ARM64_ERRATUM_843419
+	bool "Cortex-A53: 843419: A load or store might access an incorrect address"
+	depends on MODULES
+	default y
+	help
+	  This option builds kernel modules using the large memory model in
+	  order to avoid the use of the ADRP instruction, which can cause
+	  a subsequent memory access to use an incorrect address on Cortex-A53
+	  parts up to r0p4.
+
+	  Note that the kernel itself must be linked with a version of ld
+	  which fixes potentially affected ADRP instructions through the
+	  use of veneers.
+
+	  If unsure, say Y.
+
 endmenu
 
 menu "Kernel Features"
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 8185a913c5ed..be8b36304ac1 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -34,6 +34,10 @@ comma = ,
 
 CHECKFLAGS	+= -D__aarch64__
 
+ifeq ($(CONFIG_ARM64_ERRATUM_843419), y)
+CFLAGS_MODULE	+= -mcmodel=large
+endif
+
 # Default value
 head-y		:= arch/arm64/kernel/head.o
 
diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c
index 1eb1cc955139..e366329d96d8 100644
--- a/arch/arm64/kernel/module.c
+++ b/arch/arm64/kernel/module.c
@@ -330,12 +330,14 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
 			ovf = reloc_insn_imm(RELOC_OP_PREL, loc, val, 0, 21,
 					     AARCH64_INSN_IMM_ADR);
 			break;
+#ifndef CONFIG_ARM64_ERRATUM_843419
 		case R_AARCH64_ADR_PREL_PG_HI21_NC:
 			overflow_check = false;
 		case R_AARCH64_ADR_PREL_PG_HI21:
 			ovf = reloc_insn_imm(RELOC_OP_PAGE, loc, val, 12, 21,
 					     AARCH64_INSN_IMM_ADR);
 			break;
+#endif
 		case R_AARCH64_ADD_ABS_LO12_NC:
 		case R_AARCH64_LDST8_ABS_LO12_NC:
 			overflow_check = false;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 016/104] arm64: KVM: Disable virtual timer even if the guest is not using it
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (14 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 015/104] arm64: errata: add module build workaround for erratum #843419 Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 017/104] arm: " Luis Henriques
                   ` (92 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Marc Zyngier, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Marc Zyngier <marc.zyngier@arm.com>

commit c4cbba9fa078f55d9f6d081dbb4aec7cf969e7c7 upstream.

When running a guest with the architected timer disabled (with QEMU and
the kernel_irqchip=off option, for example), it is important to make
sure the timer gets turned off. Otherwise, the guest may try to
enable it anyway, leading to a screaming HW interrupt.

The fix is to unconditionally turn off the virtual timer on guest
exit.

Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/arm64/kvm/hyp.S | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kvm/hyp.S b/arch/arm64/kvm/hyp.S
index 3aaf3bc4ad8a..1343b2020891 100644
--- a/arch/arm64/kvm/hyp.S
+++ b/arch/arm64/kvm/hyp.S
@@ -485,8 +485,6 @@ CPU_BE(	rev	w5, w5 )
 	mrs	x3, cntv_ctl_el0
 	and	x3, x3, #3
 	str	w3, [x0, #VCPU_TIMER_CNTV_CTL]
-	bic	x3, x3, #1		// Clear Enable
-	msr	cntv_ctl_el0, x3
 
 	isb
 
@@ -494,6 +492,9 @@ CPU_BE(	rev	w5, w5 )
 	str	x3, [x0, #VCPU_TIMER_CNTV_CVAL]
 
 1:
+	// Disable the virtual timer
+	msr	cntv_ctl_el0, xzr
+
 	// Allow physical timer/counter access for the host
 	mrs	x2, cnthctl_el2
 	orr	x2, x2, #3

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 017/104] arm: KVM: Disable virtual timer even if the guest is not using it
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (15 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 016/104] arm64: KVM: Disable virtual timer even if the guest is not using it Luis Henriques
@ 2015-10-26 13:41 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 018/104] hp-wmi: Add missing __init annotations to initialization code Luis Henriques
                   ` (91 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:41 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Marc Zyngier, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Marc Zyngier <marc.zyngier@arm.com>

commit 688bc577ac42ae3d07c889a1f0a72f0b23763d58 upstream.

When running a guest with the architected timer disabled (with QEMU and
the kernel_irqchip=off option, for example), it is important to make
sure the timer gets turned off. Otherwise, the guest may try to
enable it anyway, leading to a screaming HW interrupt.

The fix is to unconditionally turn off the virtual timer on guest
exit.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/arm/kvm/interrupts_head.S | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kvm/interrupts_head.S b/arch/arm/kvm/interrupts_head.S
index 2973b2d342fa..cb1d567ada5e 100644
--- a/arch/arm/kvm/interrupts_head.S
+++ b/arch/arm/kvm/interrupts_head.S
@@ -502,8 +502,7 @@ vcpu	.req	r0		@ vcpu pointer always in r0
 
 	mrc	p15, 0, r2, c14, c3, 1	@ CNTV_CTL
 	str	r2, [vcpu, #VCPU_TIMER_CNTV_CTL]
-	bic	r2, #1			@ Clear ENABLE
-	mcr	p15, 0, r2, c14, c3, 1	@ CNTV_CTL
+
 	isb
 
 	mrrc	p15, 3, r2, r3, c14	@ CNTV_CVAL
@@ -516,6 +515,9 @@ vcpu	.req	r0		@ vcpu pointer always in r0
 	mcrr	p15, 4, r2, r2, c14	@ CNTVOFF
 
 1:
+	mov	r2, #0			@ Clear ENABLE
+	mcr	p15, 0, r2, c14, c3, 1	@ CNTV_CTL
+
 #endif
 	@ Allow physical timer/counter access for the host
 	mrc	p15, 4, r2, c14, c1, 0	@ CNTHCTL

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 018/104] hp-wmi: Add missing __init annotations to initialization code
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (16 preceding siblings ...)
  2015-10-26 13:41 ` [PATCH 3.16.y-ckt 017/104] arm: " Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 019/104] hp-wmi: limit hotkey enable Luis Henriques
                   ` (90 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mathias Krause, Matthew Garrett, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mathias Krause <minipli@googlemail.com>

commit 702ef54255350cc821cd1ea9095bc8b336235d26 upstream.

These functions are only called from other initialization routines, so
can be marked __init, too.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/platform/x86/hp-wmi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 484a8673b835..4c559640dcba 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -295,7 +295,7 @@ static int hp_wmi_tablet_state(void)
 	return (state & 0x4) ? 1 : 0;
 }
 
-static int hp_wmi_bios_2009_later(void)
+static int __init hp_wmi_bios_2009_later(void)
 {
 	int state = 0;
 	int ret = hp_wmi_perform_query(HPWMI_FEATURE_QUERY, 0, &state,
@@ -704,7 +704,7 @@ static void cleanup_sysfs(struct platform_device *device)
 	device_remove_file(&device->dev, &dev_attr_postcode);
 }
 
-static int hp_wmi_rfkill_setup(struct platform_device *device)
+static int __init hp_wmi_rfkill_setup(struct platform_device *device)
 {
 	int err;
 	int wireless = 0;
@@ -806,7 +806,7 @@ register_wifi_error:
 	return err;
 }
 
-static int hp_wmi_rfkill2_setup(struct platform_device *device)
+static int __init hp_wmi_rfkill2_setup(struct platform_device *device)
 {
 	int err, i;
 	struct bios_rfkill2_state state;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 019/104] hp-wmi: limit hotkey enable
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (17 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 018/104] hp-wmi: Add missing __init annotations to initialization code Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 020/104] zram: fix possible use after free in zcomp_create() Luis Henriques
                   ` (89 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Kyle Evans, Darren Hart, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Kyle Evans <kvans32@gmail.com>

commit 8a1513b49321e503fd6c8b6793e3b1f9a8a3285b upstream.

Do not write initialize magic on systems that do not have
feature query 0xb. Fixes Bug #82451.

Redefine FEATURE_QUERY to align with 0xb and FEATURE2 with 0xd
for code clearity.

Add a new test function, hp_wmi_bios_2008_later() & simplify
hp_wmi_bios_2009_later(), which fixes a bug in cases where
an improper value is returned. Probably also fixes Bug #69131.

Add missing __init tag.

Signed-off-by: Kyle Evans <kvans32@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/platform/x86/hp-wmi.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 4c559640dcba..301386c4d85b 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -54,8 +54,9 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
 #define HPWMI_HARDWARE_QUERY 0x4
 #define HPWMI_WIRELESS_QUERY 0x5
 #define HPWMI_BIOS_QUERY 0x9
+#define HPWMI_FEATURE_QUERY 0xb
 #define HPWMI_HOTKEY_QUERY 0xc
-#define HPWMI_FEATURE_QUERY 0xd
+#define HPWMI_FEATURE2_QUERY 0xd
 #define HPWMI_WIRELESS2_QUERY 0x1b
 #define HPWMI_POSTCODEERROR_QUERY 0x2a
 
@@ -295,25 +296,33 @@ static int hp_wmi_tablet_state(void)
 	return (state & 0x4) ? 1 : 0;
 }
 
-static int __init hp_wmi_bios_2009_later(void)
+static int __init hp_wmi_bios_2008_later(void)
 {
 	int state = 0;
 	int ret = hp_wmi_perform_query(HPWMI_FEATURE_QUERY, 0, &state,
 				       sizeof(state), sizeof(state));
-	if (ret)
-		return ret;
+	if (!ret)
+		return 1;
 
-	return (state & 0x10) ? 1 : 0;
+	return (ret == HPWMI_RET_UNKNOWN_CMDTYPE) ? 0 : -ENXIO;
 }
 
-static int hp_wmi_enable_hotkeys(void)
+static int __init hp_wmi_bios_2009_later(void)
 {
-	int ret;
-	int query = 0x6e;
+	int state = 0;
+	int ret = hp_wmi_perform_query(HPWMI_FEATURE2_QUERY, 0, &state,
+				       sizeof(state), sizeof(state));
+	if (!ret)
+		return 1;
 
-	ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &query, sizeof(query),
-				   0);
+	return (ret == HPWMI_RET_UNKNOWN_CMDTYPE) ? 0 : -ENXIO;
+}
 
+static int __init hp_wmi_enable_hotkeys(void)
+{
+	int value = 0x6e;
+	int ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &value,
+				       sizeof(value), 0);
 	if (ret)
 		return -EINVAL;
 	return 0;
@@ -663,7 +672,7 @@ static int __init hp_wmi_input_setup(void)
 			    hp_wmi_tablet_state());
 	input_sync(hp_wmi_input_dev);
 
-	if (hp_wmi_bios_2009_later() == 4)
+	if (!hp_wmi_bios_2009_later() && hp_wmi_bios_2008_later())
 		hp_wmi_enable_hotkeys();
 
 	status = wmi_install_notify_handler(HPWMI_EVENT_GUID, hp_wmi_notify, NULL);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 020/104] zram: fix possible use after free in zcomp_create()
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (18 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 019/104] hp-wmi: limit hotkey enable Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 021/104] perf header: Fixup reading of HEADER_NRCPUS feature Luis Henriques
                   ` (88 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Andrew Morton, Linus Torvalds, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Luis Henriques <luis.henriques@canonical.com>

commit 3aaf14da807a4e9931a37f21e4251abb8a67021b upstream.

zcomp_create() verifies the success of zcomp_strm_{multi,single}_create()
through comp->stream, which can potentially be pointing to memory that
was freed if these functions returned an error.

While at it, replace a 'ERR_PTR(-ENOMEM)' by a more generic
'ERR_PTR(error)' as in the future zcomp_strm_{multi,siggle}_create()
could return other error codes.  Function documentation updated
accordingly.

Fixes: beca3ec71fe5 ("zram: add multi stream functionality")
Acked-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/block/zram/zcomp.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
index f1ff39a3d1c1..54d946a9eee6 100644
--- a/drivers/block/zram/zcomp.c
+++ b/drivers/block/zram/zcomp.c
@@ -325,12 +325,14 @@ void zcomp_destroy(struct zcomp *comp)
  * allocate new zcomp and initialize it. return compressing
  * backend pointer or ERR_PTR if things went bad. ERR_PTR(-EINVAL)
  * if requested algorithm is not supported, ERR_PTR(-ENOMEM) in
- * case of allocation error.
+ * case of allocation error, or any other error potentially
+ * returned by functions zcomp_strm_{multi,single}_create.
  */
 struct zcomp *zcomp_create(const char *compress, int max_strm)
 {
 	struct zcomp *comp;
 	struct zcomp_backend *backend;
+	int error;
 
 	backend = find_backend(compress);
 	if (!backend)
@@ -342,12 +344,12 @@ struct zcomp *zcomp_create(const char *compress, int max_strm)
 
 	comp->backend = backend;
 	if (max_strm > 1)
-		zcomp_strm_multi_create(comp, max_strm);
+		error = zcomp_strm_multi_create(comp, max_strm);
 	else
-		zcomp_strm_single_create(comp);
-	if (!comp->stream) {
+		error = zcomp_strm_single_create(comp);
+	if (error) {
 		kfree(comp);
-		return ERR_PTR(-ENOMEM);
+		return ERR_PTR(error);
 	}
 	return comp;
 }

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 021/104] perf header: Fixup reading of HEADER_NRCPUS feature
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (19 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 020/104] zram: fix possible use after free in zcomp_create() Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 022/104] dcache: Handle escaped paths in prepend_path Luis Henriques
                   ` (87 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Adrian Hunter, Borislav Petkov, David Ahern, Frederic Weisbecker,
	Jiri Olsa, Kan Liang, Stephane Eranian, Wang Nan,
	Arnaldo Carvalho de Melo, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Arnaldo Carvalho de Melo <acme@redhat.com>

commit caa470475d9b59eeff093ae650800d34612c4379 upstream.

The original patch introducing this header wrote the number of CPUs available
and online in one order and then swapped those values when reading, fix it.

Before:

  # perf record usleep 1
  # perf report --header-only | grep 'nrcpus \(online\|avail\)'
  # nrcpus online : 4
  # nrcpus avail : 4
  # echo 0 > /sys/devices/system/cpu/cpu2/online
  # perf record usleep 1
  # perf report --header-only | grep 'nrcpus \(online\|avail\)'
  # nrcpus online : 4
  # nrcpus avail : 3
  # echo 0 > /sys/devices/system/cpu/cpu1/online
  # perf record usleep 1
  # perf report --header-only | grep 'nrcpus \(online\|avail\)'
  # nrcpus online : 4
  # nrcpus avail : 2

After the fix, bringing back the CPUs online:

  # perf report --header-only | grep 'nrcpus \(online\|avail\)'
  # nrcpus online : 2
  # nrcpus avail : 4
  # echo 1 > /sys/devices/system/cpu/cpu2/online
  # perf record usleep 1
  # perf report --header-only | grep 'nrcpus \(online\|avail\)'
  # nrcpus online : 3
  # nrcpus avail : 4
  # echo 1 > /sys/devices/system/cpu/cpu1/online
  # perf record usleep 1
  # perf report --header-only | grep 'nrcpus \(online\|avail\)'
  # nrcpus online : 4
  # nrcpus avail : 4

Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: fbe96f29ce4b ("perf tools: Make perf.data more self-descriptive (v8)")
Link: http://lkml.kernel.org/r/20150911153323.GP23511@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 tools/perf/util/header.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 893f8e2df928..96592f7bfa9f 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1715,7 +1715,7 @@ static int process_nrcpus(struct perf_file_section *section __maybe_unused,
 	if (ph->needs_swap)
 		nr = bswap_32(nr);
 
-	ph->env.nr_cpus_online = nr;
+	ph->env.nr_cpus_avail = nr;
 
 	ret = readn(fd, &nr, sizeof(nr));
 	if (ret != sizeof(nr))
@@ -1724,7 +1724,7 @@ static int process_nrcpus(struct perf_file_section *section __maybe_unused,
 	if (ph->needs_swap)
 		nr = bswap_32(nr);
 
-	ph->env.nr_cpus_avail = nr;
+	ph->env.nr_cpus_online = nr;
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 022/104] dcache: Handle escaped paths in prepend_path
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (20 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 021/104] perf header: Fixup reading of HEADER_NRCPUS feature Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 023/104] vfs: Test for and handle paths that are unreachable from their mnt_root Luis Henriques
                   ` (86 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Eric W. Biederman, Al Viro, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit cde93be45a8a90d8c264c776fab63487b5038a65 upstream.

A rename can result in a dentry that by walking up d_parent
will never reach it's mnt_root.  For lack of a better term
I call this an escaped path.

prepend_path is called by four different functions __d_path,
d_absolute_path, d_path, and getcwd.

__d_path only wants to see paths are connected to the root it passes
in.  So __d_path needs prepend_path to return an error.

d_absolute_path similarly wants to see paths that are connected to
some root.  Escaped paths are not connected to any mnt_root so
d_absolute_path needs prepend_path to return an error greater
than 1.  So escaped paths will be treated like paths on lazily
unmounted mounts.

getcwd needs to prepend "(unreachable)" so getcwd also needs
prepend_path to return an error.

d_path is the interesting hold out.  d_path just wants to print
something, and does not care about the weird cases.  Which raises
the question what should be printed?

Given that <escaped_path>/<anything> should result in -ENOENT I
believe it is desirable for escaped paths to be printed as empty
paths.  As there are not really any meaninful path components when
considered from the perspective of a mount tree.

So tweak prepend_path to return an empty path with an new error
code of 3 when it encounters an escaped path.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 fs/dcache.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/dcache.c b/fs/dcache.c
index c0214315a1d0..f9dcd166d878 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2894,6 +2894,13 @@ restart:
 
 		if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
 			struct mount *parent = ACCESS_ONCE(mnt->mnt_parent);
+			/* Escaped? */
+			if (dentry != vfsmnt->mnt_root) {
+				bptr = *buffer;
+				blen = *buflen;
+				error = 3;
+				break;
+			}
 			/* Global root? */
 			if (mnt != parent) {
 				dentry = ACCESS_ONCE(mnt->mnt_mountpoint);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 023/104] vfs: Test for and handle paths that are unreachable from their mnt_root
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (21 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 022/104] dcache: Handle escaped paths in prepend_path Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 024/104] spi: spi-pxa2xx: Check status register to determine if SSSR_TINT is disabled Luis Henriques
                   ` (85 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Eric W. Biederman, Al Viro, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit 397d425dc26da728396e66d392d5dcb8dac30c37 upstream.

In rare cases a directory can be renamed out from under a bind mount.
In those cases without special handling it becomes possible to walk up
the directory tree to the root dentry of the filesystem and down
from the root dentry to every other file or directory on the filesystem.

Like division by zero .. from an unconnected path can not be given
a useful semantic as there is no predicting at which path component
the code will realize it is unconnected.  We certainly can not match
the current behavior as the current behavior is a security hole.

Therefore when encounting .. when following an unconnected path
return -ENOENT.

- Add a function path_connected to verify path->dentry is reachable
  from path->mnt.mnt_root.  AKA to validate that rename did not do
  something nasty to the bind mount.

  To avoid races path_connected must be called after following a path
  component to it's next path component.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 fs/namei.c | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 15fc3f5a5007..8a0c3d9d8298 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -486,6 +486,24 @@ void path_put(const struct path *path)
 }
 EXPORT_SYMBOL(path_put);
 
+/**
+ * path_connected - Verify that a path->dentry is below path->mnt.mnt_root
+ * @path: nameidate to verify
+ *
+ * Rename can sometimes move a file or directory outside of a bind
+ * mount, path_connected allows those cases to be detected.
+ */
+static bool path_connected(const struct path *path)
+{
+	struct vfsmount *mnt = path->mnt;
+
+	/* Only bind mounts can have disconnected paths */
+	if (mnt->mnt_root == mnt->mnt_sb->s_root)
+		return true;
+
+	return is_subdir(path->dentry, mnt->mnt_root);
+}
+
 /*
  * Path walking has 2 modes, rcu-walk and ref-walk (see
  * Documentation/filesystems/path-lookup.txt).  In situations when we can't
@@ -1155,6 +1173,8 @@ static int follow_dotdot_rcu(struct nameidata *nd)
 				goto failed;
 			nd->path.dentry = parent;
 			nd->seq = seq;
+			if (unlikely(!path_connected(&nd->path)))
+				goto failed;
 			break;
 		}
 		if (!follow_up_rcu(&nd->path))
@@ -1251,7 +1271,7 @@ static void follow_mount(struct path *path)
 	}
 }
 
-static void follow_dotdot(struct nameidata *nd)
+static int follow_dotdot(struct nameidata *nd)
 {
 	if (!nd->root.mnt)
 		set_root(nd);
@@ -1267,6 +1287,10 @@ static void follow_dotdot(struct nameidata *nd)
 			/* rare case of legitimate dget_parent()... */
 			nd->path.dentry = dget_parent(nd->path.dentry);
 			dput(old);
+			if (unlikely(!path_connected(&nd->path))) {
+				path_put(&nd->path);
+				return -ENOENT;
+			}
 			break;
 		}
 		if (!follow_up(&nd->path))
@@ -1274,6 +1298,7 @@ static void follow_dotdot(struct nameidata *nd)
 	}
 	follow_mount(&nd->path);
 	nd->inode = nd->path.dentry->d_inode;
+	return 0;
 }
 
 /*
@@ -1497,7 +1522,7 @@ static inline int handle_dots(struct nameidata *nd, int type)
 			if (follow_dotdot_rcu(nd))
 				return -ECHILD;
 		} else
-			follow_dotdot(nd);
+			return follow_dotdot(nd);
 	}
 	return 0;
 }
@@ -2234,7 +2259,7 @@ mountpoint_last(struct nameidata *nd, struct path *path)
 	if (unlikely(nd->last_type != LAST_NORM)) {
 		error = handle_dots(nd, nd->last_type);
 		if (error)
-			goto out;
+			return error;
 		dentry = dget(nd->path.dentry);
 		goto done;
 	}

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 024/104] spi: spi-pxa2xx: Check status register to determine if SSSR_TINT is disabled
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (22 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 023/104] vfs: Test for and handle paths that are unreachable from their mnt_root Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 025/104] spi: Fix documentation of spi_alloc_master() Luis Henriques
                   ` (84 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Tan, Jui Nee, Mark Brown, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: "Tan, Jui Nee" <jui.nee.tan@intel.com>

commit 02bc933ebb59208f42c2e6305b2c17fd306f695d upstream.

On Intel Baytrail, there is case when interrupt handler get called, no SPI
message is captured. The RX FIFO is indeed empty when RX timeout pending
interrupt (SSSR_TINT) happens.

Use the BIOS version where both HSUART and SPI are on the same IRQ. Both
drivers are using IRQF_SHARED when calling the request_irq function. When
running two separate and independent SPI and HSUART application that
generate data traffic on both components, user will see messages like
below on the console:

  pxa2xx-spi pxa2xx-spi.0: bad message state in interrupt handler

This commit will fix this by first checking Receiver Time-out Interrupt,
if it is disabled, ignore the request and return without servicing.

Signed-off-by: Tan, Jui Nee <jui.nee.tan@intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/spi/spi-pxa2xx.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index ced5ff0ec9a0..4d7668c72ffc 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -564,6 +564,10 @@ static irqreturn_t ssp_int(int irq, void *dev_id)
 	if (!(sccr1_reg & SSCR1_TIE))
 		mask &= ~SSSR_TFS;
 
+	/* Ignore RX timeout interrupt if it is disabled */
+	if (!(sccr1_reg & SSCR1_TINTE))
+		mask &= ~SSSR_TINT;
+
 	if (!(status & mask))
 		return IRQ_NONE;
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 025/104] spi: Fix documentation of spi_alloc_master()
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (23 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 024/104] spi: spi-pxa2xx: Check status register to determine if SSSR_TINT is disabled Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 026/104] USB: option: add ZTE PIDs Luis Henriques
                   ` (83 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Guenter Roeck, Alexey Klimov, Mark Brown, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Guenter Roeck <linux@roeck-us.net>

commit a394d635193b641f2c86ead5ada5b115d57c51f8 upstream.

Actually, spi_master_put() after spi_alloc_master() must _not_ be followed
by kfree(). The memory is already freed with the call to spi_master_put()
through spi_master_class, which registers a release function. Calling both
spi_master_put() and kfree() results in often nasty (and delayed) crashes
elsewhere in the kernel, often in the networking stack.

This reverts commit eb4af0f5349235df2e4a5057a72fc8962d00308a.

Link to patch and concerns: https://lkml.org/lkml/2012/9/3/269
or
http://lkml.iu.edu/hypermail/linux/kernel/1209.0/00790.html

Alexey Klimov: This revert becomes valid after
94c69f765f1b4a658d96905ec59928e3e3e07e6a when spi-imx.c
has been fixed and there is no need to call kfree() so comment
for spi_alloc_master() should be fixed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/spi/spi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 3950e4495093..8f2c442eb1e1 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1458,8 +1458,7 @@ static struct class spi_master_class = {
  *
  * The caller is responsible for assigning the bus number and initializing
  * the master's methods before calling spi_register_master(); and (after errors
- * adding the device) calling spi_master_put() and kfree() to prevent a memory
- * leak.
+ * adding the device) calling spi_master_put() to prevent a memory leak.
  */
 struct spi_master *spi_alloc_master(struct device *dev, unsigned size)
 {

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 026/104] USB: option: add ZTE PIDs
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (24 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 025/104] spi: Fix documentation of spi_alloc_master() Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 027/104] drm/vmwgfx: Fix up user_dmabuf refcounting Luis Henriques
                   ` (82 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Liu.Zhao, Johan Hovold, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: "Liu.Zhao" <lzsos369@163.com>

commit 19ab6bc5674a30fdb6a2436b068d19a3c17dc73e upstream.

This is intended to add ZTE device PIDs on kernel.

Signed-off-by: Liu.Zhao <lzsos369@163.com>
[johan: sort the new entries ]
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/usb/serial/option.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index e92357d19c47..28e9bbeae8f7 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -278,6 +278,10 @@ static void option_instat_callback(struct urb *urb);
 #define ZTE_PRODUCT_MF622			0x0001
 #define ZTE_PRODUCT_MF628			0x0015
 #define ZTE_PRODUCT_MF626			0x0031
+#define ZTE_PRODUCT_ZM8620_X			0x0396
+#define ZTE_PRODUCT_ME3620_MBIM			0x0426
+#define ZTE_PRODUCT_ME3620_X			0x1432
+#define ZTE_PRODUCT_ME3620_L			0x1433
 #define ZTE_PRODUCT_AC2726			0xfff1
 #define ZTE_PRODUCT_CDMA_TECH			0xfffe
 #define ZTE_PRODUCT_AC8710T			0xffff
@@ -551,6 +555,18 @@ static const struct option_blacklist_info zte_mc2716_z_blacklist = {
 	.sendsetup = BIT(1) | BIT(2) | BIT(3),
 };
 
+static const struct option_blacklist_info zte_me3620_mbim_blacklist = {
+	.reserved = BIT(2) | BIT(3) | BIT(4),
+};
+
+static const struct option_blacklist_info zte_me3620_xl_blacklist = {
+	.reserved = BIT(3) | BIT(4) | BIT(5),
+};
+
+static const struct option_blacklist_info zte_zm8620_x_blacklist = {
+	.reserved = BIT(3) | BIT(4) | BIT(5),
+};
+
 static const struct option_blacklist_info huawei_cdc12_blacklist = {
 	.reserved = BIT(1) | BIT(2),
 };
@@ -1590,6 +1606,14 @@ static const struct usb_device_id option_ids[] = {
 	 .driver_info = (kernel_ulong_t)&zte_ad3812_z_blacklist },
 	{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2716, 0xff, 0xff, 0xff),
 	 .driver_info = (kernel_ulong_t)&zte_mc2716_z_blacklist },
+	{ USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_ME3620_L),
+	 .driver_info = (kernel_ulong_t)&zte_me3620_xl_blacklist },
+	{ USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_ME3620_MBIM),
+	 .driver_info = (kernel_ulong_t)&zte_me3620_mbim_blacklist },
+	{ USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_ME3620_X),
+	 .driver_info = (kernel_ulong_t)&zte_me3620_xl_blacklist },
+	{ USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_ZM8620_X),
+	 .driver_info = (kernel_ulong_t)&zte_zm8620_x_blacklist },
 	{ USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) },
 	{ USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) },
 	{ USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) },

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 027/104] drm/vmwgfx: Fix up user_dmabuf refcounting
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (25 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 026/104] USB: option: add ZTE PIDs Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 028/104] ARM: dts: omap3-beagle: make i2c3, ddc and tfp410 gpio work again Luis Henriques
                   ` (81 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Thomas Hellstrom, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Thomas Hellstrom <thellstrom@vmware.com>

commit 54c12bc374408faddbff75dbf1a6167c19af39c4 upstream.

If user space calls unreference on a user_dmabuf it will typically
kill the struct ttm_base_object member which is responsible for the
user-space visibility. However the dmabuf part may still be alive and
refcounted. In some situations, like for shared guest-backed surface
referencing/opening, the driver may try to reference the
struct ttm_base_object member again, causing an immediate kernel warning
and a later kernel NULL pointer dereference.

Fix this by always maintaining a reference on the struct
ttm_base_object member, in situations where it might subsequently be
referenced.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h      |  6 ++++--
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c  |  6 ++++--
 drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c  |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 29 +++++++++++++++++++++--------
 drivers/gpu/drm/vmwgfx/vmwgfx_shader.c   |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c  | 11 ++++++++---
 6 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 6b252a887ae2..a2cd01e0bbf7 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -610,7 +610,8 @@ extern int vmw_user_dmabuf_alloc(struct vmw_private *dev_priv,
 				 uint32_t size,
 				 bool shareable,
 				 uint32_t *handle,
-				 struct vmw_dma_buffer **p_dma_buf);
+				 struct vmw_dma_buffer **p_dma_buf,
+				 struct ttm_base_object **p_base);
 extern int vmw_user_dmabuf_reference(struct ttm_object_file *tfile,
 				     struct vmw_dma_buffer *dma_buf,
 				     uint32_t *handle);
@@ -624,7 +625,8 @@ extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo,
 					 uint32_t cur_validate_node);
 extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo);
 extern int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile,
-				  uint32_t id, struct vmw_dma_buffer **out);
+				  uint32_t id, struct vmw_dma_buffer **out,
+				  struct ttm_base_object **base);
 extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data,
 				  struct drm_file *file_priv);
 extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 3a21633eba2f..118e2206b792 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -873,7 +873,8 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,
 	struct vmw_relocation *reloc;
 	int ret;
 
-	ret = vmw_user_dmabuf_lookup(sw_context->fp->tfile, handle, &vmw_bo);
+	ret = vmw_user_dmabuf_lookup(sw_context->fp->tfile, handle, &vmw_bo,
+				     NULL);
 	if (unlikely(ret != 0)) {
 		DRM_ERROR("Could not find or use MOB buffer.\n");
 		return -EINVAL;
@@ -934,7 +935,8 @@ static int vmw_translate_guest_ptr(struct vmw_private *dev_priv,
 	struct vmw_relocation *reloc;
 	int ret;
 
-	ret = vmw_user_dmabuf_lookup(sw_context->fp->tfile, handle, &vmw_bo);
+	ret = vmw_user_dmabuf_lookup(sw_context->fp->tfile, handle, &vmw_bo,
+				     NULL);
 	if (unlikely(ret != 0)) {
 		DRM_ERROR("Could not find or use GMR region.\n");
 		return -EINVAL;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
index 87e39f68e9d0..e1898982b44a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
@@ -484,7 +484,7 @@ int vmw_overlay_ioctl(struct drm_device *dev, void *data,
 		goto out_unlock;
 	}
 
-	ret = vmw_user_dmabuf_lookup(tfile, arg->handle, &buf);
+	ret = vmw_user_dmabuf_lookup(tfile, arg->handle, &buf, NULL);
 	if (ret)
 		goto out_unlock;
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index 01d68f0a69dc..78196a95b0ad 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -355,7 +355,7 @@ int vmw_user_lookup_handle(struct vmw_private *dev_priv,
 	}
 
 	*out_surf = NULL;
-	ret = vmw_user_dmabuf_lookup(tfile, handle, out_buf);
+	ret = vmw_user_dmabuf_lookup(tfile, handle, out_buf, NULL);
 	return ret;
 }
 
@@ -482,7 +482,8 @@ int vmw_user_dmabuf_alloc(struct vmw_private *dev_priv,
 			  uint32_t size,
 			  bool shareable,
 			  uint32_t *handle,
-			  struct vmw_dma_buffer **p_dma_buf)
+			  struct vmw_dma_buffer **p_dma_buf,
+			  struct ttm_base_object **p_base)
 {
 	struct vmw_user_dma_buffer *user_bo;
 	struct ttm_buffer_object *tmp;
@@ -516,6 +517,10 @@ int vmw_user_dmabuf_alloc(struct vmw_private *dev_priv,
 	}
 
 	*p_dma_buf = &user_bo->dma;
+	if (p_base) {
+		*p_base = &user_bo->prime.base;
+		kref_get(&(*p_base)->refcount);
+	}
 	*handle = user_bo->prime.base.hash.key;
 
 out_no_base_object:
@@ -627,6 +632,7 @@ int vmw_user_dmabuf_synccpu_ioctl(struct drm_device *dev, void *data,
 	struct vmw_dma_buffer *dma_buf;
 	struct vmw_user_dma_buffer *user_bo;
 	struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
+	struct ttm_base_object *buffer_base;
 	int ret;
 
 	if ((arg->flags & (drm_vmw_synccpu_read | drm_vmw_synccpu_write)) == 0
@@ -639,7 +645,8 @@ int vmw_user_dmabuf_synccpu_ioctl(struct drm_device *dev, void *data,
 
 	switch (arg->op) {
 	case drm_vmw_synccpu_grab:
-		ret = vmw_user_dmabuf_lookup(tfile, arg->handle, &dma_buf);
+		ret = vmw_user_dmabuf_lookup(tfile, arg->handle, &dma_buf,
+					     &buffer_base);
 		if (unlikely(ret != 0))
 			return ret;
 
@@ -647,6 +654,7 @@ int vmw_user_dmabuf_synccpu_ioctl(struct drm_device *dev, void *data,
 				       dma);
 		ret = vmw_user_dmabuf_synccpu_grab(user_bo, tfile, arg->flags);
 		vmw_dmabuf_unreference(&dma_buf);
+		ttm_base_object_unref(&buffer_base);
 		if (unlikely(ret != 0 && ret != -ERESTARTSYS &&
 			     ret != -EBUSY)) {
 			DRM_ERROR("Failed synccpu grab on handle 0x%08x.\n",
@@ -688,7 +696,8 @@ int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data,
 		return ret;
 
 	ret = vmw_user_dmabuf_alloc(dev_priv, vmw_fpriv(file_priv)->tfile,
-				    req->size, false, &handle, &dma_buf);
+				    req->size, false, &handle, &dma_buf,
+				    NULL);
 	if (unlikely(ret != 0))
 		goto out_no_dmabuf;
 
@@ -717,7 +726,8 @@ int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data,
 }
 
 int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile,
-			   uint32_t handle, struct vmw_dma_buffer **out)
+			   uint32_t handle, struct vmw_dma_buffer **out,
+			   struct ttm_base_object **p_base)
 {
 	struct vmw_user_dma_buffer *vmw_user_bo;
 	struct ttm_base_object *base;
@@ -739,7 +749,10 @@ int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile,
 	vmw_user_bo = container_of(base, struct vmw_user_dma_buffer,
 				   prime.base);
 	(void)ttm_bo_reference(&vmw_user_bo->dma.base);
-	ttm_base_object_unref(&base);
+	if (p_base)
+		*p_base = base;
+	else
+		ttm_base_object_unref(&base);
 	*out = &vmw_user_bo->dma;
 
 	return 0;
@@ -1000,7 +1013,7 @@ int vmw_dumb_create(struct drm_file *file_priv,
 
 	ret = vmw_user_dmabuf_alloc(dev_priv, vmw_fpriv(file_priv)->tfile,
 				    args->size, false, &args->handle,
-				    &dma_buf);
+				    &dma_buf, NULL);
 	if (unlikely(ret != 0))
 		goto out_no_dmabuf;
 
@@ -1028,7 +1041,7 @@ int vmw_dumb_map_offset(struct drm_file *file_priv,
 	struct vmw_dma_buffer *out_buf;
 	int ret;
 
-	ret = vmw_user_dmabuf_lookup(tfile, handle, &out_buf);
+	ret = vmw_user_dmabuf_lookup(tfile, handle, &out_buf, NULL);
 	if (ret != 0)
 		return -EINVAL;
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
index c1559eeaffe9..4d7dedddbd97 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
@@ -455,7 +455,7 @@ int vmw_shader_define_ioctl(struct drm_device *dev, void *data,
 
 	if (arg->buffer_handle != SVGA3D_INVALID_ID) {
 		ret = vmw_user_dmabuf_lookup(tfile, arg->buffer_handle,
-					     &buffer);
+					     &buffer, NULL);
 		if (unlikely(ret != 0)) {
 			DRM_ERROR("Could not find buffer for shader "
 				  "creation.\n");
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index 4ecdbf3e59da..9e190db6cc37 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -43,6 +43,7 @@ struct vmw_user_surface {
 	struct vmw_surface srf;
 	uint32_t size;
 	struct drm_master *master;
+	struct ttm_base_object *backup_base;
 };
 
 /**
@@ -652,6 +653,7 @@ static void vmw_user_surface_base_release(struct ttm_base_object **p_base)
 	struct vmw_resource *res = &user_srf->srf.res;
 
 	*p_base = NULL;
+	ttm_base_object_unref(&user_srf->backup_base);
 	vmw_resource_unreference(&res);
 }
 
@@ -846,7 +848,8 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
 					    res->backup_size,
 					    true,
 					    &backup_handle,
-					    &res->backup);
+					    &res->backup,
+					    &user_srf->backup_base);
 		if (unlikely(ret != 0)) {
 			vmw_resource_unreference(&res);
 			goto out_unlock;
@@ -1309,7 +1312,8 @@ int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data,
 
 	if (req->buffer_handle != SVGA3D_INVALID_ID) {
 		ret = vmw_user_dmabuf_lookup(tfile, req->buffer_handle,
-					     &res->backup);
+					     &res->backup,
+					     &user_srf->backup_base);
 	} else if (req->drm_surface_flags &
 		   drm_vmw_surface_flag_create_buffer)
 		ret = vmw_user_dmabuf_alloc(dev_priv, tfile,
@@ -1317,7 +1321,8 @@ int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data,
 					    req->drm_surface_flags &
 					    drm_vmw_surface_flag_shareable,
 					    &backup_handle,
-					    &res->backup);
+					    &res->backup,
+					    &user_srf->backup_base);
 
 	if (unlikely(ret != 0)) {
 		vmw_resource_unreference(&res);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 028/104] ARM: dts: omap3-beagle: make i2c3, ddc and tfp410 gpio work again
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (26 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 027/104] drm/vmwgfx: Fix up user_dmabuf refcounting Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 029/104] Btrfs: fix read corruption of compressed and shared extents Luis Henriques
                   ` (80 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Carl Frederik Werner, Tony Lindgren, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Carl Frederik Werner <frederik@cfbw.eu>

commit 3a2fa775bd1d0579113666c1a2e37654a34018a0 upstream.

Let's fix pinmux address of gpio 170 used by tfp410 powerdown-gpio.

According to the OMAP35x Technical Reference Manual
  CONTROL_PADCONF_I2C3_SDA[15:0]  0x480021C4 mode0: i2c3_sda
  CONTROL_PADCONF_I2C3_SDA[31:16] 0x480021C4 mode4: gpio_170
the pinmux address of gpio 170 must be 0x480021C6.

The former wrong address broke i2c3 (used by hdmi ddc), resulting in
kernel message:
  omap_i2c 48060000.i2c: controller timed out

Fixes: 8cecf52befd7 ("ARM: omap3-beagle.dts: add display information")
Signed-off-by: Carl Frederik Werner <frederik@cfbw.eu>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/arm/boot/dts/omap3-beagle.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts
index 3c3e6da1deac..3595d1ceae0c 100644
--- a/arch/arm/boot/dts/omap3-beagle.dts
+++ b/arch/arm/boot/dts/omap3-beagle.dts
@@ -176,7 +176,7 @@
 
 	tfp410_pins: pinmux_tfp410_pins {
 		pinctrl-single,pins = <
-			0x194 (PIN_OUTPUT | MUX_MODE4)	/* hdq_sio.gpio_170 */
+			0x196 (PIN_OUTPUT | MUX_MODE4)	/* hdq_sio.gpio_170 */
 		>;
 	};
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 029/104] Btrfs: fix read corruption of compressed and shared extents
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (27 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 028/104] ARM: dts: omap3-beagle: make i2c3, ddc and tfp410 gpio work again Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 030/104] btrfs: skip waiting on ordered range for special files Luis Henriques
                   ` (79 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Filipe Manana, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Filipe Manana <fdmanana@suse.com>

commit 005efedf2c7d0a270ffbe28d8997b03844f3e3e7 upstream.

If a file has a range pointing to a compressed extent, followed by
another range that points to the same compressed extent and a read
operation attempts to read both ranges (either completely or part of
them), the pages that correspond to the second range are incorrectly
filled with zeroes.

Consider the following example:

  File layout
  [0 - 8K]                      [8K - 24K]
      |                             |
      |                             |
   points to extent X,         points to extent X,
   offset 4K, length of 8K     offset 0, length 16K

  [extent X, compressed length = 4K uncompressed length = 16K]

If a readpages() call spans the 2 ranges, a single bio to read the extent
is submitted - extent_io.c:submit_extent_page() would only create a new
bio to cover the second range pointing to the extent if the extent it
points to had a different logical address than the extent associated with
the first range. This has a consequence of the compressed read end io
handler (compression.c:end_compressed_bio_read()) finish once the extent
is decompressed into the pages covering the first range, leaving the
remaining pages (belonging to the second range) filled with zeroes (done
by compression.c:btrfs_clear_biovec_end()).

So fix this by submitting the current bio whenever we find a range
pointing to a compressed extent that was preceded by a range with a
different extent map. This is the simplest solution for this corner
case. Making the end io callback populate both ranges (or more, if we
have multiple pointing to the same extent) is a much more complex
solution since each bio is tightly coupled with a single extent map and
the extent maps associated to the ranges pointing to the shared extent
can have different offsets and lengths.

The following test case for fstests triggers the issue:

  seq=`basename $0`
  seqres=$RESULT_DIR/$seq
  echo "QA output created by $seq"
  tmp=/tmp/$$
  status=1	# failure is the default!
  trap "_cleanup; exit \$status" 0 1 2 3 15

  _cleanup()
  {
      rm -f $tmp.*
  }

  # get standard environment, filters and checks
  . ./common/rc
  . ./common/filter

  # real QA test starts here
  _need_to_be_root
  _supported_fs btrfs
  _supported_os Linux
  _require_scratch
  _require_cloner

  rm -f $seqres.full

  test_clone_and_read_compressed_extent()
  {
      local mount_opts=$1

      _scratch_mkfs >>$seqres.full 2>&1
      _scratch_mount $mount_opts

      # Create a test file with a single extent that is compressed (the
      # data we write into it is highly compressible no matter which
      # compression algorithm is used, zlib or lzo).
      $XFS_IO_PROG -f -c "pwrite -S 0xaa 0K 4K"        \
                      -c "pwrite -S 0xbb 4K 8K"        \
                      -c "pwrite -S 0xcc 12K 4K"       \
                      $SCRATCH_MNT/foo | _filter_xfs_io

      # Now clone our extent into an adjacent offset.
      $CLONER_PROG -s $((4 * 1024)) -d $((16 * 1024)) -l $((8 * 1024)) \
          $SCRATCH_MNT/foo $SCRATCH_MNT/foo

      # Same as before but for this file we clone the extent into a lower
      # file offset.
      $XFS_IO_PROG -f -c "pwrite -S 0xaa 8K 4K"         \
                      -c "pwrite -S 0xbb 12K 8K"        \
                      -c "pwrite -S 0xcc 20K 4K"        \
                      $SCRATCH_MNT/bar | _filter_xfs_io

      $CLONER_PROG -s $((12 * 1024)) -d 0 -l $((8 * 1024)) \
          $SCRATCH_MNT/bar $SCRATCH_MNT/bar

      echo "File digests before unmounting filesystem:"
      md5sum $SCRATCH_MNT/foo | _filter_scratch
      md5sum $SCRATCH_MNT/bar | _filter_scratch

      # Evicting the inode or clearing the page cache before reading
      # again the file would also trigger the bug - reads were returning
      # all bytes in the range corresponding to the second reference to
      # the extent with a value of 0, but the correct data was persisted
      # (it was a bug exclusively in the read path). The issue happened
      # only if the same readpages() call targeted pages belonging to the
      # first and second ranges that point to the same compressed extent.
      _scratch_remount

      echo "File digests after mounting filesystem again:"
      # Must match the same digests we got before.
      md5sum $SCRATCH_MNT/foo | _filter_scratch
      md5sum $SCRATCH_MNT/bar | _filter_scratch
  }

  echo -e "\nTesting with zlib compression..."
  test_clone_and_read_compressed_extent "-o compress=zlib"

  _scratch_unmount

  echo -e "\nTesting with lzo compression..."
  test_clone_and_read_compressed_extent "-o compress=lzo"

  status=0
  exit

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo<quwenruo@cn.fujitsu.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 fs/btrfs/extent_io.c | 65 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 57 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index a7db105139d2..0c5955b6275d 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2688,7 +2688,8 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree,
 			      bio_end_io_t end_io_func,
 			      int mirror_num,
 			      unsigned long prev_bio_flags,
-			      unsigned long bio_flags)
+			      unsigned long bio_flags,
+			      bool force_bio_submit)
 {
 	int ret = 0;
 	struct bio *bio;
@@ -2706,6 +2707,7 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree,
 			contig = bio_end_sector(bio) == sector;
 
 		if (prev_bio_flags != bio_flags || !contig ||
+		    force_bio_submit ||
 		    merge_bio(rw, tree, page, offset, page_size, bio, bio_flags) ||
 		    bio_add_page(bio, page, page_size, offset) < page_size) {
 			ret = submit_one_bio(rw, bio, mirror_num,
@@ -2797,7 +2799,8 @@ static int __do_readpage(struct extent_io_tree *tree,
 			 get_extent_t *get_extent,
 			 struct extent_map **em_cached,
 			 struct bio **bio, int mirror_num,
-			 unsigned long *bio_flags, int rw)
+			 unsigned long *bio_flags, int rw,
+			 u64 *prev_em_start)
 {
 	struct inode *inode = page->mapping->host;
 	u64 start = page_offset(page);
@@ -2845,6 +2848,7 @@ static int __do_readpage(struct extent_io_tree *tree,
 	}
 	while (cur <= end) {
 		unsigned long pnr = (last_byte >> PAGE_CACHE_SHIFT) + 1;
+		bool force_bio_submit = false;
 
 		if (cur >= last_byte) {
 			char *userpage;
@@ -2895,6 +2899,49 @@ static int __do_readpage(struct extent_io_tree *tree,
 		block_start = em->block_start;
 		if (test_bit(EXTENT_FLAG_PREALLOC, &em->flags))
 			block_start = EXTENT_MAP_HOLE;
+
+		/*
+		 * If we have a file range that points to a compressed extent
+		 * and it's followed by a consecutive file range that points to
+		 * to the same compressed extent (possibly with a different
+		 * offset and/or length, so it either points to the whole extent
+		 * or only part of it), we must make sure we do not submit a
+		 * single bio to populate the pages for the 2 ranges because
+		 * this makes the compressed extent read zero out the pages
+		 * belonging to the 2nd range. Imagine the following scenario:
+		 *
+		 *  File layout
+		 *  [0 - 8K]                     [8K - 24K]
+		 *    |                               |
+		 *    |                               |
+		 * points to extent X,         points to extent X,
+		 * offset 4K, length of 8K     offset 0, length 16K
+		 *
+		 * [extent X, compressed length = 4K uncompressed length = 16K]
+		 *
+		 * If the bio to read the compressed extent covers both ranges,
+		 * it will decompress extent X into the pages belonging to the
+		 * first range and then it will stop, zeroing out the remaining
+		 * pages that belong to the other range that points to extent X.
+		 * So here we make sure we submit 2 bios, one for the first
+		 * range and another one for the third range. Both will target
+		 * the same physical extent from disk, but we can't currently
+		 * make the compressed bio endio callback populate the pages
+		 * for both ranges because each compressed bio is tightly
+		 * coupled with a single extent map, and each range can have
+		 * an extent map with a different offset value relative to the
+		 * uncompressed data of our extent and different lengths. This
+		 * is a corner case so we prioritize correctness over
+		 * non-optimal behavior (submitting 2 bios for the same extent).
+		 */
+		if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags) &&
+		    prev_em_start && *prev_em_start != (u64)-1 &&
+		    *prev_em_start != em->orig_start)
+			force_bio_submit = true;
+
+		if (prev_em_start)
+			*prev_em_start = em->orig_start;
+
 		free_extent_map(em);
 		em = NULL;
 
@@ -2944,7 +2991,8 @@ static int __do_readpage(struct extent_io_tree *tree,
 					 bdev, bio, pnr,
 					 end_bio_extent_readpage, mirror_num,
 					 *bio_flags,
-					 this_bio_flag);
+					 this_bio_flag,
+					 force_bio_submit);
 		if (!ret) {
 			nr++;
 			*bio_flags = this_bio_flag;
@@ -2976,6 +3024,7 @@ static inline void __do_contiguous_readpages(struct extent_io_tree *tree,
 	struct inode *inode;
 	struct btrfs_ordered_extent *ordered;
 	int index;
+	u64 prev_em_start = (u64)-1;
 
 	inode = pages[0]->mapping->host;
 	while (1) {
@@ -2991,7 +3040,7 @@ static inline void __do_contiguous_readpages(struct extent_io_tree *tree,
 
 	for (index = 0; index < nr_pages; index++) {
 		__do_readpage(tree, pages[index], get_extent, em_cached, bio,
-			      mirror_num, bio_flags, rw);
+			      mirror_num, bio_flags, rw, &prev_em_start);
 		page_cache_release(pages[index]);
 	}
 }
@@ -3059,7 +3108,7 @@ static int __extent_read_full_page(struct extent_io_tree *tree,
 	}
 
 	ret = __do_readpage(tree, page, get_extent, NULL, bio, mirror_num,
-			    bio_flags, rw);
+			    bio_flags, rw, NULL);
 	return ret;
 }
 
@@ -3085,7 +3134,7 @@ int extent_read_full_page_nolock(struct extent_io_tree *tree, struct page *page,
 	int ret;
 
 	ret = __do_readpage(tree, page, get_extent, NULL, &bio, mirror_num,
-				      &bio_flags, READ);
+			    &bio_flags, READ, NULL);
 	if (bio)
 		ret = submit_one_bio(READ, bio, mirror_num, bio_flags);
 	return ret;
@@ -3338,7 +3387,7 @@ static noinline_for_stack int __extent_writepage_io(struct inode *inode,
 						 sector, iosize, pg_offset,
 						 bdev, &epd->bio, max_nr,
 						 end_bio_extent_writepage,
-						 0, 0, 0);
+						 0, 0, 0, false);
 			if (ret)
 				SetPageError(page);
 		}
@@ -3585,7 +3634,7 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb,
 		ret = submit_extent_page(rw, tree, p, offset >> 9,
 					 PAGE_CACHE_SIZE, 0, bdev, &epd->bio,
 					 -1, end_bio_extent_buffer_writepage,
-					 0, epd->bio_flags, bio_flags);
+					 0, epd->bio_flags, bio_flags, false);
 		epd->bio_flags = bio_flags;
 		if (ret) {
 			set_bit(EXTENT_BUFFER_IOERR, &eb->bflags);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 030/104] btrfs: skip waiting on ordered range for special files
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (28 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 029/104] Btrfs: fix read corruption of compressed and shared extents Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 031/104] usb: chipidea: udc: using the correct stall implementation Luis Henriques
                   ` (78 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Jeff Mahoney, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jeff Mahoney <jeffm@suse.com>

commit a30e577c96f59b1e1678ea5462432b09bf7d5cbc upstream.

In btrfs_evict_inode, we properly truncate the page cache for evicted
inodes but then we call btrfs_wait_ordered_range for every inode as well.
It's the right thing to do for regular files but results in incorrect
behavior for device inodes for block devices.

filemap_fdatawrite_range gets called with inode->i_mapping which gets
resolved to the block device inode before getting passed to
wbc_attach_fdatawrite_inode and ultimately to inode_to_bdi.  What happens
next depends on whether there's an open file handle associated with the
inode.  If there is, we write to the block device, which is unexpected
behavior.  If there isn't, we through normally and inode->i_data is used.
We can also end up racing against open/close which can result in crashes
when i_mapping points to a block device inode that has been closed.

Since there can't be any page cache associated with special file inodes,
it's safe to skip the btrfs_wait_ordered_range call entirely and avoid
the problem.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=100911
Tested-by: Christoph Biedl <linux-kernel.bfrz@manchmal.in-ulm.de>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 fs/btrfs/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 670f942e2235..89c876aabe24 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4733,7 +4733,8 @@ void btrfs_evict_inode(struct inode *inode)
 		goto no_delete;
 	}
 	/* do we really want it for ->i_nlink > 0 and zero btrfs_root_refs? */
-	btrfs_wait_ordered_range(inode, 0, (u64)-1);
+	if (!special_file(inode->i_mode))
+		btrfs_wait_ordered_range(inode, 0, (u64)-1);
 
 	if (root->fs_info->log_root_recovering) {
 		BUG_ON(test_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 031/104] usb: chipidea: udc: using the correct stall implementation
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (29 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 030/104] btrfs: skip waiting on ordered range for special files Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 032/104] net: mvneta: fix DMA buffer unmapping in mvneta_rx() Luis Henriques
                   ` (77 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Alan Stern, Felipe Balbi, Peter Chen, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Peter Chen <peter.chen@freescale.com>

commit 56ffa1d154c7e12af16273f0cdc42690dd05caf5 upstream.

According to spec, there are functional and protocol stalls.

For functional stall, it is for bulk and interrupt endpoints,
below are cases for it:
- Host sends SET_FEATURE request for Set-Halt, the udc driver
needs to set stall, and return true unconditionally.
- The gadget driver may call usb_ep_set_halt to stall certain
endpoints, if there is a transfer in pending, the udc driver
should not set stall, and return -EAGAIN accordingly.
These two kinds of stall need to be cleared by host using CLEAR_FEATURE
request (Clear-Halt).

For protocol stall, it is for control endpoint, this stall will
be set if the control request has failed. This stall will be
cleared by next setup request (hardware will do it).

It fixed usbtest (drivers/usb/misc/usbtest.c) Test 13 "set/clear halt"
test failure, meanwhile, this change has been verified by
USB2 CV Compliance Test and MSC Tests.

Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Felipe Balbi <balbi@ti.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/usb/chipidea/udc.c | 84 ++++++++++++++++++++++++----------------------
 1 file changed, 44 insertions(+), 40 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 4065323d493c..8096116fc661 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -638,6 +638,44 @@ __acquires(hwep->lock)
 	return 0;
 }
 
+static int _ep_set_halt(struct usb_ep *ep, int value, bool check_transfer)
+{
+	struct ci_hw_ep *hwep = container_of(ep, struct ci_hw_ep, ep);
+	int direction, retval = 0;
+	unsigned long flags;
+
+	if (ep == NULL || hwep->ep.desc == NULL)
+		return -EINVAL;
+
+	if (usb_endpoint_xfer_isoc(hwep->ep.desc))
+		return -EOPNOTSUPP;
+
+	spin_lock_irqsave(hwep->lock, flags);
+
+	if (value && hwep->dir == TX && check_transfer &&
+		!list_empty(&hwep->qh.queue) &&
+			!usb_endpoint_xfer_control(hwep->ep.desc)) {
+		spin_unlock_irqrestore(hwep->lock, flags);
+		return -EAGAIN;
+	}
+
+	direction = hwep->dir;
+	do {
+		retval |= hw_ep_set_halt(hwep->ci, hwep->num, hwep->dir, value);
+
+		if (!value)
+			hwep->wedge = 0;
+
+		if (hwep->type == USB_ENDPOINT_XFER_CONTROL)
+			hwep->dir = (hwep->dir == TX) ? RX : TX;
+
+	} while (hwep->dir != direction);
+
+	spin_unlock_irqrestore(hwep->lock, flags);
+	return retval;
+}
+
+
 /**
  * _gadget_stop_activity: stops all USB activity, flushes & disables all endpts
  * @gadget: gadget
@@ -1037,7 +1075,7 @@ __acquires(ci->lock)
 				num += ci->hw_ep_max / 2;
 
 			spin_unlock(&ci->lock);
-			err = usb_ep_set_halt(&ci->ci_hw_ep[num].ep);
+			err = _ep_set_halt(&ci->ci_hw_ep[num].ep, 1, false);
 			spin_lock(&ci->lock);
 			if (!err)
 				isr_setup_status_phase(ci);
@@ -1096,8 +1134,8 @@ delegate:
 
 	if (err < 0) {
 		spin_unlock(&ci->lock);
-		if (usb_ep_set_halt(&hwep->ep))
-			dev_err(ci->dev, "error: ep_set_halt\n");
+		if (_ep_set_halt(&hwep->ep, 1, false))
+			dev_err(ci->dev, "error: _ep_set_halt\n");
 		spin_lock(&ci->lock);
 	}
 }
@@ -1128,9 +1166,9 @@ __acquires(ci->lock)
 					err = isr_setup_status_phase(ci);
 				if (err < 0) {
 					spin_unlock(&ci->lock);
-					if (usb_ep_set_halt(&hwep->ep))
+					if (_ep_set_halt(&hwep->ep, 1, false))
 						dev_err(ci->dev,
-							"error: ep_set_halt\n");
+						"error: _ep_set_halt\n");
 					spin_lock(&ci->lock);
 				}
 			}
@@ -1373,41 +1411,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
  */
 static int ep_set_halt(struct usb_ep *ep, int value)
 {
-	struct ci_hw_ep *hwep = container_of(ep, struct ci_hw_ep, ep);
-	int direction, retval = 0;
-	unsigned long flags;
-
-	if (ep == NULL || hwep->ep.desc == NULL)
-		return -EINVAL;
-
-	if (usb_endpoint_xfer_isoc(hwep->ep.desc))
-		return -EOPNOTSUPP;
-
-	spin_lock_irqsave(hwep->lock, flags);
-
-#ifndef STALL_IN
-	/* g_file_storage MS compliant but g_zero fails chapter 9 compliance */
-	if (value && hwep->type == USB_ENDPOINT_XFER_BULK && hwep->dir == TX &&
-	    !list_empty(&hwep->qh.queue)) {
-		spin_unlock_irqrestore(hwep->lock, flags);
-		return -EAGAIN;
-	}
-#endif
-
-	direction = hwep->dir;
-	do {
-		retval |= hw_ep_set_halt(hwep->ci, hwep->num, hwep->dir, value);
-
-		if (!value)
-			hwep->wedge = 0;
-
-		if (hwep->type == USB_ENDPOINT_XFER_CONTROL)
-			hwep->dir = (hwep->dir == TX) ? RX : TX;
-
-	} while (hwep->dir != direction);
-
-	spin_unlock_irqrestore(hwep->lock, flags);
-	return retval;
+	return _ep_set_halt(ep, value, true);
 }
 
 /**

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 032/104] net: mvneta: fix DMA buffer unmapping in mvneta_rx()
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (30 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 031/104] usb: chipidea: udc: using the correct stall implementation Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 033/104] iser-target: remove command with state ISTATE_REMOVE Luis Henriques
                   ` (76 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Simon Guinot, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Simon Guinot <simon.guinot@sequanux.org>

commit daf158d0d544cec80b7b30deff8cfc59a6e17610 upstream.

This patch fixes a regression introduced by the commit a84e32894191
("net: mvneta: fix refilling for Rx DMA buffers"). Due to this commit
the newly allocated Rx buffers are DMA-unmapped in place of those passed
to the networking stack. Obviously, this causes data corruptions.

This patch fixes the issue by ensuring that the right Rx buffers are
DMA-unmapped.

Reported-by: Oren Laskin <oren@igneous.io>
Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
Fixes: a84e32894191 ("net: mvneta: fix refilling for Rx DMA buffers")
Tested-by: Oren Laskin <oren@igneous.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/net/ethernet/marvell/mvneta.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 109908574224..03ab691ad683 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1450,6 +1450,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
 		struct mvneta_rx_desc *rx_desc = mvneta_rxq_next_desc_get(rxq);
 		struct sk_buff *skb;
 		unsigned char *data;
+		dma_addr_t phys_addr;
 		u32 rx_status;
 		int rx_bytes, err;
 
@@ -1457,6 +1458,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
 		rx_status = rx_desc->status;
 		rx_bytes = rx_desc->data_size - (ETH_FCS_LEN + MVNETA_MH_SIZE);
 		data = (unsigned char *)rx_desc->buf_cookie;
+		phys_addr = rx_desc->buf_phys_addr;
 
 		if (!mvneta_rxq_desc_is_first_last(rx_status) ||
 		    (rx_status & MVNETA_RXD_ERR_SUMMARY)) {
@@ -1505,7 +1507,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
 		if (!skb)
 			goto err_drop_frame;
 
-		dma_unmap_single(dev->dev.parent, rx_desc->buf_phys_addr,
+		dma_unmap_single(dev->dev.parent, phys_addr,
 				 MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE);
 
 		rcvd_pkts++;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 033/104] iser-target: remove command with state ISTATE_REMOVE
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (31 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 032/104] net: mvneta: fix DMA buffer unmapping in mvneta_rx() Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 034/104] staging: ion: fix corruption of ion_import_dma_buf Luis Henriques
                   ` (75 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Jenny Derzhavetz, Sagi Grimberg, Nicholas Bellinger, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jenny Derzhavetz <jennyf@mellanox.com>

commit a4c15cd957cbd728f685645de7a150df5912591a upstream.

As documented in iscsit_sequence_cmd:
/*
 * Existing callers for iscsit_sequence_cmd() will silently
 * ignore commands with CMDSN_LOWER_THAN_EXP, so force this
 * return for CMDSN_MAXCMDSN_OVERRUN as well..
 */

We need to silently finish a command when it's in ISTATE_REMOVE.
This fixes an teardown hang we were seeing where a mis-behaved
initiator (triggered by allocation error injections) sent us a
cmdsn which was lower than expected.

Signed-off-by: Jenny Derzhavetz <jennyf@mellanox.com>
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/infiniband/ulp/isert/ib_isert.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index cdd3c6a06bb9..55ae75c7379d 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -3121,9 +3121,16 @@ isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery)
 static int
 isert_immediate_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state)
 {
-	int ret;
+	struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
+	int ret = 0;
 
 	switch (state) {
+	case ISTATE_REMOVE:
+		spin_lock_bh(&conn->cmd_lock);
+		list_del_init(&cmd->i_conn_node);
+		spin_unlock_bh(&conn->cmd_lock);
+		isert_put_cmd(isert_cmd, true);
+		break;
 	case ISTATE_SEND_NOPIN_WANT_RESPONSE:
 		ret = isert_put_nopin(cmd, conn, false);
 		break;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 034/104] staging: ion: fix corruption of ion_import_dma_buf
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (32 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 033/104] iser-target: remove command with state ISTATE_REMOVE Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 035/104] KVM: x86: trap AMD MSRs for the TSeg base and mask Luis Henriques
                   ` (74 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Shawn Lin, Greg Kroah-Hartman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shawn Lin <shawn.lin@rock-chips.com>

commit 6fa92e2bcf6390e64895b12761e851c452d87bd8 upstream.

we found this issue but still exit in lastest kernel. Simply
keep ion_handle_create under mutex_lock to avoid this race.

WARNING: CPU: 2 PID: 2648 at drivers/staging/android/ion/ion.c:512 ion_handle_add+0xb4/0xc0()
ion_handle_add: buffer already found.
Modules linked in: iwlmvm iwlwifi mac80211 cfg80211 compat
CPU: 2 PID: 2648 Comm: TimedEventQueue Tainted: G        W    3.14.0 #7
 00000000 00000000 9a3efd2c 80faf273 9a3efd6c 9a3efd5c 80935dc9 811d7fd3
 9a3efd88 00000a58 812208a0 00000200 80e128d4 80e128d4 8d4ae00c a8cd8600
 a8cd8094 9a3efd74 80935e0e 00000009 9a3efd6c 811d7fd3 9a3efd88 9a3efd9c
Call Trace:
  [<80faf273>] dump_stack+0x48/0x69
  [<80935dc9>] warn_slowpath_common+0x79/0x90
  [<80e128d4>] ? ion_handle_add+0xb4/0xc0
  [<80e128d4>] ? ion_handle_add+0xb4/0xc0
  [<80935e0e>] warn_slowpath_fmt+0x2e/0x30
  [<80e128d4>] ion_handle_add+0xb4/0xc0
  [<80e144cc>] ion_import_dma_buf+0x8c/0x110
  [<80c517c4>] reg_init+0x364/0x7d0
  [<80993363>] ? futex_wait+0x123/0x210
  [<80992e0e>] ? get_futex_key+0x16e/0x1e0
  [<8099308f>] ? futex_wake+0x5f/0x120
  [<80c51e19>] vpu_service_ioctl+0x1e9/0x500
  [<80994aec>] ? do_futex+0xec/0x8e0
  [<80971080>] ? prepare_to_wait_event+0xc0/0xc0
  [<80c51c30>] ? reg_init+0x7d0/0x7d0
  [<80a22562>] do_vfs_ioctl+0x2d2/0x4c0
  [<80b198ad>] ? inode_has_perm.isra.41+0x2d/0x40
  [<80b199cf>] ? file_has_perm+0x7f/0x90
  [<80b1a5f7>] ? selinux_file_ioctl+0x47/0xf0
  [<80a227a8>] SyS_ioctl+0x58/0x80
  [<80fb45e8>] syscall_call+0x7/0x7
  [<80fb0000>] ? mmc_do_calc_max_discard+0xab/0xe4

Fixes: 83271f626 ("ion: hold reference to handle...")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Reviewed-by: Laura Abbott <labbott@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/staging/android/ion/ion.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 389b8f67a2ec..3eb845baf3f5 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -1175,13 +1175,13 @@ struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)
 		mutex_unlock(&client->lock);
 		goto end;
 	}
-	mutex_unlock(&client->lock);
 
 	handle = ion_handle_create(client, buffer);
-	if (IS_ERR(handle))
+	if (IS_ERR(handle)) {
+		mutex_unlock(&client->lock);
 		goto end;
+	}
 
-	mutex_lock(&client->lock);
 	ret = ion_handle_add(client, handle);
 	mutex_unlock(&client->lock);
 	if (ret) {

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 035/104] KVM: x86: trap AMD MSRs for the TSeg base and mask
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (33 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 034/104] staging: ion: fix corruption of ion_import_dma_buf Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 036/104] usb: Use the USB_SS_MULT() macro to get the burst multiplier Luis Henriques
                   ` (73 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Paolo Bonzini, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Paolo Bonzini <pbonzini@redhat.com>

commit 3afb1121800128aae9f5722e50097fcf1a9d4d88 upstream.

These have roughly the same purpose as the SMRR, which we do not need
to implement in KVM.  However, Linux accesses MSR_K8_TSEG_ADDR at
boot, which causes problems when running a Xen dom0 under KVM.
Just return 0, meaning that processor protection of SMRAM is not
in effect.

Reported-by: M A Young <m.a.young@durham.ac.uk>
Acked-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[ luis: backported to 3.16:
  - file rename: arch/x86/include/asm/msr-index.h ->
    arch/x86/include/uapi/asm/msr-index.h
  - adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/x86/include/uapi/asm/msr-index.h | 1 +
 arch/x86/kvm/x86.c                    | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/arch/x86/include/uapi/asm/msr-index.h b/arch/x86/include/uapi/asm/msr-index.h
index fcf2b3ae1bf0..7db049a7f7ab 100644
--- a/arch/x86/include/uapi/asm/msr-index.h
+++ b/arch/x86/include/uapi/asm/msr-index.h
@@ -232,6 +232,7 @@
 /* C1E active bits in int pending message */
 #define K8_INTP_C1E_ACTIVE_MASK		0x18000000
 #define MSR_K8_TSEG_ADDR		0xc0010112
+#define MSR_K8_TSEG_MASK		0xc0010113
 #define K8_MTRRFIXRANGE_DRAM_ENABLE	0x00040000 /* MtrrFixDramEn bit    */
 #define K8_MTRRFIXRANGE_DRAM_MODIFY	0x00080000 /* MtrrFixDramModEn bit */
 #define K8_MTRR_RDMEM_WRMEM_MASK	0x18181818 /* Mask: RdMem|WrMem    */
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 27a8d4f9bce5..4977c1a93d52 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2425,6 +2425,8 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 	case MSR_IA32_LASTINTFROMIP:
 	case MSR_IA32_LASTINTTOIP:
 	case MSR_K8_SYSCFG:
+	case MSR_K8_TSEG_ADDR:
+	case MSR_K8_TSEG_MASK:
 	case MSR_K7_HWCR:
 	case MSR_VM_HSAVE_PA:
 	case MSR_K7_EVNTSEL0:

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 036/104] usb: Use the USB_SS_MULT() macro to get the burst multiplier.
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (34 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 035/104] KVM: x86: trap AMD MSRs for the TSeg base and mask Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 037/104] xhci: give command abortion one more chance before killing xhci Luis Henriques
                   ` (72 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mathias Nyman, Greg Kroah-Hartman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mathias Nyman <mathias.nyman@linux.intel.com>

commit ff30cbc8da425754e8ab96904db1d295bd034f27 upstream.

Bits 1:0 of the bmAttributes are used for the burst multiplier.
The rest of the bits used to be reserved (zero), but USB3.1 takes bit 7
into use.

Use the existing USB_SS_MULT() macro instead to make sure the mult value
and hence max packet calculations are correct for USB3.1 devices.

Note that burst multiplier in bmAttributes is zero based and that
the USB_SS_MULT() macro adds one.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/usb/core/config.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index b2a540b43f97..b9ddf0c1ffe5 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -112,7 +112,7 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 				cfgno, inum, asnum, ep->desc.bEndpointAddress);
 		ep->ss_ep_comp.bmAttributes = 16;
 	} else if (usb_endpoint_xfer_isoc(&ep->desc) &&
-			desc->bmAttributes > 2) {
+		   USB_SS_MULT(desc->bmAttributes) > 3) {
 		dev_warn(ddev, "Isoc endpoint has Mult of %d in "
 				"config %d interface %d altsetting %d ep %d: "
 				"setting to 3\n", desc->bmAttributes + 1,
@@ -121,7 +121,8 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 	}
 
 	if (usb_endpoint_xfer_isoc(&ep->desc))
-		max_tx = (desc->bMaxBurst + 1) * (desc->bmAttributes + 1) *
+		max_tx = (desc->bMaxBurst + 1) *
+			(USB_SS_MULT(desc->bmAttributes)) *
 			usb_endpoint_maxp(&ep->desc);
 	else if (usb_endpoint_xfer_int(&ep->desc))
 		max_tx = usb_endpoint_maxp(&ep->desc) *

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 037/104] xhci: give command abortion one more chance before killing xhci
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (35 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 036/104] usb: Use the USB_SS_MULT() macro to get the burst multiplier Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 038/104] usb: xhci: Clear XHCI_STATE_DYING on start Luis Henriques
                   ` (71 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mathias Nyman, Greg Kroah-Hartman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mathias Nyman <mathias.nyman@linux.intel.com>

commit a6809ffd1687b3a8c192960e69add559b9d32649 upstream.

We want to give the command abortion an additional try to stop
the command ring before we completely hose xhci.

Tested-by: Vincent Pelletier <plr.vincent@gmail.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ luis: backported to 3.16:
  - xhci_handshake() has an extra 'xhci' parameter in 3.16 ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/usb/host/xhci-ring.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 735659f69599..79143b8d1889 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -302,6 +302,15 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
 	ret = xhci_handshake(xhci, &xhci->op_regs->cmd_ring,
 			CMD_RING_RUNNING, 0, 5 * 1000 * 1000);
 	if (ret < 0) {
+		/* we are about to kill xhci, give it one more chance */
+		xhci_write_64(xhci, temp_64 | CMD_RING_ABORT,
+			      &xhci->op_regs->cmd_ring);
+		udelay(1000);
+		ret = xhci_handshake(xhci, &xhci->op_regs->cmd_ring,
+				     CMD_RING_RUNNING, 0, 3 * 1000 * 1000);
+		if (ret == 0)
+			return 0;
+
 		xhci_err(xhci, "Stopped the command ring failed, "
 				"maybe the host is dead\n");
 		xhci->xhc_state |= XHCI_STATE_DYING;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 038/104] usb: xhci: Clear XHCI_STATE_DYING on start
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (36 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 037/104] xhci: give command abortion one more chance before killing xhci Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 039/104] usb: xhci: Allow usb_add/remove_hcd() to be called repeatedly Luis Henriques
                   ` (70 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Roger Quadros, Mathias Nyman, Greg Kroah-Hartman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Roger Quadros <rogerq@ti.com>

commit e5bfeab0ad515b4f6df39fe716603e9dc6d3dfd0 upstream.

For whatever reason if XHCI died in the previous instant
then it will never recover on the next xhci_start unless we
clear the DYING flag.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/usb/host/xhci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 7ce24229e863..4170d913ee6e 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -147,7 +147,8 @@ static int xhci_start(struct xhci_hcd *xhci)
 				"waited %u microseconds.\n",
 				XHCI_MAX_HALT_USEC);
 	if (!ret)
-		xhci->xhc_state &= ~XHCI_STATE_HALTED;
+		xhci->xhc_state &= ~(XHCI_STATE_HALTED | XHCI_STATE_DYING);
+
 	return ret;
 }
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 039/104] usb: xhci: Allow usb_add/remove_hcd() to be called repeatedly
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (37 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 038/104] usb: xhci: Clear XHCI_STATE_DYING on start Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 040/104] xhci: change xhci 1.0 only restrictions to support xhci 1.1 Luis Henriques
                   ` (69 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Roger Quadros, Mathias Nyman, Greg Kroah-Hartman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Roger Quadros <rogerq@ti.com>

commit 8a853759c262fd52ff0f5e89f89c65928077fe4a upstream.

Don't set xhci->shared_hcd to NULL in xhci_stop() as we have
still not de-allocated it. It was resulting in a NULL pointer
de-reference if usb_add/remove_hcd() is called repeatedly.

We want repeated add/remove to work for the OTG use case.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/usb/host/xhci.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 4170d913ee6e..d7f3adf56af2 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -663,12 +663,6 @@ static void xhci_only_stop_hcd(struct usb_hcd *hcd)
 
 	spin_lock_irq(&xhci->lock);
 	xhci_halt(xhci);
-
-	/* The shared_hcd is going to be deallocated shortly (the USB core only
-	 * calls this function when allocation fails in usb_add_hcd(), or
-	 * usb_remove_hcd() is called).  So we need to unset xHCI's pointer.
-	 */
-	xhci->shared_hcd = NULL;
 	spin_unlock_irq(&xhci->lock);
 }
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 040/104] xhci: change xhci 1.0 only restrictions to support xhci 1.1
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (38 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 039/104] usb: xhci: Allow usb_add/remove_hcd() to be called repeatedly Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 041/104] xhci-mem: Use setup_timer Luis Henriques
                   ` (68 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mathias Nyman, Greg Kroah-Hartman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mathias Nyman <mathias.nyman@linux.intel.com>

commit dca7794539eff04b786fb6907186989e5eaaa9c2 upstream.

Some changes between xhci 0.96 and xhci 1.0 specifications forced us to
check the hci version in code, some of these checks were implemented as
hci_version == 1.0, which will not work with new xhci 1.1 controllers.

xhci 1.1 behaves similar to xhci 1.0 in these cases, so change these
checks to hci_version >= 1.0

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/usb/host/xhci-mem.c  | 6 +++---
 drivers/usb/host/xhci-ring.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index d06f2a336b0c..9e6e83bc5d4c 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1502,10 +1502,10 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
 	 * use Event Data TRBs, and we don't chain in a link TRB on short
 	 * transfers, we're basically dividing by 1.
 	 *
-	 * xHCI 1.0 specification indicates that the Average TRB Length should
-	 * be set to 8 for control endpoints.
+	 * xHCI 1.0 and 1.1 specification indicates that the Average TRB Length
+	 * should be set to 8 for control endpoints.
 	 */
-	if (usb_endpoint_xfer_control(&ep->desc) && xhci->hci_version == 0x100)
+	if (usb_endpoint_xfer_control(&ep->desc) && xhci->hci_version >= 0x100)
 		ep_ctx->tx_info |= cpu_to_le32(AVG_TRB_LENGTH_FOR_EP(8));
 	else
 		ep_ctx->tx_info |=
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 79143b8d1889..bac6fc071532 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3424,8 +3424,8 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
 	if (start_cycle == 0)
 		field |= 0x1;
 
-	/* xHCI 1.0 6.4.1.2.1: Transfer Type field */
-	if (xhci->hci_version == 0x100) {
+	/* xHCI 1.0/1.1 6.4.1.2.1: Transfer Type field */
+	if (xhci->hci_version >= 0x100) {
 		if (urb->transfer_buffer_length > 0) {
 			if (setup->bRequestType & USB_DIR_IN)
 				field |= TRB_TX_TYPE(TRB_DATA_IN);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 041/104] xhci-mem: Use setup_timer
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (39 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 040/104] xhci: change xhci 1.0 only restrictions to support xhci 1.1 Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 042/104] xhci: init command timeout timer earlier to avoid deleting it uninitialized Luis Henriques
                   ` (67 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Julia Lawall, Mathias Nyman, Greg Kroah-Hartman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Julia Lawall <Julia.Lawall@lip6.fr>

commit 9e08a03dc12a41ce695559f8c6d999aaf245b8be upstream.

Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression t,f,d;
@@

-init_timer(&t);
+setup_timer(&t,f,d);
-t.data = d;
-t.function = f;
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/usb/host/xhci-mem.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 9e6e83bc5d4c..7b56111c6c7a 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -833,9 +833,8 @@ void xhci_free_stream_info(struct xhci_hcd *xhci,
 static void xhci_init_endpoint_timer(struct xhci_hcd *xhci,
 		struct xhci_virt_ep *ep)
 {
-	init_timer(&ep->stop_cmd_timer);
-	ep->stop_cmd_timer.data = (unsigned long) ep;
-	ep->stop_cmd_timer.function = xhci_stop_endpoint_command_watchdog;
+	setup_timer(&ep->stop_cmd_timer, xhci_stop_endpoint_command_watchdog,
+		    (unsigned long)ep);
 	ep->xhci = xhci;
 }
 
@@ -2508,9 +2507,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 	xhci_print_ir_set(xhci, 0);
 
 	/* init command timeout timer */
-	init_timer(&xhci->cmd_timer);
-	xhci->cmd_timer.data = (unsigned long) xhci;
-	xhci->cmd_timer.function = xhci_handle_command_timeout;
+	setup_timer(&xhci->cmd_timer, xhci_handle_command_timeout,
+		    (unsigned long)xhci);
 
 	/*
 	 * XXX: Might need to set the Interrupter Moderation Register to

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 042/104] xhci: init command timeout timer earlier to avoid deleting it uninitialized
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (40 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 041/104] xhci-mem: Use setup_timer Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 043/104] spi: xtensa-xtfpga: fix register endianness Luis Henriques
                   ` (66 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mathias Nyman, Greg Kroah-Hartman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mathias Nyman <mathias.nyman@linux.intel.com>

commit cc8e4fc0c3b5e8340bc8358990515d116a3c274c upstream.

Don't check if timer is running with a timer_pending() before
deleting it with del_timer_sync(), this defies the whole point of
the sync part and can cause a possible race.

Instead we just want to make sure the timer is initialized early enough
before we have a chance to delete it.

Reported-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/usb/host/xhci-mem.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 7b56111c6c7a..f08e81f42951 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1795,8 +1795,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
 	int size;
 	int i, j, num_ports;
 
-	if (timer_pending(&xhci->cmd_timer))
-		del_timer_sync(&xhci->cmd_timer);
+	del_timer_sync(&xhci->cmd_timer);
 
 	/* Free the Event Ring Segment Table and the actual Event Ring */
 	size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
@@ -2322,6 +2321,10 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 
 	INIT_LIST_HEAD(&xhci->cmd_list);
 
+	/* init command timeout timer */
+	setup_timer(&xhci->cmd_timer, xhci_handle_command_timeout,
+		    (unsigned long)xhci);
+
 	page_size = readl(&xhci->op_regs->page_size);
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
 			"Supported page size register = 0x%x", page_size);
@@ -2506,10 +2509,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 			"Wrote ERST address to ir_set 0.");
 	xhci_print_ir_set(xhci, 0);
 
-	/* init command timeout timer */
-	setup_timer(&xhci->cmd_timer, xhci_handle_command_timeout,
-		    (unsigned long)xhci);
-
 	/*
 	 * XXX: Might need to set the Interrupter Moderation Register to
 	 * something other than the default (~1ms minimum between interrupts).

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 043/104] spi: xtensa-xtfpga: fix register endianness
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (41 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 042/104] xhci: init command timeout timer earlier to avoid deleting it uninitialized Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 044/104] disabling oplocks/leases via module parm enable_oplocks broken for SMB3 Luis Henriques
                   ` (65 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Max Filippov, Mark Brown, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Max Filippov <jcmvbkbc@gmail.com>

commit b0b4855099e301c8603ea37da9a0103a96c2e0b1 upstream.

XTFPGA SPI controller has native endian registers.
Fix register acessors so that they work in big-endian configurations.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/spi/spi-xtensa-xtfpga.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-xtensa-xtfpga.c b/drivers/spi/spi-xtensa-xtfpga.c
index 41e158187f9d..d35dbd3cdac5 100644
--- a/drivers/spi/spi-xtensa-xtfpga.c
+++ b/drivers/spi/spi-xtensa-xtfpga.c
@@ -34,13 +34,13 @@ struct xtfpga_spi {
 static inline void xtfpga_spi_write32(const struct xtfpga_spi *spi,
 				      unsigned addr, u32 val)
 {
-	iowrite32(val, spi->regs + addr);
+	__raw_writel(val, spi->regs + addr);
 }
 
 static inline unsigned int xtfpga_spi_read32(const struct xtfpga_spi *spi,
 					     unsigned addr)
 {
-	return ioread32(spi->regs + addr);
+	return __raw_readl(spi->regs + addr);
 }
 
 static inline void xtfpga_spi_wait_busy(struct xtfpga_spi *xspi)

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 044/104] disabling oplocks/leases via module parm enable_oplocks broken for SMB3
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (42 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 043/104] spi: xtensa-xtfpga: fix register endianness Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 045/104] cifs: use server timestamp for ntlmv2 authentication Luis Henriques
                   ` (64 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Steve French, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Steve French <smfrench@gmail.com>

commit e0ddde9d44e37fbc21ce893553094ecf1a633ab5 upstream.

leases (oplocks) were always requested for SMB2/SMB3 even when oplocks
disabled in the cifs.ko module.

Signed-off-by: Steve French <steve.french@primarydata.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 fs/cifs/smb2ops.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 772ee0ecf32a..b241a2a7683b 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -49,9 +49,13 @@ change_conf(struct TCP_Server_Info *server)
 		break;
 	default:
 		server->echoes = true;
-		server->oplocks = true;
+		if (enable_oplocks) {
+			server->oplocks = true;
+			server->oplock_credits = 1;
+		} else
+			server->oplocks = false;
+
 		server->echo_credits = 1;
-		server->oplock_credits = 1;
 	}
 	server->credits -= server->echo_credits + server->oplock_credits;
 	return 0;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 045/104] cifs: use server timestamp for ntlmv2 authentication
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (43 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 044/104] disabling oplocks/leases via module parm enable_oplocks broken for SMB3 Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 046/104] x86/paravirt: Replace the paravirt nop with a bona fide empty function Luis Henriques
                   ` (63 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Peter Seiderer, Steve French, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Peter Seiderer <ps.report@gmx.net>

commit 98ce94c8df762d413b3ecb849e2b966b21606d04 upstream.

Linux cifs mount with ntlmssp against an Mac OS X (Yosemite
10.10.5) share fails in case the clocks differ more than +/-2h:

digest-service: digest-request: od failed with 2 proto=ntlmv2
digest-service: digest-request: kdc failed with -1561745592 proto=ntlmv2

Fix this by (re-)using the given server timestamp for the
ntlmv2 authentication (as Windows 7 does).

A related problem was also reported earlier by Namjae Jaen (see below):

Windows machine has extended security feature which refuse to allow
authentication when there is time difference between server time and
client time when ntlmv2 negotiation is used. This problem is prevalent
in embedded enviornment where system time is set to default 1970.

Modern servers send the server timestamp in the TargetInfo Av_Pair
structure in the challenge message [see MS-NLMP 2.2.2.1]
In [MS-NLMP 3.1.5.1.2] it is explicitly mentioned that the client must
use the server provided timestamp if present OR current time if it is
not

Reported-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 fs/cifs/cifsencrypt.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 4934347321d3..3299778391fd 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -441,6 +441,48 @@ find_domain_name(struct cifs_ses *ses, const struct nls_table *nls_cp)
 	return 0;
 }
 
+/* Server has provided av pairs/target info in the type 2 challenge
+ * packet and we have plucked it and stored within smb session.
+ * We parse that blob here to find the server given timestamp
+ * as part of ntlmv2 authentication (or local current time as
+ * default in case of failure)
+ */
+static __le64
+find_timestamp(struct cifs_ses *ses)
+{
+	unsigned int attrsize;
+	unsigned int type;
+	unsigned int onesize = sizeof(struct ntlmssp2_name);
+	unsigned char *blobptr;
+	unsigned char *blobend;
+	struct ntlmssp2_name *attrptr;
+
+	if (!ses->auth_key.len || !ses->auth_key.response)
+		return 0;
+
+	blobptr = ses->auth_key.response;
+	blobend = blobptr + ses->auth_key.len;
+
+	while (blobptr + onesize < blobend) {
+		attrptr = (struct ntlmssp2_name *) blobptr;
+		type = le16_to_cpu(attrptr->type);
+		if (type == NTLMSSP_AV_EOL)
+			break;
+		blobptr += 2; /* advance attr type */
+		attrsize = le16_to_cpu(attrptr->length);
+		blobptr += 2; /* advance attr size */
+		if (blobptr + attrsize > blobend)
+			break;
+		if (type == NTLMSSP_AV_TIMESTAMP) {
+			if (attrsize == sizeof(u64))
+				return *((__le64 *)blobptr);
+		}
+		blobptr += attrsize; /* advance attr value */
+	}
+
+	return cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
+}
+
 static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
 			    const struct nls_table *nls_cp)
 {
@@ -637,6 +679,7 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
 	struct ntlmv2_resp *ntlmv2;
 	char ntlmv2_hash[16];
 	unsigned char *tiblob = NULL; /* target info blob */
+	__le64 rsp_timestamp;
 
 	if (ses->server->negflavor == CIFS_NEGFLAVOR_EXTENDED) {
 		if (!ses->domainName) {
@@ -655,6 +698,12 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
 		}
 	}
 
+	/* Must be within 5 minutes of the server (or in range +/-2h
+	 * in case of Mac OS X), so simply carry over server timestamp
+	 * (as Windows 7 does)
+	 */
+	rsp_timestamp = find_timestamp(ses);
+
 	baselen = CIFS_SESS_KEY_SIZE + sizeof(struct ntlmv2_resp);
 	tilen = ses->auth_key.len;
 	tiblob = ses->auth_key.response;
@@ -671,8 +720,8 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
 			(ses->auth_key.response + CIFS_SESS_KEY_SIZE);
 	ntlmv2->blob_signature = cpu_to_le32(0x00000101);
 	ntlmv2->reserved = 0;
-	/* Must be within 5 minutes of the server */
-	ntlmv2->time = cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
+	ntlmv2->time = rsp_timestamp;
+
 	get_random_bytes(&ntlmv2->client_chal, sizeof(ntlmv2->client_chal));
 	ntlmv2->reserved2 = 0;
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 046/104] x86/paravirt: Replace the paravirt nop with a bona fide empty function
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (44 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 045/104] cifs: use server timestamp for ntlmv2 authentication Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 047/104] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code Luis Henriques
                   ` (62 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Andy Lutomirski, Thomas Gleixner, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Andy Lutomirski <luto@kernel.org>

commit fc57a7c68020dcf954428869eafd934c0ab1536f upstream.

PARAVIRT_ADJUST_EXCEPTION_FRAME generates this code (using nmi as an
example, trimmed for readability):

    ff 15 00 00 00 00       callq  *0x0(%rip)        # 2796 <nmi+0x6>
              2792: R_X86_64_PC32     pv_irq_ops+0x2c

That's a call through a function pointer to regular C function that
does nothing on native boots, but that function isn't protected
against kprobes, isn't marked notrace, and is certainly not
guaranteed to preserve any registers if the compiler is feeling
perverse.  This is bad news for a CLBR_NONE operation.

Of course, if everything works correctly, once paravirt ops are
patched, it gets nopped out, but what if we hit this code before
paravirt ops are patched in?  This can potentially cause breakage
that is very difficult to debug.

A more subtle failure is possible here, too: if _paravirt_nop uses
the stack at all (even just to push RBP), it will overwrite the "NMI
executing" variable if it's called in the NMI prologue.

The Xen case, perhaps surprisingly, is fine, because it's already
written in asm.

Fix all of the cases that default to paravirt_nop (including
adjust_exception_frame) with a big hammer: replace paravirt_nop with
an asm function that is just a ret instruction.

The Xen case may have other problems, so document them.

This is part of a fix for some random crashes that Sasha saw.

Reported-and-tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Link: http://lkml.kernel.org/r/8f5d2ba295f9d73751c33d97fda03e0495d9ade0.1442791737.git.luto@kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[ luis: backported to 3.16:
  - file rename: arch/x86/entry/entry_64.S -> arch/x86/kernel/entry_64.S
  - adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/x86/kernel/entry_64.S | 11 +++++++++++
 arch/x86/kernel/paravirt.c | 16 ++++++++++++----
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 79565bd80cc2..47b8deb372f9 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1426,7 +1426,18 @@ END(error_exit)
 /* Runs on exception stack */
 ENTRY(nmi)
 	INTR_FRAME
+	/*
+	 * Fix up the exception frame if we're on Xen.
+	 * PARAVIRT_ADJUST_EXCEPTION_FRAME is guaranteed to push at most
+	 * one value to the stack on native, so it may clobber the rdx
+	 * scratch slot, but it won't clobber any of the important
+	 * slots past it.
+	 *
+	 * Xen is a different story, because the Xen frame itself overlaps
+	 * the "NMI executing" variable.
+	 */
 	PARAVIRT_ADJUST_EXCEPTION_FRAME
+
 	/*
 	 * We allow breakpoints in NMIs. If a breakpoint occurs, then
 	 * the iretq it performs will take us out of NMI context.
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index 548d25f00c90..8d12f0546dfc 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -41,10 +41,18 @@
 #include <asm/timer.h>
 #include <asm/special_insns.h>
 
-/* nop stub */
-void _paravirt_nop(void)
-{
-}
+/*
+ * nop stub, which must not clobber anything *including the stack* to
+ * avoid confusing the entry prologues.
+ */
+extern void _paravirt_nop(void);
+asm (".pushsection .entry.text, \"ax\"\n"
+     ".global _paravirt_nop\n"
+     "_paravirt_nop:\n\t"
+     "ret\n\t"
+     ".size _paravirt_nop, . - _paravirt_nop\n\t"
+     ".type _paravirt_nop, @function\n\t"
+     ".popsection");
 
 /* identity function, which can be inlined */
 u32 _paravirt_ident_32(u32 x)

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 047/104] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (45 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 046/104] x86/paravirt: Replace the paravirt nop with a bona fide empty function Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 048/104] ASoC: pxa: pxa2xx-ac97: fix dma requestor lines Luis Henriques
                   ` (61 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Andy Lutomirski, Thomas Gleixner, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Andy Lutomirski <luto@kernel.org>

commit 83c133cf11fb0e68a51681447e372489f052d40e upstream.

The NMI entry code that switches to the normal kernel stack needs to
be very careful not to clobber any extra stack slots on the NMI
stack.  The code is fine under the assumption that SWAPGS is just a
normal instruction, but that assumption isn't really true.  Use
SWAPGS_UNSAFE_STACK instead.

This is part of a fix for some random crashes that Sasha saw.

Fixes: 9b6e6a8334d5 ("x86/nmi/64: Switch stacks on userspace NMI entry")
Reported-and-tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Link: http://lkml.kernel.org/r/974bc40edffdb5c2950a5c4977f821a446b76178.1442791737.git.luto@kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[ luis: backported to 3.16:
  - file rename: arch/x86/entry/entry_64.S -> arch/x86/kernel/entry_64.S
  - adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/x86/kernel/entry_64.S | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 47b8deb372f9..701db48562b1 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1489,9 +1489,12 @@ ENTRY(nmi)
 	 * we don't want to enable interrupts, because then we'll end
 	 * up in an awkward situation in which IRQs are on but NMIs
 	 * are off.
+	 *
+	 * We also must not push anything to the stack before switching
+	 * stacks lest we corrupt the "NMI executing" variable.
 	 */
 
-	SWAPGS
+	SWAPGS_UNSAFE_STACK
 	cld
 	movq	%rsp, %rdx
 	movq	PER_CPU_VAR(kernel_stack), %rsp

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 048/104] ASoC: pxa: pxa2xx-ac97: fix dma requestor lines
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (46 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 047/104] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 049/104] ocfs2/dlm: fix deadlock when dispatch assert master Luis Henriques
                   ` (60 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Robert Jarzmik, Mark Brown, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Robert Jarzmik <robert.jarzmik@free.fr>

commit 8811191fdf7ed02ee07cb8469428158572d355a2 upstream.

PCM receive and transmit DMA requestor lines were reverted, breaking the
PCM playback interface for PXA platforms using the sound/soc/ variant
instead of the sound/arm variant.

The commit below shows the inversion in the requestor lines.

Fixes: d65a14587a9b ("ASoC: pxa: use snd_dmaengine_dai_dma_data")
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 sound/soc/pxa/pxa2xx-ac97.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index ae956e3f4b9d..593e3202fc35 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -49,7 +49,7 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
 	.reset	= pxa2xx_ac97_cold_reset,
 };
 
-static unsigned long pxa2xx_ac97_pcm_stereo_in_req = 12;
+static unsigned long pxa2xx_ac97_pcm_stereo_in_req = 11;
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_in = {
 	.addr		= __PREG(PCDR),
 	.addr_width	= DMA_SLAVE_BUSWIDTH_4_BYTES,
@@ -57,7 +57,7 @@ static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_in = {
 	.filter_data	= &pxa2xx_ac97_pcm_stereo_in_req,
 };
 
-static unsigned long pxa2xx_ac97_pcm_stereo_out_req = 11;
+static unsigned long pxa2xx_ac97_pcm_stereo_out_req = 12;
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_out = {
 	.addr		= __PREG(PCDR),
 	.addr_width	= DMA_SLAVE_BUSWIDTH_4_BYTES,

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 049/104] ocfs2/dlm: fix deadlock when dispatch assert master
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (47 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 048/104] ASoC: pxa: pxa2xx-ac97: fix dma requestor lines Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 050/104] drm/i915/bios: handle MIPI Sequence Block v3+ gracefully Luis Henriques
                   ` (59 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Joseph Qi, Joel Becker, Mark Fasheh, Junxiao Bi, Andrew Morton,
	Linus Torvalds, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Joseph Qi <joseph.qi@huawei.com>

commit 012572d4fc2e4ddd5c8ec8614d51414ec6cae02a upstream.

The order of the following three spinlocks should be:
dlm_domain_lock < dlm_ctxt->spinlock < dlm_lock_resource->spinlock

But dlm_dispatch_assert_master() is called while holding
dlm_ctxt->spinlock and dlm_lock_resource->spinlock, and then it calls
dlm_grab() which will take dlm_domain_lock.

Once another thread (for example, dlm_query_join_handler) has already
taken dlm_domain_lock, and tries to take dlm_ctxt->spinlock deadlock
happens.

Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: "Junxiao Bi" <junxiao.bi@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 fs/ocfs2/dlm/dlmmaster.c   | 9 ++++++---
 fs/ocfs2/dlm/dlmrecovery.c | 8 ++++++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 7b9f96899812..189e7e1b7144 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -1450,6 +1450,7 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data,
 	int found, ret;
 	int set_maybe;
 	int dispatch_assert = 0;
+	int dispatched = 0;
 
 	if (!dlm_grab(dlm))
 		return DLM_MASTER_RESP_NO;
@@ -1656,14 +1657,17 @@ send_response:
 			mlog(ML_ERROR, "failed to dispatch assert master work\n");
 			response = DLM_MASTER_RESP_ERROR;
 			dlm_lockres_put(res);
-		} else
+		} else {
+			dispatched = 1;
 			dlm_lockres_grab_inflight_worker(dlm, res);
+		}
 	} else {
 		if (res)
 			dlm_lockres_put(res);
 	}
 
-	dlm_put(dlm);
+	if (!dispatched)
+		dlm_put(dlm);
 	return response;
 }
 
@@ -2083,7 +2087,6 @@ int dlm_dispatch_assert_master(struct dlm_ctxt *dlm,
 
 
 	/* queue up work for dlm_assert_master_worker */
-	dlm_grab(dlm);  /* get an extra ref for the work item */
 	dlm_init_work_item(dlm, item, dlm_assert_master_worker, NULL);
 	item->u.am.lockres = res; /* already have a ref */
 	/* can optionally ignore node numbers higher than this node */
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 45067faf5695..5084ce856879 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -1687,6 +1687,7 @@ int dlm_master_requery_handler(struct o2net_msg *msg, u32 len, void *data,
 	unsigned int hash;
 	int master = DLM_LOCK_RES_OWNER_UNKNOWN;
 	u32 flags = DLM_ASSERT_MASTER_REQUERY;
+	int dispatched = 0;
 
 	if (!dlm_grab(dlm)) {
 		/* since the domain has gone away on this
@@ -1708,15 +1709,18 @@ int dlm_master_requery_handler(struct o2net_msg *msg, u32 len, void *data,
 				mlog_errno(-ENOMEM);
 				/* retry!? */
 				BUG();
-			} else
+			} else {
+				dispatched = 1;
 				__dlm_lockres_grab_inflight_worker(dlm, res);
+			}
 		} else /* put.. incase we are not the master */
 			dlm_lockres_put(res);
 		spin_unlock(&res->spinlock);
 	}
 	spin_unlock(&dlm->spinlock);
 
-	dlm_put(dlm);
+	if (!dispatched)
+		dlm_put(dlm);
 	return master;
 }
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 050/104] drm/i915/bios: handle MIPI Sequence Block v3+ gracefully
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (48 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 049/104] ocfs2/dlm: fix deadlock when dispatch assert master Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 051/104] USB: whiteheat: fix potential null-deref at probe Luis Henriques
                   ` (58 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Deepak M, Jani Nikula, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jani Nikula <jani.nikula@intel.com>

commit cd67d226ebd909d239d2c6e5a6abd6e2a338d1cd upstream.

The VBT MIPI Sequence Block version 3 has forward incompatible changes:

First, the block size in the header has been specified reserved, and the
actual size is a separate 32-bit value within the block. The current
find_section() function to will only look at the size in the block
header, and, depending on what's in that now reserved size field,
continue looking for other sections in the wrong place.

Fix this by taking the new block size field into account. This will
ensure that the lookups for other sections will work properly, as long
as the new 32-bit size does not go beyond the opregion VBT mailbox size.

Second, the contents of the block have been completely
changed. Gracefully refuse parsing the yet unknown data version.

Cc: Deepak M <m.deepak@intel.com>
Reviewed-by: Deepak M <m.deepak@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/gpu/drm/i915/intel_bios.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 2e0a2feb4cda..07d72573fc60 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -41,7 +41,7 @@ find_section(struct bdb_header *bdb, int section_id)
 {
 	u8 *base = (u8 *)bdb;
 	int index = 0;
-	u16 total, current_size;
+	u32 total, current_size;
 	u8 current_id;
 
 	/* skip to first section */
@@ -56,6 +56,10 @@ find_section(struct bdb_header *bdb, int section_id)
 		current_size = *((u16 *)(base + index));
 		index += 2;
 
+		/* The MIPI Sequence Block v3+ has a separate size field. */
+		if (current_id == BDB_MIPI_SEQUENCE && *(base + index) >= 3)
+			current_size = *((const u32 *)(base + index + 1));
+
 		if (index + current_size > total)
 			return NULL;
 
@@ -793,6 +797,12 @@ parse_mipi(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 		return;
 	}
 
+	/* Fail gracefully for forward incompatible sequence block. */
+	if (sequence->version >= 3) {
+		DRM_ERROR("Unable to parse MIPI Sequence Block v3+\n");
+		return;
+	}
+
 	DRM_DEBUG_DRIVER("Found MIPI sequence block\n");
 
 	block_size = get_blocksize(sequence);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 051/104] USB: whiteheat: fix potential null-deref at probe
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (49 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 050/104] drm/i915/bios: handle MIPI Sequence Block v3+ gracefully Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 052/104] drm/qxl: only report first monitor as connected if we have no state Luis Henriques
                   ` (57 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Johan Hovold, Greg Kroah-Hartman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit cbb4be652d374f64661137756b8f357a1827d6a4 upstream.

Fix potential null-pointer dereference at probe by making sure that the
required endpoints are present.

The whiteheat driver assumes there are at least five pairs of bulk
endpoints, of which the final pair is used for the "command port". An
attempt to bind to an interface with fewer bulk endpoints would
currently lead to an oops.

Fixes CVE-2015-5257.

Reported-by: Moein Ghasemzadeh <moein@istuary.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/usb/serial/whiteheat.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 6c3734d2b45a..d3ea90bef84d 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -80,6 +80,8 @@ static int  whiteheat_firmware_download(struct usb_serial *serial,
 static int  whiteheat_firmware_attach(struct usb_serial *serial);
 
 /* function prototypes for the Connect Tech WhiteHEAT serial converter */
+static int whiteheat_probe(struct usb_serial *serial,
+				const struct usb_device_id *id);
 static int  whiteheat_attach(struct usb_serial *serial);
 static void whiteheat_release(struct usb_serial *serial);
 static int  whiteheat_port_probe(struct usb_serial_port *port);
@@ -116,6 +118,7 @@ static struct usb_serial_driver whiteheat_device = {
 	.description =		"Connect Tech - WhiteHEAT",
 	.id_table =		id_table_std,
 	.num_ports =		4,
+	.probe =		whiteheat_probe,
 	.attach =		whiteheat_attach,
 	.release =		whiteheat_release,
 	.port_probe =		whiteheat_port_probe,
@@ -217,6 +220,34 @@ static int whiteheat_firmware_attach(struct usb_serial *serial)
 /*****************************************************************************
  * Connect Tech's White Heat serial driver functions
  *****************************************************************************/
+
+static int whiteheat_probe(struct usb_serial *serial,
+				const struct usb_device_id *id)
+{
+	struct usb_host_interface *iface_desc;
+	struct usb_endpoint_descriptor *endpoint;
+	size_t num_bulk_in = 0;
+	size_t num_bulk_out = 0;
+	size_t min_num_bulk;
+	unsigned int i;
+
+	iface_desc = serial->interface->cur_altsetting;
+
+	for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
+		endpoint = &iface_desc->endpoint[i].desc;
+		if (usb_endpoint_is_bulk_in(endpoint))
+			++num_bulk_in;
+		if (usb_endpoint_is_bulk_out(endpoint))
+			++num_bulk_out;
+	}
+
+	min_num_bulk = COMMAND_PORT + 1;
+	if (num_bulk_in < min_num_bulk || num_bulk_out < min_num_bulk)
+		return -ENODEV;
+
+	return 0;
+}
+
 static int whiteheat_attach(struct usb_serial *serial)
 {
 	struct usb_serial_port *command_port;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 052/104] drm/qxl: only report first monitor as connected if we have no state
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (50 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 051/104] USB: whiteheat: fix potential null-deref at probe Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 053/104] PCI: Fix devfn for VPD access through function 0 Luis Henriques
                   ` (56 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Dave Airlie, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dave Airlie <airlied@redhat.com>

commit 69e5d3f893e19613486f300fd6e631810338aa4b upstream.

If the server isn't new enough to give us state, report the first
monitor as always connected, otherwise believe the server side.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/gpu/drm/qxl/qxl_display.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index db72b4c17987..6071a9943ed9 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -820,13 +820,15 @@ static enum drm_connector_status qxl_conn_detect(
 		drm_connector_to_qxl_output(connector);
 	struct drm_device *ddev = connector->dev;
 	struct qxl_device *qdev = ddev->dev_private;
-	int connected;
+	bool connected = false;
 
 	/* The first monitor is always connected */
-	connected = (output->index == 0) ||
-		    (qdev->client_monitors_config &&
-		     qdev->client_monitors_config->count > output->index &&
-		     qxl_head_enabled(&qdev->client_monitors_config->heads[output->index]));
+	if (!qdev->client_monitors_config) {
+		if (output->index == 0)
+			connected = true;
+	} else
+		connected = qdev->client_monitors_config->count > output->index &&
+		     qxl_head_enabled(&qdev->client_monitors_config->heads[output->index]);
 
 	DRM_DEBUG("#%d connected: %d\n", output->index, connected);
 	if (!connected)

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 053/104] PCI: Fix devfn for VPD access through function 0
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (51 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 052/104] drm/qxl: only report first monitor as connected if we have no state Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 054/104] PCI: Use function 0 VPD for identical functions, regular VPD for others Luis Henriques
                   ` (55 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Alex Williamson, Bjorn Helgaas, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alex Williamson <alex.williamson@redhat.com>

commit 9d9240756e63dd87d6cbf5da8b98ceb8f8192b55 upstream.

Commit 932c435caba8 ("PCI: Add dev_flags bit to access VPD through function
0") passes PCI_SLOT(devfn) for the devfn parameter of pci_get_slot().
Generally this works because we're fairly well guaranteed that a PCIe
device is at slot address 0, but for the general case, including
conventional PCI, it's incorrect.  We need to get the slot and then convert
it back into a devfn.

Fixes: 932c435caba8 ("PCI: Add dev_flags bit to access VPD through function 0")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <helgaas@kernel.org>
Acked-by: Myron Stowe <myron.stowe@redhat.com>
Acked-by: Mark Rustad <mark.d.rustad@intel.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/pci/access.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index cf4733b05db2..2fbf74eda817 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -355,7 +355,8 @@ static const struct pci_vpd_ops pci_vpd_pci22_ops = {
 static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count,
 			       void *arg)
 {
-	struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
+	struct pci_dev *tdev = pci_get_slot(dev->bus,
+					    PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
 	ssize_t ret;
 
 	if (!tdev)
@@ -369,7 +370,8 @@ static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count,
 static ssize_t pci_vpd_f0_write(struct pci_dev *dev, loff_t pos, size_t count,
 				const void *arg)
 {
-	struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
+	struct pci_dev *tdev = pci_get_slot(dev->bus,
+					    PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
 	ssize_t ret;
 
 	if (!tdev)
@@ -388,7 +390,8 @@ static const struct pci_vpd_ops pci_vpd_f0_ops = {
 
 static int pci_vpd_f0_dev_check(struct pci_dev *dev)
 {
-	struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
+	struct pci_dev *tdev = pci_get_slot(dev->bus,
+					    PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
 	int ret = 0;
 
 	if (!tdev)

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 054/104] PCI: Use function 0 VPD for identical functions, regular VPD for others
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (52 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 053/104] PCI: Fix devfn for VPD access through function 0 Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 055/104] netfilter: nft_compat: skip family comparison in case of NFPROTO_UNSPEC Luis Henriques
                   ` (54 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Alex Williamson, Bjorn Helgaas, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alex Williamson <alex.williamson@redhat.com>

commit da2d03ea27f6ed9d2005a67b20dd021ddacf1e4d upstream.

932c435caba8 ("PCI: Add dev_flags bit to access VPD through function 0")
added PCI_DEV_FLAGS_VPD_REF_F0.  Previously, we set the flag on every
non-zero function of quirked devices.  If a function turned out to be
different from function 0, i.e., it had a different class, vendor ID, or
device ID, the flag remained set but we didn't make VPD accessible at all.

Flip this around so we only set PCI_DEV_FLAGS_VPD_REF_F0 for functions that
are identical to function 0, and allow regular VPD access for any other
functions.

[bhelgaas: changelog, stable tag]
Fixes: 932c435caba8 ("PCI: Add dev_flags bit to access VPD through function 0")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <helgaas@kernel.org>
Acked-by: Myron Stowe <myron.stowe@redhat.com>
Acked-by: Mark Rustad <mark.d.rustad@intel.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/pci/access.c | 22 ----------------------
 drivers/pci/quirks.c | 20 ++++++++++++++++++--
 2 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 2fbf74eda817..c1373b8d4989 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -388,23 +388,6 @@ static const struct pci_vpd_ops pci_vpd_f0_ops = {
 	.release = pci_vpd_pci22_release,
 };
 
-static int pci_vpd_f0_dev_check(struct pci_dev *dev)
-{
-	struct pci_dev *tdev = pci_get_slot(dev->bus,
-					    PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
-	int ret = 0;
-
-	if (!tdev)
-		return -ENODEV;
-	if (!tdev->vpd || !tdev->multifunction ||
-	    dev->class != tdev->class || dev->vendor != tdev->vendor ||
-	    dev->device != tdev->device)
-		ret = -ENODEV;
-
-	pci_dev_put(tdev);
-	return ret;
-}
-
 int pci_vpd_pci22_init(struct pci_dev *dev)
 {
 	struct pci_vpd_pci22 *vpd;
@@ -413,12 +396,7 @@ int pci_vpd_pci22_init(struct pci_dev *dev)
 	cap = pci_find_capability(dev, PCI_CAP_ID_VPD);
 	if (!cap)
 		return -ENODEV;
-	if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) {
-		int ret = pci_vpd_f0_dev_check(dev);
 
-		if (ret)
-			return ret;
-	}
 	vpd = kzalloc(sizeof(*vpd), GFP_ATOMIC);
 	if (!vpd)
 		return -ENOMEM;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 61c0b5807986..1f5ea2403d94 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1883,11 +1883,27 @@ static void quirk_netmos(struct pci_dev *dev)
 DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_NETMOS, PCI_ANY_ID,
 			 PCI_CLASS_COMMUNICATION_SERIAL, 8, quirk_netmos);
 
+/*
+ * Quirk non-zero PCI functions to route VPD access through function 0 for
+ * devices that share VPD resources between functions.  The functions are
+ * expected to be identical devices.
+ */
 static void quirk_f0_vpd_link(struct pci_dev *dev)
 {
-	if (!dev->multifunction || !PCI_FUNC(dev->devfn))
+	struct pci_dev *f0;
+
+	if (!PCI_FUNC(dev->devfn))
 		return;
-	dev->dev_flags |= PCI_DEV_FLAGS_VPD_REF_F0;
+
+	f0 = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
+	if (!f0)
+		return;
+
+	if (f0->vpd && dev->class == f0->class &&
+	    dev->vendor == f0->vendor && dev->device == f0->device)
+		dev->dev_flags |= PCI_DEV_FLAGS_VPD_REF_F0;
+
+	pci_dev_put(f0);
 }
 DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
 			      PCI_CLASS_NETWORK_ETHERNET, 8, quirk_f0_vpd_link);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 055/104] netfilter: nft_compat: skip family comparison in case of NFPROTO_UNSPEC
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (53 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 054/104] PCI: Use function 0 VPD for identical functions, regular VPD for others Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 056/104] ASoC: fix broken pxa SoC support Luis Henriques
                   ` (53 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Pablo Neira Ayuso, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Pablo Neira Ayuso <pablo@netfilter.org>

commit ba378ca9c04a5fc1b2cf0f0274a9d02eb3d1bad9 upstream.

Fix lookup of existing match/target structures in the corresponding list
by skipping the family check if NFPROTO_UNSPEC is used.

This is resulting in the allocation and insertion of one match/target
structure for each use of them. So this not only bloats memory
consumption but also severely affects the time to reload the ruleset
from the iptables-compat utility.

After this patch, iptables-compat-restore and iptables-compat take
almost the same time to reload large rulesets.

Fixes: 0ca743a55991 ("netfilter: nf_tables: add compatibility layer for x_tables")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 net/netfilter/nft_compat.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 4b8de88bb49d..62097fda49dc 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -612,6 +612,13 @@ struct nft_xt {
 
 static struct nft_expr_type nft_match_type;
 
+static bool nft_match_cmp(const struct xt_match *match,
+			  const char *name, u32 rev, u32 family)
+{
+	return strcmp(match->name, name) == 0 && match->revision == rev &&
+	       (match->family == NFPROTO_UNSPEC || match->family == family);
+}
+
 static const struct nft_expr_ops *
 nft_match_select_ops(const struct nft_ctx *ctx,
 		     const struct nlattr * const tb[])
@@ -619,7 +626,7 @@ nft_match_select_ops(const struct nft_ctx *ctx,
 	struct nft_xt *nft_match;
 	struct xt_match *match;
 	char *mt_name;
-	__u32 rev, family;
+	u32 rev, family;
 
 	if (tb[NFTA_MATCH_NAME] == NULL ||
 	    tb[NFTA_MATCH_REV] == NULL ||
@@ -634,8 +641,7 @@ nft_match_select_ops(const struct nft_ctx *ctx,
 	list_for_each_entry(nft_match, &nft_match_list, head) {
 		struct xt_match *match = nft_match->ops.data;
 
-		if (strcmp(match->name, mt_name) == 0 &&
-		    match->revision == rev && match->family == family) {
+		if (nft_match_cmp(match, mt_name, rev, family)) {
 			if (!try_module_get(match->me))
 				return ERR_PTR(-ENOENT);
 
@@ -687,6 +693,13 @@ static LIST_HEAD(nft_target_list);
 
 static struct nft_expr_type nft_target_type;
 
+static bool nft_target_cmp(const struct xt_target *tg,
+			   const char *name, u32 rev, u32 family)
+{
+	return strcmp(tg->name, name) == 0 && tg->revision == rev &&
+	       (tg->family == NFPROTO_UNSPEC || tg->family == family);
+}
+
 static const struct nft_expr_ops *
 nft_target_select_ops(const struct nft_ctx *ctx,
 		      const struct nlattr * const tb[])
@@ -694,7 +707,7 @@ nft_target_select_ops(const struct nft_ctx *ctx,
 	struct nft_xt *nft_target;
 	struct xt_target *target;
 	char *tg_name;
-	__u32 rev, family;
+	u32 rev, family;
 
 	if (tb[NFTA_TARGET_NAME] == NULL ||
 	    tb[NFTA_TARGET_REV] == NULL ||
@@ -709,8 +722,7 @@ nft_target_select_ops(const struct nft_ctx *ctx,
 	list_for_each_entry(nft_target, &nft_target_list, head) {
 		struct xt_target *target = nft_target->ops.data;
 
-		if (strcmp(target->name, tg_name) == 0 &&
-		    target->revision == rev && target->family == family) {
+		if (nft_target_cmp(target, tg_name, rev, family)) {
 			if (!try_module_get(target->me))
 				return ERR_PTR(-ENOENT);
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 056/104] ASoC: fix broken pxa SoC support
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (54 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 055/104] netfilter: nft_compat: skip family comparison in case of NFPROTO_UNSPEC Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 057/104] ARM: dts: omap5-uevm.dts: fix i2c5 pinctrl offsets Luis Henriques
                   ` (52 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Robert Jarzmik, Mark Brown, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Robert Jarzmik <robert.jarzmik@free.fr>

commit 3c8f7710c1c44fb650bc29b6ef78ed8b60cfaa28 upstream.

The previous fix of pxa library support, which was introduced to fix the
library dependency, broke the previous SoC behavior, where a machine
code binding pxa2xx-ac97 with a coded relied on :
 - sound/soc/pxa/pxa2xx-ac97.c
 - sound/soc/codecs/XXX.c

For example, the mioa701_wm9713.c machine code is currently broken. The
"select ARM" statement wrongly selects the soc/arm/pxa2xx-ac97 for
compilation, as per an unfortunate fate SND_PXA2XX_AC97 is both declared
in sound/arm/Kconfig and sound/soc/pxa/Kconfig.

Fix this by ensuring that SND_PXA2XX_SOC correctly triggers the correct
pxa2xx-ac97 compilation.

Fixes: 846172dfe33c ("ASoC: fix SND_PXA2XX_LIB Kconfig warning")
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 sound/arm/Kconfig     | 15 ++++++++-------
 sound/soc/pxa/Kconfig |  2 --
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/sound/arm/Kconfig b/sound/arm/Kconfig
index 885683a3b0bd..e0406211716b 100644
--- a/sound/arm/Kconfig
+++ b/sound/arm/Kconfig
@@ -9,6 +9,14 @@ menuconfig SND_ARM
 	  Drivers that are implemented on ASoC can be found in
 	  "ALSA for SoC audio support" section.
 
+config SND_PXA2XX_LIB
+	tristate
+	select SND_AC97_CODEC if SND_PXA2XX_LIB_AC97
+	select SND_DMAENGINE_PCM
+
+config SND_PXA2XX_LIB_AC97
+	bool
+
 if SND_ARM
 
 config SND_ARMAACI
@@ -21,13 +29,6 @@ config SND_PXA2XX_PCM
 	tristate
 	select SND_PCM
 
-config SND_PXA2XX_LIB
-	tristate
-	select SND_AC97_CODEC if SND_PXA2XX_LIB_AC97
-
-config SND_PXA2XX_LIB_AC97
-	bool
-
 config SND_PXA2XX_AC97
 	tristate "AC97 driver for the Intel PXA2xx chip"
 	depends on ARCH_PXA
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index 2434b6d61675..e1f501b46c9d 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -1,7 +1,6 @@
 config SND_PXA2XX_SOC
 	tristate "SoC Audio for the Intel PXA2xx chip"
 	depends on ARCH_PXA
-	select SND_ARM
 	select SND_PXA2XX_LIB
 	help
 	  Say Y or M if you want to add support for codecs attached to
@@ -25,7 +24,6 @@ config SND_PXA2XX_AC97
 config SND_PXA2XX_SOC_AC97
 	tristate
 	select AC97_BUS
-	select SND_ARM
 	select SND_PXA2XX_LIB_AC97
 	select SND_SOC_AC97_BUS
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 057/104] ARM: dts: omap5-uevm.dts: fix i2c5 pinctrl offsets
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (55 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 056/104] ASoC: fix broken pxa SoC support Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 058/104] vxlan: set needed headroom correctly Luis Henriques
                   ` (51 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Grazvydas Ignotas, Tony Lindgren, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Grazvydas Ignotas <notasas@gmail.com>

commit 1dbdad75074d16c3e3005180f81a01cdc04a7872 upstream.

The i2c5 pinctrl offsets are wrong. If the bootloader doesn't set the
pins up, communication with tca6424a doesn't work (controller timeouts)
and it is not possible to enable HDMI.

Fixes: 9be495c42609 ("ARM: dts: omap5-evm: Add I2c pinctrl data")
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/arm/boot/dts/omap5-uevm.dts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/omap5-uevm.dts b/arch/arm/boot/dts/omap5-uevm.dts
index 1e1b05768cec..c0d460649089 100644
--- a/arch/arm/boot/dts/omap5-uevm.dts
+++ b/arch/arm/boot/dts/omap5-uevm.dts
@@ -156,8 +156,8 @@
 
 	i2c5_pins: pinmux_i2c5_pins {
 		pinctrl-single,pins = <
-			0x184 (PIN_INPUT | MUX_MODE0)		/* i2c5_scl */
-			0x186 (PIN_INPUT | MUX_MODE0)		/* i2c5_sda */
+			0x186 (PIN_INPUT | MUX_MODE0)		/* i2c5_scl */
+			0x188 (PIN_INPUT | MUX_MODE0)		/* i2c5_sda */
 		>;
 	};
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 058/104] vxlan: set needed headroom correctly
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (56 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 057/104] ARM: dts: omap5-uevm.dts: fix i2c5 pinctrl offsets Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 059/104] Revert "ARM: orion5x: fix legacy orion5x IRQ numbers" Luis Henriques
                   ` (50 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Cong Wang, Jiri Benc, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jiri Benc <jbenc@redhat.com>

commit 9dc2ad1008c9f91f55ec6c89ec0f8639dfc91596 upstream.

vxlan_setup is called when allocating the net_device, i.e. way before
vxlan_newlink (or vxlan_dev_configure) is called. This means
vxlan->default_dst is actually unset in vxlan_setup and the condition that
sets needed_headroom always takes the else branch.

Set the needed_headrom at the point when we have the information about
the address family available.

Fixes: e4c7ed415387c ("vxlan: add ipv6 support")
Fixes: 2853af6a2ea1a ("vxlan: use dev->needed_headroom instead of dev->hard_header_len")
CC: Cong Wang <cwang@twopensource.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[ luis: backported to 3.16:
  - initialise needed_headrom in vxlan_newlink() instead of
    vxlan_dev_configure() ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/net/vxlan.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 40bf8a87b3d9..8a7a35c4f6bd 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2251,10 +2251,6 @@ static void vxlan_setup(struct net_device *dev)
 
 	eth_hw_addr_random(dev);
 	ether_setup(dev);
-	if (vxlan->default_dst.remote_ip.sa.sa_family == AF_INET6)
-		dev->needed_headroom = ETH_HLEN + VXLAN6_HEADROOM;
-	else
-		dev->needed_headroom = ETH_HLEN + VXLAN_HEADROOM;
 
 	dev->netdev_ops = &vxlan_netdev_ops;
 	dev->destructor = free_netdev;
@@ -2651,8 +2647,12 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
 
 		dev->needed_headroom = lowerdev->hard_header_len +
 				       (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM);
-	} else if (use_ipv6)
+	} else if (use_ipv6) {
 		vxlan->flags |= VXLAN_F_IPV6;
+		dev->needed_headroom = ETH_HLEN + VXLAN6_HEADROOM;
+	} else {
+		dev->needed_headroom = ETH_HLEN + VXLAN_HEADROOM;
+	}
 
 	if (data[IFLA_VXLAN_TOS])
 		vxlan->tos  = nla_get_u8(data[IFLA_VXLAN_TOS]);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 059/104] Revert "ARM: orion5x: fix legacy orion5x IRQ numbers"
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (57 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 058/104] vxlan: set needed headroom correctly Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 060/104] jbd2: avoid infinite loop when destroying aborted journal Luis Henriques
                   ` (49 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Ben Hutchings, Gregory CLEMENT, Benjamin Cama, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Luis Henriques <luis.henriques@canonical.com>

This reverts commit b5614b199b9990b015ae0973db5adf53e7be1651,
which was commit 5be9fc23cdb42e1d383ecc8eae8a8ff70a752708 upstream.

Ben Hutchings pointed out this was not applicable to the 3.16-ckt kernel.

Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: Benjamin Cama <benoar@dolka.fr>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/arm/Kconfig                          |  1 -
 arch/arm/mach-orion5x/include/mach/irqs.h | 64 +++++++++++++++----------------
 arch/arm/mach-orion5x/irq.c               |  4 +-
 3 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f32418a0cd18..290f02ee0157 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -565,7 +565,6 @@ config ARCH_ORION5X
 	select MVEBU_MBUS
 	select PCI
 	select PLAT_ORION_LEGACY
-	select MULTI_IRQ_HANDLER
 	help
 	  Support for the following Marvell Orion 5x series SoCs:
 	  Orion-1 (5181), Orion-VoIP (5181L), Orion-NAS (5182),
diff --git a/arch/arm/mach-orion5x/include/mach/irqs.h b/arch/arm/mach-orion5x/include/mach/irqs.h
index 2431d9923427..a6fa9d8f12d8 100644
--- a/arch/arm/mach-orion5x/include/mach/irqs.h
+++ b/arch/arm/mach-orion5x/include/mach/irqs.h
@@ -16,42 +16,42 @@
 /*
  * Orion Main Interrupt Controller
  */
-#define IRQ_ORION5X_BRIDGE		(1 + 0)
-#define IRQ_ORION5X_DOORBELL_H2C	(1 + 1)
-#define IRQ_ORION5X_DOORBELL_C2H	(1 + 2)
-#define IRQ_ORION5X_UART0		(1 + 3)
-#define IRQ_ORION5X_UART1		(1 + 4)
-#define IRQ_ORION5X_I2C			(1 + 5)
-#define IRQ_ORION5X_GPIO_0_7		(1 + 6)
-#define IRQ_ORION5X_GPIO_8_15		(1 + 7)
-#define IRQ_ORION5X_GPIO_16_23		(1 + 8)
-#define IRQ_ORION5X_GPIO_24_31		(1 + 9)
-#define IRQ_ORION5X_PCIE0_ERR		(1 + 10)
-#define IRQ_ORION5X_PCIE0_INT		(1 + 11)
-#define IRQ_ORION5X_USB1_CTRL		(1 + 12)
-#define IRQ_ORION5X_DEV_BUS_ERR		(1 + 14)
-#define IRQ_ORION5X_PCI_ERR		(1 + 15)
-#define IRQ_ORION5X_USB_BR_ERR		(1 + 16)
-#define IRQ_ORION5X_USB0_CTRL		(1 + 17)
-#define IRQ_ORION5X_ETH_RX		(1 + 18)
-#define IRQ_ORION5X_ETH_TX		(1 + 19)
-#define IRQ_ORION5X_ETH_MISC		(1 + 20)
-#define IRQ_ORION5X_ETH_SUM		(1 + 21)
-#define IRQ_ORION5X_ETH_ERR		(1 + 22)
-#define IRQ_ORION5X_IDMA_ERR		(1 + 23)
-#define IRQ_ORION5X_IDMA_0		(1 + 24)
-#define IRQ_ORION5X_IDMA_1		(1 + 25)
-#define IRQ_ORION5X_IDMA_2		(1 + 26)
-#define IRQ_ORION5X_IDMA_3		(1 + 27)
-#define IRQ_ORION5X_CESA		(1 + 28)
-#define IRQ_ORION5X_SATA		(1 + 29)
-#define IRQ_ORION5X_XOR0		(1 + 30)
-#define IRQ_ORION5X_XOR1		(1 + 31)
+#define IRQ_ORION5X_BRIDGE		0
+#define IRQ_ORION5X_DOORBELL_H2C	1
+#define IRQ_ORION5X_DOORBELL_C2H	2
+#define IRQ_ORION5X_UART0		3
+#define IRQ_ORION5X_UART1		4
+#define IRQ_ORION5X_I2C			5
+#define IRQ_ORION5X_GPIO_0_7		6
+#define IRQ_ORION5X_GPIO_8_15		7
+#define IRQ_ORION5X_GPIO_16_23		8
+#define IRQ_ORION5X_GPIO_24_31		9
+#define IRQ_ORION5X_PCIE0_ERR		10
+#define IRQ_ORION5X_PCIE0_INT		11
+#define IRQ_ORION5X_USB1_CTRL		12
+#define IRQ_ORION5X_DEV_BUS_ERR		14
+#define IRQ_ORION5X_PCI_ERR		15
+#define IRQ_ORION5X_USB_BR_ERR		16
+#define IRQ_ORION5X_USB0_CTRL		17
+#define IRQ_ORION5X_ETH_RX		18
+#define IRQ_ORION5X_ETH_TX		19
+#define IRQ_ORION5X_ETH_MISC		20
+#define IRQ_ORION5X_ETH_SUM		21
+#define IRQ_ORION5X_ETH_ERR		22
+#define IRQ_ORION5X_IDMA_ERR		23
+#define IRQ_ORION5X_IDMA_0		24
+#define IRQ_ORION5X_IDMA_1		25
+#define IRQ_ORION5X_IDMA_2		26
+#define IRQ_ORION5X_IDMA_3		27
+#define IRQ_ORION5X_CESA		28
+#define IRQ_ORION5X_SATA		29
+#define IRQ_ORION5X_XOR0		30
+#define IRQ_ORION5X_XOR1		31
 
 /*
  * Orion General Purpose Pins
  */
-#define IRQ_ORION5X_GPIO_START	33
+#define IRQ_ORION5X_GPIO_START	32
 #define NR_GPIO_IRQS		32
 
 #define NR_IRQS			(IRQ_ORION5X_GPIO_START + NR_GPIO_IRQS)
diff --git a/arch/arm/mach-orion5x/irq.c b/arch/arm/mach-orion5x/irq.c
index 086ecb87d885..cd4bac4d7e43 100644
--- a/arch/arm/mach-orion5x/irq.c
+++ b/arch/arm/mach-orion5x/irq.c
@@ -42,7 +42,7 @@ __exception_irq_entry orion5x_legacy_handle_irq(struct pt_regs *regs)
 	stat = readl_relaxed(MAIN_IRQ_CAUSE);
 	stat &= readl_relaxed(MAIN_IRQ_MASK);
 	if (stat) {
-		unsigned int hwirq = 1 + __fls(stat);
+		unsigned int hwirq = __fls(stat);
 		handle_IRQ(hwirq, regs);
 		return;
 	}
@@ -51,7 +51,7 @@ __exception_irq_entry orion5x_legacy_handle_irq(struct pt_regs *regs)
 
 void __init orion5x_init_irq(void)
 {
-	orion_irq_init(1, MAIN_IRQ_MASK);
+	orion_irq_init(0, MAIN_IRQ_MASK);
 
 #ifdef CONFIG_MULTI_IRQ_HANDLER
 	set_handle_irq(orion5x_legacy_handle_irq);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 060/104] jbd2: avoid infinite loop when destroying aborted journal
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (58 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 059/104] Revert "ARM: orion5x: fix legacy orion5x IRQ numbers" Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 061/104] asix: Don't reset PHY on if_up for ASIX 88772 Luis Henriques
                   ` (48 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Jan Kara, Theodore Ts'o, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jan Kara <jack@suse.com>

commit 841df7df196237ea63233f0f9eaa41db53afd70f upstream.

Commit 6f6a6fda2945 "jbd2: fix ocfs2 corrupt when updating journal
superblock fails" changed jbd2_cleanup_journal_tail() to return EIO
when the journal is aborted. That makes logic in
jbd2_log_do_checkpoint() bail out which is fine, except that
jbd2_journal_destroy() expects jbd2_log_do_checkpoint() to always make
a progress in cleaning the journal. Without it jbd2_journal_destroy()
just loops in an infinite loop.

Fix jbd2_journal_destroy() to cleanup journal checkpoint lists of
jbd2_log_do_checkpoint() fails with error.

Reported-by: Eryu Guan <guaneryu@gmail.com>
Tested-by: Eryu Guan <guaneryu@gmail.com>
Fixes: 6f6a6fda294506dfe0e3e0a253bb2d2923f28f0a
Signed-off-by: Jan Kara <jack@suse.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
[ luis: backported to 3.16: used Jan's backport ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 fs/jbd2/checkpoint.c | 39 +++++++++++++++++++++++++++++++++------
 fs/jbd2/commit.c     |  2 +-
 fs/jbd2/journal.c    | 11 ++++++++++-
 include/linux/jbd2.h |  3 ++-
 4 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
index b892355f1944..d4c7e470dec8 100644
--- a/fs/jbd2/checkpoint.c
+++ b/fs/jbd2/checkpoint.c
@@ -475,14 +475,15 @@ int jbd2_cleanup_journal_tail(journal_t *journal)
  * journal_clean_one_cp_list
  *
  * Find all the written-back checkpoint buffers in the given list and
- * release them.
+ * release them. If 'destroy' is set, clean all buffers unconditionally.
  *
  * Called with the journal locked.
  * Called with j_list_lock held.
  * Returns number of buffers reaped (for debug)
  */
 
-static int journal_clean_one_cp_list(struct journal_head *jh, int *released)
+static int journal_clean_one_cp_list(struct journal_head *jh, bool destroy,
+				     int *released)
 {
 	struct journal_head *last_jh;
 	struct journal_head *next_jh = jh;
@@ -496,7 +497,10 @@ static int journal_clean_one_cp_list(struct journal_head *jh, int *released)
 	do {
 		jh = next_jh;
 		next_jh = jh->b_cpnext;
-		ret = __try_to_free_cp_buf(jh);
+		if (!destroy)
+			ret = __try_to_free_cp_buf(jh);
+		else
+			ret = __jbd2_journal_remove_checkpoint(jh) + 1;
 		if (ret) {
 			freed++;
 			if (ret == 2) {
@@ -521,13 +525,14 @@ static int journal_clean_one_cp_list(struct journal_head *jh, int *released)
  * journal_clean_checkpoint_list
  *
  * Find all the written-back checkpoint buffers in the journal and release them.
+ * If 'destroy' is set, release all buffers unconditionally.
  *
  * Called with the journal locked.
  * Called with j_list_lock held.
  * Returns number of buffers reaped (for debug)
  */
 
-int __jbd2_journal_clean_checkpoint_list(journal_t *journal)
+int __jbd2_journal_clean_checkpoint_list(journal_t *journal, bool destroy)
 {
 	transaction_t *transaction, *last_transaction, *next_transaction;
 	int ret = 0;
@@ -543,7 +548,7 @@ int __jbd2_journal_clean_checkpoint_list(journal_t *journal)
 		transaction = next_transaction;
 		next_transaction = transaction->t_cpnext;
 		ret += journal_clean_one_cp_list(transaction->
-				t_checkpoint_list, &released);
+				t_checkpoint_list, destroy, &released);
 		/*
 		 * This function only frees up some memory if possible so we
 		 * dont have an obligation to finish processing. Bail out if
@@ -559,7 +564,7 @@ int __jbd2_journal_clean_checkpoint_list(journal_t *journal)
 		 * we can possibly see not yet submitted buffers on io_list
 		 */
 		ret += journal_clean_one_cp_list(transaction->
-				t_checkpoint_io_list, &released);
+				t_checkpoint_io_list, destroy, &released);
 		if (need_resched())
 			goto out;
 	} while (transaction != last_transaction);
@@ -568,6 +573,28 @@ out:
 }
 
 /*
+ * Remove buffers from all checkpoint lists as journal is aborted and we just
+ * need to free memory
+ */
+void jbd2_journal_destroy_checkpoint(journal_t *journal)
+{
+	/*
+	 * We loop because __jbd2_journal_clean_checkpoint_list() may abort
+	 * early due to a need of rescheduling.
+	 */
+	while (1) {
+		spin_lock(&journal->j_list_lock);
+		if (!journal->j_checkpoint_transactions) {
+			spin_unlock(&journal->j_list_lock);
+			break;
+		}
+		__jbd2_journal_clean_checkpoint_list(journal, true);
+		spin_unlock(&journal->j_list_lock);
+		cond_resched();
+	}
+}
+
+/*
  * journal_remove_checkpoint: called after a buffer has been committed
  * to disk (either by being write-back flushed to disk, or being
  * committed to the log).
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index b73e0215baa7..362e5f614450 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -510,7 +510,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
 	 * frees some memory
 	 */
 	spin_lock(&journal->j_list_lock);
-	__jbd2_journal_clean_checkpoint_list(journal);
+	__jbd2_journal_clean_checkpoint_list(journal, false);
 	spin_unlock(&journal->j_list_lock);
 
 	jbd_debug(3, "JBD2: commit phase 1\n");
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 72e238b50ad1..8c649c3f0a80 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1708,8 +1708,17 @@ int jbd2_journal_destroy(journal_t *journal)
 	while (journal->j_checkpoint_transactions != NULL) {
 		spin_unlock(&journal->j_list_lock);
 		mutex_lock(&journal->j_checkpoint_mutex);
-		jbd2_log_do_checkpoint(journal);
+		err = jbd2_log_do_checkpoint(journal);
 		mutex_unlock(&journal->j_checkpoint_mutex);
+		/*
+		 * If checkpointing failed, just free the buffers to avoid
+		 * looping forever
+		 */
+		if (err) {
+			jbd2_journal_destroy_checkpoint(journal);
+			spin_lock(&journal->j_list_lock);
+			break;
+		}
 		spin_lock(&journal->j_list_lock);
 	}
 
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index e1fb0f613a99..385593d748f6 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1042,8 +1042,9 @@ void jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block);
 extern void jbd2_journal_commit_transaction(journal_t *);
 
 /* Checkpoint list management */
-int __jbd2_journal_clean_checkpoint_list(journal_t *journal);
+int __jbd2_journal_clean_checkpoint_list(journal_t *journal, bool destroy);
 int __jbd2_journal_remove_checkpoint(struct journal_head *);
+void jbd2_journal_destroy_checkpoint(journal_t *journal);
 void __jbd2_journal_insert_checkpoint(struct journal_head *, transaction_t *);
 
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 061/104] asix: Don't reset PHY on if_up for ASIX 88772
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (59 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 060/104] jbd2: avoid infinite loop when destroying aborted journal Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 062/104] asix: Do full reset during ax88772_bind Luis Henriques
                   ` (47 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Michel Stam, David S. Miller, Ian Campbell, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Michel Stam <m.stam@fugro.nl>

commit 3cc81d85ee01e5a0b7ea2f4190e2ed1165f53c31 upstream.

I've noticed every time the interface is set to 'up,', the kernel
reports that the link speed is set to 100 Mbps/Full Duplex, even
when ethtool is used to set autonegotiation to 'off', half
duplex, 10 Mbps.
It can be tested by:
 ifconfig eth0 down
 ethtool -s eth0 autoneg off speed 10 duplex half
 ifconfig eth0 up

Then checking 'dmesg' for the link speed.

Signed-off-by: Michel Stam <m.stam@fugro.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/net/usb/asix_devices.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 5d194093f3e1..2c05f6cdb12f 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -890,7 +890,7 @@ static const struct driver_info ax88772_info = {
 	.unbind = ax88772_unbind,
 	.status = asix_status,
 	.link_reset = ax88772_link_reset,
-	.reset = ax88772_reset,
+	.reset = ax88772_link_reset,
 	.flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | FLAG_MULTI_PACKET,
 	.rx_fixup = asix_rx_fixup_common,
 	.tx_fixup = asix_tx_fixup,

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 062/104] asix: Do full reset during ax88772_bind
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (60 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 061/104] asix: Don't reset PHY on if_up for ASIX 88772 Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 063/104] fib_rules: Fix dump_rules() not to exit early Luis Henriques
                   ` (46 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Charles Keepax, David S. Miller, Ian Campbell, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

commit 436c2a5036b6ffe813310df2cf327d3b69be0734 upstream.

commit 3cc81d85ee01 ("asix: Don't reset PHY on if_up for ASIX 88772")
causes the ethernet on Arndale to no longer function. This appears to
be because the Arndale ethernet requires a full reset before it will
function correctly, however simply reverting the above patch causes
problems with ethtool settings getting reset.

It seems the problem is that the ethernet is not properly reset during
bind, and indeed the code in ax88772_bind that resets the device is a
very small subset of the actual ax88772_reset function. This patch uses
ax88772_reset in place of the existing reset code in ax88772_bind which
removes some code duplication and fixes the ethernet on Arndale.

It is still possible that the original patch causes some issues with
suspend and resume but that seems like a separate issue and I haven't
had a chance to test that yet.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Tested-by: Riku Voipio <riku.voipio@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/net/usb/asix_devices.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 2c05f6cdb12f..816d511e34d3 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -465,19 +465,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
 		return ret;
 	}
 
-	ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL);
-	if (ret < 0)
-		return ret;
-
-	msleep(150);
-
-	ret = asix_sw_reset(dev, AX_SWRESET_CLEAR);
-	if (ret < 0)
-		return ret;
-
-	msleep(150);
-
-	ret = asix_sw_reset(dev, embd_phy ? AX_SWRESET_IPRL : AX_SWRESET_PRTE);
+	ax88772_reset(dev);
 
 	/* Read PHYID register *AFTER* the PHY was reset properly */
 	phyid = asix_get_phyid(dev);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 063/104] fib_rules: Fix dump_rules() not to exit early
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (61 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 062/104] asix: Do full reset during ax88772_bind Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 064/104] net/xen-netfront: only napi_synchronize() if running Luis Henriques
                   ` (45 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Roland Dreier, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Roland Dreier <roland@purestorage.com>

Backports of 41fc014332d9 ("fib_rules: fix fib rule dumps across
multiple skbs") introduced a regression in "ip rule show" - it ends up
dumping the first rule over and over and never exiting, because 3.19
and earlier are missing commit 053c095a82cf ("netlink: make
nlmsg_end() and genlmsg_end() void"), so fib_nl_fill_rule() ends up
returning skb->len (i.e. > 0) in the success case.

Fix this by checking the return code for < 0 instead of != 0.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 net/core/fib_rules.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index aeedc3a961a1..99ae718b79be 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -631,7 +631,7 @@ static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb,
 		err = fib_nl_fill_rule(skb, rule, NETLINK_CB(cb->skb).portid,
 				       cb->nlh->nlmsg_seq, RTM_NEWRULE,
 				       NLM_F_MULTI, ops);
-		if (err)
+		if (err < 0)
 			break;
 skip:
 		idx++;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 064/104] net/xen-netfront: only napi_synchronize() if running
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (62 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 063/104] fib_rules: Fix dump_rules() not to exit early Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 065/104] cpufreq: intel_pstate: Remove unnecessary type casting in div_s64() call Luis Henriques
                   ` (44 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Chas Williams, David S. Miller, Kamata, Munehisa, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Chas Williams <3chas3@gmail.com>

commit 274b045509175db0405c784be85e8cce116e6f7d upstream.

If an interface isn't running napi_synchronize() will hang forever.

[  392.248403] rmmod           R  running task        0   359    343 0x00000000
[  392.257671]  ffff88003760fc88 ffff880037193b40 ffff880037193160 ffff88003760fc88
[  392.267644]  ffff880037610000 ffff88003760fcd8 0000000100014c22 ffffffff81f75c40
[  392.277524]  0000000000bc7010 ffff88003760fca8 ffffffff81796927 ffffffff81f75c40
[  392.287323] Call Trace:
[  392.291599]  [<ffffffff81796927>] schedule+0x37/0x90
[  392.298553]  [<ffffffff8179985b>] schedule_timeout+0x14b/0x280
[  392.306421]  [<ffffffff810f91b9>] ? irq_free_descs+0x69/0x80
[  392.314006]  [<ffffffff811084d0>] ? internal_add_timer+0xb0/0xb0
[  392.322125]  [<ffffffff81109d07>] msleep+0x37/0x50
[  392.329037]  [<ffffffffa00ec79a>] xennet_disconnect_backend.isra.24+0xda/0x390 [xen_netfront]
[  392.339658]  [<ffffffffa00ecadc>] xennet_remove+0x2c/0x80 [xen_netfront]
[  392.348516]  [<ffffffff81481c69>] xenbus_dev_remove+0x59/0xc0
[  392.356257]  [<ffffffff814e7217>] __device_release_driver+0x87/0x120
[  392.364645]  [<ffffffff814e7cf8>] driver_detach+0xb8/0xc0
[  392.371989]  [<ffffffff814e6e69>] bus_remove_driver+0x59/0xe0
[  392.379883]  [<ffffffff814e84f0>] driver_unregister+0x30/0x70
[  392.387495]  [<ffffffff814814b2>] xenbus_unregister_driver+0x12/0x20
[  392.395908]  [<ffffffffa00ed89b>] netif_exit+0x10/0x775 [xen_netfront]
[  392.404877]  [<ffffffff81124e08>] SyS_delete_module+0x1d8/0x230
[  392.412804]  [<ffffffff8179a8ee>] system_call_fastpath+0x12/0x71

Signed-off-by: Chas Williams <3chas3@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Kamata, Munehisa <kamatam@amazon.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/net/xen-netfront.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 0838a2db5570..9d3bdea182cd 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1449,7 +1449,8 @@ static void xennet_disconnect_backend(struct netfront_info *info)
 		queue->tx_evtchn = queue->rx_evtchn = 0;
 		queue->tx_irq = queue->rx_irq = 0;
 
-		napi_synchronize(&queue->napi);
+		if (netif_running(info->netdev))
+			napi_synchronize(&queue->napi);
 
 		/* End access and free the pages */
 		xennet_end_access(queue->tx_ring_ref, queue->tx.sring);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 065/104] cpufreq: intel_pstate: Remove unnecessary type casting in div_s64() call
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (63 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 064/104] net/xen-netfront: only napi_synchronize() if running Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 066/104] intel_pstate: Fix overflow in busy_scaled due to long delay Luis Henriques
                   ` (43 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Stratos Karafotis, Dirk Brandewie, Rafael J. Wysocki, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Stratos Karafotis <stratosk@semaphore.gr>

commit fa30dff9a81ea9fdc2e985a14fe14ce6393a3214 upstream.

div_s64() accepts the divisor parameter as s32. Helper div_fp()
also accepts divisor as int32_t.

So, remove the unnecessary int64_t type casting.

Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/cpufreq/intel_pstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 0a91eea08198..08f653669a52 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -50,7 +50,7 @@ static inline int32_t mul_fp(int32_t x, int32_t y)
 
 static inline int32_t div_fp(int32_t x, int32_t y)
 {
-	return div_s64((int64_t)x << FRAC_BITS, (int64_t)y);
+	return div_s64((int64_t)x << FRAC_BITS, y);
 }
 
 static inline int ceiling_fp(int32_t x)

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 066/104] intel_pstate: Fix overflow in busy_scaled due to long delay
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (64 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 065/104] cpufreq: intel_pstate: Remove unnecessary type casting in div_s64() call Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 067/104] tools lib traceevent: Fix string handling in heterogeneous arch environments Luis Henriques
                   ` (42 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Prarit Bhargava, Rafael J. Wysocki, Thomas Renninger, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Prarit Bhargava <prarit@redhat.com>

commit 7180dddf7c32c49975c7e7babf2b60ed450cb760 upstream.

The kernel may delay interrupts for a long time which can result in timers
being delayed. If this occurs the intel_pstate driver will crash with a
divide by zero error:

divide error: 0000 [#1] SMP
Modules linked in: btrfs zlib_deflate raid6_pq xor msdos ext4 mbcache jbd2 binfmt_misc arc4 md4 nls_utf8 cifs dns_resolver tcp_lp bnep bluetooth rfkill fuse dm_service_time iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi nf_conntrack_netbios_ns nf_conntrack_broadcast nf_conntrack_ftp ip6t_rpfilter ip6t_REJECT ipt_REJECT xt_conntrack ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw iptable_filter ip_tables intel_powerclamp coretemp vfat fat kvm_intel iTCO_wdt iTCO_vendor_support ipmi_devintf sr_mod kvm crct10dif_pclmul
 crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel cdc_ether lrw usbnet cdrom mii gf128mul glue_helper ablk_helper cryptd lpc_ich mfd_core pcspkr sb_edac edac_core ipmi_si ipmi_msghandler ioatdma wmi shpchp acpi_pad nfsd auth_rpcgss nfs_acl lockd uinput dm_multipath sunrpc xfs libcrc32c usb_storage sd_mod crc_t10dif crct10dif_common ixgbe mgag200 syscopyarea sysfillrect sysimgblt mdio drm_kms_helper ttm igb drm ptp pps_core dca i2c_algo_bit megaraid_sas i2c_core dm_mirror dm_region_hash dm_log dm_mod
CPU: 113 PID: 0 Comm: swapper/113 Tainted: G        W   --------------   3.10.0-229.1.2.el7.x86_64 #1
Hardware name: IBM x3950 X6 -[3837AC2]-/00FN827, BIOS -[A8E112BUS-1.00]- 08/27/2014
task: ffff880fe8abe660 ti: ffff880fe8ae4000 task.ti: ffff880fe8ae4000
RIP: 0010:[<ffffffff814a9279>]  [<ffffffff814a9279>] intel_pstate_timer_func+0x179/0x3d0
RSP: 0018:ffff883fff4e3db8  EFLAGS: 00010206
RAX: 0000000027100000 RBX: ffff883fe6965100 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000010 RDI: 000000002e53632d
RBP: ffff883fff4e3e20 R08: 000e6f69a5a125c0 R09: ffff883fe84ec001
R10: 0000000000000002 R11: 0000000000000005 R12: 00000000000049f5
R13: 0000000000271000 R14: 00000000000049f5 R15: 0000000000000246
FS:  0000000000000000(0000) GS:ffff883fff4e0000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f7668601000 CR3: 000000000190a000 CR4: 00000000001407e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Stack:
 ffff883fff4e3e58 ffffffff81099dc1 0000000000000086 0000000000000071
 ffff883fff4f3680 0000000000000071 fbdc8a965e33afee ffffffff810b69dd
 ffff883fe84ec000 ffff883fe6965108 0000000000000100 ffffffff814a9100
Call Trace:
 <IRQ>

 [<ffffffff81099dc1>] ? run_posix_cpu_timers+0x51/0x840
 [<ffffffff810b69dd>] ? trigger_load_balance+0x5d/0x200
 [<ffffffff814a9100>] ? pid_param_set+0x130/0x130
 [<ffffffff8107df56>] call_timer_fn+0x36/0x110
 [<ffffffff814a9100>] ? pid_param_set+0x130/0x130
 [<ffffffff8107fdcf>] run_timer_softirq+0x21f/0x320
 [<ffffffff81077b2f>] __do_softirq+0xef/0x280
 [<ffffffff816156dc>] call_softirq+0x1c/0x30
 [<ffffffff81015d95>] do_softirq+0x65/0xa0
 [<ffffffff81077ec5>] irq_exit+0x115/0x120
 [<ffffffff81616355>] smp_apic_timer_interrupt+0x45/0x60
 [<ffffffff81614a1d>] apic_timer_interrupt+0x6d/0x80
 <EOI>

 [<ffffffff814a9c32>] ? cpuidle_enter_state+0x52/0xc0
 [<ffffffff814a9c28>] ? cpuidle_enter_state+0x48/0xc0
 [<ffffffff814a9d65>] cpuidle_idle_call+0xc5/0x200
 [<ffffffff8101d14e>] arch_cpu_idle+0xe/0x30
 [<ffffffff810c67c1>] cpu_startup_entry+0xf1/0x290
 [<ffffffff8104228a>] start_secondary+0x1ba/0x230
Code: 42 0f 00 45 89 e6 48 01 c2 43 8d 44 6d 00 39 d0 73 26 49 c1 e5 08 89 d2 4d 63 f4 49 63 c5 48 c1 e2 08 48 c1 e0 08 48 63 ca 48 99 <48> f7 f9 48 98 4c 0f af f0 49 c1 ee 08 8b 43 78 c1 e0 08 44 29
RIP  [<ffffffff814a9279>] intel_pstate_timer_func+0x179/0x3d0
 RSP <ffff883fff4e3db8>

The kernel values for cpudata for CPU 113 were:

struct cpudata {
  cpu = 113,
  timer = {
    entry = {
      next = 0x0,
      prev = 0xdead000000200200
    },
    expires = 8357799745,
    base = 0xffff883fe84ec001,
    function = 0xffffffff814a9100 <intel_pstate_timer_func>,
    data = 18446612406765768960,
<snip>
    i_gain = 0,
    d_gain = 0,
    deadband = 0,
    last_err = 22489
  },
  last_sample_time = {
    tv64 = 4063132438017305
  },
  prev_aperf = 287326796397463,
  prev_mperf = 251427432090198,
  sample = {
    core_pct_busy = 23081,
    aperf = 2937407,
    mperf = 3257884,
    freq = 2524484,
    time = {
      tv64 = 4063149215234118
    }
  }
}

which results in the time between samples = last_sample_time - sample.time
= 4063149215234118 - 4063132438017305 = 16777216813 which is 16.777 seconds.

The duration between reads of the APERF and MPERF registers overflowed a s32
sized integer in intel_pstate_get_scaled_busy()'s call to div_fp().  The result
is that int_tofp(duration_us) == 0, and the kernel attempts to divide by 0.

While the kernel shouldn't be delaying for a long time, it can and does
happen and the intel_pstate driver should not panic in this situation.  This
patch changes the div_fp() function to use div64_s64() to allow for "long"
division.  This will avoid the overflow condition on long delays.

[v2]: use div64_s64() in div_fp()

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Thomas Renninger <trenn@suse.de>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/cpufreq/intel_pstate.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 08f653669a52..dad4346189ae 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -48,9 +48,9 @@ static inline int32_t mul_fp(int32_t x, int32_t y)
 	return ((int64_t)x * (int64_t)y) >> FRAC_BITS;
 }
 
-static inline int32_t div_fp(int32_t x, int32_t y)
+static inline int32_t div_fp(s64 x, s64 y)
 {
-	return div_s64((int64_t)x << FRAC_BITS, y);
+	return div64_s64((int64_t)x << FRAC_BITS, y);
 }
 
 static inline int ceiling_fp(int32_t x)
@@ -679,7 +679,7 @@ static inline void intel_pstate_set_sample_time(struct cpudata *cpu)
 static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu)
 {
 	int32_t core_busy, max_pstate, current_pstate, sample_ratio;
-	u32 duration_us;
+	s64 duration_us;
 	u32 sample_time;
 
 	core_busy = cpu->sample.core_pct_busy;
@@ -688,8 +688,8 @@ static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu)
 	core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate));
 
 	sample_time = (pid_params.sample_rate_ms  * USEC_PER_MSEC);
-	duration_us = (u32) ktime_us_delta(cpu->sample.time,
-					cpu->last_sample_time);
+	duration_us = ktime_us_delta(cpu->sample.time,
+				     cpu->last_sample_time);
 	if (duration_us > sample_time * 3) {
 		sample_ratio = div_fp(int_tofp(sample_time),
 				int_tofp(duration_us));

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 067/104] tools lib traceevent: Fix string handling in heterogeneous arch environments
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (65 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 066/104] intel_pstate: Fix overflow in busy_scaled due to long delay Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 068/104] perf tools: Fix copying of /proc/kcore Luis Henriques
                   ` (41 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Kapileshwar Singh, David Ahern, Javi Merino, Jiri Olsa,
	Namhyung Kim, Arnaldo Carvalho de Melo, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Kapileshwar Singh <kapileshwar.singh@arm.com>

commit c2e4b24ff848bb180f9b9cd873a38327cd219ad2 upstream.

When a trace recorded on a 32-bit device is processed with a 64-bit
binary, the higher 32-bits of the address need to ignored.

The lack of this results in the output of the 64-bit pointer
value to the trace as the 32-bit address lookup fails in find_printk().

Before:

  burn-1778  [003]   548.600305: bputs:   0xc0046db2s: 2cec5c058d98c

After:

  burn-1778  [003]   548.600305: bputs:   0xc0046db2s: RT throttling activated

The problem occurs in PRINT_FIELD when the field is recognized as a
pointer to a string (of the type const char *)

Heterogeneous architectures cases below can arise and should be handled:

* Traces recorded using 32-bit addresses processed on a 64-bit machine
* Traces recorded using 64-bit addresses processed on a 32-bit machine

Reported-by: Juri Lelli <juri.lelli@arm.com>
Signed-off-by: Kapileshwar Singh <kapileshwar.singh@arm.com>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Javi Merino <javi.merino@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1442928123-13824-1-git-send-email-kapileshwar.singh@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 tools/lib/traceevent/event-parse.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 93825a17dcce..7959d66e1048 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3658,7 +3658,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
 	struct format_field *field;
 	struct printk_map *printk;
 	unsigned long long val, fval;
-	unsigned long addr;
+	unsigned long long addr;
 	char *str;
 	unsigned char *hex;
 	int print;
@@ -3691,13 +3691,30 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
 		 */
 		if (!(field->flags & FIELD_IS_ARRAY) &&
 		    field->size == pevent->long_size) {
-			addr = *(unsigned long *)(data + field->offset);
+
+			/* Handle heterogeneous recording and processing
+			 * architectures
+			 *
+			 * CASE I:
+			 * Traces recorded on 32-bit devices (32-bit
+			 * addressing) and processed on 64-bit devices:
+			 * In this case, only 32 bits should be read.
+			 *
+			 * CASE II:
+			 * Traces recorded on 64 bit devices and processed
+			 * on 32-bit devices:
+			 * In this case, 64 bits must be read.
+			 */
+			addr = (pevent->long_size == 8) ?
+				*(unsigned long long *)(data + field->offset) :
+				(unsigned long long)*(unsigned int *)(data + field->offset);
+
 			/* Check if it matches a print format */
 			printk = find_printk(pevent, addr);
 			if (printk)
 				trace_seq_puts(s, printk->printk);
 			else
-				trace_seq_printf(s, "%lx", addr);
+				trace_seq_printf(s, "%llx", addr);
 			break;
 		}
 		str = malloc(len + 1);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 068/104] perf tools: Fix copying of /proc/kcore
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (66 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 067/104] tools lib traceevent: Fix string handling in heterogeneous arch environments Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 069/104] m68k: Define asmlinkage_protect Luis Henriques
                   ` (40 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Adrian Hunter, Jiri Olsa, Arnaldo Carvalho de Melo, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Adrian Hunter <adrian.hunter@intel.com>

commit b5cabbcbd157a4bf5a92dfc85134999a3b55342d upstream.

A copy of /proc/kcore containing the kernel text can be made to the
buildid cache. e.g.

	perf buildid-cache -v -k /proc/kcore

To workaround objdump limitations, a copy is also made when annotating
against /proc/kcore.

The copying process stops working from libelf about v1.62 onwards (the
problem was found with v1.63).

The cause is that a call to gelf_getphdr() in kcore__add_phdr() fails
because additional validation has been added to gelf_getphdr().

The use of gelf_getphdr() is a misguided attempt to get default
initialization of the Gelf_Phdr structure.  That should not be
necessary because every member of the Gelf_Phdr structure is
subsequently assigned.  So just remove the call to gelf_getphdr().

Similarly, a call to gelf_getehdr() in gelf_kcore__init() can be
removed also.

Committer notes:

Note to stable@kernel.org, from Adrian in the cover letter for this
patchkit:

The "Fix copying of /proc/kcore" problem goes back to v3.13 if you think
it is important enough for stable.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1443089122-19082-3-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 tools/perf/util/symbol-elf.c | 35 +++++++++++++----------------------
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 6864661a79dd..a9ef5c1f78df 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1104,8 +1104,6 @@ out_close:
 static int kcore__init(struct kcore *kcore, char *filename, int elfclass,
 		       bool temp)
 {
-	GElf_Ehdr *ehdr;
-
 	kcore->elfclass = elfclass;
 
 	if (temp)
@@ -1122,9 +1120,7 @@ static int kcore__init(struct kcore *kcore, char *filename, int elfclass,
 	if (!gelf_newehdr(kcore->elf, elfclass))
 		goto out_end;
 
-	ehdr = gelf_getehdr(kcore->elf, &kcore->ehdr);
-	if (!ehdr)
-		goto out_end;
+	memset(&kcore->ehdr, 0, sizeof(GElf_Ehdr));
 
 	return 0;
 
@@ -1181,23 +1177,18 @@ static int kcore__copy_hdr(struct kcore *from, struct kcore *to, size_t count)
 static int kcore__add_phdr(struct kcore *kcore, int idx, off_t offset,
 			   u64 addr, u64 len)
 {
-	GElf_Phdr gphdr;
-	GElf_Phdr *phdr;
-
-	phdr = gelf_getphdr(kcore->elf, idx, &gphdr);
-	if (!phdr)
-		return -1;
-
-	phdr->p_type	= PT_LOAD;
-	phdr->p_flags	= PF_R | PF_W | PF_X;
-	phdr->p_offset	= offset;
-	phdr->p_vaddr	= addr;
-	phdr->p_paddr	= 0;
-	phdr->p_filesz	= len;
-	phdr->p_memsz	= len;
-	phdr->p_align	= page_size;
-
-	if (!gelf_update_phdr(kcore->elf, idx, phdr))
+	GElf_Phdr phdr = {
+		.p_type		= PT_LOAD,
+		.p_flags	= PF_R | PF_W | PF_X,
+		.p_offset	= offset,
+		.p_vaddr	= addr,
+		.p_paddr	= 0,
+		.p_filesz	= len,
+		.p_memsz	= len,
+		.p_align	= page_size,
+	};
+
+	if (!gelf_update_phdr(kcore->elf, idx, &phdr))
 		return -1;
 
 	return 0;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 069/104] m68k: Define asmlinkage_protect
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (67 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 068/104] perf tools: Fix copying of /proc/kcore Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 070/104] UBI: Validate data_size Luis Henriques
                   ` (39 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Andreas Schwab, Geert Uytterhoeven, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Andreas Schwab <schwab@linux-m68k.org>

commit 8474ba74193d302e8340dddd1e16c85cc4b98caf upstream.

Make sure the compiler does not modify arguments of syscall functions.
This can happen if the compiler generates a tailcall to another
function.  For example, without asmlinkage_protect sys_openat is compiled
into this function:

sys_openat:
	clr.l %d0
	move.w 18(%sp),%d0
	move.l %d0,16(%sp)
	jbra do_sys_open

Note how the fourth argument is modified in place, modifying the register
%d4 that gets restored from this stack slot when the function returns to
user-space.  The caller may expect the register to be unmodified across
system calls.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/m68k/include/asm/linkage.h | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/arch/m68k/include/asm/linkage.h b/arch/m68k/include/asm/linkage.h
index 5a822bb790f7..066e74f666ae 100644
--- a/arch/m68k/include/asm/linkage.h
+++ b/arch/m68k/include/asm/linkage.h
@@ -4,4 +4,34 @@
 #define __ALIGN .align 4
 #define __ALIGN_STR ".align 4"
 
+/*
+ * Make sure the compiler doesn't do anything stupid with the
+ * arguments on the stack - they are owned by the *caller*, not
+ * the callee. This just fools gcc into not spilling into them,
+ * and keeps it from doing tailcall recursion and/or using the
+ * stack slots for temporaries, since they are live and "used"
+ * all the way to the end of the function.
+ */
+#define asmlinkage_protect(n, ret, args...) \
+	__asmlinkage_protect##n(ret, ##args)
+#define __asmlinkage_protect_n(ret, args...) \
+	__asm__ __volatile__ ("" : "=r" (ret) : "0" (ret), ##args)
+#define __asmlinkage_protect0(ret) \
+	__asmlinkage_protect_n(ret)
+#define __asmlinkage_protect1(ret, arg1) \
+	__asmlinkage_protect_n(ret, "m" (arg1))
+#define __asmlinkage_protect2(ret, arg1, arg2) \
+	__asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2))
+#define __asmlinkage_protect3(ret, arg1, arg2, arg3) \
+	__asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2), "m" (arg3))
+#define __asmlinkage_protect4(ret, arg1, arg2, arg3, arg4) \
+	__asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2), "m" (arg3), \
+			      "m" (arg4))
+#define __asmlinkage_protect5(ret, arg1, arg2, arg3, arg4, arg5) \
+	__asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2), "m" (arg3), \
+			      "m" (arg4), "m" (arg5))
+#define __asmlinkage_protect6(ret, arg1, arg2, arg3, arg4, arg5, arg6) \
+	__asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2), "m" (arg3), \
+			      "m" (arg4), "m" (arg5), "m" (arg6))
+
 #endif

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 070/104] UBI: Validate data_size
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (68 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 069/104] m68k: Define asmlinkage_protect Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 071/104] UBI: return ENOSPC if no enough space available Luis Henriques
                   ` (38 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Richard Weinberger, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Richard Weinberger <richard@nod.at>

commit 281fda27673f833a01d516658a64d22a32c8e072 upstream.

Make sure that data_size is less than LEB size.
Otherwise a handcrafted UBI image is able to trigger
an out of bounds memory access in ubi_compare_lebs().

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: David Gstir <david@sigma-star.at>
[ luis: backported to 3.16:
  - no ubi_device parameter for the ubi_err() macro in 3.16 ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/mtd/ubi/io.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index d36134925d31..db657f2168d7 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -921,6 +921,11 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
 		goto bad;
 	}
 
+	if (data_size > ubi->leb_size) {
+		ubi_err("bad data_size");
+		goto bad;
+	}
+
 	if (vol_type == UBI_VID_STATIC) {
 		/*
 		 * Although from high-level point of view static volumes may

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 071/104] UBI: return ENOSPC if no enough space available
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (69 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 070/104] UBI: Validate data_size Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 072/104] drm/radeon: Restore LCD backlight level on resume (>= R5xx) Luis Henriques
                   ` (37 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Sheng Yong, Richard Weinberger, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: shengyong <shengyong1@huawei.com>

commit 7c7feb2ebfc9c0552c51f0c050db1d1a004faac5 upstream.

UBI: attaching mtd1 to ubi0
UBI: scanning is finished
UBI error: init_volumes: not enough PEBs, required 706, available 686
UBI error: ubi_wl_init: no enough physical eraseblocks (-20, need 1)
UBI error: ubi_attach_mtd_dev: failed to attach mtd1, error -12 <= NOT ENOMEM
UBI error: ubi_init: cannot attach mtd1

If available PEBs are not enough when initializing volumes, return -ENOSPC
directly. If available PEBs are not enough when initializing WL, return
-ENOSPC instead of -ENOMEM.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: David Gstir <david@sigma-star.at>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/mtd/ubi/vtbl.c | 1 +
 drivers/mtd/ubi/wl.c   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index d77b1c1d7c72..bebf49e0dbe9 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -651,6 +651,7 @@ static int init_volumes(struct ubi_device *ubi,
 		if (ubi->corr_peb_count)
 			ubi_err("%d PEBs are corrupted and not used",
 				ubi->corr_peb_count);
+		return -ENOSPC;
 	}
 	ubi->rsvd_pebs += reserved_pebs;
 	ubi->avail_pebs -= reserved_pebs;
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 31afc91a326f..a5eb1f667ef8 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1980,6 +1980,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
 		if (ubi->corr_peb_count)
 			ubi_err("%d PEBs are corrupted and not used",
 				ubi->corr_peb_count);
+		err = -ENOSPC;
 		goto out_free;
 	}
 	ubi->avail_pebs -= reserved_pebs;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 072/104] drm/radeon: Restore LCD backlight level on resume (>= R5xx)
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (70 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 071/104] UBI: return ENOSPC if no enough space available Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-27  2:10   ` Michel Dänzer
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 073/104] MIPS: dma-default: Fix 32-bit fall back to GFP_DMA Luis Henriques
                   ` (36 subsequent siblings)
  108 siblings, 1 reply; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Michel Dänzer, Alex Deucher, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <michel.daenzer@amd.com>

commit 4281f46ef839050d2ef60348f661eb463c21cc2e upstream.

Instead of only enabling the backlight (which seems to set it to max
brightness), just re-set the current backlight level, which also takes
care of enabling the backlight if necessary.

Only the radeon_atom_encoder_dpms_dig part tested on a Kaveri laptop,
the radeon_atom_encoder_dpms_avivo part is only compile tested.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/gpu/drm/radeon/atombios_encoders.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index 7d68203a3737..f35008cf0bc3 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -1609,8 +1609,9 @@ radeon_atom_encoder_dpms_avivo(struct drm_encoder *encoder, int mode)
 		} else
 			atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
 		if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
-			args.ucAction = ATOM_LCD_BLON;
-			atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
+			struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
+
+			atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
 		}
 		break;
 	case DRM_MODE_DPMS_STANDBY:
@@ -1691,8 +1692,7 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
 				atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON, 0);
 		}
 		if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT))
-			atombios_dig_transmitter_setup(encoder,
-						       ATOM_TRANSMITTER_ACTION_LCD_BLON, 0, 0);
+			atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
 		if (ext_encoder)
 			atombios_external_encoder_setup(encoder, ext_encoder, ATOM_ENABLE);
 		break;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 073/104] MIPS: dma-default: Fix 32-bit fall back to GFP_DMA
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (71 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 072/104] drm/radeon: Restore LCD backlight level on resume (>= R5xx) Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 074/104] MIPS: CPS: Stop dangling delay slot from has_mt Luis Henriques
                   ` (35 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: James Hogan, Ralf Baechle, linux-mips, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: James Hogan <james.hogan@imgtec.com>

commit 53960059d56ecef67d4ddd546731623641a3d2d1 upstream.

If there is a DMA zone (usually 24bit = 16MB I believe), but no DMA32
zone, as is the case for some 32-bit kernels, then massage_gfp_flags()
will cause DMA memory allocated for devices with a 32..63-bit
coherent_dma_mask to fall back to using __GFP_DMA, even though there may
only be 32-bits of physical address available anyway.

Correct that case to compare against a mask the size of phys_addr_t
instead of always using a 64-bit mask.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Fixes: a2e715a86c6d ("MIPS: DMA: Fix computation of DMA flags from device's coherent_dma_mask.")
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/9610/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/mips/mm/dma-default.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 44b6dff5aba2..a1087593b3c2 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -94,7 +94,7 @@ static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
 	else
 #endif
 #if defined(CONFIG_ZONE_DMA) && !defined(CONFIG_ZONE_DMA32)
-	     if (dev->coherent_dma_mask < DMA_BIT_MASK(64))
+	     if (dev->coherent_dma_mask < DMA_BIT_MASK(sizeof(phys_addr_t) * 8))
 		dma_flag = __GFP_DMA;
 	else
 #endif

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 074/104] MIPS: CPS: Stop dangling delay slot from has_mt.
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (72 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 073/104] MIPS: dma-default: Fix 32-bit fall back to GFP_DMA Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 075/104] MIPS: CPS: Don't include MT code in non-MT kernels Luis Henriques
                   ` (34 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Paul Burton, Markos Chandras, James Hogan, linux-mips,
	Ralf Baechle, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Paul Burton <paul.burton@imgtec.com>

commit 1e5fb282f8eda889776ee83f9214d5df9edaa26d upstream.

The has_mt macro ended with a branch, leaving its callers with a delay
slot that would be executed if Config3.MT is not set. However it would
not be executed if Config3 (or earlier Config registers) don't exist
which makes it somewhat inconsistent at best. Fill the delay slot in the
macro & fix the mips_cps_boot_vpes caller appropriately.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/10865/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/mips/kernel/cps-vec.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S
index 3b3fb8924628..5652af5786ef 100644
--- a/arch/mips/kernel/cps-vec.S
+++ b/arch/mips/kernel/cps-vec.S
@@ -39,6 +39,7 @@
 	 mfc0	\dest, CP0_CONFIG, 3
 	andi	\dest, \dest, MIPS_CONF3_MT
 	beqz	\dest, \nomt
+	 nop
 	.endm
 
 .section .text.cps-vec
@@ -226,7 +227,6 @@ LEAF(mips_cps_core_init)
 #ifdef CONFIG_MIPS_MT
 	/* Check that the core implements the MT ASE */
 	has_mt	t0, 3f
-	 nop
 
 	.set	push
 	.set	mt
@@ -309,8 +309,8 @@ LEAF(mips_cps_boot_vpes)
 	addu	t0, t0, t1
 
 	/* Calculate this VPEs ID. If the core doesn't support MT use 0 */
+	li	t9, 0
 	has_mt	t6, 1f
-	 li	t9, 0
 
 	/* Find the number of VPEs present in the core */
 	mfc0	t1, CP0_MVPCONF0

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 075/104] MIPS: CPS: Don't include MT code in non-MT kernels.
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (73 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 074/104] MIPS: CPS: Stop dangling delay slot from has_mt Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 076/104] MIPS: CPS: #ifdef on CONFIG_MIPS_MT_SMP rather than CONFIG_MIPS_MT Luis Henriques
                   ` (33 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Paul Burton, Markos Chandras, James Hogan, linux-mips,
	Ralf Baechle, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Paul Burton <paul.burton@imgtec.com>

commit a5b0f6db0e6cf6224e50f6585e9c8f0c2d38a8f8 upstream.

The MT-specific code in mips_cps_boot_vpes can safely be omitted from
kernels which don't support MT, with the default VPE==0 case being used
as it would be after the has_mt (Config3.MT) check failed at runtime.
Discarding the code entirely will save us a few bytes & allow cleaner
handling of MT ASE instructions by later patches.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/10866/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/mips/kernel/cps-vec.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S
index 5652af5786ef..acd9bd6daf99 100644
--- a/arch/mips/kernel/cps-vec.S
+++ b/arch/mips/kernel/cps-vec.S
@@ -310,6 +310,7 @@ LEAF(mips_cps_boot_vpes)
 
 	/* Calculate this VPEs ID. If the core doesn't support MT use 0 */
 	li	t9, 0
+#ifdef CONFIG_MIPS_MT
 	has_mt	t6, 1f
 
 	/* Find the number of VPEs present in the core */
@@ -329,6 +330,7 @@ LEAF(mips_cps_boot_vpes)
 	/* Retrieve the VPE ID from EBase.CPUNum */
 	mfc0	t9, $15, 1
 	and	t9, t9, t1
+#endif
 
 1:	/* Calculate a pointer to this VPEs struct vpe_boot_config */
 	li	t1, VPEBOOTCFG_SIZE

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 076/104] MIPS: CPS: #ifdef on CONFIG_MIPS_MT_SMP rather than CONFIG_MIPS_MT
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (74 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 075/104] MIPS: CPS: Don't include MT code in non-MT kernels Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 077/104] Initialize msg/shm IPC objects before doing ipc_addid() Luis Henriques
                   ` (32 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Paul Burton, Markos Chandras, James Hogan, linux-mips,
	Ralf Baechle, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Paul Burton <paul.burton@imgtec.com>

commit 7a63076d9a31a6c2073da45021eeb4f89d2a8b56 upstream.

The CONFIG_MIPS_MT symbol can be selected by CONFIG_MIPS_VPE_LOADER in
addition to CONFIG_MIPS_MT_SMP. We only want MT code in the CPS SMP boot
vector if we're using MT for SMP. Thus switch the config symbol we ifdef
against to CONFIG_MIPS_MT_SMP.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/10867/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/mips/kernel/cps-vec.S | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S
index acd9bd6daf99..05a96be42075 100644
--- a/arch/mips/kernel/cps-vec.S
+++ b/arch/mips/kernel/cps-vec.S
@@ -224,7 +224,7 @@ LEAF(excep_ejtag)
 	END(excep_ejtag)
 
 LEAF(mips_cps_core_init)
-#ifdef CONFIG_MIPS_MT
+#ifdef CONFIG_MIPS_MT_SMP
 	/* Check that the core implements the MT ASE */
 	has_mt	t0, 3f
 
@@ -310,7 +310,7 @@ LEAF(mips_cps_boot_vpes)
 
 	/* Calculate this VPEs ID. If the core doesn't support MT use 0 */
 	li	t9, 0
-#ifdef CONFIG_MIPS_MT
+#ifdef CONFIG_MIPS_MT_SMP
 	has_mt	t6, 1f
 
 	/* Find the number of VPEs present in the core */
@@ -338,7 +338,7 @@ LEAF(mips_cps_boot_vpes)
 	lw	t7, COREBOOTCFG_VPECONFIG(t0)
 	addu	v0, v0, t7
 
-#ifdef CONFIG_MIPS_MT
+#ifdef CONFIG_MIPS_MT_SMP
 
 	/* If the core doesn't support MT then return */
 	bnez	t6, 1f
@@ -451,7 +451,7 @@ LEAF(mips_cps_boot_vpes)
 
 2:	.set	pop
 
-#endif /* CONFIG_MIPS_MT */
+#endif /* CONFIG_MIPS_MT_SMP */
 
 	/* Return */
 	jr	ra

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 077/104] Initialize msg/shm IPC objects before doing ipc_addid()
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (75 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 076/104] MIPS: CPS: #ifdef on CONFIG_MIPS_MT_SMP rather than CONFIG_MIPS_MT Luis Henriques
@ 2015-10-26 13:42 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 078/104] drm/qxl: recreate the primary surface when the bo is not primary Luis Henriques
                   ` (31 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:42 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Manfred Spraul, Davidlohr Bueso, Linus Torvalds, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Linus Torvalds <torvalds@linux-foundation.org>

commit b9a532277938798b53178d5a66af6e2915cb27cf upstream.

As reported by Dmitry Vyukov, we really shouldn't do ipc_addid() before
having initialized the IPC object state.  Yes, we initialize the IPC
object in a locked state, but with all the lockless RCU lookup work,
that IPC object lock no longer means that the state cannot be seen.

We already did this for the IPC semaphore code (see commit e8577d1f0329:
"ipc/sem.c: fully initialize sem_array before making it visible") but we
clearly forgot about msg and shm.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Manfred Spraul <manfred@colorfullife.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 ipc/msg.c  | 14 +++++++-------
 ipc/shm.c  | 12 ++++++------
 ipc/util.c |  8 ++++----
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/ipc/msg.c b/ipc/msg.c
index c5d8e3749985..cfc8b388332d 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -137,13 +137,6 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
 		return retval;
 	}
 
-	/* ipc_addid() locks msq upon success. */
-	id = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni);
-	if (id < 0) {
-		ipc_rcu_putref(msq, msg_rcu_free);
-		return id;
-	}
-
 	msq->q_stime = msq->q_rtime = 0;
 	msq->q_ctime = get_seconds();
 	msq->q_cbytes = msq->q_qnum = 0;
@@ -153,6 +146,13 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
 	INIT_LIST_HEAD(&msq->q_receivers);
 	INIT_LIST_HEAD(&msq->q_senders);
 
+	/* ipc_addid() locks msq upon success. */
+	id = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni);
+	if (id < 0) {
+		ipc_rcu_putref(msq, msg_rcu_free);
+		return id;
+	}
+
 	ipc_unlock_object(&msq->q_perm);
 	rcu_read_unlock();
 
diff --git a/ipc/shm.c b/ipc/shm.c
index 89fc354156cb..9438ab9027dc 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -547,12 +547,6 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
 	if (IS_ERR(file))
 		goto no_file;
 
-	id = ipc_addid(&shm_ids(ns), &shp->shm_perm, ns->shm_ctlmni);
-	if (id < 0) {
-		error = id;
-		goto no_id;
-	}
-
 	shp->shm_cprid = task_tgid_vnr(current);
 	shp->shm_lprid = 0;
 	shp->shm_atim = shp->shm_dtim = 0;
@@ -562,6 +556,12 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
 	shp->shm_file = file;
 	shp->shm_creator = current;
 
+	id = ipc_addid(&shm_ids(ns), &shp->shm_perm, ns->shm_ctlmni);
+	if (id < 0) {
+		error = id;
+		goto no_id;
+	}
+
 	/*
 	 * shmid gets reported as "inode#" in /proc/pid/maps.
 	 * proc-ps tools use this. Changing this will break them.
diff --git a/ipc/util.c b/ipc/util.c
index 27d74e69fd57..a07ec27e1bfa 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -277,6 +277,10 @@ int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size)
 	rcu_read_lock();
 	spin_lock(&new->lock);
 
+	current_euid_egid(&euid, &egid);
+	new->cuid = new->uid = euid;
+	new->gid = new->cgid = egid;
+
 	id = idr_alloc(&ids->ipcs_idr, new,
 		       (next_id < 0) ? 0 : ipcid_to_idx(next_id), 0,
 		       GFP_NOWAIT);
@@ -289,10 +293,6 @@ int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size)
 
 	ids->in_use++;
 
-	current_euid_egid(&euid, &egid);
-	new->cuid = new->uid = euid;
-	new->gid = new->cgid = egid;
-
 	if (next_id < 0) {
 		new->seq = ids->seq++;
 		if (ids->seq > IPCID_SEQ_MAX)

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 078/104] drm/qxl: recreate the primary surface when the bo is not primary
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (76 preceding siblings ...)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 077/104] Initialize msg/shm IPC objects before doing ipc_addid() Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 079/104] genirq: Fix race in register_irq_proc() Luis Henriques
                   ` (30 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Fabiano Fidêncio, Dave Airlie, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>

commit 8d0d94015e96b8853c4f7f06eac3f269e1b3d866 upstream.

When disabling/enabling a crtc the primary area must be updated
independently of which crtc has been disabled/enabled.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1264735

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/gpu/drm/qxl/qxl_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 6071a9943ed9..7780a5edfdbb 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -552,7 +552,7 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc,
 		  adjusted_mode->hdisplay,
 		  adjusted_mode->vdisplay);
 
-	if (qcrtc->index == 0)
+	if (bo->is_primary == false)
 		recreate_primary = true;
 
 	if (bo->surf.stride * bo->surf.height > qdev->vram_size) {

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 079/104] genirq: Fix race in register_irq_proc()
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (77 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 078/104] drm/qxl: recreate the primary surface when the bo is not primary Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 080/104] x86/efi: Fix boot crash by mapping EFI memmap entries bottom-up at runtime, instead of top-down Luis Henriques
                   ` (29 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Ben Hutchings, Thomas Gleixner, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ben Hutchings <ben@decadent.org.uk>

commit 95c2b17534654829db428f11bcf4297c059a2a7e upstream.

Per-IRQ directories in procfs are created only when a handler is first
added to the irqdesc, not when the irqdesc is created.  In the case of
a shared IRQ, multiple tasks can race to create a directory.  This
race condition seems to have been present forever, but is easier to
hit with async probing.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Link: http://lkml.kernel.org/r/1443266636.2004.2.camel@decadent.org.uk
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 kernel/irq/proc.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 9dc9bfd8a678..9791f93dd5f2 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -12,6 +12,7 @@
 #include <linux/seq_file.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
+#include <linux/mutex.h>
 
 #include "internals.h"
 
@@ -326,18 +327,29 @@ void register_handler_proc(unsigned int irq, struct irqaction *action)
 
 void register_irq_proc(unsigned int irq, struct irq_desc *desc)
 {
+	static DEFINE_MUTEX(register_lock);
 	char name [MAX_NAMELEN];
 
-	if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip) || desc->dir)
+	if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip))
 		return;
 
+	/*
+	 * irq directories are registered only when a handler is
+	 * added, not when the descriptor is created, so multiple
+	 * tasks might try to register at the same time.
+	 */
+	mutex_lock(&register_lock);
+
+	if (desc->dir)
+		goto out_unlock;
+
 	memset(name, 0, MAX_NAMELEN);
 	sprintf(name, "%d", irq);
 
 	/* create /proc/irq/1234 */
 	desc->dir = proc_mkdir(name, root_irq_dir);
 	if (!desc->dir)
-		return;
+		goto out_unlock;
 
 #ifdef CONFIG_SMP
 	/* create /proc/irq/<irq>/smp_affinity */
@@ -358,6 +370,9 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc)
 
 	proc_create_data("spurious", 0444, desc->dir,
 			 &irq_spurious_proc_fops, (void *)(long)irq);
+
+out_unlock:
+	mutex_unlock(&register_lock);
 }
 
 void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 080/104] x86/efi: Fix boot crash by mapping EFI memmap entries bottom-up at runtime, instead of top-down
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (78 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 079/104] genirq: Fix race in register_irq_proc() Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 081/104] Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS Luis Henriques
                   ` (28 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Matt Fleming, Borislav Petkov, Chun-Yi, Dave Young,
	H. Peter Anvin, James Bottomley, Leif Lindholm, Linus Torvalds,
	Matthew Garrett, Mike Galbraith, Peter Jones, Peter Zijlstra,
	Thomas Gleixner, Ingo Molnar, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matt Fleming <matt.fleming@intel.com>

commit a5caa209ba9c29c6421292e7879d2387a2ef39c9 upstream.

Beginning with UEFI v2.5 EFI_PROPERTIES_TABLE was introduced
that signals that the firmware PE/COFF loader supports splitting
code and data sections of PE/COFF images into separate EFI
memory map entries. This allows the kernel to map those regions
with strict memory protections, e.g. EFI_MEMORY_RO for code,
EFI_MEMORY_XP for data, etc.

Unfortunately, an unwritten requirement of this new feature is
that the regions need to be mapped with the same offsets
relative to each other as observed in the EFI memory map. If
this is not done crashes like this may occur,

  BUG: unable to handle kernel paging request at fffffffefe6086dd
  IP: [<fffffffefe6086dd>] 0xfffffffefe6086dd
  Call Trace:
   [<ffffffff8104c90e>] efi_call+0x7e/0x100
   [<ffffffff81602091>] ? virt_efi_set_variable+0x61/0x90
   [<ffffffff8104c583>] efi_delete_dummy_variable+0x63/0x70
   [<ffffffff81f4e4aa>] efi_enter_virtual_mode+0x383/0x392
   [<ffffffff81f37e1b>] start_kernel+0x38a/0x417
   [<ffffffff81f37495>] x86_64_start_reservations+0x2a/0x2c
   [<ffffffff81f37582>] x86_64_start_kernel+0xeb/0xef

Here 0xfffffffefe6086dd refers to an address the firmware
expects to be mapped but which the OS never claimed was mapped.
The issue is that included in these regions are relative
addresses to other regions which were emitted by the firmware
toolchain before the "splitting" of sections occurred at
runtime.

Needless to say, we don't satisfy this unwritten requirement on
x86_64 and instead map the EFI memory map entries in reverse
order. The above crash is almost certainly triggerable with any
kernel newer than v3.13 because that's when we rewrote the EFI
runtime region mapping code, in commit d2f7cbe7b26a ("x86/efi:
Runtime services virtual mapping"). For kernel versions before
v3.13 things may work by pure luck depending on the
fragmentation of the kernel virtual address space at the time we
map the EFI regions.

Instead of mapping the EFI memory map entries in reverse order,
where entry N has a higher virtual address than entry N+1, map
them in the same order as they appear in the EFI memory map to
preserve this relative offset between regions.

This patch has been kept as small as possible with the intention
that it should be applied aggressively to stable and
distribution kernels. It is very much a bugfix rather than
support for a new feature, since when EFI_PROPERTIES_TABLE is
enabled we must map things as outlined above to even boot - we
have no way of asking the firmware not to split the code/data
regions.

In fact, this patch doesn't even make use of the more strict
memory protections available in UEFI v2.5. That will come later.

Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Chun-Yi <jlee@suse.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: James Bottomley <JBottomley@Odin.com>
Cc: Lee, Chun-Yi <jlee@suse.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Jones <pjones@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/1443218539-7610-2-git-send-email-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/x86/platform/efi/efi.c | 67 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 66 insertions(+), 1 deletion(-)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 53a324606d11..5bbb477f5c2a 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -968,6 +968,70 @@ out:
 }
 
 /*
+ * Iterate the EFI memory map in reverse order because the regions
+ * will be mapped top-down. The end result is the same as if we had
+ * mapped things forward, but doesn't require us to change the
+ * existing implementation of efi_map_region().
+ */
+static inline void *efi_map_next_entry_reverse(void *entry)
+{
+	/* Initial call */
+	if (!entry)
+		return memmap.map_end - memmap.desc_size;
+
+	entry -= memmap.desc_size;
+	if (entry < memmap.map)
+		return NULL;
+
+	return entry;
+}
+
+/*
+ * efi_map_next_entry - Return the next EFI memory map descriptor
+ * @entry: Previous EFI memory map descriptor
+ *
+ * This is a helper function to iterate over the EFI memory map, which
+ * we do in different orders depending on the current configuration.
+ *
+ * To begin traversing the memory map @entry must be %NULL.
+ *
+ * Returns %NULL when we reach the end of the memory map.
+ */
+static void *efi_map_next_entry(void *entry)
+{
+	if (!efi_enabled(EFI_OLD_MEMMAP) && efi_enabled(EFI_64BIT)) {
+		/*
+		 * Starting in UEFI v2.5 the EFI_PROPERTIES_TABLE
+		 * config table feature requires us to map all entries
+		 * in the same order as they appear in the EFI memory
+		 * map. That is to say, entry N must have a lower
+		 * virtual address than entry N+1. This is because the
+		 * firmware toolchain leaves relative references in
+		 * the code/data sections, which are split and become
+		 * separate EFI memory regions. Mapping things
+		 * out-of-order leads to the firmware accessing
+		 * unmapped addresses.
+		 *
+		 * Since we need to map things this way whether or not
+		 * the kernel actually makes use of
+		 * EFI_PROPERTIES_TABLE, let's just switch to this
+		 * scheme by default for 64-bit.
+		 */
+		return efi_map_next_entry_reverse(entry);
+	}
+
+	/* Initial call */
+	if (!entry)
+		return memmap.map;
+
+	entry += memmap.desc_size;
+	if (entry >= memmap.map_end)
+		return NULL;
+
+	return entry;
+}
+
+/*
  * Map the efi memory ranges of the runtime services and update new_mmap with
  * virtual addresses.
  */
@@ -977,7 +1041,8 @@ static void * __init efi_map_regions(int *count, int *pg_shift)
 	unsigned long left = 0;
 	efi_memory_desc_t *md;
 
-	for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
+	p = NULL;
+	while ((p = efi_map_next_entry(p))) {
 		md = p;
 		if (!(md->attribute & EFI_MEMORY_RUNTIME)) {
 #ifdef CONFIG_X86_64

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 081/104] Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (79 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 080/104] x86/efi: Fix boot crash by mapping EFI memmap entries bottom-up at runtime, instead of top-down Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 082/104] mm: hugetlbfs: skip shared VMAs when unmapping private pages to satisfy a fault Luis Henriques
                   ` (27 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Dirk Mueller, Paolo Bonzini, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: =?UTF-8?q?Dirk=20M=C3=BCller?= <dmueller@suse.com>

commit d2922422c48df93f3edff7d872ee4f3191fefb08 upstream.

The cpu feature flags are not ever going to change, so warning
everytime can cause a lot of kernel log spam
(in our case more than 10GB/hour).

The warning seems to only occur when nested virtualization is
enabled, so it's probably triggered by a KVM bug.  This is a
sensible and safe change anyway, and the KVM bug fix might not
be suitable for stable releases anyway.

Signed-off-by: Dirk Mueller <dmueller@suse.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/x86/kvm/svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 37e85d0a1940..539f233965f1 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -512,7 +512,7 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
 	struct vcpu_svm *svm = to_svm(vcpu);
 
 	if (svm->vmcb->control.next_rip != 0) {
-		WARN_ON(!static_cpu_has(X86_FEATURE_NRIPS));
+		WARN_ON_ONCE(!static_cpu_has(X86_FEATURE_NRIPS));
 		svm->next_rip = svm->vmcb->control.next_rip;
 	}
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 082/104] mm: hugetlbfs: skip shared VMAs when unmapping private pages to satisfy a fault
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (80 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 081/104] Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 083/104] x86/mm: Set NX on gap between __ex_table and rodata Luis Henriques
                   ` (26 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mel Gorman, Andrea Arcangeli, Hugh Dickins, Naoya Horiguchi,
	David Rientjes, Andrew Morton, Linus Torvalds, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mel Gorman <mgorman@techsingularity.net>

commit 2f84a8990ebbe235c59716896e017c6b2ca1200f upstream.

SunDong reported the following on

  https://bugzilla.kernel.org/show_bug.cgi?id=103841

	I think I find a linux bug, I have the test cases is constructed. I
	can stable recurring problems in fedora22(4.0.4) kernel version,
	arch for x86_64.  I construct transparent huge page, when the parent
	and child process with MAP_SHARE, MAP_PRIVATE way to access the same
	huge page area, it has the opportunity to lead to huge page copy on
	write failure, and then it will munmap the child corresponding mmap
	area, but then the child mmap area with VM_MAYSHARE attributes, child
	process munmap this area can trigger VM_BUG_ON in set_vma_resv_flags
	functions (vma - > vm_flags & VM_MAYSHARE).

There were a number of problems with the report (e.g.  it's hugetlbfs that
triggers this, not transparent huge pages) but it was fundamentally
correct in that a VM_BUG_ON in set_vma_resv_flags() can be triggered that
looks like this

	 vma ffff8804651fd0d0 start 00007fc474e00000 end 00007fc475e00000
	 next ffff8804651fd018 prev ffff8804651fd188 mm ffff88046b1b1800
	 prot 8000000000000027 anon_vma           (null) vm_ops ffffffff8182a7a0
	 pgoff 0 file ffff88106bdb9800 private_data           (null)
	 flags: 0x84400fb(read|write|shared|mayread|maywrite|mayexec|mayshare|dontexpand|hugetlb)
	 ------------
	 kernel BUG at mm/hugetlb.c:462!
	 SMP
	 Modules linked in: xt_pkttype xt_LOG xt_limit [..]
	 CPU: 38 PID: 26839 Comm: map Not tainted 4.0.4-default #1
	 Hardware name: Dell Inc. PowerEdge R810/0TT6JF, BIOS 2.7.4 04/26/2012
	 set_vma_resv_flags+0x2d/0x30

The VM_BUG_ON is correct because private and shared mappings have
different reservation accounting but the warning clearly shows that the
VMA is shared.

When a private COW fails to allocate a new page then only the process
that created the VMA gets the page -- all the children unmap the page.
If the children access that data in the future then they get killed.

The problem is that the same file is mapped shared and private.  During
the COW, the allocation fails, the VMAs are traversed to unmap the other
private pages but a shared VMA is found and the bug is triggered.  This
patch identifies such VMAs and skips them.

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
Reported-by: SunDong <sund_sky@126.com>
Reviewed-by: Michal Hocko <mhocko@suse.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: David Rientjes <rientjes@google.com>
Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 mm/hugetlb.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 94add6da0fad..f3111955b701 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2790,6 +2790,14 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
 			continue;
 
 		/*
+		 * Shared VMAs have their own reserves and do not affect
+		 * MAP_PRIVATE accounting but it is possible that a shared
+		 * VMA is using the same page so check and skip such VMAs.
+		 */
+		if (iter_vma->vm_flags & VM_MAYSHARE)
+			continue;
+
+		/*
 		 * Unmap the page from other VMAs without their own reserves.
 		 * They get marked to be SIGKILLed if they fault in these
 		 * areas. This is because a future no-page fault on this VMA

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 083/104] x86/mm: Set NX on gap between __ex_table and rodata
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (81 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 082/104] mm: hugetlbfs: skip shared VMAs when unmapping private pages to satisfy a fault Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 084/104] clocksource: Fix abs() usage w/ 64bit values Luis Henriques
                   ` (25 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Stephen Smalley, Linus Torvalds, Mike Galbraith, Peter Zijlstra,
	Thomas Gleixner, Ingo Molnar, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Stephen Smalley <sds@tycho.nsa.gov>

commit ab76f7b4ab2397ffdd2f1eb07c55697d19991d10 upstream.

Unused space between the end of __ex_table and the start of
rodata can be left W+x in the kernel page tables.  Extend the
setting of the NX bit to cover this gap by starting from
text_end rather than rodata_start.

  Before:
  ---[ High Kernel Mapping ]---
  0xffffffff80000000-0xffffffff81000000          16M                               pmd
  0xffffffff81000000-0xffffffff81600000           6M     ro         PSE     GLB x  pmd
  0xffffffff81600000-0xffffffff81754000        1360K     ro                 GLB x  pte
  0xffffffff81754000-0xffffffff81800000         688K     RW                 GLB x  pte
  0xffffffff81800000-0xffffffff81a00000           2M     ro         PSE     GLB NX pmd
  0xffffffff81a00000-0xffffffff81b3b000        1260K     ro                 GLB NX pte
  0xffffffff81b3b000-0xffffffff82000000        4884K     RW                 GLB NX pte
  0xffffffff82000000-0xffffffff82200000           2M     RW         PSE     GLB NX pmd
  0xffffffff82200000-0xffffffffa0000000         478M                               pmd

  After:
  ---[ High Kernel Mapping ]---
  0xffffffff80000000-0xffffffff81000000          16M                               pmd
  0xffffffff81000000-0xffffffff81600000           6M     ro         PSE     GLB x  pmd
  0xffffffff81600000-0xffffffff81754000        1360K     ro                 GLB x  pte
  0xffffffff81754000-0xffffffff81800000         688K     RW                 GLB NX pte
  0xffffffff81800000-0xffffffff81a00000           2M     ro         PSE     GLB NX pmd
  0xffffffff81a00000-0xffffffff81b3b000        1260K     ro                 GLB NX pte
  0xffffffff81b3b000-0xffffffff82000000        4884K     RW                 GLB NX pte
  0xffffffff82000000-0xffffffff82200000           2M     RW         PSE     GLB NX pmd
  0xffffffff82200000-0xffffffffa0000000         478M                               pmd

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/1443704662-3138-1-git-send-email-sds@tycho.nsa.gov
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/x86/mm/init_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 5146f4652092..12e5ac7885f8 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1131,7 +1131,7 @@ void mark_rodata_ro(void)
 	 * has been zapped already via cleanup_highmem().
 	 */
 	all_end = roundup((unsigned long)_brk_end, PMD_SIZE);
-	set_memory_nx(rodata_start, (all_end - rodata_start) >> PAGE_SHIFT);
+	set_memory_nx(text_end, (all_end - text_end) >> PAGE_SHIFT);
 
 	rodata_test();
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 084/104] clocksource: Fix abs() usage w/ 64bit values
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (82 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 083/104] x86/mm: Set NX on gap between __ex_table and rodata Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 085/104] dmaengine: dw: properly read DWC_PARAMS register Luis Henriques
                   ` (24 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: John Stultz, Prarit Bhargava, Richard Cochran, Ingo Molnar,
	Thomas Gleixner, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: John Stultz <john.stultz@linaro.org>

commit 67dfae0cd72fec5cd158b6e5fb1647b7dbe0834c upstream.

This patch fixes one cases where abs() was being used with 64-bit
nanosecond values, where the result may be capped at 32-bits.

This potentially could cause watchdog false negatives on 32-bit
systems, so this patch addresses the issue by using abs64().

Signed-off-by: John Stultz <john.stultz@linaro.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1442279124-7309-2-git-send-email-john.stultz@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 kernel/time/clocksource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index ba3e502c955a..64ebaca04fc9 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -294,7 +294,7 @@ static void clocksource_watchdog(unsigned long data)
 			continue;
 
 		/* Check the deviation from the watchdog clocksource. */
-		if ((abs(cs_nsec - wd_nsec) > WATCHDOG_THRESHOLD)) {
+		if (abs64(cs_nsec - wd_nsec) > WATCHDOG_THRESHOLD) {
 			clocksource_unstable(cs, cs_nsec - wd_nsec);
 			continue;
 		}

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 085/104] dmaengine: dw: properly read DWC_PARAMS register
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (83 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 084/104] clocksource: Fix abs() usage w/ 64bit values Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 086/104] mm/slab: fix unexpected index mapping result of kmalloc_size(INDEX_NODE+1) Luis Henriques
                   ` (23 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: yitian.bu, Andy Shevchenko, Vinod Koul, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

commit 6bea0f6d1c47b07be88dfd93f013ae05fcb3d8bf upstream.

In case we have less than maximum allowed channels (8) and autoconfiguration is
enabled the DWC_PARAMS read is wrong because it uses different arithmetic to
what is needed for channel priority setup.

Re-do the caclulations properly. This now works on AVR32 board well.

Fixes: fed2574b3c9f (dw_dmac: introduce software emulation of LLP transfers)
Cc: yitian.bu@tangramtek.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/dma/dw/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index 525b4654bd90..a1315dd54514 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -1573,7 +1573,6 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
 	INIT_LIST_HEAD(&dw->dma.channels);
 	for (i = 0; i < nr_channels; i++) {
 		struct dw_dma_chan	*dwc = &dw->chan[i];
-		int			r = nr_channels - i - 1;
 
 		dwc->chan.device = &dw->dma;
 		dma_cookie_init(&dwc->chan);
@@ -1585,7 +1584,7 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
 
 		/* 7 is highest priority & 0 is lowest. */
 		if (pdata->chan_priority == CHAN_PRIORITY_ASCENDING)
-			dwc->priority = r;
+			dwc->priority = nr_channels - i - 1;
 		else
 			dwc->priority = i;
 
@@ -1605,6 +1604,7 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
 		/* Hardware configuration */
 		if (autocfg) {
 			unsigned int dwc_params;
+			unsigned int r = DW_DMA_MAX_NR_CHANNELS - i - 1;
 			void __iomem *addr = chip->regs + r * sizeof(u32);
 
 			dwc_params = dma_read_byaddr(addr, DWC_PARAMS);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 086/104] mm/slab: fix unexpected index mapping result of kmalloc_size(INDEX_NODE+1)
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (84 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 085/104] dmaengine: dw: properly read DWC_PARAMS register Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 087/104] drm/vmwgfx: Fix kernel NULL pointer dereference on older hardware Luis Henriques
                   ` (22 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Joonsoo Kim, Pekka Enberg, David Rientjes, Andrew Morton,
	Linus Torvalds, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Joonsoo Kim <js1304@gmail.com>

commit 03a2d2a3eafe4015412cf4e9675ca0e2d9204074 upstream.

Commit description is copied from the original post of this bug:

  http://comments.gmane.org/gmane.linux.kernel.mm/135349

Kernels after v3.9 use kmalloc_size(INDEX_NODE + 1) to get the next
larger cache size than the size index INDEX_NODE mapping.  In kernels
3.9 and earlier we used malloc_sizes[INDEX_L3 + 1].cs_size.

However, sometimes we can't get the right output we expected via
kmalloc_size(INDEX_NODE + 1), causing a BUG().

The mapping table in the latest kernel is like:
    index = {0,   1,  2 ,  3,  4,   5,   6,   n}
     size = {0,   96, 192, 8, 16,  32,  64,   2^n}
The mapping table before 3.10 is like this:
    index = {0 , 1 , 2,   3,  4 ,  5 ,  6,   n}
    size  = {32, 64, 96, 128, 192, 256, 512, 2^(n+3)}

The problem on my mips64 machine is as follows:

(1) When configured DEBUG_SLAB && DEBUG_PAGEALLOC && DEBUG_LOCK_ALLOC
    && DEBUG_SPINLOCK, the sizeof(struct kmem_cache_node) will be "150",
    and the macro INDEX_NODE turns out to be "2": #define INDEX_NODE
    kmalloc_index(sizeof(struct kmem_cache_node))

(2) Then the result of kmalloc_size(INDEX_NODE + 1) is 8.

(3) Then "if(size >= kmalloc_size(INDEX_NODE + 1)" will lead to "size
    = PAGE_SIZE".

(4) Then "if ((size >= (PAGE_SIZE >> 3))" test will be satisfied and
    "flags |= CFLGS_OFF_SLAB" will be covered.

(5) if (flags & CFLGS_OFF_SLAB)" test will be satisfied and will go to
    "cachep->slabp_cache = kmalloc_slab(slab_size, 0u)", and the result
    here may be NULL while kernel bootup.

(6) Finally,"BUG_ON(ZERO_OR_NULL_PTR(cachep->slabp_cache));" causes the
    BUG info as the following shows (may be only mips64 has this problem):

This patch fixes the problem of kmalloc_size(INDEX_NODE + 1) and removes
the BUG by adding 'size >= 256' check to guarantee that all necessary
small sized slabs are initialized regardless sequence of slab size in
mapping table.

Fixes: e33660165c90 ("slab: Use common kmalloc_index/kmalloc_size...")
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Reported-by: Liuhailong <liu.hailong6@zte.com.cn>
Acked-by: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 mm/slab.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 92dbea7e7132..9a8dc5470e5e 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2306,9 +2306,16 @@ __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags)
 			size += BYTES_PER_WORD;
 	}
 #if FORCED_DEBUG && defined(CONFIG_DEBUG_PAGEALLOC)
-	if (size >= kmalloc_size(INDEX_NODE + 1)
-	    && cachep->object_size > cache_line_size()
-	    && ALIGN(size, cachep->align) < PAGE_SIZE) {
+	/*
+	 * To activate debug pagealloc, off-slab management is necessary
+	 * requirement. In early phase of initialization, small sized slab
+	 * doesn't get initialized so it would not be possible. So, we need
+	 * to check size >= 256. It guarantees that all necessary small
+	 * sized slab is initialized in current slab initialization sequence.
+	 */
+	if (!slab_early_init && size >= kmalloc_size(INDEX_NODE) &&
+		size >= 256 && cachep->object_size > cache_line_size() &&
+		ALIGN(size, cachep->align) < PAGE_SIZE) {
 		cachep->obj_offset += PAGE_SIZE - ALIGN(size, cachep->align);
 		size = PAGE_SIZE;
 	}

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 087/104] drm/vmwgfx: Fix kernel NULL pointer dereference on older hardware
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (85 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 086/104] mm/slab: fix unexpected index mapping result of kmalloc_size(INDEX_NODE+1) Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 088/104] fs: if a coredump already exists, unlink and recreate with O_EXCL Luis Henriques
                   ` (21 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Thomas Hellstrom, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Thomas Hellstrom <thellstrom@vmware.com>

commit ed7d78b2da32198ca4c70172e3b63c6b3e2c570b upstream.

The commit "drm/vmwgfx: Fix up user_dmabuf refcounting", while fixing a
kernel crash introduced a NULL pointer dereference on older hardware.
Fix this.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index 9e190db6cc37..17a4107639b2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -653,7 +653,8 @@ static void vmw_user_surface_base_release(struct ttm_base_object **p_base)
 	struct vmw_resource *res = &user_srf->srf.res;
 
 	*p_base = NULL;
-	ttm_base_object_unref(&user_srf->backup_base);
+	if (user_srf->backup_base)
+		ttm_base_object_unref(&user_srf->backup_base);
 	vmw_resource_unreference(&res);
 }
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 088/104] fs: if a coredump already exists, unlink and recreate with O_EXCL
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (86 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 087/104] drm/vmwgfx: Fix kernel NULL pointer dereference on older hardware Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 089/104] sctp: donot reset the overall_error_count in SHUTDOWN_RECEIVE state Luis Henriques
                   ` (20 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Jann Horn, Kees Cook, Al Viro, Andrew Morton, Linus Torvalds,
	Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jann Horn <jann@thejh.net>

commit fbb1816942c04429e85dbf4c1a080accc534299e upstream.

It was possible for an attacking user to trick root (or another user) into
writing his coredumps into an attacker-readable, pre-existing file using
rename() or link(), causing the disclosure of secret data from the victim
process' virtual memory.  Depending on the configuration, it was also
possible to trick root into overwriting system files with coredumps.  Fix
that issue by never writing coredumps into existing files.

Requirements for the attack:
 - The attack only applies if the victim's process has a nonzero
   RLIMIT_CORE and is dumpable.
 - The attacker can trick the victim into coredumping into an
   attacker-writable directory D, either because the core_pattern is
   relative and the victim's cwd is attacker-writable or because an
   absolute core_pattern pointing to a world-writable directory is used.
 - The attacker has one of these:
  A: on a system with protected_hardlinks=0:
     execute access to a folder containing a victim-owned,
     attacker-readable file on the same partition as D, and the
     victim-owned file will be deleted before the main part of the attack
     takes place. (In practice, there are lots of files that fulfill
     this condition, e.g. entries in Debian's /var/lib/dpkg/info/.)
     This does not apply to most Linux systems because most distros set
     protected_hardlinks=1.
  B: on a system with protected_hardlinks=1:
     execute access to a folder containing a victim-owned,
     attacker-readable and attacker-writable file on the same partition
     as D, and the victim-owned file will be deleted before the main part
     of the attack takes place.
     (This seems to be uncommon.)
  C: on any system, independent of protected_hardlinks:
     write access to a non-sticky folder containing a victim-owned,
     attacker-readable file on the same partition as D
     (This seems to be uncommon.)

The basic idea is that the attacker moves the victim-owned file to where
he expects the victim process to dump its core.  The victim process dumps
its core into the existing file, and the attacker reads the coredump from
it.

If the attacker can't move the file because he does not have write access
to the containing directory, he can instead link the file to a directory
he controls, then wait for the original link to the file to be deleted
(because the kernel checks that the link count of the corefile is 1).

A less reliable variant that requires D to be non-sticky works with link()
and does not require deletion of the original link: link() the file into
D, but then unlink() it directly before the kernel performs the link count
check.

On systems with protected_hardlinks=0, this variant allows an attacker to
not only gain information from coredumps, but also clobber existing,
victim-writable files with coredumps.  (This could theoretically lead to a
privilege escalation.)

Signed-off-by: Jann Horn <jann@thejh.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 fs/coredump.c | 38 ++++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)

diff --git a/fs/coredump.c b/fs/coredump.c
index a93f7e6ea4cf..72f97a56966f 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -498,10 +498,10 @@ void do_coredump(const siginfo_t *siginfo)
 	const struct cred *old_cred;
 	struct cred *cred;
 	int retval = 0;
-	int flag = 0;
 	int ispipe;
 	struct files_struct *displaced;
-	bool need_nonrelative = false;
+	/* require nonrelative corefile path and be extra careful */
+	bool need_suid_safe = false;
 	bool core_dumped = false;
 	static atomic_t core_dump_count = ATOMIC_INIT(0);
 	struct coredump_params cprm = {
@@ -535,9 +535,8 @@ void do_coredump(const siginfo_t *siginfo)
 	 */
 	if (__get_dumpable(cprm.mm_flags) == SUID_DUMP_ROOT) {
 		/* Setuid core dump mode */
-		flag = O_EXCL;		/* Stop rewrite attacks */
 		cred->fsuid = GLOBAL_ROOT_UID;	/* Dump root private */
-		need_nonrelative = true;
+		need_suid_safe = true;
 	}
 
 	retval = coredump_wait(siginfo->si_signo, &core_state);
@@ -618,7 +617,7 @@ void do_coredump(const siginfo_t *siginfo)
 		if (cprm.limit < binfmt->min_coredump)
 			goto fail_unlock;
 
-		if (need_nonrelative && cn.corename[0] != '/') {
+		if (need_suid_safe && cn.corename[0] != '/') {
 			printk(KERN_WARNING "Pid %d(%s) can only dump core "\
 				"to fully qualified path!\n",
 				task_tgid_vnr(current), current->comm);
@@ -626,8 +625,35 @@ void do_coredump(const siginfo_t *siginfo)
 			goto fail_unlock;
 		}
 
+		/*
+		 * Unlink the file if it exists unless this is a SUID
+		 * binary - in that case, we're running around with root
+		 * privs and don't want to unlink another user's coredump.
+		 */
+		if (!need_suid_safe) {
+			mm_segment_t old_fs;
+
+			old_fs = get_fs();
+			set_fs(KERNEL_DS);
+			/*
+			 * If it doesn't exist, that's fine. If there's some
+			 * other problem, we'll catch it at the filp_open().
+			 */
+			(void) sys_unlink((const char __user *)cn.corename);
+			set_fs(old_fs);
+		}
+
+		/*
+		 * There is a race between unlinking and creating the
+		 * file, but if that causes an EEXIST here, that's
+		 * fine - another process raced with us while creating
+		 * the corefile, and the other process won. To userspace,
+		 * what matters is that at least one of the two processes
+		 * writes its coredump successfully, not which one.
+		 */
 		cprm.file = filp_open(cn.corename,
-				 O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
+				 O_CREAT | 2 | O_NOFOLLOW |
+				 O_LARGEFILE | O_EXCL,
 				 0600);
 		if (IS_ERR(cprm.file))
 			goto fail_unlock;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 089/104] sctp: donot reset the overall_error_count in SHUTDOWN_RECEIVE state
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (87 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 088/104] fs: if a coredump already exists, unlink and recreate with O_EXCL Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 090/104] ipc/sem.c: fully initialize sem_array before making it visible Luis Henriques
                   ` (19 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Xin Long, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: lucien <lucien.xin@gmail.com>

commit f648f807f61e64d247d26611e34cc97e4ed03401 upstream.

Commit f8d960524328 ("sctp: Enforce retransmission limit during shutdown")
fixed a problem with excessive retransmissions in the SHUTDOWN_PENDING by not
resetting the association overall_error_count.  This allowed the association
to better enforce assoc.max_retrans limit.

However, the same issue still exists when the association is in SHUTDOWN_RECEIVED
state.  In this state, HB-ACKs will continue to reset the overall_error_count
for the association would extend the lifetime of association unnecessarily.

This patch solves this by resetting the overall_error_count whenever the current
state is small then SCTP_STATE_SHUTDOWN_PENDING.  As a small side-effect, we
end up also handling SCTP_STATE_SHUTDOWN_ACK_SENT and SCTP_STATE_SHUTDOWN_SENT
states, but they are not really impacted because we disable Heartbeats in those
states.

Fixes: Commit f8d960524328 ("sctp: Enforce retransmission limit during shutdown")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 net/sctp/sm_sideeffect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index fef2acdf4a2e..85e6f03aeb70 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -702,7 +702,7 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds,
 	 * outstanding data and rely on the retransmission limit be reached
 	 * to shutdown the association.
 	 */
-	if (t->asoc->state != SCTP_STATE_SHUTDOWN_PENDING)
+	if (t->asoc->state < SCTP_STATE_SHUTDOWN_PENDING)
 		t->asoc->overall_error_count = 0;
 
 	/* Clear the hb_sent flag to signal that we had a good

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 090/104] ipc/sem.c: fully initialize sem_array before making it visible
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (88 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 089/104] sctp: donot reset the overall_error_count in SHUTDOWN_RECEIVE state Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 091/104] drivers: usb :fsl: Implement Workaround for USB Erratum A007792 Luis Henriques
                   ` (18 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Manfred Spraul, Andrew Morton, Linus Torvalds, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Manfred Spraul <manfred@colorfullife.com>

commit e8577d1f0329d4842e8302e289fb2c22156abef4 upstream.

ipc_addid() makes a new ipc identifier visible to everyone.  New objects
start as locked, so that the caller can complete the initialization
after the call.  Within struct sem_array, at least sma->sem_base and
sma->sem_nsems are accessed without any locks, therefore this approach
doesn't work.

Thus: Move the ipc_addid() to the end of the initialization.

Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Reported-by: Rik van Riel <riel@redhat.com>
Acked-by: Rik van Riel <riel@redhat.com>
Acked-by: Davidlohr Bueso <dave@stgolabs.net>
Acked-by: Rafael Aquini <aquini@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 ipc/sem.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/ipc/sem.c b/ipc/sem.c
index 0e6504c9e907..541cb0ff9bd6 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -524,13 +524,6 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params)
 		return retval;
 	}
 
-	id = ipc_addid(&sem_ids(ns), &sma->sem_perm, ns->sc_semmni);
-	if (id < 0) {
-		ipc_rcu_putref(sma, sem_rcu_free);
-		return id;
-	}
-	ns->used_sems += nsems;
-
 	sma->sem_base = (struct sem *) &sma[1];
 
 	for (i = 0; i < nsems; i++) {
@@ -545,6 +538,14 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params)
 	INIT_LIST_HEAD(&sma->list_id);
 	sma->sem_nsems = nsems;
 	sma->sem_ctime = get_seconds();
+
+	id = ipc_addid(&sem_ids(ns), &sma->sem_perm, ns->sc_semmni);
+	if (id < 0) {
+		ipc_rcu_putref(sma, sem_rcu_free);
+		return id;
+	}
+	ns->used_sems += nsems;
+
 	sem_unlock(sma, -1);
 	rcu_read_unlock();
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 091/104] drivers: usb :fsl: Implement Workaround for USB Erratum A007792
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (89 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 090/104] ipc/sem.c: fully initialize sem_array before making it visible Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 092/104] drivers: usb: fsl: Workaround for USB erratum-A005275 Luis Henriques
                   ` (17 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Nikhil Badola, Suresh Gupta, Greg Kroah-Hartman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nikhil Badola <nikhil.badola@freescale.com>

commit 523f1dec58408b36e7683a3d61a0286eed1fc1c8 upstream.

USB controller version-2.5 requires to enable internal UTMI
phy and program PTS field in PORTSC register before asserting
controller reset. This is must for successful resetting of the
controller and subsequent enumeration of usb devices

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
Signed-off-by: Suresh Gupta <suresh.gupta@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/usb/host/ehci-fsl.c      | 9 +++++++++
 drivers/usb/host/fsl-mph-dr-of.c | 6 ++++++
 include/linux/fsl_devices.h      | 1 +
 3 files changed, 16 insertions(+)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index cf2734b532a7..c412c4f35007 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -125,6 +125,15 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
 	if (pdata->have_sysif_regs && pdata->controller_ver < FSL_USB_VER_1_6)
 		setbits32(hcd->regs + FSL_SOC_USB_CTRL, 0x4);
 
+	/*
+	 * Enable UTMI phy and program PTS field in UTMI mode before asserting
+	 * controller reset for USB Controller version 2.5
+	 */
+	if (pdata->has_fsl_erratum_a007792) {
+		writel_be(CTRL_UTMI_PHY_EN, hcd->regs + FSL_SOC_USB_CTRL);
+		writel(PORT_PTS_UTMI, hcd->regs + FSL_SOC_USB_PORTSC1);
+	}
+
 	/* Don't need to set host mode here. It will be done by tdi_reset() */
 
 	retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 9162d1b6c0a3..4d03afb7cf4a 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -206,6 +206,12 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
 	pdata->phy_mode = determine_usb_phy(prop);
 	pdata->controller_ver = usb_get_ver_info(np);
 
+	/* Activate Erratum by reading property in device tree */
+	if (of_get_property(np, "fsl,usb-erratum-a007792", NULL))
+		pdata->has_fsl_erratum_a007792 = 1;
+	else
+		pdata->has_fsl_erratum_a007792 = 0;
+
 	if (pdata->have_sysif_regs) {
 		if (pdata->controller_ver < 0) {
 			dev_warn(&ofdev->dev, "Could not get controller version\n");
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index a82296af413f..0f17316ce420 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -92,6 +92,7 @@ struct fsl_usb2_platform_data {
 
 	unsigned	suspended:1;
 	unsigned	already_suspended:1;
+	unsigned        has_fsl_erratum_a007792:1;
 
 	/* register save area for suspend/resume */
 	u32		pm_command;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 092/104] drivers: usb: fsl: Workaround for USB erratum-A005275
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (90 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 091/104] drivers: usb :fsl: Implement Workaround for USB Erratum A007792 Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 093/104] l2tp: protect tunnel->del_work by ref_count Luis Henriques
                   ` (16 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Ramneek Mehresh, Nikhil Badola, Greg Kroah-Hartman, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nikhil Badola <nikhil.badola@freescale.com>

commit f8786a91548df6930643a052e40e5c0b7a8403a5 upstream.

Incoming packets in high speed are randomly corrupted by h/w
resulting in multiple errors. This workaround makes FS as
default mode in all affected socs by disabling HS chirp
signalling.This errata does not affect FS and LS mode.

Forces all HS devices to connect in FS mode for all socs
affected by this erratum:
P3041 and P2041 rev 1.0 and 1.1
P5020 and P5010 rev 1.0 and 2.0
P5040, P1010 and T4240 rev 1.0

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/usb/host/ehci-fsl.c      |  4 ++++
 drivers/usb/host/ehci-hub.c      |  7 +++++++
 drivers/usb/host/ehci.h          | 12 ++++++++++++
 drivers/usb/host/fsl-mph-dr-of.c |  4 ++++
 include/linux/fsl_devices.h      |  1 +
 5 files changed, 28 insertions(+)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index c412c4f35007..0b5b95e350dc 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -298,6 +298,10 @@ static int ehci_fsl_usb_setup(struct ehci_hcd *ehci)
 		out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x80000000 | SNOOP_SIZE_2GB);
 	}
 
+	/* Deal with USB erratum A-005275 */
+	if (pdata->has_fsl_erratum_a005275 == 1)
+		ehci->has_fsl_hs_errata = 1;
+
 	if ((pdata->operating_mode == FSL_USB2_DR_HOST) ||
 			(pdata->operating_mode == FSL_USB2_DR_OTG))
 		if (ehci_fsl_setup_phy(hcd, pdata->phy_mode, 0))
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 837a1edd33e2..f82bc5cded08 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -1218,6 +1218,13 @@ int ehci_hub_control(
 				 */
 				ehci->reset_done [wIndex] = jiffies
 						+ msecs_to_jiffies (50);
+
+				/*
+				 * Force full-speed connect for FSL high-speed
+				 * erratum; disable HS Chirp by setting PFSC bit
+				 */
+				if (ehci_has_fsl_hs_errata(ehci))
+					temp |= (1 << PORTSC_FSL_PFSC);
 			}
 			ehci_writel(ehci, temp, status_reg);
 			break;
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index eee228a26a0e..1c57b4a148e4 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -215,6 +215,7 @@ struct ehci_hcd {			/* one per controller */
 	/* SILICON QUIRKS */
 	unsigned		no_selective_suspend:1;
 	unsigned		has_fsl_port_bug:1; /* FreeScale */
+	unsigned		has_fsl_hs_errata:1;	/* Freescale HS quirk */
 	unsigned		big_endian_mmio:1;
 	unsigned		big_endian_desc:1;
 	unsigned		big_endian_capbase:1;
@@ -686,6 +687,17 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc)
 #define	ehci_has_fsl_portno_bug(e)		(0)
 #endif
 
+#define PORTSC_FSL_PFSC	24	/* Port Force Full-Speed Connect */
+
+#if defined(CONFIG_PPC_85xx)
+/* Some Freescale processors have an erratum (USB A-005275) in which
+ * incoming packets get corrupted in HS mode
+ */
+#define ehci_has_fsl_hs_errata(e)	((e)->has_fsl_hs_errata)
+#else
+#define ehci_has_fsl_hs_errata(e)	(0)
+#endif
+
 /*
  * While most USB host controllers implement their registers in
  * little-endian format, a minority (celleb companion chip) implement
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 4d03afb7cf4a..21dcdc8f95c2 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -211,6 +211,10 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
 		pdata->has_fsl_erratum_a007792 = 1;
 	else
 		pdata->has_fsl_erratum_a007792 = 0;
+	if (of_get_property(np, "fsl,usb-erratum-a005275", NULL))
+		pdata->has_fsl_erratum_a005275 = 1;
+	else
+		pdata->has_fsl_erratum_a005275 = 0;
 
 	if (pdata->have_sysif_regs) {
 		if (pdata->controller_ver < 0) {
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index 0f17316ce420..f7103ba6e509 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -93,6 +93,7 @@ struct fsl_usb2_platform_data {
 	unsigned	suspended:1;
 	unsigned	already_suspended:1;
 	unsigned        has_fsl_erratum_a007792:1;
+	unsigned        has_fsl_erratum_a005275:1;
 
 	/* register save area for suspend/resume */
 	u32		pm_command;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 093/104] l2tp: protect tunnel->del_work by ref_count
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (91 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 092/104] drivers: usb: fsl: Workaround for USB erratum-A005275 Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 094/104] af_unix: Convert the unix_sk macro to an inline function for type safety Luis Henriques
                   ` (15 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Alexander Couzens, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alexander Couzens <lynxis@fe80.eu>

commit 06a15f51cf3618e32a73871ee6a547ef7fd902b5 upstream.

There is a small chance that tunnel_free() is called before tunnel->del_work scheduled
resulting in a zero pointer dereference.

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
Acked-by: James Chapman <jchapman@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 net/l2tp/l2tp_core.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index bea259043205..0c6a8f18b0fc 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -1318,7 +1318,7 @@ static void l2tp_tunnel_del_work(struct work_struct *work)
 	tunnel = container_of(work, struct l2tp_tunnel, del_work);
 	sk = l2tp_tunnel_sock_lookup(tunnel);
 	if (!sk)
-		return;
+		goto out;
 
 	sock = sk->sk_socket;
 
@@ -1339,6 +1339,8 @@ static void l2tp_tunnel_del_work(struct work_struct *work)
 	}
 
 	l2tp_tunnel_sock_put(sk);
+out:
+	l2tp_tunnel_dec_refcount(tunnel);
 }
 
 /* Create a socket for the tunnel, if one isn't set up by
@@ -1673,8 +1675,13 @@ EXPORT_SYMBOL_GPL(l2tp_tunnel_create);
  */
 int l2tp_tunnel_delete(struct l2tp_tunnel *tunnel)
 {
+	l2tp_tunnel_inc_refcount(tunnel);
 	l2tp_tunnel_closeall(tunnel);
-	return (false == queue_work(l2tp_wq, &tunnel->del_work));
+	if (false == queue_work(l2tp_wq, &tunnel->del_work)) {
+		l2tp_tunnel_dec_refcount(tunnel);
+		return 1;
+	}
+	return 0;
 }
 EXPORT_SYMBOL_GPL(l2tp_tunnel_delete);
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 094/104] af_unix: Convert the unix_sk macro to an inline function for type safety
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (92 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 093/104] l2tp: protect tunnel->del_work by ref_count Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 095/104] af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag Luis Henriques
                   ` (14 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Aaron Conole, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Aaron Conole <aconole@bytheb.org>

commit 4613012db1d911f80897f9446a49de817b2c4c47 upstream.

As suggested by Eric Dumazet this change replaces the
complaints by the compiler when misusing the API.

Signed-off-by: Aaron Conole <aconole@bytheb.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 include/net/af_unix.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index a175ba4a7adb..dfe4ddfbb43c 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -64,7 +64,11 @@ struct unix_sock {
 #define UNIX_GC_MAYBE_CYCLE	1
 	struct socket_wq	peer_wq;
 };
-#define unix_sk(__sk) ((struct unix_sock *)__sk)
+
+static inline struct unix_sock *unix_sk(struct sock *sk)
+{
+	return (struct unix_sock *)sk;
+}
 
 #define peer_wait peer_wq.wait
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 095/104] af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (93 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 094/104] af_unix: Convert the unix_sk macro to an inline function for type safety Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 096/104] net/unix: fix logic about sk_peek_offset Luis Henriques
                   ` (13 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Aaron Conole, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Aaron Conole <aconole@bytheb.org>

commit 9f389e35674f5b086edd70ed524ca0f287259725 upstream.

AF_UNIX sockets now return multiple skbs from recv() when MSG_PEEK flag
is set.

This is referenced in kernel bugzilla #12323 @
https://bugzilla.kernel.org/show_bug.cgi?id=12323

As described both in the BZ and lkml thread @
http://lkml.org/lkml/2008/1/8/444 calling recv() with MSG_PEEK on an
AF_UNIX socket only reads a single skb, where the desired effect is
to return as much skb data has been queued, until hitting the recv
buffer size (whichever comes first).

The modified MSG_PEEK path will now move to the next skb in the tree
and jump to the again: label, rather than following the natural loop
structure. This requires duplicating some of the loop head actions.

This was tested using the python socketpair python code attached to
the bugzilla issue.

Signed-off-by: Aaron Conole <aconole@bytheb.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
[ luis: backported to 3.16: used davem's backport to 3.14 ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 net/unix/af_unix.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 8232118b3f82..30a705ee0ac8 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2070,8 +2070,20 @@ again:
 			if (UNIXCB(skb).fp)
 				siocb->scm->fp = scm_fp_dup(UNIXCB(skb).fp);
 
-			sk_peek_offset_fwd(sk, chunk);
+			if (skip) {
+				sk_peek_offset_fwd(sk, chunk);
+				skip -= chunk;
+			}
+
+			if (UNIXCB(skb).fp)
+				break;
 
+			last = skb;
+			unix_state_lock(sk);
+			skb = skb_peek_next(skb, &sk->sk_receive_queue);
+			if (skb)
+				goto again;
+			unix_state_unlock(sk);
 			break;
 		}
 	} while (size);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 096/104] net/unix: fix logic about sk_peek_offset
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (94 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 095/104] af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 097/104] skbuff: Fix skb checksum flag on skb pull Luis Henriques
                   ` (12 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: David S. Miller, Eric Dumazet, Aaron Conole, Andrey Vagin,
	Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Andrey Vagin <avagin@openvz.org>

commit e9193d60d363e4dff75ff6d43a48f22be26d59c7 upstream.

Now send with MSG_PEEK can return data from multiple SKBs.

Unfortunately we take into account the peek offset for each skb,
that is wrong. We need to apply the peek offset only once.

In addition, the peek offset should be used only if MSG_PEEK is set.

Cc: "David S. Miller" <davem@davemloft.net> (maintainer:NETWORKING
Cc: Eric Dumazet <edumazet@google.com> (commit_signer:1/14=7%)
Cc: Aaron Conole <aconole@bytheb.org>
Fixes: 9f389e35674f ("af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag")
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Tested-by: Aaron Conole <aconole@bytheb.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 net/unix/af_unix.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 30a705ee0ac8..2ae4a5915aa7 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1962,6 +1962,11 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
 		goto out;
 	}
 
+	if (flags & MSG_PEEK)
+		skip = sk_peek_offset(sk, flags);
+	else
+		skip = 0;
+
 	do {
 		int chunk;
 		struct sk_buff *skb, *last;
@@ -2008,7 +2013,6 @@ again:
 			break;
 		}
 
-		skip = sk_peek_offset(sk, flags);
 		while (skip >= unix_skb_len(skb)) {
 			skip -= unix_skb_len(skb);
 			last = skb;
@@ -2070,14 +2074,12 @@ again:
 			if (UNIXCB(skb).fp)
 				siocb->scm->fp = scm_fp_dup(UNIXCB(skb).fp);
 
-			if (skip) {
-				sk_peek_offset_fwd(sk, chunk);
-				skip -= chunk;
-			}
+			sk_peek_offset_fwd(sk, chunk);
 
 			if (UNIXCB(skb).fp)
 				break;
 
+			skip = 0;
 			last = skb;
 			unix_state_lock(sk);
 			skb = skb_peek_next(skb, &sk->sk_receive_queue);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 097/104] skbuff: Fix skb checksum flag on skb pull
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (95 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 096/104] net/unix: fix logic about sk_peek_offset Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 098/104] skbuff: Fix skb checksum partial check Luis Henriques
                   ` (11 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Pravin B Shelar, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Pravin B Shelar <pshelar@nicira.com>

commit 6ae459bdaaeebc632b16e54dcbabb490c6931d61 upstream.

VXLAN device can receive skb with checksum partial. But the checksum
offset could be in outer header which is pulled on receive. This results
in negative checksum offset for the skb. Such skb can cause the assert
failure in skb_checksum_help(). Following patch fixes the bug by setting
checksum-none while pulling outer header.

Following is the kernel panic msg from old kernel hitting the bug.

------------[ cut here ]------------
kernel BUG at net/core/dev.c:1906!
RIP: 0010:[<ffffffff81518034>] skb_checksum_help+0x144/0x150
Call Trace:
<IRQ>
[<ffffffffa0164c28>] queue_userspace_packet+0x408/0x470 [openvswitch]
[<ffffffffa016614d>] ovs_dp_upcall+0x5d/0x60 [openvswitch]
[<ffffffffa0166236>] ovs_dp_process_packet_with_key+0xe6/0x100 [openvswitch]
[<ffffffffa016629b>] ovs_dp_process_received_packet+0x4b/0x80 [openvswitch]
[<ffffffffa016c51a>] ovs_vport_receive+0x2a/0x30 [openvswitch]
[<ffffffffa0171383>] vxlan_rcv+0x53/0x60 [openvswitch]
[<ffffffffa01734cb>] vxlan_udp_encap_recv+0x8b/0xf0 [openvswitch]
[<ffffffff8157addc>] udp_queue_rcv_skb+0x2dc/0x3b0
[<ffffffff8157b56f>] __udp4_lib_rcv+0x1cf/0x6c0
[<ffffffff8157ba7a>] udp_rcv+0x1a/0x20
[<ffffffff8154fdbd>] ip_local_deliver_finish+0xdd/0x280
[<ffffffff81550128>] ip_local_deliver+0x88/0x90
[<ffffffff8154fa7d>] ip_rcv_finish+0x10d/0x370
[<ffffffff81550365>] ip_rcv+0x235/0x300
[<ffffffff8151ba1d>] __netif_receive_skb+0x55d/0x620
[<ffffffff8151c360>] netif_receive_skb+0x80/0x90
[<ffffffff81459935>] virtnet_poll+0x555/0x6f0
[<ffffffff8151cd04>] net_rx_action+0x134/0x290
[<ffffffff810683d8>] __do_softirq+0xa8/0x210
[<ffffffff8162fe6c>] call_softirq+0x1c/0x30
[<ffffffff810161a5>] do_softirq+0x65/0xa0
[<ffffffff810687be>] irq_exit+0x8e/0xb0
[<ffffffff81630733>] do_IRQ+0x63/0xe0
[<ffffffff81625f2e>] common_interrupt+0x6e/0x6e

Reported-by: Anupam Chanda <achanda@vmware.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 include/linux/skbuff.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 89524732dd5e..cfe9676d2e71 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2438,6 +2438,9 @@ static inline void skb_postpull_rcsum(struct sk_buff *skb,
 {
 	if (skb->ip_summed == CHECKSUM_COMPLETE)
 		skb->csum = csum_sub(skb->csum, csum_partial(start, len, 0));
+	else if (skb->ip_summed == CHECKSUM_PARTIAL &&
+		 skb_checksum_start_offset(skb) <= len)
+		skb->ip_summed = CHECKSUM_NONE;
 }
 
 unsigned char *skb_pull_rcsum(struct sk_buff *skb, unsigned int len);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 098/104] skbuff: Fix skb checksum partial check.
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (96 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 097/104] skbuff: Fix skb checksum flag on skb pull Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 099/104] net: add pfmemalloc check in sk_add_backlog() Luis Henriques
                   ` (10 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Pravin B Shelar, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Pravin B Shelar <pshelar@nicira.com>

commit 31b33dfb0a144469dd805514c9e63f4993729a48 upstream.

Earlier patch 6ae459bda tried to detect void ckecksum partial
skb by comparing pull length to checksum offset. But it does
not work for all cases since checksum-offset depends on
updates to skb->data.

Following patch fixes it by validating checksum start offset
after skb-data pointer is updated. Negative value of checksum
offset start means there is no need to checksum.

Fixes: 6ae459bda ("skbuff: Fix skb checksum flag on skb pull")
Reported-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 include/linux/skbuff.h | 2 +-
 net/core/skbuff.c      | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index cfe9676d2e71..010bc80be91c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2439,7 +2439,7 @@ static inline void skb_postpull_rcsum(struct sk_buff *skb,
 	if (skb->ip_summed == CHECKSUM_COMPLETE)
 		skb->csum = csum_sub(skb->csum, csum_partial(start, len, 0));
 	else if (skb->ip_summed == CHECKSUM_PARTIAL &&
-		 skb_checksum_start_offset(skb) <= len)
+		 skb_checksum_start_offset(skb) < 0)
 		skb->ip_summed = CHECKSUM_NONE;
 }
 
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 167a92c896b9..a280d04a3414 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2869,11 +2869,12 @@ EXPORT_SYMBOL(skb_append_datato_frags);
  */
 unsigned char *skb_pull_rcsum(struct sk_buff *skb, unsigned int len)
 {
+	unsigned char *data = skb->data;
+
 	BUG_ON(len > skb->len);
-	skb->len -= len;
-	BUG_ON(skb->len < skb->data_len);
-	skb_postpull_rcsum(skb, skb->data, len);
-	return skb->data += len;
+	__skb_pull(skb, len);
+	skb_postpull_rcsum(skb, data, len);
+	return skb->data;
 }
 EXPORT_SYMBOL_GPL(skb_pull_rcsum);
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 099/104] net: add pfmemalloc check in sk_add_backlog()
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (97 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 098/104] skbuff: Fix skb checksum partial check Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 100/104] ppp: don't override sk->sk_state in pppoe_flush_dev() Luis Henriques
                   ` (9 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Eric Dumazet, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <edumazet@google.com>

commit c7c49b8fde26b74277188bdc6c9dca38db6fa35b upstream.

Greg reported crashes hitting the following check in __sk_backlog_rcv()

	BUG_ON(!sock_flag(sk, SOCK_MEMALLOC));

The pfmemalloc bit is currently checked in sk_filter().

This works correctly for TCP, because sk_filter() is ran in
tcp_v[46]_rcv() before hitting the prequeue or backlog checks.

For UDP or other protocols, this does not work, because the sk_filter()
is ran from sock_queue_rcv_skb(), which might be called _after_ backlog
queuing if socket is owned by user by the time packet is processed by
softirq handler.

Fixes: b4b9e35585089 ("netvm: set PF_MEMALLOC as appropriate during SKB processing")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Greg Thelen <gthelen@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 include/net/sock.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/net/sock.h b/include/net/sock.h
index 927cfc56b76a..9c24377a7bc9 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -807,6 +807,14 @@ static inline __must_check int sk_add_backlog(struct sock *sk, struct sk_buff *s
 	if (sk_rcvqueues_full(sk, skb, limit))
 		return -ENOBUFS;
 
+	/*
+	 * If the skb was allocated from pfmemalloc reserves, only
+	 * allow SOCK_MEMALLOC sockets to use it as this socket is
+	 * helping free memory
+	 */
+	if (skb_pfmemalloc(skb) && !sock_flag(sk, SOCK_MEMALLOC))
+		return -ENOMEM;
+
 	__sk_add_backlog(sk, skb);
 	sk->sk_backlog.len += skb->truesize;
 	return 0;

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 100/104] ppp: don't override sk->sk_state in pppoe_flush_dev()
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (98 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 099/104] net: add pfmemalloc check in sk_add_backlog() Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 101/104] ethtool: Use kcalloc instead of kmalloc for ethtool_get_strings Luis Henriques
                   ` (8 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Guillaume Nault, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Guillaume Nault <g.nault@alphalink.fr>

commit e6740165b8f7f06d8caee0fceab3fb9d790a6fed upstream.

Since commit 2b018d57ff18 ("pppoe: drop PPPOX_ZOMBIEs in pppoe_release"),
pppoe_release() calls dev_put(po->pppoe_dev) if sk is in the
PPPOX_ZOMBIE state. But pppoe_flush_dev() can set sk->sk_state to
PPPOX_ZOMBIE _and_ reset po->pppoe_dev to NULL. This leads to the
following oops:

[  570.140800] BUG: unable to handle kernel NULL pointer dereference at 00000000000004e0
[  570.142931] IP: [<ffffffffa018c701>] pppoe_release+0x50/0x101 [pppoe]
[  570.144601] PGD 3d119067 PUD 3dbc1067 PMD 0
[  570.144601] Oops: 0000 [#1] SMP
[  570.144601] Modules linked in: l2tp_ppp l2tp_netlink l2tp_core ip6_udp_tunnel udp_tunnel pppoe pppox ppp_generic slhc loop crc32c_intel ghash_clmulni_intel jitterentropy_rng sha256_generic hmac drbg ansi_cprng aesni_intel aes_x86_64 ablk_helper cryptd lrw gf128mul glue_helper acpi_cpufreq evdev serio_raw processor button ext4 crc16 mbcache jbd2 virtio_net virtio_blk virtio_pci virtio_ring virtio
[  570.144601] CPU: 1 PID: 15738 Comm: ppp-apitest Not tainted 4.2.0 #1
[  570.144601] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Debian-1.8.2-1 04/01/2014
[  570.144601] task: ffff88003d30d600 ti: ffff880036b60000 task.ti: ffff880036b60000
[  570.144601] RIP: 0010:[<ffffffffa018c701>]  [<ffffffffa018c701>] pppoe_release+0x50/0x101 [pppoe]
[  570.144601] RSP: 0018:ffff880036b63e08  EFLAGS: 00010202
[  570.144601] RAX: 0000000000000000 RBX: ffff880034340000 RCX: 0000000000000206
[  570.144601] RDX: 0000000000000006 RSI: ffff88003d30dd20 RDI: ffff88003d30dd20
[  570.144601] RBP: ffff880036b63e28 R08: 0000000000000001 R09: 0000000000000000
[  570.144601] R10: 00007ffee9b50420 R11: ffff880034340078 R12: ffff8800387ec780
[  570.144601] R13: ffff8800387ec7b0 R14: ffff88003e222aa0 R15: ffff8800387ec7b0
[  570.144601] FS:  00007f5672f48700(0000) GS:ffff88003fc80000(0000) knlGS:0000000000000000
[  570.144601] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  570.144601] CR2: 00000000000004e0 CR3: 0000000037f7e000 CR4: 00000000000406a0
[  570.144601] Stack:
[  570.144601]  ffffffffa018f240 ffff8800387ec780 ffffffffa018f240 ffff8800387ec7b0
[  570.144601]  ffff880036b63e48 ffffffff812caabe ffff880039e4e000 0000000000000008
[  570.144601]  ffff880036b63e58 ffffffff812cabad ffff880036b63ea8 ffffffff811347f5
[  570.144601] Call Trace:
[  570.144601]  [<ffffffff812caabe>] sock_release+0x1a/0x75
[  570.144601]  [<ffffffff812cabad>] sock_close+0xd/0x11
[  570.144601]  [<ffffffff811347f5>] __fput+0xff/0x1a5
[  570.144601]  [<ffffffff811348cb>] ____fput+0x9/0xb
[  570.144601]  [<ffffffff81056682>] task_work_run+0x66/0x90
[  570.144601]  [<ffffffff8100189e>] prepare_exit_to_usermode+0x8c/0xa7
[  570.144601]  [<ffffffff81001a26>] syscall_return_slowpath+0x16d/0x19b
[  570.144601]  [<ffffffff813babb1>] int_ret_from_sys_call+0x25/0x9f
[  570.144601] Code: 48 8b 83 c8 01 00 00 a8 01 74 12 48 89 df e8 8b 27 14 e1 b8 f7 ff ff ff e9 b7 00 00 00 8a 43 12 a8 0b 74 1c 48 8b 83 a8 04 00 00 <48> 8b 80 e0 04 00 00 65 ff 08 48 c7 83 a8 04 00 00 00 00 00 00
[  570.144601] RIP  [<ffffffffa018c701>] pppoe_release+0x50/0x101 [pppoe]
[  570.144601]  RSP <ffff880036b63e08>
[  570.144601] CR2: 00000000000004e0
[  570.200518] ---[ end trace 46956baf17349563 ]---

pppoe_flush_dev() has no reason to override sk->sk_state with
PPPOX_ZOMBIE. pppox_unbind_sock() already sets sk->sk_state to
PPPOX_DEAD, which is the correct state given that sk is unbound and
po->pppoe_dev is NULL.

Fixes: 2b018d57ff18 ("pppoe: drop PPPOX_ZOMBIEs in pppoe_release")
Tested-by: Oleksii Berezhniak <core@irc.lg.ua>
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/net/ppp/pppoe.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index 6c9c16d76935..f606b5ba611f 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -313,7 +313,6 @@ static void pppoe_flush_dev(struct net_device *dev)
 			if (po->pppoe_dev == dev &&
 			    sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND | PPPOX_ZOMBIE)) {
 				pppox_unbind_sock(sk);
-				sk->sk_state = PPPOX_ZOMBIE;
 				sk->sk_state_change(sk);
 				po->pppoe_dev = NULL;
 				dev_put(dev);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 101/104] ethtool: Use kcalloc instead of kmalloc for ethtool_get_strings
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (99 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 100/104] ppp: don't override sk->sk_state in pppoe_flush_dev() Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 102/104] ovs: do not allocate memory from offline numa node Luis Henriques
                   ` (7 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Joe Perches, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Joe Perches <joe@perches.com>

commit 077cb37fcf6f00a45f375161200b5ee0cd4e937b upstream.

It seems that kernel memory can leak into userspace by a
kmalloc, ethtool_get_strings, then copy_to_user sequence.

Avoid this by using kcalloc to zero fill the copied buffer.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 net/core/ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 17cb912793fa..e264527e41f8 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1255,7 +1255,7 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
 
 	gstrings.len = ret;
 
-	data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
+	data = kcalloc(gstrings.len, ETH_GSTRING_LEN, GFP_USER);
 	if (!data)
 		return -ENOMEM;
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 102/104] ovs: do not allocate memory from offline numa node
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (100 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 101/104] ethtool: Use kcalloc instead of kmalloc for ethtool_get_strings Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 103/104] netlink: Trim skb to alloc size to avoid MSG_TRUNC Luis Henriques
                   ` (6 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Konstantin Khlebnikov, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>

commit 598c12d0ba6de9060f04999746eb1e015774044b upstream.

When openvswitch tries allocate memory from offline numa node 0:
stats = kmem_cache_alloc_node(flow_stats_cache, GFP_KERNEL | __GFP_ZERO, 0)
It catches VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES || !node_online(nid))
[ replaced with VM_WARN_ON(!node_online(nid)) recently ] in linux/gfp.h
This patch disables numa affinity in this case.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 net/openvswitch/flow_table.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c
index 740041a09b9d..7a797ffd75a0 100644
--- a/net/openvswitch/flow_table.c
+++ b/net/openvswitch/flow_table.c
@@ -90,7 +90,8 @@ struct sw_flow *ovs_flow_alloc(void)
 
 	/* Initialize the default stat node. */
 	stats = kmem_cache_alloc_node(flow_stats_cache,
-				      GFP_KERNEL | __GFP_ZERO, 0);
+				      GFP_KERNEL | __GFP_ZERO,
+				      node_online(0) ? 0 : NUMA_NO_NODE);
 	if (!stats)
 		goto err;
 

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 103/104] netlink: Trim skb to alloc size to avoid MSG_TRUNC
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (101 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 102/104] ovs: do not allocate memory from offline numa node Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 104/104] net: add length argument to skb_copy_and_csum_datagram_iovec Luis Henriques
                   ` (5 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Ronen Arad, David S. Miller, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: "Arad, Ronen" <ronen.arad@intel.com>

commit db65a3aaf29ecce2e34271d52e8d2336b97bd9fe upstream.

netlink_dump() allocates skb based on the calculated min_dump_alloc or
a per socket max_recvmsg_len.
min_alloc_size is maximum space required for any single netdev
attributes as calculated by rtnl_calcit().
max_recvmsg_len tracks the user provided buffer to netlink_recvmsg.
It is capped at 16KiB.
The intention is to avoid small allocations and to minimize the number
of calls required to obtain dump information for all net devices.

netlink_dump packs as many small messages as could fit within an skb
that was sized for the largest single netdev information. The actual
space available within an skb is larger than what is requested. It could
be much larger and up to near 2x with align to next power of 2 approach.

Allowing netlink_dump to use all the space available within the
allocated skb increases the buffer size a user has to provide to avoid
truncaion (i.e. MSG_TRUNG flag set).

It was observed that with many VLANs configured on at least one netdev,
a larger buffer of near 64KiB was necessary to avoid "Message truncated"
error in "ip link" or "bridge [-c[ompressvlans]] vlan show" when
min_alloc_size was only little over 32KiB.

This patch trims skb to allocated size in order to allow the user to
avoid truncation with more reasonable buffer size.

Signed-off-by: Ronen Arad <ronen.arad@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 net/netlink/af_netlink.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 5f5c976b369d..7e1ac5b5de0a 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2694,6 +2694,7 @@ static int netlink_dump(struct sock *sk)
 	struct sk_buff *skb = NULL;
 	struct nlmsghdr *nlh;
 	int len, err = -ENOBUFS;
+	int alloc_min_size;
 	int alloc_size;
 
 	mutex_lock(nlk->cb_mutex);
@@ -2702,9 +2703,6 @@ static int netlink_dump(struct sock *sk)
 		goto errout_skb;
 	}
 
-	cb = &nlk->cb;
-	alloc_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE);
-
 	if (!netlink_rx_is_mmaped(sk) &&
 	    atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf)
 		goto errout_skb;
@@ -2714,23 +2712,35 @@ static int netlink_dump(struct sock *sk)
 	 * to reduce number of system calls on dump operations, if user
 	 * ever provided a big enough buffer.
 	 */
-	if (alloc_size < nlk->max_recvmsg_len) {
-		skb = netlink_alloc_skb(sk,
-					nlk->max_recvmsg_len,
-					nlk->portid,
+	cb = &nlk->cb;
+	alloc_min_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE);
+
+	if (alloc_min_size < nlk->max_recvmsg_len) {
+		alloc_size = nlk->max_recvmsg_len;
+		skb = netlink_alloc_skb(sk, alloc_size, nlk->portid,
 					GFP_KERNEL |
 					__GFP_NOWARN |
 					__GFP_NORETRY);
-		/* available room should be exact amount to avoid MSG_TRUNC */
-		if (skb)
-			skb_reserve(skb, skb_tailroom(skb) -
-					 nlk->max_recvmsg_len);
 	}
-	if (!skb)
+	if (!skb) {
+		alloc_size = alloc_min_size;
 		skb = netlink_alloc_skb(sk, alloc_size, nlk->portid,
 					GFP_KERNEL);
+	}
 	if (!skb)
 		goto errout_skb;
+
+	/* Trim skb to allocated size. User is expected to provide buffer as
+	 * large as max(min_dump_alloc, 16KiB (mac_recvmsg_len capped at
+	 * netlink_recvmsg())). dump will pack as many smaller messages as
+	 * could fit within the allocated skb. skb is typically allocated
+	 * with larger space than required (could be as much as near 2x the
+	 * requested size with align to next power of 2 approach). Allowing
+	 * dump to use the excess space makes it difficult for a user to have a
+	 * reasonable static buffer based on the expected largest dump of a
+	 * single netdev. The outcome is MSG_TRUNC error.
+	 */
+	skb_reserve(skb, skb_tailroom(skb) - alloc_size);
 	netlink_skb_set_owner_r(skb, sk);
 
 	len = cb->dump(skb, cb);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 104/104] net: add length argument to skb_copy_and_csum_datagram_iovec
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (102 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 103/104] netlink: Trim skb to alloc size to avoid MSG_TRUNC Luis Henriques
@ 2015-10-26 13:43 ` Luis Henriques
  2015-10-26 19:02 ` [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (4 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 13:43 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Sabrina Dubroca, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sabrina Dubroca <sd@queasysnail.net>

Without this length argument, we can read past the end of the iovec in
memcpy_toiovec because we have no way of knowing the total length of the
iovec's buffers.

This is needed for stable kernels where 89c22d8c3b27 ("net: Fix skb
csum races when peeking") has been backported but that don't have the
ioviter conversion, which is almost all the stable trees <= 3.18.

This also fixes a kernel crash for NFS servers when the client uses
 -onfsvers=3,proto=udp to mount the export.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
[ luis: backported to 3.16:
  - dropped changes to net/rxrpc/ar-recvmsg.c ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 include/linux/skbuff.h | 2 +-
 net/core/datagram.c    | 6 +++++-
 net/ipv4/tcp_input.c   | 2 +-
 net/ipv4/udp.c         | 2 +-
 net/ipv6/raw.c         | 2 +-
 net/ipv6/udp.c         | 3 ++-
 6 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 010bc80be91c..94038f93f145 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2525,7 +2525,7 @@ unsigned int datagram_poll(struct file *file, struct socket *sock,
 int skb_copy_datagram_iovec(const struct sk_buff *from, int offset,
 			    struct iovec *to, int size);
 int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, int hlen,
-				     struct iovec *iov);
+				     struct iovec *iov, int len);
 int skb_copy_datagram_from_iovec(struct sk_buff *skb, int offset,
 				 const struct iovec *from, int from_offset,
 				 int len);
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 3c69a464595e..169f742d1464 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -818,6 +818,7 @@ EXPORT_SYMBOL(__skb_checksum_complete);
  *	@skb: skbuff
  *	@hlen: hardware length
  *	@iov: io vector
+ *	@len: amount of data to copy from skb to iov
  *
  *	Caller _must_ check that skb will fit to this iovec.
  *
@@ -827,11 +828,14 @@ EXPORT_SYMBOL(__skb_checksum_complete);
  *			   can be modified!
  */
 int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
-				     int hlen, struct iovec *iov)
+				     int hlen, struct iovec *iov, int len)
 {
 	__wsum csum;
 	int chunk = skb->len - hlen;
 
+	if (chunk > len)
+		chunk = len;
+
 	if (!chunk)
 		return 0;
 
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 486f70050563..0cdaa633059b 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4906,7 +4906,7 @@ static int tcp_copy_to_iovec(struct sock *sk, struct sk_buff *skb, int hlen)
 		err = skb_copy_datagram_iovec(skb, hlen, tp->ucopy.iov, chunk);
 	else
 		err = skb_copy_and_csum_datagram_iovec(skb, hlen,
-						       tp->ucopy.iov);
+						       tp->ucopy.iov, chunk);
 
 	if (!err) {
 		tp->ucopy.len -= chunk;
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 10c1530ba978..4b9e4aba11b0 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1307,7 +1307,7 @@ try_again:
 	else {
 		err = skb_copy_and_csum_datagram_iovec(skb,
 						       sizeof(struct udphdr),
-						       msg->msg_iov);
+						       msg->msg_iov, copied);
 
 		if (err == -EINVAL)
 			goto csum_copy_err;
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index b2dc60b0c764..fd377c4d8986 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -492,7 +492,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
 			goto csum_copy_err;
 		err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
 	} else {
-		err = skb_copy_and_csum_datagram_iovec(skb, 0, msg->msg_iov);
+		err = skb_copy_and_csum_datagram_iovec(skb, 0, msg->msg_iov, copied);
 		if (err == -EINVAL)
 			goto csum_copy_err;
 	}
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index ad5891072a89..72603a9af4bc 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -428,7 +428,8 @@ try_again:
 		err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),
 					      msg->msg_iov, copied);
 	else {
-		err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov);
+		err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr),
+						       msg->msg_iov, copied);
 		if (err == -EINVAL)
 			goto csum_copy_err;
 	}

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* Re: [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (103 preceding siblings ...)
  2015-10-26 13:43 ` [PATCH 3.16.y-ckt 104/104] net: add length argument to skb_copy_and_csum_datagram_iovec Luis Henriques
@ 2015-10-26 19:02 ` Luis Henriques
  2015-10-28 16:51   ` Luis Henriques
  2015-10-26 19:05 ` [PATCH 3.16.y-ckt 105/107] KEYS: Fix race between key destruction and finding a keyring by name Luis Henriques
                   ` (3 subsequent siblings)
  108 siblings, 1 reply; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 19:02 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team

On Mon, Oct 26, 2015 at 01:41:42PM +0000, Luis Henriques wrote:
> This is the start of the review cycle for the Linux 3.16.7-ckt19 stable kernel.
> 
> This version contains 104 new patches, summarized below.  The new patches are
> posted as replies to this message and also available in this git branch:
>

I am adding 3 additional patches for this 3.16 stable kernel release,
that fix CVE-2015-7872:

911b79cde95c KEYS: Don't permit request_key() to construct a new keyring
f05819df10d7 KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring
94c4554ba07a KEYS: Fix race between key destruction and finding a keyring by name

Cheers,
--
Luís


> http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-3.16.y-review
> 
> git://kernel.ubuntu.com/ubuntu/linux.git  linux-3.16.y-review
> 
> The review period for version 3.16.7-ckt19 will be open for the next three days.
> To report a problem, please reply to the relevant follow-up patch message.
> 
> For more information about the Linux 3.16.y-ckt extended stable kernel version,
> see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable .
> 
>  -Luis
> 
> --
>  arch/arm/Kconfig                           |   1 -
>  arch/arm/Makefile                          |   8 ++
>  arch/arm/boot/dts/omap3-beagle.dts         |   2 +-
>  arch/arm/boot/dts/omap5-uevm.dts           |   4 +-
>  arch/arm/kernel/signal.c                   |  15 ++--
>  arch/arm/kvm/interrupts_head.S             |   6 +-
>  arch/arm/mach-orion5x/include/mach/irqs.h  |  64 +++++++--------
>  arch/arm/mach-orion5x/irq.c                |   4 +-
>  arch/arm64/Kconfig                         |  16 ++++
>  arch/arm64/Makefile                        |   4 +
>  arch/arm64/kernel/head.S                   |   5 ++
>  arch/arm64/kernel/module.c                 |   2 +
>  arch/arm64/kernel/signal32.c               |  47 ++++++++---
>  arch/arm64/kvm/hyp.S                       |   5 +-
>  arch/m68k/include/asm/linkage.h            |  30 +++++++
>  arch/mips/kernel/cps-vec.S                 |  12 +--
>  arch/mips/mm/dma-default.c                 |   2 +-
>  arch/powerpc/boot/Makefile                 |   3 +
>  arch/powerpc/mm/hugepage-hash64.c          |   3 +-
>  arch/x86/include/uapi/asm/msr-index.h      |   1 +
>  arch/x86/kernel/apic/apic.c                |   7 ++
>  arch/x86/kernel/entry_64.S                 |  16 +++-
>  arch/x86/kernel/paravirt.c                 |  16 +++-
>  arch/x86/kernel/tsc.c                      |  17 ++--
>  arch/x86/kvm/svm.c                         |   2 +-
>  arch/x86/kvm/x86.c                         |   2 +
>  arch/x86/mm/init_64.c                      |   2 +-
>  arch/x86/platform/efi/efi.c                |  67 +++++++++++++++-
>  drivers/block/zram/zcomp.c                 |  12 +--
>  drivers/cpufreq/intel_pstate.c             |  10 +--
>  drivers/dma/dw/core.c                      |   4 +-
>  drivers/gpu/drm/i915/intel_bios.c          |  12 ++-
>  drivers/gpu/drm/qxl/qxl_display.c          |  14 ++--
>  drivers/gpu/drm/radeon/atombios_encoders.c |   8 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h        |   6 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c    |   6 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c    |   2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_resource.c   |  29 +++++--
>  drivers/gpu/drm/vmwgfx/vmwgfx_shader.c     |   2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_surface.c    |  12 ++-
>  drivers/hwmon/nct6775.c                    |  16 ++--
>  drivers/infiniband/ulp/isert/ib_isert.c    |   9 ++-
>  drivers/mtd/ubi/io.c                       |   5 ++
>  drivers/mtd/ubi/vtbl.c                     |   1 +
>  drivers/mtd/ubi/wl.c                       |   1 +
>  drivers/net/ethernet/marvell/mvneta.c      |   4 +-
>  drivers/net/ppp/pppoe.c                    |   1 -
>  drivers/net/usb/asix_devices.c             |  16 +---
>  drivers/net/vxlan.c                        |  10 +--
>  drivers/net/xen-netfront.c                 |   3 +-
>  drivers/pci/access.c                       |  27 +------
>  drivers/pci/quirks.c                       |  20 ++++-
>  drivers/platform/x86/hp-wmi.c              |  35 +++++---
>  drivers/spi/spi-pxa2xx.c                   |   4 +
>  drivers/spi/spi-xtensa-xtfpga.c            |   4 +-
>  drivers/spi/spi.c                          |   3 +-
>  drivers/staging/android/ion/ion.c          |   6 +-
>  drivers/usb/chipidea/udc.c                 |  84 +++++++++----------
>  drivers/usb/core/config.c                  |   5 +-
>  drivers/usb/host/ehci-fsl.c                |  13 +++
>  drivers/usb/host/ehci-hub.c                |   7 ++
>  drivers/usb/host/ehci.h                    |  12 +++
>  drivers/usb/host/fsl-mph-dr-of.c           |  10 +++
>  drivers/usb/host/xhci-mem.c                |  23 +++---
>  drivers/usb/host/xhci-ring.c               |  13 ++-
>  drivers/usb/host/xhci.c                    |   9 +--
>  drivers/usb/serial/option.c                |  24 ++++++
>  drivers/usb/serial/whiteheat.c             |  31 ++++++++
>  fs/btrfs/extent_io.c                       |  65 +++++++++++++--
>  fs/btrfs/inode.c                           |   3 +-
>  fs/cifs/cifsencrypt.c                      |  53 +++++++++++-
>  fs/cifs/ioctl.c                            |   6 ++
>  fs/cifs/smb2ops.c                          |   8 +-
>  fs/coredump.c                              |  38 +++++++--
>  fs/dcache.c                                |   7 ++
>  fs/jbd2/checkpoint.c                       |  39 +++++++--
>  fs/jbd2/commit.c                           |   2 +-
>  fs/jbd2/journal.c                          |  11 ++-
>  fs/namei.c                                 |  31 +++++++-
>  fs/ocfs2/dlm/dlmmaster.c                   |   9 ++-
>  fs/ocfs2/dlm/dlmrecovery.c                 |   8 +-
>  include/linux/fsl_devices.h                |   2 +
>  include/linux/jbd2.h                       |   3 +-
>  include/linux/skbuff.h                     |   5 +-
>  include/net/af_unix.h                      |   6 +-
>  include/net/sock.h                         |   8 ++
>  ipc/msg.c                                  |  14 ++--
>  ipc/sem.c                                  |  15 ++--
>  ipc/shm.c                                  |  12 +--
>  ipc/util.c                                 |   8 +-
>  kernel/irq/proc.c                          |  19 ++++-
>  kernel/time/clocksource.c                  |   2 +-
>  mm/hugetlb.c                               |   8 ++
>  mm/slab.c                                  |  13 ++-
>  net/core/datagram.c                        |   6 +-
>  net/core/ethtool.c                         |   2 +-
>  net/core/fib_rules.c                       |   2 +-
>  net/core/skbuff.c                          |   9 ++-
>  net/ipv4/tcp_input.c                       |   2 +-
>  net/ipv4/udp.c                             |   2 +-
>  net/ipv6/raw.c                             |   2 +-
>  net/ipv6/udp.c                             |   3 +-
>  net/l2tp/l2tp_core.c                       |  11 ++-
>  net/netfilter/nft_compat.c                 |  24 ++++--
>  net/netlink/af_netlink.c                   |  34 +++++---
>  net/openvswitch/flow_table.c               |   3 +-
>  net/sctp/sm_sideeffect.c                   |   2 +-
>  net/unix/af_unix.c                         |  16 +++-
>  sound/arm/Kconfig                          |  15 ++--
>  sound/soc/pxa/Kconfig                      |   2 -
>  sound/soc/pxa/pxa2xx-ac97.c                |   4 +-
>  tools/lib/traceevent/event-parse.c         |  23 +++++-
>  tools/perf/util/header.c                   |   4 +-
>  tools/perf/util/symbol-elf.c               |  35 +++-----
>  virt/kvm/eventfd.c                         | 124 +++++++++++++++++------------
>  virt/kvm/kvm_main.c                        |  19 ++++-
>  116 files changed, 1164 insertions(+), 451 deletions(-)
> 
> Aaron Conole (2):
>       af_unix: Convert the unix_sk macro to an inline function for type safety
>       af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag
> 
> Adrian Hunter (1):
>       perf tools: Fix copying of /proc/kcore
> 
> Alex Williamson (2):
>       PCI: Fix devfn for VPD access through function 0
>       PCI: Use function 0 VPD for identical functions, regular VPD for others
> 
> Alexander Couzens (1):
>       l2tp: protect tunnel->del_work by ref_count
> 
> Andreas Schwab (1):
>       m68k: Define asmlinkage_protect
> 
> Andrey Vagin (1):
>       net/unix: fix logic about sk_peek_offset
> 
> Andy Lutomirski (2):
>       x86/paravirt: Replace the paravirt nop with a bona fide empty function
>       x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code
> 
> Andy Shevchenko (1):
>       dmaengine: dw: properly read DWC_PARAMS register
> 
> Aneesh Kumar K.V (1):
>       powerpc/mm: Recompute hash value after a failed update
> 
> Arad, Ronen (1):
>       netlink: Trim skb to alloc size to avoid MSG_TRUNC
> 
> Ard Biesheuvel (1):
>       ARM: 8429/1: disable GCC SRA optimization
> 
> Arnaldo Carvalho de Melo (1):
>       perf header: Fixup reading of HEADER_NRCPUS feature
> 
> Ben Hutchings (1):
>       genirq: Fix race in register_irq_proc()
> 
> Benjamin Herrenschmidt (1):
>       powerpc/boot: Specify ABI v2 when building an LE boot wrapper
> 
> Carl Frederik Werner (1):
>       ARM: dts: omap3-beagle: make i2c3, ddc and tfp410 gpio work again
> 
> Charles Keepax (1):
>       asix: Do full reset during ax88772_bind
> 
> Chas Williams (1):
>       net/xen-netfront: only napi_synchronize() if running
> 
> Dave Airlie (1):
>       drm/qxl: only report first monitor as connected if we have no state
> 
> David Woodhouse (1):
>       x86/platform: Fix Geode LX timekeeping in the generic x86 build
> 
> Dirk Müller (1):
>       Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS
> 
> Eric Dumazet (1):
>       net: add pfmemalloc check in sk_add_backlog()
> 
> Eric W. Biederman (2):
>       dcache: Handle escaped paths in prepend_path
>       vfs: Test for and handle paths that are unreachable from their mnt_root
> 
> Fabiano Fidêncio (1):
>       drm/qxl: recreate the primary surface when the bo is not primary
> 
> Filipe Manana (1):
>       Btrfs: fix read corruption of compressed and shared extents
> 
> Grazvydas Ignotas (1):
>       ARM: dts: omap5-uevm.dts: fix i2c5 pinctrl offsets
> 
> Guenter Roeck (2):
>       hwmon: (nct6775) Swap STEP_UP_TIME and STEP_DOWN_TIME registers for most chips
>       spi: Fix documentation of spi_alloc_master()
> 
> Guillaume Nault (1):
>       ppp: don't override sk->sk_state in pppoe_flush_dev()
> 
> James Hogan (1):
>       MIPS: dma-default: Fix 32-bit fall back to GFP_DMA
> 
> Jan Kara (1):
>       jbd2: avoid infinite loop when destroying aborted journal
> 
> Jani Nikula (1):
>       drm/i915/bios: handle MIPI Sequence Block v3+ gracefully
> 
> Jann Horn (2):
>       CIFS: fix type confusion in copy offload ioctl
>       fs: if a coredump already exists, unlink and recreate with O_EXCL
> 
> Jason Wang (4):
>       kvm: don't try to register to KVM_FAST_MMIO_BUS for non mmio eventfd
>       kvm: factor out core eventfd assign/deassign logic
>       kvm: fix double free for fast mmio eventfd
>       kvm: fix zero length mmio searching
> 
> Jeff Mahoney (1):
>       btrfs: skip waiting on ordered range for special files
> 
> Jenny Derzhavetz (1):
>       iser-target: remove command with state ISTATE_REMOVE
> 
> Jiri Benc (1):
>       vxlan: set needed headroom correctly
> 
> Joe Perches (1):
>       ethtool: Use kcalloc instead of kmalloc for ethtool_get_strings
> 
> Johan Hovold (1):
>       USB: whiteheat: fix potential null-deref at probe
> 
> John Stultz (1):
>       clocksource: Fix abs() usage w/ 64bit values
> 
> Joonsoo Kim (1):
>       mm/slab: fix unexpected index mapping result of kmalloc_size(INDEX_NODE+1)
> 
> Joseph Qi (1):
>       ocfs2/dlm: fix deadlock when dispatch assert master
> 
> Julia Lawall (1):
>       xhci-mem: Use setup_timer
> 
> Kapileshwar Singh (1):
>       tools lib traceevent: Fix string handling in heterogeneous arch environments
> 
> Konstantin Khlebnikov (1):
>       ovs: do not allocate memory from offline numa node
> 
> Kyle Evans (1):
>       hp-wmi: limit hotkey enable
> 
> Linus Torvalds (1):
>       Initialize msg/shm IPC objects before doing ipc_addid()
> 
> Liu.Zhao (1):
>       USB: option: add ZTE PIDs
> 
> Luis Henriques (2):
>       zram: fix possible use after free in zcomp_create()
>       Revert "ARM: orion5x: fix legacy orion5x IRQ numbers"
> 
> Manfred Spraul (1):
>       ipc/sem.c: fully initialize sem_array before making it visible
> 
> Marc Zyngier (2):
>       arm64: KVM: Disable virtual timer even if the guest is not using it
>       arm: KVM: Disable virtual timer even if the guest is not using it
> 
> Mathias Krause (1):
>       hp-wmi: Add missing __init annotations to initialization code
> 
> Mathias Nyman (4):
>       usb: Use the USB_SS_MULT() macro to get the burst multiplier.
>       xhci: give command abortion one more chance before killing xhci
>       xhci: change xhci 1.0 only restrictions to support xhci 1.1
>       xhci: init command timeout timer earlier to avoid deleting it uninitialized
> 
> Matt Fleming (1):
>       x86/efi: Fix boot crash by mapping EFI memmap entries bottom-up at runtime, instead of top-down
> 
> Max Filippov (1):
>       spi: xtensa-xtfpga: fix register endianness
> 
> Mel Gorman (1):
>       mm: hugetlbfs: skip shared VMAs when unmapping private pages to satisfy a fault
> 
> Michel Dänzer (1):
>       drm/radeon: Restore LCD backlight level on resume (>= R5xx)
> 
> Michel Stam (1):
>       asix: Don't reset PHY on if_up for ASIX 88772
> 
> Nikhil Badola (2):
>       drivers: usb :fsl: Implement Workaround for USB Erratum A007792
>       drivers: usb: fsl: Workaround for USB erratum-A005275
> 
> Pablo Neira Ayuso (1):
>       netfilter: nft_compat: skip family comparison in case of NFPROTO_UNSPEC
> 
> Paolo Bonzini (1):
>       KVM: x86: trap AMD MSRs for the TSeg base and mask
> 
> Paul Burton (3):
>       MIPS: CPS: Stop dangling delay slot from has_mt.
>       MIPS: CPS: Don't include MT code in non-MT kernels.
>       MIPS: CPS: #ifdef on CONFIG_MIPS_MT_SMP rather than CONFIG_MIPS_MT
> 
> Peter Chen (1):
>       usb: chipidea: udc: using the correct stall implementation
> 
> Peter Seiderer (1):
>       cifs: use server timestamp for ntlmv2 authentication
> 
> Prarit Bhargava (1):
>       intel_pstate: Fix overflow in busy_scaled due to long delay
> 
> Pravin B Shelar (2):
>       skbuff: Fix skb checksum flag on skb pull
>       skbuff: Fix skb checksum partial check.
> 
> Richard Weinberger (1):
>       UBI: Validate data_size
> 
> Robert Jarzmik (2):
>       ASoC: pxa: pxa2xx-ac97: fix dma requestor lines
>       ASoC: fix broken pxa SoC support
> 
> Roger Quadros (2):
>       usb: xhci: Clear XHCI_STATE_DYING on start
>       usb: xhci: Allow usb_add/remove_hcd() to be called repeatedly
> 
> Roland Dreier (1):
>       fib_rules: Fix dump_rules() not to exit early
> 
> Russell King (1):
>       ARM: fix Thumb2 signal handling when ARMv6 is enabled
> 
> Sabrina Dubroca (1):
>       net: add length argument to skb_copy_and_csum_datagram_iovec
> 
> Shaohua Li (1):
>       x86/apic: Serialize LVTT and TSC_DEADLINE writes
> 
> Shawn Lin (1):
>       staging: ion: fix corruption of ion_import_dma_buf
> 
> Simon Guinot (1):
>       net: mvneta: fix DMA buffer unmapping in mvneta_rx()
> 
> Stephen Smalley (1):
>       x86/mm: Set NX on gap between __ex_table and rodata
> 
> Steve French (1):
>       disabling oplocks/leases via module parm enable_oplocks broken for SMB3
> 
> Stratos Karafotis (1):
>       cpufreq: intel_pstate: Remove unnecessary type casting in div_s64() call
> 
> Tan, Jui Nee (1):
>       spi: spi-pxa2xx: Check status register to determine if SSSR_TINT is disabled
> 
> Thomas Hellstrom (2):
>       drm/vmwgfx: Fix up user_dmabuf refcounting
>       drm/vmwgfx: Fix kernel NULL pointer dereference on older hardware
> 
> Will Deacon (3):
>       arm64: head.S: initialise mdcr_el2 in el2_setup
>       arm64: compat: fix vfp save/restore across signal handlers in big-endian
>       arm64: errata: add module build workaround for erratum #843419
> 
> lucien (1):
>       sctp: donot reset the overall_error_count in SHUTDOWN_RECEIVE state
> 
> shengyong (1):
>       UBI: return ENOSPC if no enough space available

^ permalink raw reply	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 105/107] KEYS: Fix race between key destruction and finding a keyring by name
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (104 preceding siblings ...)
  2015-10-26 19:02 ` [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
@ 2015-10-26 19:05 ` Luis Henriques
  2015-10-26 19:05 ` [PATCH 3.16.y-ckt 106/107] KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring Luis Henriques
                   ` (2 subsequent siblings)
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 19:05 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: David Howells, Kamal Mostafa, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Howells <dhowells@redhat.com>

commit 94c4554ba07adbdde396748ee7ae01e86cf2d8d7 upstream.

There appears to be a race between:

 (1) key_gc_unused_keys() which frees key->security and then calls
     keyring_destroy() to unlink the name from the name list

 (2) find_keyring_by_name() which calls key_permission(), thus accessing
     key->security, on a key before checking to see whether the key usage is 0
     (ie. the key is dead and might be cleaned up).

Fix this by calling ->destroy() before cleaning up the core key data -
including key->security.

Reported-by: Petr Matousek <pmatouse@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 security/keys/gc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/security/keys/gc.c b/security/keys/gc.c
index 009d9370c8fd..38676fac7943 100644
--- a/security/keys/gc.c
+++ b/security/keys/gc.c
@@ -143,6 +143,10 @@ static noinline void key_gc_unused_keys(struct list_head *keys)
 		kdebug("- %u", key->serial);
 		key_check(key);
 
+		/* Throw away the key data */
+		if (key->type->destroy)
+			key->type->destroy(key);
+
 		security_key_free(key);
 
 		/* deal with the user's key tracking and quota */
@@ -157,10 +161,6 @@ static noinline void key_gc_unused_keys(struct list_head *keys)
 		if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags))
 			atomic_dec(&key->user->nikeys);
 
-		/* now throw away the key memory */
-		if (key->type->destroy)
-			key->type->destroy(key);
-
 		key_user_put(key->user);
 
 		kfree(key->description);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 106/107] KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (105 preceding siblings ...)
  2015-10-26 19:05 ` [PATCH 3.16.y-ckt 105/107] KEYS: Fix race between key destruction and finding a keyring by name Luis Henriques
@ 2015-10-26 19:05 ` Luis Henriques
  2015-10-26 19:05 ` [PATCH 3.16.y-ckt 107/107] KEYS: Don't permit request_key() to construct a new keyring Luis Henriques
  2015-10-28 16:52 ` [PATCH 3.16.y-ckt 108/108] Btrfs: update fix for read corruption of compressed and shared extents Luis Henriques
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 19:05 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: David Howells, Kamal Mostafa, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Howells <dhowells@redhat.com>

commit f05819df10d7b09f6d1eb6f8534a8f68e5a4fe61 upstream.

The following sequence of commands:

    i=`keyctl add user a a @s`
    keyctl request2 keyring foo bar @t
    keyctl unlink $i @s

tries to invoke an upcall to instantiate a keyring if one doesn't already
exist by that name within the user's keyring set.  However, if the upcall
fails, the code sets keyring->type_data.reject_error to -ENOKEY or some
other error code.  When the key is garbage collected, the key destroy
function is called unconditionally and keyring_destroy() uses list_empty()
on keyring->type_data.link - which is in a union with reject_error.
Subsequently, the kernel tries to unlink the keyring from the keyring names
list - which oopses like this:

	BUG: unable to handle kernel paging request at 00000000ffffff8a
	IP: [<ffffffff8126e051>] keyring_destroy+0x3d/0x88
	...
	Workqueue: events key_garbage_collector
	...
	RIP: 0010:[<ffffffff8126e051>] keyring_destroy+0x3d/0x88
	RSP: 0018:ffff88003e2f3d30  EFLAGS: 00010203
	RAX: 00000000ffffff82 RBX: ffff88003bf1a900 RCX: 0000000000000000
	RDX: 0000000000000000 RSI: 000000003bfc6901 RDI: ffffffff81a73a40
	RBP: ffff88003e2f3d38 R08: 0000000000000152 R09: 0000000000000000
	R10: ffff88003e2f3c18 R11: 000000000000865b R12: ffff88003bf1a900
	R13: 0000000000000000 R14: ffff88003bf1a908 R15: ffff88003e2f4000
	...
	CR2: 00000000ffffff8a CR3: 000000003e3ec000 CR4: 00000000000006f0
	...
	Call Trace:
	 [<ffffffff8126c756>] key_gc_unused_keys.constprop.1+0x5d/0x10f
	 [<ffffffff8126ca71>] key_garbage_collector+0x1fa/0x351
	 [<ffffffff8105ec9b>] process_one_work+0x28e/0x547
	 [<ffffffff8105fd17>] worker_thread+0x26e/0x361
	 [<ffffffff8105faa9>] ? rescuer_thread+0x2a8/0x2a8
	 [<ffffffff810648ad>] kthread+0xf3/0xfb
	 [<ffffffff810647ba>] ? kthread_create_on_node+0x1c2/0x1c2
	 [<ffffffff815f2ccf>] ret_from_fork+0x3f/0x70
	 [<ffffffff810647ba>] ? kthread_create_on_node+0x1c2/0x1c2

Note the value in RAX.  This is a 32-bit representation of -ENOKEY.

The solution is to only call ->destroy() if the key was successfully
instantiated.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 security/keys/gc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/security/keys/gc.c b/security/keys/gc.c
index 38676fac7943..4a780333c22c 100644
--- a/security/keys/gc.c
+++ b/security/keys/gc.c
@@ -143,8 +143,10 @@ static noinline void key_gc_unused_keys(struct list_head *keys)
 		kdebug("- %u", key->serial);
 		key_check(key);
 
-		/* Throw away the key data */
-		if (key->type->destroy)
+		/* Throw away the key data if the key is instantiated */
+		if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags) &&
+		    !test_bit(KEY_FLAG_NEGATIVE, &key->flags) &&
+		    key->type->destroy)
 			key->type->destroy(key);
 
 		security_key_free(key);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 107/107] KEYS: Don't permit request_key() to construct a new keyring
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (106 preceding siblings ...)
  2015-10-26 19:05 ` [PATCH 3.16.y-ckt 106/107] KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring Luis Henriques
@ 2015-10-26 19:05 ` Luis Henriques
  2015-10-28 16:52 ` [PATCH 3.16.y-ckt 108/108] Btrfs: update fix for read corruption of compressed and shared extents Luis Henriques
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-26 19:05 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: David Howells, Kamal Mostafa, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Howells <dhowells@redhat.com>

commit 911b79cde95c7da0ec02f48105358a36636b7a71 upstream.

If request_key() is used to find a keyring, only do the search part - don't
do the construction part if the keyring was not found by the search.  We
don't really want keyrings in the negative instantiated state since the
rejected/negative instantiation error value in the payload is unioned with
keyring metadata.

Now the kernel gives an error:

	request_key("keyring", "#selinux,bdekeyring", "keyring", KEY_SPEC_USER_SESSION_KEYRING) = -1 EPERM (Operation not permitted)

Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 security/keys/request_key.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 381411941cc1..9ea60a7bac78 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -457,6 +457,9 @@ static struct key *construct_key_and_link(struct keyring_search_context *ctx,
 
 	kenter("");
 
+	if (ctx->index_key.type == &key_type_keyring)
+		return ERR_PTR(-EPERM);
+	
 	user = key_user_lookup(current_fsuid());
 	if (!user)
 		return ERR_PTR(-ENOMEM);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* Re: [PATCH 3.16.y-ckt 072/104] drm/radeon: Restore LCD backlight level on resume (>= R5xx)
  2015-10-26 13:42 ` [PATCH 3.16.y-ckt 072/104] drm/radeon: Restore LCD backlight level on resume (>= R5xx) Luis Henriques
@ 2015-10-27  2:10   ` Michel Dänzer
  2015-10-28 10:45     ` Luis Henriques
  0 siblings, 1 reply; 115+ messages in thread
From: Michel Dänzer @ 2015-10-27  2:10 UTC (permalink / raw)
  To: Luis Henriques; +Cc: linux-kernel, stable, kernel-team, Alex Deucher

On 26.10.2015 22:42, Luis Henriques wrote:
> 3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.
> 
> ------------------
> 
> From: =TF-8?q?Michel Dänzer?= <michel.daenzer@amd.com>
> 
> commit 4281f46ef839050d2ef60348f661eb463c21cc2e upstream.
> 
> Instead of only enabling the backlight (which seems to set it to max
> brightness), just re-set the current backlight level, which also takes
> care of enabling the backlight if necessary.
> 
> Only the radeon_atom_encoder_dpms_dig part tested on a Kaveri laptop,
> the radeon_atom_encoder_dpms_avivo part is only compile tested.
> 
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Luis Henriques <luis.henriques@canonical.com>

We're currently investigating a regression which was bisected to this
change. Please hold off on backporting this change until we have a
solution for that.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer

^ permalink raw reply	[flat|nested] 115+ messages in thread

* Re: [PATCH 3.16.y-ckt 072/104] drm/radeon: Restore LCD backlight level on resume (>= R5xx)
  2015-10-27  2:10   ` Michel Dänzer
@ 2015-10-28 10:45     ` Luis Henriques
  2015-11-02  7:52       ` Michel Dänzer
  0 siblings, 1 reply; 115+ messages in thread
From: Luis Henriques @ 2015-10-28 10:45 UTC (permalink / raw)
  To: Michel Dänzer; +Cc: linux-kernel, stable, kernel-team, Alex Deucher

On Tue, Oct 27, 2015 at 11:10:29AM +0900, Michel Dänzer wrote:
> On 26.10.2015 22:42, Luis Henriques wrote:
> > 3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.
> > 
> > ------------------
> > 
> > From: =TF-8?q?Michel Dänzer?= <michel.daenzer@amd.com>
> > 
> > commit 4281f46ef839050d2ef60348f661eb463c21cc2e upstream.
> > 
> > Instead of only enabling the backlight (which seems to set it to max
> > brightness), just re-set the current backlight level, which also takes
> > care of enabling the backlight if necessary.
> > 
> > Only the radeon_atom_encoder_dpms_dig part tested on a Kaveri laptop,
> > the radeon_atom_encoder_dpms_avivo part is only compile tested.
> > 
> > Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
> > Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> > Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
> 
> We're currently investigating a regression which was bisected to this
> change. Please hold off on backporting this change until we have a
> solution for that.

Thanks, I'll drop this patch for this 3.16 release, and will wait for a
fix to be available.

Cheers,
--
Luís

^ permalink raw reply	[flat|nested] 115+ messages in thread

* Re: [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review
  2015-10-26 19:02 ` [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
@ 2015-10-28 16:51   ` Luis Henriques
  0 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-28 16:51 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team

On Mon, Oct 26, 2015 at 07:02:01PM +0000, Luis Henriques wrote:
> On Mon, Oct 26, 2015 at 01:41:42PM +0000, Luis Henriques wrote:
> > This is the start of the review cycle for the Linux 3.16.7-ckt19 stable kernel.
> > 
> > This version contains 104 new patches, summarized below.  The new patches are
> > posted as replies to this message and also available in this git branch:
> >
> 
> I am adding 3 additional patches for this 3.16 stable kernel release,
> that fix CVE-2015-7872:
> 
> 911b79cde95c KEYS: Don't permit request_key() to construct a new keyring
> f05819df10d7 KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring
> 94c4554ba07a KEYS: Fix race between key destruction and finding a keyring by name
>

Ok, I'm adding yet another patch for 3.16.7-ckt19:

808f80b46790 Btrfs: update fix for read corruption of compressed and shared extents

This fixes an issue that is introduced by 005efedf2c7d ("Btrfs: fix read
corruption of compressed and shared extents"), which is also queued for
this kernel release.

Cheers,
--
Luís

> 
> 
> > http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-3.16.y-review
> > 
> > git://kernel.ubuntu.com/ubuntu/linux.git  linux-3.16.y-review
> > 
> > The review period for version 3.16.7-ckt19 will be open for the next three days.
> > To report a problem, please reply to the relevant follow-up patch message.
> > 
> > For more information about the Linux 3.16.y-ckt extended stable kernel version,
> > see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable .
> > 
> >  -Luis
> > 
> > --
> >  arch/arm/Kconfig                           |   1 -
> >  arch/arm/Makefile                          |   8 ++
> >  arch/arm/boot/dts/omap3-beagle.dts         |   2 +-
> >  arch/arm/boot/dts/omap5-uevm.dts           |   4 +-
> >  arch/arm/kernel/signal.c                   |  15 ++--
> >  arch/arm/kvm/interrupts_head.S             |   6 +-
> >  arch/arm/mach-orion5x/include/mach/irqs.h  |  64 +++++++--------
> >  arch/arm/mach-orion5x/irq.c                |   4 +-
> >  arch/arm64/Kconfig                         |  16 ++++
> >  arch/arm64/Makefile                        |   4 +
> >  arch/arm64/kernel/head.S                   |   5 ++
> >  arch/arm64/kernel/module.c                 |   2 +
> >  arch/arm64/kernel/signal32.c               |  47 ++++++++---
> >  arch/arm64/kvm/hyp.S                       |   5 +-
> >  arch/m68k/include/asm/linkage.h            |  30 +++++++
> >  arch/mips/kernel/cps-vec.S                 |  12 +--
> >  arch/mips/mm/dma-default.c                 |   2 +-
> >  arch/powerpc/boot/Makefile                 |   3 +
> >  arch/powerpc/mm/hugepage-hash64.c          |   3 +-
> >  arch/x86/include/uapi/asm/msr-index.h      |   1 +
> >  arch/x86/kernel/apic/apic.c                |   7 ++
> >  arch/x86/kernel/entry_64.S                 |  16 +++-
> >  arch/x86/kernel/paravirt.c                 |  16 +++-
> >  arch/x86/kernel/tsc.c                      |  17 ++--
> >  arch/x86/kvm/svm.c                         |   2 +-
> >  arch/x86/kvm/x86.c                         |   2 +
> >  arch/x86/mm/init_64.c                      |   2 +-
> >  arch/x86/platform/efi/efi.c                |  67 +++++++++++++++-
> >  drivers/block/zram/zcomp.c                 |  12 +--
> >  drivers/cpufreq/intel_pstate.c             |  10 +--
> >  drivers/dma/dw/core.c                      |   4 +-
> >  drivers/gpu/drm/i915/intel_bios.c          |  12 ++-
> >  drivers/gpu/drm/qxl/qxl_display.c          |  14 ++--
> >  drivers/gpu/drm/radeon/atombios_encoders.c |   8 +-
> >  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h        |   6 +-
> >  drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c    |   6 +-
> >  drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c    |   2 +-
> >  drivers/gpu/drm/vmwgfx/vmwgfx_resource.c   |  29 +++++--
> >  drivers/gpu/drm/vmwgfx/vmwgfx_shader.c     |   2 +-
> >  drivers/gpu/drm/vmwgfx/vmwgfx_surface.c    |  12 ++-
> >  drivers/hwmon/nct6775.c                    |  16 ++--
> >  drivers/infiniband/ulp/isert/ib_isert.c    |   9 ++-
> >  drivers/mtd/ubi/io.c                       |   5 ++
> >  drivers/mtd/ubi/vtbl.c                     |   1 +
> >  drivers/mtd/ubi/wl.c                       |   1 +
> >  drivers/net/ethernet/marvell/mvneta.c      |   4 +-
> >  drivers/net/ppp/pppoe.c                    |   1 -
> >  drivers/net/usb/asix_devices.c             |  16 +---
> >  drivers/net/vxlan.c                        |  10 +--
> >  drivers/net/xen-netfront.c                 |   3 +-
> >  drivers/pci/access.c                       |  27 +------
> >  drivers/pci/quirks.c                       |  20 ++++-
> >  drivers/platform/x86/hp-wmi.c              |  35 +++++---
> >  drivers/spi/spi-pxa2xx.c                   |   4 +
> >  drivers/spi/spi-xtensa-xtfpga.c            |   4 +-
> >  drivers/spi/spi.c                          |   3 +-
> >  drivers/staging/android/ion/ion.c          |   6 +-
> >  drivers/usb/chipidea/udc.c                 |  84 +++++++++----------
> >  drivers/usb/core/config.c                  |   5 +-
> >  drivers/usb/host/ehci-fsl.c                |  13 +++
> >  drivers/usb/host/ehci-hub.c                |   7 ++
> >  drivers/usb/host/ehci.h                    |  12 +++
> >  drivers/usb/host/fsl-mph-dr-of.c           |  10 +++
> >  drivers/usb/host/xhci-mem.c                |  23 +++---
> >  drivers/usb/host/xhci-ring.c               |  13 ++-
> >  drivers/usb/host/xhci.c                    |   9 +--
> >  drivers/usb/serial/option.c                |  24 ++++++
> >  drivers/usb/serial/whiteheat.c             |  31 ++++++++
> >  fs/btrfs/extent_io.c                       |  65 +++++++++++++--
> >  fs/btrfs/inode.c                           |   3 +-
> >  fs/cifs/cifsencrypt.c                      |  53 +++++++++++-
> >  fs/cifs/ioctl.c                            |   6 ++
> >  fs/cifs/smb2ops.c                          |   8 +-
> >  fs/coredump.c                              |  38 +++++++--
> >  fs/dcache.c                                |   7 ++
> >  fs/jbd2/checkpoint.c                       |  39 +++++++--
> >  fs/jbd2/commit.c                           |   2 +-
> >  fs/jbd2/journal.c                          |  11 ++-
> >  fs/namei.c                                 |  31 +++++++-
> >  fs/ocfs2/dlm/dlmmaster.c                   |   9 ++-
> >  fs/ocfs2/dlm/dlmrecovery.c                 |   8 +-
> >  include/linux/fsl_devices.h                |   2 +
> >  include/linux/jbd2.h                       |   3 +-
> >  include/linux/skbuff.h                     |   5 +-
> >  include/net/af_unix.h                      |   6 +-
> >  include/net/sock.h                         |   8 ++
> >  ipc/msg.c                                  |  14 ++--
> >  ipc/sem.c                                  |  15 ++--
> >  ipc/shm.c                                  |  12 +--
> >  ipc/util.c                                 |   8 +-
> >  kernel/irq/proc.c                          |  19 ++++-
> >  kernel/time/clocksource.c                  |   2 +-
> >  mm/hugetlb.c                               |   8 ++
> >  mm/slab.c                                  |  13 ++-
> >  net/core/datagram.c                        |   6 +-
> >  net/core/ethtool.c                         |   2 +-
> >  net/core/fib_rules.c                       |   2 +-
> >  net/core/skbuff.c                          |   9 ++-
> >  net/ipv4/tcp_input.c                       |   2 +-
> >  net/ipv4/udp.c                             |   2 +-
> >  net/ipv6/raw.c                             |   2 +-
> >  net/ipv6/udp.c                             |   3 +-
> >  net/l2tp/l2tp_core.c                       |  11 ++-
> >  net/netfilter/nft_compat.c                 |  24 ++++--
> >  net/netlink/af_netlink.c                   |  34 +++++---
> >  net/openvswitch/flow_table.c               |   3 +-
> >  net/sctp/sm_sideeffect.c                   |   2 +-
> >  net/unix/af_unix.c                         |  16 +++-
> >  sound/arm/Kconfig                          |  15 ++--
> >  sound/soc/pxa/Kconfig                      |   2 -
> >  sound/soc/pxa/pxa2xx-ac97.c                |   4 +-
> >  tools/lib/traceevent/event-parse.c         |  23 +++++-
> >  tools/perf/util/header.c                   |   4 +-
> >  tools/perf/util/symbol-elf.c               |  35 +++-----
> >  virt/kvm/eventfd.c                         | 124 +++++++++++++++++------------
> >  virt/kvm/kvm_main.c                        |  19 ++++-
> >  116 files changed, 1164 insertions(+), 451 deletions(-)
> > 
> > Aaron Conole (2):
> >       af_unix: Convert the unix_sk macro to an inline function for type safety
> >       af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag
> > 
> > Adrian Hunter (1):
> >       perf tools: Fix copying of /proc/kcore
> > 
> > Alex Williamson (2):
> >       PCI: Fix devfn for VPD access through function 0
> >       PCI: Use function 0 VPD for identical functions, regular VPD for others
> > 
> > Alexander Couzens (1):
> >       l2tp: protect tunnel->del_work by ref_count
> > 
> > Andreas Schwab (1):
> >       m68k: Define asmlinkage_protect
> > 
> > Andrey Vagin (1):
> >       net/unix: fix logic about sk_peek_offset
> > 
> > Andy Lutomirski (2):
> >       x86/paravirt: Replace the paravirt nop with a bona fide empty function
> >       x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code
> > 
> > Andy Shevchenko (1):
> >       dmaengine: dw: properly read DWC_PARAMS register
> > 
> > Aneesh Kumar K.V (1):
> >       powerpc/mm: Recompute hash value after a failed update
> > 
> > Arad, Ronen (1):
> >       netlink: Trim skb to alloc size to avoid MSG_TRUNC
> > 
> > Ard Biesheuvel (1):
> >       ARM: 8429/1: disable GCC SRA optimization
> > 
> > Arnaldo Carvalho de Melo (1):
> >       perf header: Fixup reading of HEADER_NRCPUS feature
> > 
> > Ben Hutchings (1):
> >       genirq: Fix race in register_irq_proc()
> > 
> > Benjamin Herrenschmidt (1):
> >       powerpc/boot: Specify ABI v2 when building an LE boot wrapper
> > 
> > Carl Frederik Werner (1):
> >       ARM: dts: omap3-beagle: make i2c3, ddc and tfp410 gpio work again
> > 
> > Charles Keepax (1):
> >       asix: Do full reset during ax88772_bind
> > 
> > Chas Williams (1):
> >       net/xen-netfront: only napi_synchronize() if running
> > 
> > Dave Airlie (1):
> >       drm/qxl: only report first monitor as connected if we have no state
> > 
> > David Woodhouse (1):
> >       x86/platform: Fix Geode LX timekeeping in the generic x86 build
> > 
> > Dirk Müller (1):
> >       Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS
> > 
> > Eric Dumazet (1):
> >       net: add pfmemalloc check in sk_add_backlog()
> > 
> > Eric W. Biederman (2):
> >       dcache: Handle escaped paths in prepend_path
> >       vfs: Test for and handle paths that are unreachable from their mnt_root
> > 
> > Fabiano Fidêncio (1):
> >       drm/qxl: recreate the primary surface when the bo is not primary
> > 
> > Filipe Manana (1):
> >       Btrfs: fix read corruption of compressed and shared extents
> > 
> > Grazvydas Ignotas (1):
> >       ARM: dts: omap5-uevm.dts: fix i2c5 pinctrl offsets
> > 
> > Guenter Roeck (2):
> >       hwmon: (nct6775) Swap STEP_UP_TIME and STEP_DOWN_TIME registers for most chips
> >       spi: Fix documentation of spi_alloc_master()
> > 
> > Guillaume Nault (1):
> >       ppp: don't override sk->sk_state in pppoe_flush_dev()
> > 
> > James Hogan (1):
> >       MIPS: dma-default: Fix 32-bit fall back to GFP_DMA
> > 
> > Jan Kara (1):
> >       jbd2: avoid infinite loop when destroying aborted journal
> > 
> > Jani Nikula (1):
> >       drm/i915/bios: handle MIPI Sequence Block v3+ gracefully
> > 
> > Jann Horn (2):
> >       CIFS: fix type confusion in copy offload ioctl
> >       fs: if a coredump already exists, unlink and recreate with O_EXCL
> > 
> > Jason Wang (4):
> >       kvm: don't try to register to KVM_FAST_MMIO_BUS for non mmio eventfd
> >       kvm: factor out core eventfd assign/deassign logic
> >       kvm: fix double free for fast mmio eventfd
> >       kvm: fix zero length mmio searching
> > 
> > Jeff Mahoney (1):
> >       btrfs: skip waiting on ordered range for special files
> > 
> > Jenny Derzhavetz (1):
> >       iser-target: remove command with state ISTATE_REMOVE
> > 
> > Jiri Benc (1):
> >       vxlan: set needed headroom correctly
> > 
> > Joe Perches (1):
> >       ethtool: Use kcalloc instead of kmalloc for ethtool_get_strings
> > 
> > Johan Hovold (1):
> >       USB: whiteheat: fix potential null-deref at probe
> > 
> > John Stultz (1):
> >       clocksource: Fix abs() usage w/ 64bit values
> > 
> > Joonsoo Kim (1):
> >       mm/slab: fix unexpected index mapping result of kmalloc_size(INDEX_NODE+1)
> > 
> > Joseph Qi (1):
> >       ocfs2/dlm: fix deadlock when dispatch assert master
> > 
> > Julia Lawall (1):
> >       xhci-mem: Use setup_timer
> > 
> > Kapileshwar Singh (1):
> >       tools lib traceevent: Fix string handling in heterogeneous arch environments
> > 
> > Konstantin Khlebnikov (1):
> >       ovs: do not allocate memory from offline numa node
> > 
> > Kyle Evans (1):
> >       hp-wmi: limit hotkey enable
> > 
> > Linus Torvalds (1):
> >       Initialize msg/shm IPC objects before doing ipc_addid()
> > 
> > Liu.Zhao (1):
> >       USB: option: add ZTE PIDs
> > 
> > Luis Henriques (2):
> >       zram: fix possible use after free in zcomp_create()
> >       Revert "ARM: orion5x: fix legacy orion5x IRQ numbers"
> > 
> > Manfred Spraul (1):
> >       ipc/sem.c: fully initialize sem_array before making it visible
> > 
> > Marc Zyngier (2):
> >       arm64: KVM: Disable virtual timer even if the guest is not using it
> >       arm: KVM: Disable virtual timer even if the guest is not using it
> > 
> > Mathias Krause (1):
> >       hp-wmi: Add missing __init annotations to initialization code
> > 
> > Mathias Nyman (4):
> >       usb: Use the USB_SS_MULT() macro to get the burst multiplier.
> >       xhci: give command abortion one more chance before killing xhci
> >       xhci: change xhci 1.0 only restrictions to support xhci 1.1
> >       xhci: init command timeout timer earlier to avoid deleting it uninitialized
> > 
> > Matt Fleming (1):
> >       x86/efi: Fix boot crash by mapping EFI memmap entries bottom-up at runtime, instead of top-down
> > 
> > Max Filippov (1):
> >       spi: xtensa-xtfpga: fix register endianness
> > 
> > Mel Gorman (1):
> >       mm: hugetlbfs: skip shared VMAs when unmapping private pages to satisfy a fault
> > 
> > Michel Dänzer (1):
> >       drm/radeon: Restore LCD backlight level on resume (>= R5xx)
> > 
> > Michel Stam (1):
> >       asix: Don't reset PHY on if_up for ASIX 88772
> > 
> > Nikhil Badola (2):
> >       drivers: usb :fsl: Implement Workaround for USB Erratum A007792
> >       drivers: usb: fsl: Workaround for USB erratum-A005275
> > 
> > Pablo Neira Ayuso (1):
> >       netfilter: nft_compat: skip family comparison in case of NFPROTO_UNSPEC
> > 
> > Paolo Bonzini (1):
> >       KVM: x86: trap AMD MSRs for the TSeg base and mask
> > 
> > Paul Burton (3):
> >       MIPS: CPS: Stop dangling delay slot from has_mt.
> >       MIPS: CPS: Don't include MT code in non-MT kernels.
> >       MIPS: CPS: #ifdef on CONFIG_MIPS_MT_SMP rather than CONFIG_MIPS_MT
> > 
> > Peter Chen (1):
> >       usb: chipidea: udc: using the correct stall implementation
> > 
> > Peter Seiderer (1):
> >       cifs: use server timestamp for ntlmv2 authentication
> > 
> > Prarit Bhargava (1):
> >       intel_pstate: Fix overflow in busy_scaled due to long delay
> > 
> > Pravin B Shelar (2):
> >       skbuff: Fix skb checksum flag on skb pull
> >       skbuff: Fix skb checksum partial check.
> > 
> > Richard Weinberger (1):
> >       UBI: Validate data_size
> > 
> > Robert Jarzmik (2):
> >       ASoC: pxa: pxa2xx-ac97: fix dma requestor lines
> >       ASoC: fix broken pxa SoC support
> > 
> > Roger Quadros (2):
> >       usb: xhci: Clear XHCI_STATE_DYING on start
> >       usb: xhci: Allow usb_add/remove_hcd() to be called repeatedly
> > 
> > Roland Dreier (1):
> >       fib_rules: Fix dump_rules() not to exit early
> > 
> > Russell King (1):
> >       ARM: fix Thumb2 signal handling when ARMv6 is enabled
> > 
> > Sabrina Dubroca (1):
> >       net: add length argument to skb_copy_and_csum_datagram_iovec
> > 
> > Shaohua Li (1):
> >       x86/apic: Serialize LVTT and TSC_DEADLINE writes
> > 
> > Shawn Lin (1):
> >       staging: ion: fix corruption of ion_import_dma_buf
> > 
> > Simon Guinot (1):
> >       net: mvneta: fix DMA buffer unmapping in mvneta_rx()
> > 
> > Stephen Smalley (1):
> >       x86/mm: Set NX on gap between __ex_table and rodata
> > 
> > Steve French (1):
> >       disabling oplocks/leases via module parm enable_oplocks broken for SMB3
> > 
> > Stratos Karafotis (1):
> >       cpufreq: intel_pstate: Remove unnecessary type casting in div_s64() call
> > 
> > Tan, Jui Nee (1):
> >       spi: spi-pxa2xx: Check status register to determine if SSSR_TINT is disabled
> > 
> > Thomas Hellstrom (2):
> >       drm/vmwgfx: Fix up user_dmabuf refcounting
> >       drm/vmwgfx: Fix kernel NULL pointer dereference on older hardware
> > 
> > Will Deacon (3):
> >       arm64: head.S: initialise mdcr_el2 in el2_setup
> >       arm64: compat: fix vfp save/restore across signal handlers in big-endian
> >       arm64: errata: add module build workaround for erratum #843419
> > 
> > lucien (1):
> >       sctp: donot reset the overall_error_count in SHUTDOWN_RECEIVE state
> > 
> > shengyong (1):
> >       UBI: return ENOSPC if no enough space available
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

^ permalink raw reply	[flat|nested] 115+ messages in thread

* [PATCH 3.16.y-ckt 108/108] Btrfs: update fix for read corruption of compressed and shared extents
  2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
                   ` (107 preceding siblings ...)
  2015-10-26 19:05 ` [PATCH 3.16.y-ckt 107/107] KEYS: Don't permit request_key() to construct a new keyring Luis Henriques
@ 2015-10-28 16:52 ` Luis Henriques
  108 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-10-28 16:52 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Filipe Manana, Luis Henriques

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Filipe Manana <fdmanana@suse.com>

commit 808f80b46790f27e145c72112189d6a3be2bc884 upstream.

My previous fix in commit 005efedf2c7d ("Btrfs: fix read corruption of
compressed and shared extents") was effective only if the compressed
extents cover a file range with a length that is not a multiple of 16
pages. That's because the detection of when we reached a different range
of the file that shares the same compressed extent as the previously
processed range was done at extent_io.c:__do_contiguous_readpages(),
which covers subranges with a length up to 16 pages, because
extent_readpages() groups the pages in clusters no larger than 16 pages.
So fix this by tracking the start of the previously processed file
range's extent map at extent_readpages().

The following test case for fstests reproduces the issue:

  seq=`basename $0`
  seqres=$RESULT_DIR/$seq
  echo "QA output created by $seq"
  tmp=/tmp/$$
  status=1	# failure is the default!
  trap "_cleanup; exit \$status" 0 1 2 3 15

  _cleanup()
  {
      rm -f $tmp.*
  }

  # get standard environment, filters and checks
  . ./common/rc
  . ./common/filter

  # real QA test starts here
  _need_to_be_root
  _supported_fs btrfs
  _supported_os Linux
  _require_scratch
  _require_cloner

  rm -f $seqres.full

  test_clone_and_read_compressed_extent()
  {
      local mount_opts=$1

      _scratch_mkfs >>$seqres.full 2>&1
      _scratch_mount $mount_opts

      # Create our test file with a single extent of 64Kb that is going to
      # be compressed no matter which compression algo is used (zlib/lzo).
      $XFS_IO_PROG -f -c "pwrite -S 0xaa 0K 64K" \
          $SCRATCH_MNT/foo | _filter_xfs_io

      # Now clone the compressed extent into an adjacent file offset.
      $CLONER_PROG -s 0 -d $((64 * 1024)) -l $((64 * 1024)) \
          $SCRATCH_MNT/foo $SCRATCH_MNT/foo

      echo "File digest before unmount:"
      md5sum $SCRATCH_MNT/foo | _filter_scratch

      # Remount the fs or clear the page cache to trigger the bug in
      # btrfs. Because the extent has an uncompressed length that is a
      # multiple of 16 pages, all the pages belonging to the second range
      # of the file (64K to 128K), which points to the same extent as the
      # first range (0K to 64K), had their contents full of zeroes instead
      # of the byte 0xaa. This was a bug exclusively in the read path of
      # compressed extents, the correct data was stored on disk, btrfs
      # just failed to fill in the pages correctly.
      _scratch_remount

      echo "File digest after remount:"
      # Must match the digest we got before.
      md5sum $SCRATCH_MNT/foo | _filter_scratch
  }

  echo -e "\nTesting with zlib compression..."
  test_clone_and_read_compressed_extent "-o compress=zlib"

  _scratch_unmount

  echo -e "\nTesting with lzo compression..."
  test_clone_and_read_compressed_extent "-o compress=lzo"

  status=0
  exit

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Tested-by: Timofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 fs/btrfs/extent_io.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 0c5955b6275d..13ee2bb1ed9c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3019,12 +3019,12 @@ static inline void __do_contiguous_readpages(struct extent_io_tree *tree,
 					     get_extent_t *get_extent,
 					     struct extent_map **em_cached,
 					     struct bio **bio, int mirror_num,
-					     unsigned long *bio_flags, int rw)
+					     unsigned long *bio_flags, int rw,
+					     u64 *prev_em_start)
 {
 	struct inode *inode;
 	struct btrfs_ordered_extent *ordered;
 	int index;
-	u64 prev_em_start = (u64)-1;
 
 	inode = pages[0]->mapping->host;
 	while (1) {
@@ -3040,7 +3040,7 @@ static inline void __do_contiguous_readpages(struct extent_io_tree *tree,
 
 	for (index = 0; index < nr_pages; index++) {
 		__do_readpage(tree, pages[index], get_extent, em_cached, bio,
-			      mirror_num, bio_flags, rw, &prev_em_start);
+			      mirror_num, bio_flags, rw, prev_em_start);
 		page_cache_release(pages[index]);
 	}
 }
@@ -3050,7 +3050,8 @@ static void __extent_readpages(struct extent_io_tree *tree,
 			       int nr_pages, get_extent_t *get_extent,
 			       struct extent_map **em_cached,
 			       struct bio **bio, int mirror_num,
-			       unsigned long *bio_flags, int rw)
+			       unsigned long *bio_flags, int rw,
+			       u64 *prev_em_start)
 {
 	u64 start = 0;
 	u64 end = 0;
@@ -3071,7 +3072,7 @@ static void __extent_readpages(struct extent_io_tree *tree,
 						  index - first_index, start,
 						  end, get_extent, em_cached,
 						  bio, mirror_num, bio_flags,
-						  rw);
+						  rw, prev_em_start);
 			start = page_start;
 			end = start + PAGE_CACHE_SIZE - 1;
 			first_index = index;
@@ -3082,7 +3083,8 @@ static void __extent_readpages(struct extent_io_tree *tree,
 		__do_contiguous_readpages(tree, &pages[first_index],
 					  index - first_index, start,
 					  end, get_extent, em_cached, bio,
-					  mirror_num, bio_flags, rw);
+					  mirror_num, bio_flags, rw,
+					  prev_em_start);
 }
 
 static int __extent_read_full_page(struct extent_io_tree *tree,
@@ -4037,6 +4039,7 @@ int extent_readpages(struct extent_io_tree *tree,
 	struct page *page;
 	struct extent_map *em_cached = NULL;
 	int nr = 0;
+	u64 prev_em_start = (u64)-1;
 
 	for (page_idx = 0; page_idx < nr_pages; page_idx++) {
 		page = list_entry(pages->prev, struct page, lru);
@@ -4053,12 +4056,12 @@ int extent_readpages(struct extent_io_tree *tree,
 		if (nr < ARRAY_SIZE(pagepool))
 			continue;
 		__extent_readpages(tree, pagepool, nr, get_extent, &em_cached,
-				   &bio, 0, &bio_flags, READ);
+				   &bio, 0, &bio_flags, READ, &prev_em_start);
 		nr = 0;
 	}
 	if (nr)
 		__extent_readpages(tree, pagepool, nr, get_extent, &em_cached,
-				   &bio, 0, &bio_flags, READ);
+				   &bio, 0, &bio_flags, READ, &prev_em_start);
 
 	if (em_cached)
 		free_extent_map(em_cached);

^ permalink raw reply related	[flat|nested] 115+ messages in thread

* Re: [PATCH 3.16.y-ckt 072/104] drm/radeon: Restore LCD backlight level on resume (>= R5xx)
  2015-10-28 10:45     ` Luis Henriques
@ 2015-11-02  7:52       ` Michel Dänzer
  2015-11-11 15:43         ` Luis Henriques
  0 siblings, 1 reply; 115+ messages in thread
From: Michel Dänzer @ 2015-11-02  7:52 UTC (permalink / raw)
  To: Luis Henriques; +Cc: linux-kernel, stable, kernel-team, Alex Deucher

On 28.10.2015 19:45, Luis Henriques wrote:
> On Tue, Oct 27, 2015 at 11:10:29AM +0900, Michel Dänzer wrote:
>> On 26.10.2015 22:42, Luis Henriques wrote:
>>> 3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.
>>>
>>> ------------------
>>>
>>> From: =TF-8?q?Michel Dänzer?= <michel.daenzer@amd.com>
>>>
>>> commit 4281f46ef839050d2ef60348f661eb463c21cc2e upstream.
>>>
>>> Instead of only enabling the backlight (which seems to set it to max
>>> brightness), just re-set the current backlight level, which also takes
>>> care of enabling the backlight if necessary.
>>>
>>> Only the radeon_atom_encoder_dpms_dig part tested on a Kaveri laptop,
>>> the radeon_atom_encoder_dpms_avivo part is only compile tested.
>>>
>>> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>>> Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
>>
>> We're currently investigating a regression which was bisected to this
>> change. Please hold off on backporting this change until we have a
>> solution for that.
> 
> Thanks, I'll drop this patch for this 3.16 release, and will wait for a
> fix to be available.

The regression is fixed in commits
4cee6a9057d5e13911f0cb6e143d11dc1a3245dd and
ae93580ee59c02395c1711d3e6b90546b8137b86 . Please only backport
4281f46ef839050d2ef60348f661eb463c21cc2e together with those two.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer

^ permalink raw reply	[flat|nested] 115+ messages in thread

* Re: [PATCH 3.16.y-ckt 072/104] drm/radeon: Restore LCD backlight level on resume (>= R5xx)
  2015-11-02  7:52       ` Michel Dänzer
@ 2015-11-11 15:43         ` Luis Henriques
  0 siblings, 0 replies; 115+ messages in thread
From: Luis Henriques @ 2015-11-11 15:43 UTC (permalink / raw)
  To: Michel Dänzer; +Cc: linux-kernel, stable, kernel-team, Alex Deucher

On Mon, Nov 02, 2015 at 04:52:06PM +0900, Michel Dänzer wrote:
> On 28.10.2015 19:45, Luis Henriques wrote:
> > On Tue, Oct 27, 2015 at 11:10:29AM +0900, Michel Dänzer wrote:
> >> On 26.10.2015 22:42, Luis Henriques wrote:
> >>> 3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.
> >>>
> >>> ------------------
> >>>
> >>> From: =TF-8?q?Michel Dänzer?= <michel.daenzer@amd.com>
> >>>
> >>> commit 4281f46ef839050d2ef60348f661eb463c21cc2e upstream.
> >>>
> >>> Instead of only enabling the backlight (which seems to set it to max
> >>> brightness), just re-set the current backlight level, which also takes
> >>> care of enabling the backlight if necessary.
> >>>
> >>> Only the radeon_atom_encoder_dpms_dig part tested on a Kaveri laptop,
> >>> the radeon_atom_encoder_dpms_avivo part is only compile tested.
> >>>
> >>> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
> >>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> >>> Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
> >>
> >> We're currently investigating a regression which was bisected to this
> >> change. Please hold off on backporting this change until we have a
> >> solution for that.
> > 
> > Thanks, I'll drop this patch for this 3.16 release, and will wait for a
> > fix to be available.
> 
> The regression is fixed in commits
> 4cee6a9057d5e13911f0cb6e143d11dc1a3245dd and
> ae93580ee59c02395c1711d3e6b90546b8137b86 . Please only backport
> 4281f46ef839050d2ef60348f661eb463c21cc2e together with those two.
> 

Thanks (and sorry for the delay in my reply!).

I'll queue all these 3 commits for the 3.16 kernel.  Commit 4cee6a9057d5
("drm/radeon: move bl encoder assignment into bl init") required a bit of
backporting which I would appreciate if you could review it (you'll
received the email with the patch soon).

Cheers,
--
Luís

^ permalink raw reply	[flat|nested] 115+ messages in thread

end of thread, other threads:[~2015-11-11 15:43 UTC | newest]

Thread overview: 115+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 001/104] ARM: 8429/1: disable GCC SRA optimization Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 002/104] CIFS: fix type confusion in copy offload ioctl Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 003/104] hwmon: (nct6775) Swap STEP_UP_TIME and STEP_DOWN_TIME registers for most chips Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 004/104] x86/apic: Serialize LVTT and TSC_DEADLINE writes Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 005/104] arm64: head.S: initialise mdcr_el2 in el2_setup Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 006/104] kvm: don't try to register to KVM_FAST_MMIO_BUS for non mmio eventfd Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 007/104] kvm: factor out core eventfd assign/deassign logic Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 008/104] kvm: fix double free for fast mmio eventfd Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 009/104] kvm: fix zero length mmio searching Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 010/104] ARM: fix Thumb2 signal handling when ARMv6 is enabled Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 011/104] powerpc/boot: Specify ABI v2 when building an LE boot wrapper Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 012/104] powerpc/mm: Recompute hash value after a failed update Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 013/104] x86/platform: Fix Geode LX timekeeping in the generic x86 build Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 014/104] arm64: compat: fix vfp save/restore across signal handlers in big-endian Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 015/104] arm64: errata: add module build workaround for erratum #843419 Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 016/104] arm64: KVM: Disable virtual timer even if the guest is not using it Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 017/104] arm: " Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 018/104] hp-wmi: Add missing __init annotations to initialization code Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 019/104] hp-wmi: limit hotkey enable Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 020/104] zram: fix possible use after free in zcomp_create() Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 021/104] perf header: Fixup reading of HEADER_NRCPUS feature Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 022/104] dcache: Handle escaped paths in prepend_path Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 023/104] vfs: Test for and handle paths that are unreachable from their mnt_root Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 024/104] spi: spi-pxa2xx: Check status register to determine if SSSR_TINT is disabled Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 025/104] spi: Fix documentation of spi_alloc_master() Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 026/104] USB: option: add ZTE PIDs Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 027/104] drm/vmwgfx: Fix up user_dmabuf refcounting Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 028/104] ARM: dts: omap3-beagle: make i2c3, ddc and tfp410 gpio work again Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 029/104] Btrfs: fix read corruption of compressed and shared extents Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 030/104] btrfs: skip waiting on ordered range for special files Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 031/104] usb: chipidea: udc: using the correct stall implementation Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 032/104] net: mvneta: fix DMA buffer unmapping in mvneta_rx() Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 033/104] iser-target: remove command with state ISTATE_REMOVE Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 034/104] staging: ion: fix corruption of ion_import_dma_buf Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 035/104] KVM: x86: trap AMD MSRs for the TSeg base and mask Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 036/104] usb: Use the USB_SS_MULT() macro to get the burst multiplier Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 037/104] xhci: give command abortion one more chance before killing xhci Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 038/104] usb: xhci: Clear XHCI_STATE_DYING on start Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 039/104] usb: xhci: Allow usb_add/remove_hcd() to be called repeatedly Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 040/104] xhci: change xhci 1.0 only restrictions to support xhci 1.1 Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 041/104] xhci-mem: Use setup_timer Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 042/104] xhci: init command timeout timer earlier to avoid deleting it uninitialized Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 043/104] spi: xtensa-xtfpga: fix register endianness Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 044/104] disabling oplocks/leases via module parm enable_oplocks broken for SMB3 Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 045/104] cifs: use server timestamp for ntlmv2 authentication Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 046/104] x86/paravirt: Replace the paravirt nop with a bona fide empty function Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 047/104] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 048/104] ASoC: pxa: pxa2xx-ac97: fix dma requestor lines Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 049/104] ocfs2/dlm: fix deadlock when dispatch assert master Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 050/104] drm/i915/bios: handle MIPI Sequence Block v3+ gracefully Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 051/104] USB: whiteheat: fix potential null-deref at probe Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 052/104] drm/qxl: only report first monitor as connected if we have no state Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 053/104] PCI: Fix devfn for VPD access through function 0 Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 054/104] PCI: Use function 0 VPD for identical functions, regular VPD for others Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 055/104] netfilter: nft_compat: skip family comparison in case of NFPROTO_UNSPEC Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 056/104] ASoC: fix broken pxa SoC support Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 057/104] ARM: dts: omap5-uevm.dts: fix i2c5 pinctrl offsets Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 058/104] vxlan: set needed headroom correctly Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 059/104] Revert "ARM: orion5x: fix legacy orion5x IRQ numbers" Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 060/104] jbd2: avoid infinite loop when destroying aborted journal Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 061/104] asix: Don't reset PHY on if_up for ASIX 88772 Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 062/104] asix: Do full reset during ax88772_bind Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 063/104] fib_rules: Fix dump_rules() not to exit early Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 064/104] net/xen-netfront: only napi_synchronize() if running Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 065/104] cpufreq: intel_pstate: Remove unnecessary type casting in div_s64() call Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 066/104] intel_pstate: Fix overflow in busy_scaled due to long delay Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 067/104] tools lib traceevent: Fix string handling in heterogeneous arch environments Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 068/104] perf tools: Fix copying of /proc/kcore Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 069/104] m68k: Define asmlinkage_protect Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 070/104] UBI: Validate data_size Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 071/104] UBI: return ENOSPC if no enough space available Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 072/104] drm/radeon: Restore LCD backlight level on resume (>= R5xx) Luis Henriques
2015-10-27  2:10   ` Michel Dänzer
2015-10-28 10:45     ` Luis Henriques
2015-11-02  7:52       ` Michel Dänzer
2015-11-11 15:43         ` Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 073/104] MIPS: dma-default: Fix 32-bit fall back to GFP_DMA Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 074/104] MIPS: CPS: Stop dangling delay slot from has_mt Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 075/104] MIPS: CPS: Don't include MT code in non-MT kernels Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 076/104] MIPS: CPS: #ifdef on CONFIG_MIPS_MT_SMP rather than CONFIG_MIPS_MT Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 077/104] Initialize msg/shm IPC objects before doing ipc_addid() Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 078/104] drm/qxl: recreate the primary surface when the bo is not primary Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 079/104] genirq: Fix race in register_irq_proc() Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 080/104] x86/efi: Fix boot crash by mapping EFI memmap entries bottom-up at runtime, instead of top-down Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 081/104] Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 082/104] mm: hugetlbfs: skip shared VMAs when unmapping private pages to satisfy a fault Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 083/104] x86/mm: Set NX on gap between __ex_table and rodata Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 084/104] clocksource: Fix abs() usage w/ 64bit values Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 085/104] dmaengine: dw: properly read DWC_PARAMS register Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 086/104] mm/slab: fix unexpected index mapping result of kmalloc_size(INDEX_NODE+1) Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 087/104] drm/vmwgfx: Fix kernel NULL pointer dereference on older hardware Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 088/104] fs: if a coredump already exists, unlink and recreate with O_EXCL Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 089/104] sctp: donot reset the overall_error_count in SHUTDOWN_RECEIVE state Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 090/104] ipc/sem.c: fully initialize sem_array before making it visible Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 091/104] drivers: usb :fsl: Implement Workaround for USB Erratum A007792 Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 092/104] drivers: usb: fsl: Workaround for USB erratum-A005275 Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 093/104] l2tp: protect tunnel->del_work by ref_count Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 094/104] af_unix: Convert the unix_sk macro to an inline function for type safety Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 095/104] af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 096/104] net/unix: fix logic about sk_peek_offset Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 097/104] skbuff: Fix skb checksum flag on skb pull Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 098/104] skbuff: Fix skb checksum partial check Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 099/104] net: add pfmemalloc check in sk_add_backlog() Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 100/104] ppp: don't override sk->sk_state in pppoe_flush_dev() Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 101/104] ethtool: Use kcalloc instead of kmalloc for ethtool_get_strings Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 102/104] ovs: do not allocate memory from offline numa node Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 103/104] netlink: Trim skb to alloc size to avoid MSG_TRUNC Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 104/104] net: add length argument to skb_copy_and_csum_datagram_iovec Luis Henriques
2015-10-26 19:02 ` [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
2015-10-28 16:51   ` Luis Henriques
2015-10-26 19:05 ` [PATCH 3.16.y-ckt 105/107] KEYS: Fix race between key destruction and finding a keyring by name Luis Henriques
2015-10-26 19:05 ` [PATCH 3.16.y-ckt 106/107] KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring Luis Henriques
2015-10-26 19:05 ` [PATCH 3.16.y-ckt 107/107] KEYS: Don't permit request_key() to construct a new keyring Luis Henriques
2015-10-28 16:52 ` [PATCH 3.16.y-ckt 108/108] Btrfs: update fix for read corruption of compressed and shared extents Luis Henriques

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).