linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3.18 00/60] 3.18.63-stable review
@ 2017-07-25 19:15 Greg Kroah-Hartman
  2017-07-25 19:15 ` [PATCH 3.18 01/60] disable new gcc-7.1.1 warnings for now Greg Kroah-Hartman
                   ` (58 more replies)
  0 siblings, 59 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, torvalds, akpm, linux, shuahkh, patches,
	ben.hutchings, stable

This is the start of the stable review cycle for the 3.18.63 release.
There are 60 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Thu Jul 27 19:15:49 UTC 2017.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:
	kernel.org/pub/linux/kernel/v3.x/stable-review/patch-3.18.63-rc1.gz
or in the git tree and branch at:
  git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-3.18.y
and the diffstat can be found below.

thanks,

greg k-h

-------------
Pseudo-Shortlog of commits:

Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Linux 3.18.63-rc1

Maciej W. Rozycki <macro@imgtec.com>
    MIPS: Send SIGILL for BPOSGE32 in `__compute_return_epc_for_insn'

Greg Hackmann <ghackmann@google.com>
    alarmtimer: don't rate limit one-shot timers

Chunyu Hu <chuhu@redhat.com>
    tracing: Fix kmemleak in instance_rmdir

Bjorn Andersson <bjorn.andersson@linaro.org>
    spmi: Include OF based modalias in device uevent

Stephen Boyd <stephen.boyd@linaro.org>
    of: device: Export of_device_{get_modalias, uvent_modalias} to modules

Paul Mackerras <paulus@ozlabs.org>
    KVM: PPC: Book3S HV: Context-switch EBB registers properly

Imre Deak <imre.deak@intel.com>
    drm/mst: Avoid processing partially received up/down message transactions

Imre Deak <imre.deak@intel.com>
    drm/mst: Avoid dereferencing a NULL mstb in drm_dp_mst_handle_up_req()

Imre Deak <imre.deak@intel.com>
    drm/mst: Fix error handling during MST sideband message reception

Michael Gugino <michael.gugino.2@gmail.com>
    staging: rtl8188eu: add TL-WN722N v2 support

Ingo Molnar <mingo@kernel.org>
    Revert "perf/core: Drop kernel samples even though :u is specified"

Jin Yao <yao.jin@linux.intel.com>
    perf annotate: Fix broken arrow at row 0 connecting jmp instruction to its target

Jiang Yi <jiangyilism@gmail.com>
    target: Fix COMPARE_AND_WRITE caw_sem leak during se_cmd quiesce

Jan Kara <jack@suse.cz>
    udf: Fix deadlock between writeback and udf_setsize()

NeilBrown <neilb@suse.com>
    NFS: only invalidate dentrys that are clearly invalid.

Chen Hong <chenhong3@huawei.com>
    Input: i8042 - fix crash at boot time

Maciej W. Rozycki <macro@imgtec.com>
    MIPS: math-emu: Prevent wrong ISA mode instruction emulation

Maciej W. Rozycki <macro@imgtec.com>
    MIPS: Fix unaligned PC interpretation in `compute_return_epc'

Maciej W. Rozycki <macro@imgtec.com>
    MIPS: Actually decode JALX in `__compute_return_epc_for_insn'

James Hogan <james.hogan@imgtec.com>
    MIPS: Save static registers before sysmips

Seunghun Han <kkamagui@gmail.com>
    x86/acpi: Prevent out of bound access caused by broken ACPI tables

James Hogan <james.hogan@imgtec.com>
    MIPS: Negate error syscall return in trace

James Hogan <james.hogan@imgtec.com>
    MIPS: Fix mips_atomic_set() with EVA

James Hogan <james.hogan@imgtec.com>
    MIPS: Fix mips_atomic_set() retry condition

Alex Williamson <alex.williamson@redhat.com>
    vfio: New external user group/file match

Alex Williamson <alex.williamson@redhat.com>
    vfio: Fix group release deadlock

Jaegeuk Kim <jaegeuk@kernel.org>
    f2fs: Don't clear SGID when inheriting ACLs

Alex Deucher <alexander.deucher@amd.com>
    drm/radeon/ci: disable mclk switching for high refresh rates (v2)

Jiri Olsa <jolsa@kernel.org>
    s390/syscalls: Fix out of bounds arguments access

Xiao Ni <xni@redhat.com>
    Raid5 should update rdev->sectors after reshape

Mikulas Patocka <mpatocka@redhat.com>
    md: don't use flush_signals in userspace processes

Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL

Johan Hovold <johan@kernel.org>
    USB: cdc-acm: add device-id for quirky printer

Colin Ian King <colin.king@canonical.com>
    usb: storage: return on error to avoid a null pointer dereference

Mathias Nyman <mathias.nyman@linux.intel.com>
    xhci: Fix NULL pointer dereference when cleaning up streams for removed host

Mathias Nyman <mathias.nyman@linux.intel.com>
    xhci: fix 20000ms port resume timeout

Chen Yu <yu.c.chen@intel.com>
    PCI/PM: Restore the status of PCI devices across hibernation

Herbert Xu <herbert@gondor.apana.org.au>
    af_key: Fix sadb_x_ipsecrequest parsing

Oliver O'Halloran <oohall@gmail.com>
    powerpc/asm: Mark cr0 as clobbered in mftb()

Anton Blanchard <anton@samba.org>
    powerpc: Fix emulation of mfocrf in emulate_step()

Anton Blanchard <anton@samba.org>
    powerpc: Fix emulation of mcrf in emulate_step()

Michael Ellerman <mpe@ellerman.id.au>
    powerpc/64: Fix atomic64_inc_not_zero() to return an int

Maurizio Lombardi <mlombard@redhat.com>
    scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails.

Krzysztof Kozlowski <krzk@kernel.org>
    PM / Domains: Fix unsafe iteration over modified list of domain providers

Krzysztof Kozlowski <krzk@kernel.org>
    PM / Domains: Fix unsafe iteration over modified list of device links

Satish Babu Patakokila <sbpata@codeaurora.org>
    ASoC: compress: Derive substream from stream based on direction

Jason A. Donenfeld <Jason@zx2c4.com>
    Bluetooth: use constant time memory comparison for secret values

Mateusz Jurczyk <mjurczyk@google.com>
    NFC: Add sockaddr length checks before accessing sa_family in bind handlers

Joe Perches <joe@perches.com>
    stddef.h: move offsetofend inside #ifndef/#endif guard, neaten

Denys Vlasenko <dvlasenk@redhat.com>
    include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header

Mateusz Jurczyk <mjurczyk@google.com>
    nfc: Fix the sockaddr length sanitization in llcp_sock_connect

Mateusz Jurczyk <mjurczyk@google.com>
    nfc: Ensure presence of required attributes in the activate_target handler

Johan Hovold <johan@kernel.org>
    NFC: fix broken device allocation

Miaoqing Pan <miaoqing@codeaurora.org>
    ath9k: fix tx99 bus error

Miaoqing Pan <miaoqing@codeaurora.org>
    ath9k: fix tx99 use after free

Pavel Shilovsky <pshilov@microsoft.com>
    CIFS: Fix handle_cancelled_mid callback initialization

Arnd Bergmann <arnd@arndb.de>
    ir-core: fix gcc-7 warning on bool arithmetic

Colin King <colin.king@canonical.com>
    x86/rtc: Remove duplicate const specifier

Jiri Slaby <jslaby@suse.cz>
    kvm: x86: memset whole irq_eoi

Linus Torvalds <torvalds@linux-foundation.org>
    disable new gcc-7.1.1 warnings for now


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

Diffstat:

 Makefile                                    |  7 +++--
 arch/mips/include/asm/branch.h              |  5 +--
 arch/mips/kernel/branch.c                   |  8 +++--
 arch/mips/kernel/ptrace.c                   |  2 +-
 arch/mips/kernel/scall32-o32.S              |  2 +-
 arch/mips/kernel/scall64-64.S               |  2 +-
 arch/mips/kernel/scall64-n32.S              |  2 +-
 arch/mips/kernel/scall64-o32.S              |  2 +-
 arch/mips/kernel/syscall.c                  | 15 +++++++--
 arch/mips/math-emu/cp1emu.c                 | 38 +++++++++++++++++++++++
 arch/powerpc/include/asm/atomic.h           |  4 +--
 arch/powerpc/include/asm/reg.h              |  2 +-
 arch/powerpc/kvm/book3s_hv.c                | 16 ++++++++++
 arch/powerpc/lib/sstep.c                    | 19 ++++++++++--
 arch/s390/include/asm/syscall.h             |  6 ++++
 arch/x86/kernel/acpi/boot.c                 |  8 +++++
 arch/x86/kernel/rtc.c                       |  2 +-
 drivers/base/power/domain.c                 |  8 ++---
 drivers/gpu/drm/drm_dp_mst_topology.c       | 41 ++++++++++++++++++++-----
 drivers/gpu/drm/radeon/ci_dpm.c             |  6 ++++
 drivers/input/serio/i8042.c                 | 12 ++++++--
 drivers/md/raid1.c                          |  5 ++-
 drivers/md/raid5.c                          |  9 +++---
 drivers/media/rc/imon.c                     |  2 +-
 drivers/misc/enclosure.c                    | 14 ++++++---
 drivers/net/wireless/ath/ath9k/ar9003_phy.c |  2 --
 drivers/net/wireless/ath/ath9k/tx99.c       | 13 +++++---
 drivers/of/device.c                         |  2 ++
 drivers/pci/pci-driver.c                    |  1 +
 drivers/spmi/spmi.c                         | 12 ++++++++
 drivers/staging/rtl8188eu/os_dep/usb_intf.c |  1 +
 drivers/target/target_core_transport.c      |  9 ++++++
 drivers/usb/class/cdc-acm.c                 |  3 ++
 drivers/usb/host/xhci-hub.c                 |  3 ++
 drivers/usb/host/xhci-ring.c                | 11 ++++---
 drivers/usb/renesas_usbhs/common.c          |  4 ++-
 drivers/usb/storage/isd200.c                |  5 ++-
 drivers/vfio/vfio.c                         | 46 +++++++++++++++++++++++++++-
 fs/cifs/smb2ops.c                           |  3 +-
 fs/f2fs/acl.c                               |  2 +-
 fs/nfs/dir.c                                | 12 +++++---
 fs/nfs/inode.c                              |  4 +--
 fs/udf/inode.c                              |  4 +--
 include/linux/stddef.h                      | 15 +++++++--
 include/linux/vfio.h                        | 15 ++-------
 kernel/events/core.c                        | 21 -------------
 kernel/time/alarmtimer.c                    |  3 +-
 kernel/trace/trace.c                        |  1 +
 net/bluetooth/smp.c                         |  5 +--
 net/key/af_key.c                            | 47 ++++++++++++++++-------------
 net/nfc/core.c                              | 31 +++++++++++--------
 net/nfc/llcp_sock.c                         |  9 +++---
 net/nfc/netlink.c                           |  4 ++-
 sound/soc/soc-compress.c                    |  6 ++--
 tools/perf/ui/browser.c                     |  2 +-
 virt/kvm/ioapic.c                           |  2 +-
 virt/kvm/vfio.c                             | 27 ++++++++++++-----
 57 files changed, 399 insertions(+), 163 deletions(-)

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

* [PATCH 3.18 01/60] disable new gcc-7.1.1 warnings for now
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
@ 2017-07-25 19:15 ` Greg Kroah-Hartman
  2017-07-25 19:15 ` [PATCH 3.18 03/60] x86/rtc: Remove duplicate const specifier Greg Kroah-Hartman
                   ` (57 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Linus Torvalds

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

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

From: Linus Torvalds <torvalds@linux-foundation.org>

commit bd664f6b3e376a8ef4990f87d08271cc2d01ba9a upstream.

I made the mistake of upgrading my desktop to the new Fedora 26 that
comes with gcc-7.1.1.

There's nothing wrong per se that I've noticed, but I now have 1500
lines of warnings, mostly from the new format-truncation warning
triggering all over the tree.

We use 'snprintf()' and friends in a lot of places, and often know that
the numbers are fairly small (ie a controller index or similar), but gcc
doesn't know that, and sees an 'int', and thinks that it could be some
huge number.  And then complains when our buffers are not able to fit
the name for the ten millionth controller.

These warnings aren't necessarily bad per se, and we probably want to
look through them subsystem by subsystem, but at least during the merge
window they just mean that I can't even see if somebody is introducing
any *real* problems when I pull.

So warnings disabled for now.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 Makefile |    3 +++
 1 file changed, 3 insertions(+)

--- a/Makefile
+++ b/Makefile
@@ -611,6 +611,9 @@ include $(srctree)/arch/$(SRCARCH)/Makef
 
 KBUILD_CFLAGS	+= $(call cc-option,-fno-delete-null-pointer-checks,)
 KBUILD_CFLAGS	+= $(call cc-disable-warning,frame-address,)
+KBUILD_CFLAGS	+= $(call cc-disable-warning, format-truncation)
+KBUILD_CFLAGS	+= $(call cc-disable-warning, format-overflow)
+KBUILD_CFLAGS	+= $(call cc-disable-warning, int-in-bool-context)
 KBUILD_CFLAGS	+= $(call cc-option,-fno-PIE)
 KBUILD_AFLAGS	+= $(call cc-option,-fno-PIE)
 

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

* [PATCH 3.18 03/60] x86/rtc: Remove duplicate const specifier
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
  2017-07-25 19:15 ` [PATCH 3.18 01/60] disable new gcc-7.1.1 warnings for now Greg Kroah-Hartman
@ 2017-07-25 19:15 ` Greg Kroah-Hartman
  2017-07-25 19:15 ` [PATCH 3.18 04/60] [media] ir-core: fix gcc-7 warning on bool arithmetic Greg Kroah-Hartman
                   ` (56 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Colin Ian King, Thomas Gleixner

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

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

From: Colin King <colin.king@canonical.com>

commit d505ad1d66c9cd31db5ab0d2c7bcb2a47e5bb29e upstream.

Building with clang:

  CC      arch/x86/kernel/rtc.o
arch/x86/kernel/rtc.c:173:29: warning: duplicate 'const' declaration
  specifier [-Wduplicate-decl-specifier]
        static const char * const  const ids[] __initconst =

Remove the duplicate const, it is not needed and causes a warning.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: http://lkml.kernel.org/r/1421244475-313-1-git-send-email-colin.king@canonical.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/rtc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -170,7 +170,7 @@ static struct platform_device rtc_device
 static __init int add_rtc_cmos(void)
 {
 #ifdef CONFIG_PNP
-	static const char * const  const ids[] __initconst =
+	static const char * const ids[] __initconst =
 	    { "PNP0b00", "PNP0b01", "PNP0b02", };
 	struct pnp_dev *dev;
 	struct pnp_id *id;

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

* [PATCH 3.18 04/60] [media] ir-core: fix gcc-7 warning on bool arithmetic
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
  2017-07-25 19:15 ` [PATCH 3.18 01/60] disable new gcc-7.1.1 warnings for now Greg Kroah-Hartman
  2017-07-25 19:15 ` [PATCH 3.18 03/60] x86/rtc: Remove duplicate const specifier Greg Kroah-Hartman
@ 2017-07-25 19:15 ` Greg Kroah-Hartman
  2017-07-25 19:15 ` [PATCH 3.18 05/60] CIFS: Fix handle_cancelled_mid callback initialization Greg Kroah-Hartman
                   ` (55 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Arnd Bergmann, Mauro Carvalho Chehab

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

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

From: Arnd Bergmann <arnd@arndb.de>

commit bd7e31bbade02bc1e92aa00d5cf2cee2da66838a upstream.

gcc-7 suggests that an expression using a bitwise not and a bitmask
on a 'bool' variable is better written using boolean logic:

drivers/media/rc/imon.c: In function 'imon_incoming_scancode':
drivers/media/rc/imon.c:1725:22: error: '~' on a boolean expression [-Werror=bool-operation]
    ictx->pad_mouse = ~(ictx->pad_mouse) & 0x1;
                      ^
drivers/media/rc/imon.c:1725:22: note: did you mean to use logical not?

I agree.

Fixes: 21677cfc562a ("V4L/DVB: ir-core: add imon driver")

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/media/rc/imon.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -1629,7 +1629,7 @@ static void imon_incoming_packet(struct
 	if (kc == KEY_KEYBOARD && !ictx->release_code) {
 		ictx->last_keycode = kc;
 		if (!nomouse) {
-			ictx->pad_mouse = ~(ictx->pad_mouse) & 0x1;
+			ictx->pad_mouse = !ictx->pad_mouse;
 			dev_dbg(dev, "toggling to %s mode\n",
 				ictx->pad_mouse ? "mouse" : "keyboard");
 			spin_unlock_irqrestore(&ictx->kc_lock, flags);

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

* [PATCH 3.18 05/60] CIFS: Fix handle_cancelled_mid callback initialization
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (2 preceding siblings ...)
  2017-07-25 19:15 ` [PATCH 3.18 04/60] [media] ir-core: fix gcc-7 warning on bool arithmetic Greg Kroah-Hartman
@ 2017-07-25 19:15 ` Greg Kroah-Hartman
  2017-07-25 19:15 ` [PATCH 3.18 06/60] ath9k: fix tx99 use after free Greg Kroah-Hartman
                   ` (54 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Pavel Shilovsky

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

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

From: Pavel Shilovsky <pshilov@microsoft.com>

Commit 99e214e006cf ("Handle mismatched open calls") was applied with
errors that result in initializing handle_cancelled_mid callback twice
in smb21_operations and smb30_operations structures but not initializing
it in smb20_operations structure.

Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/cifs/smb2ops.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -1383,6 +1383,7 @@ struct smb_version_operations smb20_oper
 	.clear_stats = smb2_clear_stats,
 	.print_stats = smb2_print_stats,
 	.is_oplock_break = smb2_is_valid_oplock_break,
+	.handle_cancelled_mid = smb2_handle_cancelled_mid,
 	.downgrade_oplock = smb2_downgrade_oplock,
 	.need_neg = smb2_need_neg,
 	.negotiate = smb2_negotiate,
@@ -1462,7 +1463,6 @@ struct smb_version_operations smb21_oper
 	.print_stats = smb2_print_stats,
 	.is_oplock_break = smb2_is_valid_oplock_break,
 	.handle_cancelled_mid = smb2_handle_cancelled_mid,
-	.handle_cancelled_mid = smb2_handle_cancelled_mid,
 	.downgrade_oplock = smb2_downgrade_oplock,
 	.need_neg = smb2_need_neg,
 	.negotiate = smb2_negotiate,
@@ -1545,7 +1545,6 @@ struct smb_version_operations smb30_oper
 	.dump_share_caps = smb2_dump_share_caps,
 	.is_oplock_break = smb2_is_valid_oplock_break,
 	.handle_cancelled_mid = smb2_handle_cancelled_mid,
-	.handle_cancelled_mid = smb2_handle_cancelled_mid,
 	.downgrade_oplock = smb2_downgrade_oplock,
 	.need_neg = smb2_need_neg,
 	.negotiate = smb2_negotiate,

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

* [PATCH 3.18 06/60] ath9k: fix tx99 use after free
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (3 preceding siblings ...)
  2017-07-25 19:15 ` [PATCH 3.18 05/60] CIFS: Fix handle_cancelled_mid callback initialization Greg Kroah-Hartman
@ 2017-07-25 19:15 ` Greg Kroah-Hartman
  2017-07-25 19:15 ` [PATCH 3.18 07/60] ath9k: fix tx99 bus error Greg Kroah-Hartman
                   ` (53 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Miaoqing Pan, Kalle Valo

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

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

From: Miaoqing Pan <miaoqing@codeaurora.org>

commit cf8ce1ea61b75712a154c93e40f2a5af2e4dd997 upstream.

One scenario that could lead to UAF is two threads writing
simultaneously to the "tx99" debug file. One of them would
set the "start" value to true and follow to ath9k_tx99_init().
Inside the function it would set the sc->tx99_state to true
after allocating sc->tx99skb. Then, the other thread would
execute write_file_tx99() and call ath9k_tx99_deinit().
sc->tx99_state would be freed. After that, the first thread
would continue inside ath9k_tx99_init() and call
r = ath9k_tx99_send(sc, sc->tx99_skb, &txctl);
that would make use of the freed sc->tx99_skb memory.

Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/wireless/ath/ath9k/tx99.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

--- a/drivers/net/wireless/ath/ath9k/tx99.c
+++ b/drivers/net/wireless/ath/ath9k/tx99.c
@@ -190,22 +190,27 @@ static ssize_t write_file_tx99(struct fi
 	if (strtobool(buf, &start))
 		return -EINVAL;
 
+	mutex_lock(&sc->mutex);
+
 	if (start == sc->tx99_state) {
 		if (!start)
-			return count;
+			goto out;
 		ath_dbg(common, XMIT, "Resetting TX99\n");
 		ath9k_tx99_deinit(sc);
 	}
 
 	if (!start) {
 		ath9k_tx99_deinit(sc);
-		return count;
+		goto out;
 	}
 
 	r = ath9k_tx99_init(sc);
-	if (r)
+	if (r) {
+		mutex_unlock(&sc->mutex);
 		return r;
-
+	}
+out:
+	mutex_unlock(&sc->mutex);
 	return count;
 }
 

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

* [PATCH 3.18 07/60] ath9k: fix tx99 bus error
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (4 preceding siblings ...)
  2017-07-25 19:15 ` [PATCH 3.18 06/60] ath9k: fix tx99 use after free Greg Kroah-Hartman
@ 2017-07-25 19:15 ` Greg Kroah-Hartman
  2017-07-25 19:15 ` [PATCH 3.18 08/60] NFC: fix broken device allocation Greg Kroah-Hartman
                   ` (52 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Miaoqing Pan, Kalle Valo

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

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

From: Miaoqing Pan <miaoqing@codeaurora.org>

commit bde717ab473668377fc65872398a102d40cb2d58 upstream.

The hard coded register 0x9864 and 0x9924 are invalid
for ar9300 chips.

Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/wireless/ath/ath9k/ar9003_phy.c |    2 --
 1 file changed, 2 deletions(-)

--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -1707,8 +1707,6 @@ static void ar9003_hw_spectral_scan_wait
 static void ar9003_hw_tx99_start(struct ath_hw *ah, u32 qnum)
 {
 	REG_SET_BIT(ah, AR_PHY_TEST, PHY_AGC_CLR);
-	REG_SET_BIT(ah, 0x9864, 0x7f000);
-	REG_SET_BIT(ah, 0x9924, 0x7f00fe);
 	REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
 	REG_WRITE(ah, AR_CR, AR_CR_RXD);
 	REG_WRITE(ah, AR_DLCL_IFS(qnum), 0);

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

* [PATCH 3.18 08/60] NFC: fix broken device allocation
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (5 preceding siblings ...)
  2017-07-25 19:15 ` [PATCH 3.18 07/60] ath9k: fix tx99 bus error Greg Kroah-Hartman
@ 2017-07-25 19:15 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 09/60] nfc: Ensure presence of required attributes in the activate_target handler Greg Kroah-Hartman
                   ` (51 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Samuel Ortiz, Johan Hovold

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

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

From: Johan Hovold <johan@kernel.org>

commit 20777bc57c346b6994f465e0d8261a7fbf213a09 upstream.

Commit 7eda8b8e9677 ("NFC: Use IDR library to assing NFC devices IDs")
moved device-id allocation and struct-device initialisation from
nfc_allocate_device() to nfc_register_device().

This broke just about every nfc-device-registration error path, which
continue to call nfc_free_device() that tries to put the device
reference of the now uninitialised (but zeroed) struct device:

kobject: '(null)' (ce316420): is not initialized, yet kobject_put() is being called.

The late struct-device initialisation also meant that various work
queues whose names are derived from the nfc device name were also
misnamed:

  421 root         0 SW<  [(null)_nci_cmd_]
  422 root         0 SW<  [(null)_nci_rx_w]
  423 root         0 SW<  [(null)_nci_tx_w]

Move the id-allocation and struct-device initialisation back to
nfc_allocate_device() and fix up the single call site which did not use
nfc_free_device() in its error path.

Fixes: 7eda8b8e9677 ("NFC: Use IDR library to assing NFC devices IDs")
Cc: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/nfc/core.c |   31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -950,6 +950,8 @@ static void nfc_release(struct device *d
 			kfree(se);
 	}
 
+	ida_simple_remove(&nfc_index_ida, dev->idx);
+
 	kfree(dev);
 }
 
@@ -1024,6 +1026,7 @@ struct nfc_dev *nfc_allocate_device(stru
 				    int tx_headroom, int tx_tailroom)
 {
 	struct nfc_dev *dev;
+	int rc;
 
 	if (!ops->start_poll || !ops->stop_poll || !ops->activate_target ||
 	    !ops->deactivate_target || !ops->im_transceive)
@@ -1036,6 +1039,15 @@ struct nfc_dev *nfc_allocate_device(stru
 	if (!dev)
 		return NULL;
 
+	rc = ida_simple_get(&nfc_index_ida, 0, 0, GFP_KERNEL);
+	if (rc < 0)
+		goto err_free_dev;
+	dev->idx = rc;
+
+	dev->dev.class = &nfc_class;
+	dev_set_name(&dev->dev, "nfc%d", dev->idx);
+	device_initialize(&dev->dev);
+
 	dev->ops = ops;
 	dev->supported_protocols = supported_protocols;
 	dev->tx_headroom = tx_headroom;
@@ -1058,6 +1070,11 @@ struct nfc_dev *nfc_allocate_device(stru
 	}
 
 	return dev;
+
+err_free_dev:
+	kfree(dev);
+
+	return ERR_PTR(rc);
 }
 EXPORT_SYMBOL(nfc_allocate_device);
 
@@ -1072,14 +1089,6 @@ int nfc_register_device(struct nfc_dev *
 
 	pr_debug("dev_name=%s\n", dev_name(&dev->dev));
 
-	dev->idx = ida_simple_get(&nfc_index_ida, 0, 0, GFP_KERNEL);
-	if (dev->idx < 0)
-		return dev->idx;
-
-	dev->dev.class = &nfc_class;
-	dev_set_name(&dev->dev, "nfc%d", dev->idx);
-	device_initialize(&dev->dev);
-
 	mutex_lock(&nfc_devlist_mutex);
 	nfc_devlist_generation++;
 	rc = device_add(&dev->dev);
@@ -1117,12 +1126,10 @@ EXPORT_SYMBOL(nfc_register_device);
  */
 void nfc_unregister_device(struct nfc_dev *dev)
 {
-	int rc, id;
+	int rc;
 
 	pr_debug("dev_name=%s\n", dev_name(&dev->dev));
 
-	id = dev->idx;
-
 	if (dev->rfkill) {
 		rfkill_unregister(dev->rfkill);
 		rfkill_destroy(dev->rfkill);
@@ -1147,8 +1154,6 @@ void nfc_unregister_device(struct nfc_de
 	nfc_devlist_generation++;
 	device_del(&dev->dev);
 	mutex_unlock(&nfc_devlist_mutex);
-
-	ida_simple_remove(&nfc_index_ida, id);
 }
 EXPORT_SYMBOL(nfc_unregister_device);
 

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

* [PATCH 3.18 09/60] nfc: Ensure presence of required attributes in the activate_target handler
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (6 preceding siblings ...)
  2017-07-25 19:15 ` [PATCH 3.18 08/60] NFC: fix broken device allocation Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 10/60] nfc: Fix the sockaddr length sanitization in llcp_sock_connect Greg Kroah-Hartman
                   ` (50 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mateusz Jurczyk, Kees Cook, Samuel Ortiz

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

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

From: Mateusz Jurczyk <mjurczyk@google.com>

commit a0323b979f81ad2deb2c8836eab506534891876a upstream.

Check that the NFC_ATTR_TARGET_INDEX and NFC_ATTR_PROTOCOLS attributes (in
addition to NFC_ATTR_DEVICE_INDEX) are provided by the netlink client
prior to accessing them. This prevents potential unhandled NULL pointer
dereference exceptions which can be triggered by malicious user-mode
programs, if they omit one or both of these attributes.

Signed-off-by: Mateusz Jurczyk <mjurczyk@google.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/nfc/netlink.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -899,7 +899,9 @@ static int nfc_genl_llc_get_params(struc
 	struct sk_buff *msg = NULL;
 	u32 idx;
 
-	if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
+	if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
+	    !info->attrs[NFC_ATTR_TARGET_INDEX] ||
+	    !info->attrs[NFC_ATTR_PROTOCOLS])
 		return -EINVAL;
 
 	idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);

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

* [PATCH 3.18 10/60] nfc: Fix the sockaddr length sanitization in llcp_sock_connect
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (7 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 09/60] nfc: Ensure presence of required attributes in the activate_target handler Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 11/60] include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header Greg Kroah-Hartman
                   ` (49 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mateusz Jurczyk, Kees Cook, Samuel Ortiz

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

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

From: Mateusz Jurczyk <mjurczyk@google.com>

commit 608c4adfcabab220142ee335a2a003ccd1c0b25b upstream.

Fix the sockaddr length verification in the connect() handler of NFC/LLCP
sockets, to compare against the size of the actual structure expected on
input (sockaddr_nfc_llcp) instead of its shorter version (sockaddr_nfc).

Both structures are defined in include/uapi/linux/nfc.h. The fields
specific to the _llcp extended struct are as follows:

   276		__u8 dsap; /* Destination SAP, if known */
   277		__u8 ssap; /* Source SAP to be bound to */
   278		char service_name[NFC_LLCP_MAX_SERVICE_NAME]; /* Service name URI */;
   279		size_t service_name_len;

If the caller doesn't provide a sufficiently long sockaddr buffer, these
fields remain uninitialized (and they currently originate from the stack
frame of the top-level sys_connect handler). They are then copied by
llcp_sock_connect() into internal storage (nfc_llcp_sock structure), and
could be subsequently read back through the user-mode getsockname()
function (handled by llcp_sock_getname()). This would result in the
disclosure of up to ~70 uninitialized bytes from the kernel stack to
user-mode clients capable of creating AFC_NFC sockets.

Signed-off-by: Mateusz Jurczyk <mjurczyk@google.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/nfc/llcp_sock.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -655,8 +655,7 @@ static int llcp_sock_connect(struct sock
 
 	pr_debug("sock %p sk %p flags 0x%x\n", sock, sk, flags);
 
-	if (!addr || len < sizeof(struct sockaddr_nfc) ||
-	    addr->sa_family != AF_NFC)
+	if (!addr || len < sizeof(*addr) || addr->sa_family != AF_NFC)
 		return -EINVAL;
 
 	if (addr->service_name_len == 0 && addr->dsap == 0)

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

* [PATCH 3.18 11/60] include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (8 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 10/60] nfc: Fix the sockaddr length sanitization in llcp_sock_connect Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 12/60] stddef.h: move offsetofend inside #ifndef/#endif guard, neaten Greg Kroah-Hartman
                   ` (48 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, Denys Vlasenko,
	Linus Torvalds, Alexei Starovoitov, Borislav Petkov,
	Frederic Weisbecker, H. Peter Anvin, Kees Cook, Oleg Nesterov,
	Steven Rostedt, Will Drewry, Ingo Molnar

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

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

From: Denys Vlasenko <dvlasenk@redhat.com>

commit 3876488444e71238e287459c39d7692b6f718c3e upstream.

Suggested by Andy.

Suggested-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1425912738-559-1-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/stddef.h |    9 +++++++++
 include/linux/vfio.h   |   13 -------------
 2 files changed, 9 insertions(+), 13 deletions(-)

--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -19,3 +19,12 @@ enum {
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 #endif
 #endif
+
+/**
+ * offsetofend(TYPE, MEMBER)
+ *
+ * @TYPE: The type of the structure
+ * @MEMBER: The member within the structure to get the end offset of
+ */
+#define offsetofend(TYPE, MEMBER) \
+	(offsetof(TYPE, MEMBER)	+ sizeof(((TYPE *)0)->MEMBER))
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -76,19 +76,6 @@ extern int vfio_register_iommu_driver(co
 extern void vfio_unregister_iommu_driver(
 				const struct vfio_iommu_driver_ops *ops);
 
-/**
- * offsetofend(TYPE, MEMBER)
- *
- * @TYPE: The type of the structure
- * @MEMBER: The member within the structure to get the end offset of
- *
- * Simple helper macro for dealing with variable sized structures passed
- * from user space.  This allows us to easily determine if the provided
- * structure is sized to include various fields.
- */
-#define offsetofend(TYPE, MEMBER) \
-	(offsetof(TYPE, MEMBER)	+ sizeof(((TYPE *)0)->MEMBER))
-
 /*
  * External user API
  */

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

* [PATCH 3.18 12/60] stddef.h: move offsetofend inside #ifndef/#endif guard, neaten
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (9 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 11/60] include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 13/60] NFC: Add sockaddr length checks before accessing sa_family in bind handlers Greg Kroah-Hartman
                   ` (47 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Joe Perches, Denys Vlasenko,
	Andrew Morton, Linus Torvalds

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

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

From: Joe Perches <joe@perches.com>

commit 8c7fbe5795a016259445a61e072eb0118aaf6a61 upstream.

Commit 3876488444e7 ("include/stddef.h: Move offsetofend() from vfio.h
to a generic kernel header") added offsetofend outside the normal
include #ifndef/#endif guard.  Move it inside.

Miscellanea:

o remove unnecessary blank line
o standardize offsetof macros whitespace style

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/stddef.h |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -3,7 +3,6 @@
 
 #include <uapi/linux/stddef.h>
 
-
 #undef NULL
 #define NULL ((void *)0)
 
@@ -14,10 +13,9 @@ enum {
 
 #undef offsetof
 #ifdef __compiler_offsetof
-#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
+#define offsetof(TYPE, MEMBER)	__compiler_offsetof(TYPE, MEMBER)
 #else
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
+#define offsetof(TYPE, MEMBER)	((size_t)&((TYPE *)0)->MEMBER)
 #endif
 
 /**
@@ -28,3 +26,5 @@ enum {
  */
 #define offsetofend(TYPE, MEMBER) \
 	(offsetof(TYPE, MEMBER)	+ sizeof(((TYPE *)0)->MEMBER))
+
+#endif

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

* [PATCH 3.18 13/60] NFC: Add sockaddr length checks before accessing sa_family in bind handlers
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (10 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 12/60] stddef.h: move offsetofend inside #ifndef/#endif guard, neaten Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 14/60] Bluetooth: use constant time memory comparison for secret values Greg Kroah-Hartman
                   ` (46 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Mateusz Jurczyk, Samuel Ortiz

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

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

From: Mateusz Jurczyk <mjurczyk@google.com>

commit f6a5885fc4d68e7f25ffb42b9d8d80aebb3bacbb upstream.

Verify that the caller-provided sockaddr structure is large enough to
contain the sa_family field, before accessing it in bind() handlers of the
AF_NFC socket. Since the syscall doesn't enforce a minimum size of the
corresponding memory region, very short sockaddrs (zero or one byte long)
result in operating on uninitialized memory while referencing .sa_family.

Signed-off-by: Mateusz Jurczyk <mjurczyk@google.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/nfc/llcp_sock.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -76,7 +76,8 @@ static int llcp_sock_bind(struct socket
 	struct sockaddr_nfc_llcp llcp_addr;
 	int len, ret = 0;
 
-	if (!addr || addr->sa_family != AF_NFC)
+	if (!addr || alen < offsetofend(struct sockaddr, sa_family) ||
+	    addr->sa_family != AF_NFC)
 		return -EINVAL;
 
 	pr_debug("sk %p addr %p family %d\n", sk, addr, addr->sa_family);
@@ -150,7 +151,8 @@ static int llcp_raw_sock_bind(struct soc
 	struct sockaddr_nfc_llcp llcp_addr;
 	int len, ret = 0;
 
-	if (!addr || addr->sa_family != AF_NFC)
+	if (!addr || alen < offsetofend(struct sockaddr, sa_family) ||
+	    addr->sa_family != AF_NFC)
 		return -EINVAL;
 
 	pr_debug("sk %p addr %p family %d\n", sk, addr, addr->sa_family);

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

* [PATCH 3.18 14/60] Bluetooth: use constant time memory comparison for secret values
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (11 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 13/60] NFC: Add sockaddr length checks before accessing sa_family in bind handlers Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 15/60] ASoC: compress: Derive substream from stream based on direction Greg Kroah-Hartman
                   ` (45 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Jason A. Donenfeld, Marcel Holtmann

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

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

From: Jason A. Donenfeld <Jason@zx2c4.com>

commit 329d82309824ff1082dc4a91a5bbed8c3bec1580 upstream.

This file is filled with complex cryptography. Thus, the comparisons of
MACs and secret keys and curve points and so forth should not add timing
attacks, which could either result in a direct forgery, or, given the
complexity, some other type of attack.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/bluetooth/smp.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -22,6 +22,7 @@
 
 #include <linux/crypto.h>
 #include <linux/scatterlist.h>
+#include <crypto/algapi.h>
 #include <crypto/b128ops.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -163,7 +164,7 @@ bool smp_irk_matches(struct hci_dev *hde
 	if (err)
 		return false;
 
-	return !memcmp(bdaddr->b, hash, 3);
+	return !crypto_memneq(bdaddr->b, hash, 3);
 }
 
 int smp_generate_rpa(struct hci_dev *hdev, u8 irk[16], bdaddr_t *rpa)
@@ -584,7 +585,7 @@ static u8 smp_random(struct smp_chan *sm
 	if (ret)
 		return SMP_UNSPECIFIED;
 
-	if (memcmp(smp->pcnf, confirm, sizeof(smp->pcnf)) != 0) {
+	if (crypto_memneq(smp->pcnf, confirm, sizeof(smp->pcnf))) {
 		BT_ERR("Pairing failed (confirmation values mismatch)");
 		return SMP_CONFIRM_FAILED;
 	}

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

* [PATCH 3.18 15/60] ASoC: compress: Derive substream from stream based on direction
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (12 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 14/60] Bluetooth: use constant time memory comparison for secret values Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 16/60] PM / Domains: Fix unsafe iteration over modified list of device links Greg Kroah-Hartman
                   ` (44 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Satish Babu Patakokila,
	Banajit Goswami, Vinod Koul, Mark Brown

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

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

From: Satish Babu Patakokila <sbpata@codeaurora.org>

commit 01b8cedfd0422326caae308641dcadaa85e0ca72 upstream.

Currently compress driver hardcodes direction as playback to get
substream from the stream. This results in getting the incorrect
substream for compressed capture usecase.
To fix this, remove the hardcoding and derive substream based on
the stream direction.

Signed-off-by: Satish Babu Patakokila <sbpata@codeaurora.org>
Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/soc/soc-compress.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -68,7 +68,8 @@ out:
 static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
-	struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream;
+	struct snd_pcm_substream *fe_substream =
+		 fe->pcm->streams[cstream->direction].substream;
 	struct snd_soc_platform *platform = fe->platform;
 	struct snd_soc_dpcm *dpcm;
 	struct snd_soc_dapm_widget_list *list;
@@ -415,7 +416,8 @@ static int soc_compr_set_params_fe(struc
 					struct snd_compr_params *params)
 {
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
-	struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream;
+	struct snd_pcm_substream *fe_substream =
+		 fe->pcm->streams[cstream->direction].substream;
 	struct snd_soc_platform *platform = fe->platform;
 	int ret = 0, stream;
 

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

* [PATCH 3.18 16/60] PM / Domains: Fix unsafe iteration over modified list of device links
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (13 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 15/60] ASoC: compress: Derive substream from stream based on direction Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 17/60] PM / Domains: Fix unsafe iteration over modified list of domain providers Greg Kroah-Hartman
                   ` (43 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Krzysztof Kozlowski, Ulf Hansson,
	Rafael J. Wysocki

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

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

From: Krzysztof Kozlowski <krzk@kernel.org>

commit c6e83cac3eda5f7dd32ee1453df2f7abb5c6cd46 upstream.

pm_genpd_remove_subdomain() iterates over domain's master_links list and
removes matching element thus it has to use safe version of list
iteration.

Fixes: f721889ff65a ("PM / Domains: Support for generic I/O PM domains (v8)")
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/base/power/domain.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1673,7 +1673,7 @@ int pm_genpd_add_subdomain_names(const c
 int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
 			      struct generic_pm_domain *subdomain)
 {
-	struct gpd_link *link;
+	struct gpd_link *l, *link;
 	int ret = -EINVAL;
 
 	if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain))
@@ -1682,7 +1682,7 @@ int pm_genpd_remove_subdomain(struct gen
  start:
 	genpd_acquire_lock(genpd);
 
-	list_for_each_entry(link, &genpd->master_links, master_node) {
+	list_for_each_entry_safe(link, l, &genpd->master_links, master_node) {
 		if (link->slave != subdomain)
 			continue;
 

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

* [PATCH 3.18 17/60] PM / Domains: Fix unsafe iteration over modified list of domain providers
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (14 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 16/60] PM / Domains: Fix unsafe iteration over modified list of device links Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 18/60] scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails Greg Kroah-Hartman
                   ` (42 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Krzysztof Kozlowski, Ulf Hansson,
	Rafael J. Wysocki

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

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

From: Krzysztof Kozlowski <krzk@kernel.org>

commit b556b15dc04e9b9b98790f04c21acf5e24f994b2 upstream.

of_genpd_del_provider() iterates over list of domain provides and
removes matching element thus it has to use safe version of list
iteration.

Fixes: aa42240ab254 (PM / Domains: Add generic OF-based PM domain look-up)
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/base/power/domain.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2056,10 +2056,10 @@ EXPORT_SYMBOL_GPL(__of_genpd_add_provide
  */
 void of_genpd_del_provider(struct device_node *np)
 {
-	struct of_genpd_provider *cp;
+	struct of_genpd_provider *cp, *tmp;
 
 	mutex_lock(&of_genpd_mutex);
-	list_for_each_entry(cp, &of_genpd_providers, link) {
+	list_for_each_entry_safe(cp, tmp, &of_genpd_providers, link) {
 		if (cp->node == np) {
 			list_del(&cp->link);
 			of_node_put(cp->node);

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

* [PATCH 3.18 18/60] scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails.
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (15 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 17/60] PM / Domains: Fix unsafe iteration over modified list of domain providers Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 19/60] powerpc/64: Fix atomic64_inc_not_zero() to return an int Greg Kroah-Hartman
                   ` (41 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Maurizio Lombardi, Douglas Miller,
	James Bottomley, Martin K. Petersen

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

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

From: Maurizio Lombardi <mlombard@redhat.com>

commit 62e62ffd95539b9220894a7900a619e0f3ef4756 upstream.

The enclosure_add_device() function should fail if it can't create the
relevant sysfs links.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Tested-by: Douglas Miller <dougmill@linux.vnet.ibm.com>
Acked-by: James Bottomley <jejb@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/misc/enclosure.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -320,6 +320,7 @@ int enclosure_add_device(struct enclosur
 			 struct device *dev)
 {
 	struct enclosure_component *cdev;
+	int err;
 
 	if (!edev || component >= edev->components)
 		return -EINVAL;
@@ -329,12 +330,17 @@ int enclosure_add_device(struct enclosur
 	if (cdev->dev == dev)
 		return -EEXIST;
 
-	if (cdev->dev)
+	if (cdev->dev) {
 		enclosure_remove_links(cdev);
-
-	put_device(cdev->dev);
+		put_device(cdev->dev);
+	}
 	cdev->dev = get_device(dev);
-	return enclosure_add_links(cdev);
+	err = enclosure_add_links(cdev);
+	if (err) {
+		put_device(cdev->dev);
+		cdev->dev = NULL;
+	}
+	return err;
 }
 EXPORT_SYMBOL_GPL(enclosure_add_device);
 

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

* [PATCH 3.18 19/60] powerpc/64: Fix atomic64_inc_not_zero() to return an int
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (16 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 18/60] scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 20/60] powerpc: Fix emulation of mcrf in emulate_step() Greg Kroah-Hartman
                   ` (40 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Michael Ellerman

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

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

From: Michael Ellerman <mpe@ellerman.id.au>

commit 01e6a61aceb82e13bec29502a8eb70d9574f97ad upstream.

Although it's not documented anywhere, there is an expectation that
atomic64_inc_not_zero() returns a result which fits in an int. This is
the behaviour implemented on all arches except powerpc.

This has caused at least one bug in practice, in the percpu-refcount
code, where the long result from our atomic64_inc_not_zero() was
truncated to an int leading to lost references and stuck systems. That
was worked around in that code in commit 966d2b04e070 ("percpu-refcount:
fix reference leak during percpu-atomic transition").

To the best of my grepping abilities there are no other callers
in-tree which truncate the value, but we should fix it anyway. Because
the breakage is subtle and potentially very harmful I'm also tagging
it for stable.

Code generation is largely unaffected because in most cases the
callers are just using the result for a test anyway. In particular the
case of fget() that was mentioned in commit a6cf7ed5119f
("powerpc/atomic: Implement atomic*_inc_not_zero") generates exactly
the same code.

Fixes: a6cf7ed5119f ("powerpc/atomic: Implement atomic*_inc_not_zero")
Noticed-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/powerpc/include/asm/atomic.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/arch/powerpc/include/asm/atomic.h
+++ b/arch/powerpc/include/asm/atomic.h
@@ -453,7 +453,7 @@ static __inline__ int atomic64_add_unles
  * Atomically increments @v by 1, so long as @v is non-zero.
  * Returns non-zero if @v was non-zero, and zero otherwise.
  */
-static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
+static __inline__ int atomic64_inc_not_zero(atomic64_t *v)
 {
 	long t1, t2;
 
@@ -472,7 +472,7 @@ static __inline__ long atomic64_inc_not_
 	: "r" (&v->counter)
 	: "cc", "xer", "memory");
 
-	return t1;
+	return t1 != 0;
 }
 
 #endif /* __powerpc64__ */

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

* [PATCH 3.18 20/60] powerpc: Fix emulation of mcrf in emulate_step()
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (17 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 19/60] powerpc/64: Fix atomic64_inc_not_zero() to return an int Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 21/60] powerpc: Fix emulation of mfocrf " Greg Kroah-Hartman
                   ` (39 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Anton Blanchard, Naveen N. Rao,
	Michael Ellerman

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

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

From: Anton Blanchard <anton@samba.org>

commit 87c4b83e0fe234a1f0eed131ab6fa232036860d5 upstream.

The mcrf emulation code was using the CR field number directly as the shift
value, without taking into account that CR fields are numbered from 0-7 starting
at the high bits. That meant it was looking at the CR fields in the reverse
order.

Fixes: cf87c3f6b647 ("powerpc: Emulate icbi, mcrf and conditional-trap instructions")
Signed-off-by: Anton Blanchard <anton@samba.org>
Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/powerpc/lib/sstep.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -687,8 +687,10 @@ int __kprobes analyse_instr(struct instr
 	case 19:
 		switch ((instr >> 1) & 0x3ff) {
 		case 0:		/* mcrf */
-			rd = (instr >> 21) & 0x1c;
-			ra = (instr >> 16) & 0x1c;
+			rd = 7 - ((instr >> 23) & 0x7);
+			ra = 7 - ((instr >> 18) & 0x7);
+			rd *= 4;
+			ra *= 4;
 			val = (regs->ccr >> ra) & 0xf;
 			regs->ccr = (regs->ccr & ~(0xfUL << rd)) | (val << rd);
 			goto instr_done;

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

* [PATCH 3.18 21/60] powerpc: Fix emulation of mfocrf in emulate_step()
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (18 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 20/60] powerpc: Fix emulation of mcrf in emulate_step() Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 22/60] powerpc/asm: Mark cr0 as clobbered in mftb() Greg Kroah-Hartman
                   ` (38 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Anton Blanchard, Naveen N. Rao,
	Michael Ellerman

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

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

From: Anton Blanchard <anton@samba.org>

commit 64e756c55aa46fc18fd53e8f3598b73b528d8637 upstream.

>From POWER4 onwards, mfocrf() only places the specified CR field into
the destination GPR, and the rest of it is set to 0. The PowerPC AS
from version 3.0 now requires this behaviour.

The emulation code currently puts the entire CR into the destination GPR.
Fix it.

Fixes: 6888199f7fe5 ("[POWERPC] Emulate more instructions in software")
Signed-off-by: Anton Blanchard <anton@samba.org>
Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/powerpc/lib/sstep.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -969,6 +969,19 @@ int __kprobes analyse_instr(struct instr
 #endif
 
 		case 19:	/* mfcr */
+			if ((instr >> 20) & 1) {
+				imm = 0xf0000000UL;
+				for (sh = 0; sh < 8; ++sh) {
+					if (instr & (0x80000 >> sh)) {
+						regs->gpr[rd] = regs->ccr & imm;
+						break;
+					}
+					imm >>= 4;
+				}
+
+				goto instr_done;
+			}
+
 			regs->gpr[rd] = regs->ccr;
 			regs->gpr[rd] &= 0xffffffffUL;
 			goto instr_done;

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

* [PATCH 3.18 22/60] powerpc/asm: Mark cr0 as clobbered in mftb()
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (19 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 21/60] powerpc: Fix emulation of mfocrf " Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 23/60] af_key: Fix sadb_x_ipsecrequest parsing Greg Kroah-Hartman
                   ` (37 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Oliver OHalloran, Michael Ellerman

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

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

From: Oliver O'Halloran <oohall@gmail.com>

commit 2400fd822f467cb4c886c879d8ad99feac9cf319 upstream.

The workaround for the CELL timebase bug does not correctly mark cr0 as
being clobbered. This means GCC doesn't know that the asm block changes cr0 and
might leave the result of an unrelated comparison in cr0 across the block, which
we then trash, leading to basically random behaviour.

Fixes: 859deea949c3 ("[POWERPC] Cell timebase bug workaround")
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
[mpe: Tweak change log and flag for stable]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/powerpc/include/asm/reg.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1231,7 +1231,7 @@ static inline unsigned long mfvtb (void)
 				"	.llong 0\n"			\
 				".previous"				\
 			: "=r" (rval) \
-			: "i" (CPU_FTR_CELL_TB_BUG), "i" (SPRN_TBRL)); \
+			: "i" (CPU_FTR_CELL_TB_BUG), "i" (SPRN_TBRL) : "cr0"); \
 			rval;})
 #else
 #define mftb()		({unsigned long rval;	\

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

* [PATCH 3.18 23/60] af_key: Fix sadb_x_ipsecrequest parsing
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (20 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 22/60] powerpc/asm: Mark cr0 as clobbered in mftb() Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 24/60] PCI/PM: Restore the status of PCI devices across hibernation Greg Kroah-Hartman
                   ` (36 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andrey Konovalov, Herbert Xu,
	Steffen Klassert

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

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

From: Herbert Xu <herbert@gondor.apana.org.au>

commit 096f41d3a8fcbb8dde7f71379b1ca85fe213eded upstream.

The parsing of sadb_x_ipsecrequest is broken in a number of ways.
First of all we're not verifying sadb_x_ipsecrequest_len.  This
is needed when the structure carries addresses at the end.  Worse
we don't even look at the length when we parse those optional
addresses.

The migration code had similar parsing code that's better but
it also has some deficiencies.  The length is overcounted first
of all as it includes the header itself.  It also fails to check
the length before dereferencing the sa_family field.

This patch fixes those problems in parse_sockaddr_pair and then
uses it in parse_ipsecrequest.

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/key/af_key.c |   47 ++++++++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 21 deletions(-)

--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -65,6 +65,10 @@ struct pfkey_sock {
 	} dump;
 };
 
+static int parse_sockaddr_pair(struct sockaddr *sa, int ext_len,
+			       xfrm_address_t *saddr, xfrm_address_t *daddr,
+			       u16 *family);
+
 static inline struct pfkey_sock *pfkey_sk(struct sock *sk)
 {
 	return (struct pfkey_sock *)sk;
@@ -1921,19 +1925,14 @@ parse_ipsecrequest(struct xfrm_policy *x
 
 	/* addresses present only in tunnel mode */
 	if (t->mode == XFRM_MODE_TUNNEL) {
-		u8 *sa = (u8 *) (rq + 1);
-		int family, socklen;
+		int err;
 
-		family = pfkey_sockaddr_extract((struct sockaddr *)sa,
-						&t->saddr);
-		if (!family)
-			return -EINVAL;
-
-		socklen = pfkey_sockaddr_len(family);
-		if (pfkey_sockaddr_extract((struct sockaddr *)(sa + socklen),
-					   &t->id.daddr) != family)
-			return -EINVAL;
-		t->encap_family = family;
+		err = parse_sockaddr_pair(
+			(struct sockaddr *)(rq + 1),
+			rq->sadb_x_ipsecrequest_len - sizeof(*rq),
+			&t->saddr, &t->id.daddr, &t->encap_family);
+		if (err)
+			return err;
 	} else
 		t->encap_family = xp->family;
 
@@ -1953,7 +1952,11 @@ parse_ipsecrequests(struct xfrm_policy *
 	if (pol->sadb_x_policy_len * 8 < sizeof(struct sadb_x_policy))
 		return -EINVAL;
 
-	while (len >= sizeof(struct sadb_x_ipsecrequest)) {
+	while (len >= sizeof(*rq)) {
+		if (len < rq->sadb_x_ipsecrequest_len ||
+		    rq->sadb_x_ipsecrequest_len < sizeof(*rq))
+			return -EINVAL;
+
 		if ((err = parse_ipsecrequest(xp, rq)) < 0)
 			return err;
 		len -= rq->sadb_x_ipsecrequest_len;
@@ -2416,7 +2419,6 @@ out:
 	return err;
 }
 
-#ifdef CONFIG_NET_KEY_MIGRATE
 static int pfkey_sockaddr_pair_size(sa_family_t family)
 {
 	return PFKEY_ALIGN8(pfkey_sockaddr_len(family) * 2);
@@ -2428,7 +2430,7 @@ static int parse_sockaddr_pair(struct so
 {
 	int af, socklen;
 
-	if (ext_len < pfkey_sockaddr_pair_size(sa->sa_family))
+	if (ext_len < 2 || ext_len < pfkey_sockaddr_pair_size(sa->sa_family))
 		return -EINVAL;
 
 	af = pfkey_sockaddr_extract(sa, saddr);
@@ -2444,6 +2446,7 @@ static int parse_sockaddr_pair(struct so
 	return 0;
 }
 
+#ifdef CONFIG_NET_KEY_MIGRATE
 static int ipsecrequests_to_migrate(struct sadb_x_ipsecrequest *rq1, int len,
 				    struct xfrm_migrate *m)
 {
@@ -2451,13 +2454,14 @@ static int ipsecrequests_to_migrate(stru
 	struct sadb_x_ipsecrequest *rq2;
 	int mode;
 
-	if (len <= sizeof(struct sadb_x_ipsecrequest) ||
-	    len < rq1->sadb_x_ipsecrequest_len)
+	if (len < sizeof(*rq1) ||
+	    len < rq1->sadb_x_ipsecrequest_len ||
+	    rq1->sadb_x_ipsecrequest_len < sizeof(*rq1))
 		return -EINVAL;
 
 	/* old endoints */
 	err = parse_sockaddr_pair((struct sockaddr *)(rq1 + 1),
-				  rq1->sadb_x_ipsecrequest_len,
+				  rq1->sadb_x_ipsecrequest_len - sizeof(*rq1),
 				  &m->old_saddr, &m->old_daddr,
 				  &m->old_family);
 	if (err)
@@ -2466,13 +2470,14 @@ static int ipsecrequests_to_migrate(stru
 	rq2 = (struct sadb_x_ipsecrequest *)((u8 *)rq1 + rq1->sadb_x_ipsecrequest_len);
 	len -= rq1->sadb_x_ipsecrequest_len;
 
-	if (len <= sizeof(struct sadb_x_ipsecrequest) ||
-	    len < rq2->sadb_x_ipsecrequest_len)
+	if (len <= sizeof(*rq2) ||
+	    len < rq2->sadb_x_ipsecrequest_len ||
+	    rq2->sadb_x_ipsecrequest_len < sizeof(*rq2))
 		return -EINVAL;
 
 	/* new endpoints */
 	err = parse_sockaddr_pair((struct sockaddr *)(rq2 + 1),
-				  rq2->sadb_x_ipsecrequest_len,
+				  rq2->sadb_x_ipsecrequest_len - sizeof(*rq2),
 				  &m->new_saddr, &m->new_daddr,
 				  &m->new_family);
 	if (err)

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

* [PATCH 3.18 24/60] PCI/PM: Restore the status of PCI devices across hibernation
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (21 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 23/60] af_key: Fix sadb_x_ipsecrequest parsing Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 25/60] xhci: fix 20000ms port resume timeout Greg Kroah-Hartman
                   ` (35 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Ying Huang, Rafael J. Wysocki,
	Chen Yu, Bjorn Helgaas, Len Brown, Dan Williams, Rui Zhang

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

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

From: Chen Yu <yu.c.chen@intel.com>

commit e60514bd4485c0c7c5a7cf779b200ce0b95c70d6 upstream.

Currently we saw a lot of "No irq handler" errors during hibernation, which
caused the system hang finally:

  ata4.00: qc timeout (cmd 0xec)
  ata4.00: failed to IDENTIFY (I/O error, err_mask=0x4)
  ata4.00: revalidation failed (errno=-5)
  ata4: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
  do_IRQ: 31.151 No irq handler for vector

According to above logs, there is an interrupt triggered and it is
dispatched to CPU31 with a vector number 151, but there is no handler for
it, thus this IRQ will not get acked and will cause an IRQ flood which
kills the system.  To be more specific, the 31.151 is an interrupt from the
AHCI host controller.

After some investigation, the reason why this issue is triggered is because
the thaw_noirq() function does not restore the MSI/MSI-X settings across
hibernation.

The scenario is illustrated below:

  1. Before hibernation, IRQ 34 is the handler for the AHCI device, which
     is bound to CPU31.

  2. Hibernation starts, the AHCI device is put into low power state.

  3. All the nonboot CPUs are put offline, so IRQ 34 has to be migrated to
     the last alive one - CPU0.

  4. After the snapshot has been created, all the nonboot CPUs are brought
     up again; IRQ 34 remains bound to CPU0.

  5. AHCI devices are put into D0.

  6. The snapshot is written to the disk.

The issue is triggered in step 6.  The AHCI interrupt should be delivered
to CPU0, however it is delivered to the original CPU31 instead, which
causes the "No irq handler" issue.

Ying Huang has provided a clue that, in step 3 it is possible that writing
to the register might not take effect as the PCI devices have been
suspended.

In step 3, the IRQ 34 affinity should be modified from CPU31 to CPU0, but
in fact it is not.  In __pci_write_msi_msg(), if the device is already in
low power state, the low level MSI message entry will not be updated but
cached.  During the device restore process after a normal suspend/resume,
pci_restore_msi_state() writes the cached MSI back to the hardware.

But this is not the case for hibernation.  pci_restore_msi_state() is not
currently called in pci_pm_thaw_noirq(), although pci_save_state() has
saved the necessary PCI cached information in pci_pm_freeze_noirq().

Restore the PCI status for the device during hibernation.  Otherwise the
status might be lost across hibernation (for example, settings for MSI,
MSI-X, ATS, ACS, IOV, etc.), which might cause problems during hibernation.

Suggested-by: Ying Huang <ying.huang@intel.com>
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
[bhelgaas: changelog]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Rui Zhang <rui.zhang@intel.com>
Cc: Ying Huang <ying.huang@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/pci/pci-driver.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -925,6 +925,7 @@ static int pci_pm_thaw_noirq(struct devi
 		return pci_legacy_resume_early(dev);
 
 	pci_update_current_state(pci_dev, PCI_D0);
+	pci_restore_state(pci_dev);
 
 	if (drv && drv->pm && drv->pm->thaw_noirq)
 		error = drv->pm->thaw_noirq(dev);

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

* [PATCH 3.18 25/60] xhci: fix 20000ms port resume timeout
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (22 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 24/60] PCI/PM: Restore the status of PCI devices across hibernation Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 26/60] xhci: Fix NULL pointer dereference when cleaning up streams for removed host Greg Kroah-Hartman
                   ` (34 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Mathias Nyman

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

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

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

commit a54408d0a004757789863d74e29c2297edae0b4d upstream.

A uncleared PLC (port link change) bit will prevent furuther port event
interrupts for that port. Leaving it uncleared caused get_port_status()
to timeout after 20000ms while waiting to get the final port event
interrupt for resume -> U0 state change.

This is a targeted fix for a specific case where we get a port resume event
racing with xhci resume. The port event interrupt handler notices xHC is
not yet running and bails out early, leaving PLC uncleared.

The whole xhci port resuming needs more attention, but while working on it
it anyways makes sense to always ensure PLC is cleared in get_port_status
before setting a new link state and waiting for its completion.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-hub.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -651,6 +651,9 @@ static u32 xhci_get_port_status(struct u
 			clear_bit(wIndex, &bus_state->resuming_ports);
 
 			set_bit(wIndex, &bus_state->rexit_ports);
+
+			xhci_test_and_clear_bit(xhci, port_array, wIndex,
+						PORT_PLC);
 			xhci_set_link_state(xhci, port_array, wIndex,
 					XDEV_U0);
 

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

* [PATCH 3.18 26/60] xhci: Fix NULL pointer dereference when cleaning up streams for removed host
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (23 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 25/60] xhci: fix 20000ms port resume timeout Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 27/60] usb: storage: return on error to avoid a null pointer dereference Greg Kroah-Hartman
                   ` (33 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, rocko r, Mathias Nyman

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

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

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

commit 4b895868bb2da60a386a17cde3bf9ecbc70c79f4 upstream.

This off by one in stream_id indexing caused NULL pointer dereference and
soft lockup on machines with USB attached SCSI devices connected to a
hotpluggable xhci controller.

The code that cleans up pending URBs for dead hosts tried to dereference
a stream ring at the invalid stream_id 0.
ep->stream_info->stream_rings[0] doesn't point to a ring.

Start looping stream_id from 1 like in all the other places in the driver,
and check that the ring exists before trying to kill URBs on it.

Reported-by: rocko r <rockorequin@gmail.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-ring.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -782,13 +782,16 @@ static void xhci_kill_endpoint_urbs(stru
 			(ep->ep_state & EP_GETTING_NO_STREAMS)) {
 		int stream_id;
 
-		for (stream_id = 0; stream_id < ep->stream_info->num_streams;
+		for (stream_id = 1; stream_id < ep->stream_info->num_streams;
 				stream_id++) {
+			ring = ep->stream_info->stream_rings[stream_id];
+			if (!ring)
+				continue;
+
 			xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
 					"Killing URBs for slot ID %u, ep index %u, stream %u",
-					slot_id, ep_index, stream_id + 1);
-			xhci_kill_ring_urbs(xhci,
-					ep->stream_info->stream_rings[stream_id]);
+					slot_id, ep_index, stream_id);
+			xhci_kill_ring_urbs(xhci, ring);
 		}
 	} else {
 		ring = ep->ring;

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

* [PATCH 3.18 27/60] usb: storage: return on error to avoid a null pointer dereference
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (24 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 26/60] xhci: Fix NULL pointer dereference when cleaning up streams for removed host Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 28/60] USB: cdc-acm: add device-id for quirky printer Greg Kroah-Hartman
                   ` (32 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Colin Ian King, Alan Stern

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

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

From: Colin Ian King <colin.king@canonical.com>

commit 446230f52a5bef593554510302465eabab45a372 upstream.

When us->extra is null the driver is not initialized, however, a
later call to osd200_scsi_to_ata is made that dereferences
us->extra, causing a null pointer dereference.  The code
currently detects and reports that the driver is not initialized;
add a return to avoid the subsequent dereference issue in this
check.

Thanks to Alan Stern for pointing out that srb->result needs setting
to DID_ERROR << 16

Detected by CoverityScan, CID#100308 ("Dereference after null check")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/storage/isd200.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -1522,8 +1522,11 @@ static void isd200_ata_command(struct sc
 
 	/* Make sure driver was initialized */
 
-	if (us->extra == NULL)
+	if (us->extra == NULL) {
 		usb_stor_dbg(us, "ERROR Driver not initialized\n");
+		srb->result = DID_ERROR << 16;
+		return;
+	}
 
 	scsi_set_resid(srb, 0);
 	/* scsi_bufflen might change in protocol translation to ata */

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

* [PATCH 3.18 28/60] USB: cdc-acm: add device-id for quirky printer
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (25 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 27/60] usb: storage: return on error to avoid a null pointer dereference Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 29/60] usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL Greg Kroah-Hartman
                   ` (31 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Anton Avramov, Johan Hovold, Oliver Neukum

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

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

From: Johan Hovold <johan@kernel.org>

commit fe855789d605590e57f9cd968d85ecce46f5c3fd upstream.

Add device-id entry for DATECS FP-2000 fiscal printer needing the
NO_UNION_NORMAL quirk.

Reported-by: Anton Avramov <lukav@lukav.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Acked-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/class/cdc-acm.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1776,6 +1776,9 @@ static const struct usb_device_id acm_id
 	{ USB_DEVICE(0x1576, 0x03b1), /* Maretron USB100 */
 	.driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
 	},
+	{ USB_DEVICE(0xfff0, 0x0100), /* DATECS FP-2000 */
+	.driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
+	},
 
 	{ USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */
 	.driver_info = CLEAR_HALT_CONDITIONS,

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

* [PATCH 3.18 29/60] usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (26 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 28/60] USB: cdc-acm: add device-id for quirky printer Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 30/60] md: dont use flush_signals in userspace processes Greg Kroah-Hartman
                   ` (30 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Yoshihiro Shimoda, Felipe Balbi

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

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

From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

commit 59a0879a0e17b2e43ecdc5e3299da85b8410d7ce upstream.

This patch fixes an issue that some registers may be not initialized
after resume if the USBHSF_RUNTIME_PWCTRL is not set. Otherwise,
if a cable is not connected, the driver will not enable INTENB0.VBSE
after resume. And then, the driver cannot detect the VBUS.

Fixes: ca8a282a5373 ("usb: gadget: renesas_usbhs: add suspend/resume support")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/renesas_usbhs/common.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -699,8 +699,10 @@ static int usbhsc_resume(struct device *
 	struct usbhs_priv *priv = dev_get_drvdata(dev);
 	struct platform_device *pdev = usbhs_priv_to_pdev(priv);
 
-	if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
+	if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) {
 		usbhsc_power_ctrl(priv, 1);
+		usbhs_mod_autonomy_mode(priv);
+	}
 
 	usbhs_platform_call(priv, phy_reset, pdev);
 

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

* [PATCH 3.18 30/60] md: dont use flush_signals in userspace processes
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (27 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 29/60] usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 31/60] Raid5 should update rdev->sectors after reshape Greg Kroah-Hartman
                   ` (29 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mikulas Patocka, NeilBrown, Shaohua Li

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

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

From: Mikulas Patocka <mpatocka@redhat.com>

commit f9c79bc05a2a91f4fba8bfd653579e066714b1ec upstream.

The function flush_signals clears all pending signals for the process. It
may be used by kernel threads when we need to prepare a kernel thread for
responding to signals. However using this function for an userspaces
processes is incorrect - clearing signals without the program expecting it
can cause misbehavior.

The raid1 and raid5 code uses flush_signals in its request routine because
it wants to prepare for an interruptible wait. This patch drops
flush_signals and uses sigprocmask instead to block all signals (including
SIGKILL) around the schedule() call. The signals are not lost, but the
schedule() call won't respond to them.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/raid1.c |    5 ++++-
 drivers/md/raid5.c |    5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1120,13 +1120,16 @@ static void make_request(struct mddev *m
 		 */
 		DEFINE_WAIT(w);
 		for (;;) {
-			flush_signals(current);
+			sigset_t full, old;
 			prepare_to_wait(&conf->wait_barrier,
 					&w, TASK_INTERRUPTIBLE);
 			if (bio_end_sector(bio) <= mddev->suspend_lo ||
 			    bio->bi_iter.bi_sector >= mddev->suspend_hi)
 				break;
+			sigfillset(&full);
+			sigprocmask(SIG_BLOCK, &full, &old);
 			schedule();
+			sigprocmask(SIG_SETMASK, &old, NULL);
 		}
 		finish_wait(&conf->wait_barrier, &w);
 	}
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -4705,12 +4705,15 @@ static void make_request(struct mddev *m
 				 * userspace, we want an interruptible
 				 * wait.
 				 */
-				flush_signals(current);
 				prepare_to_wait(&conf->wait_for_overlap,
 						&w, TASK_INTERRUPTIBLE);
 				if (logical_sector >= mddev->suspend_lo &&
 				    logical_sector < mddev->suspend_hi) {
+					sigset_t full, old;
+					sigfillset(&full);
+					sigprocmask(SIG_BLOCK, &full, &old);
 					schedule();
+					sigprocmask(SIG_SETMASK, &old, NULL);
 					do_prepare = true;
 				}
 				goto retry;

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

* [PATCH 3.18 31/60] Raid5 should update rdev->sectors after reshape
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (28 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 30/60] md: dont use flush_signals in userspace processes Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 32/60] s390/syscalls: Fix out of bounds arguments access Greg Kroah-Hartman
                   ` (28 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Xiao Ni, Guoqing Jiang, Shaohua Li

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

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

From: Xiao Ni <xni@redhat.com>

commit b5d27718f38843a74552e9a93d32e2391fd3999f upstream.

The raid5 md device is created by the disks which we don't use the total size. For example,
the size of the device is 5G and it just uses 3G of the devices to create one raid5 device.
Then change the chunksize and wait reshape to finish. After reshape finishing stop the raid
and assemble it again. It fails.
mdadm -CR /dev/md0 -l5 -n3 /dev/loop[0-2] --size=3G --chunk=32 --assume-clean
mdadm /dev/md0 --grow --chunk=64
wait reshape to finish
mdadm -S /dev/md0
mdadm -As
The error messages:
[197519.814302] md: loop1 does not have a valid v1.2 superblock, not importing!
[197519.821686] md: md_import_device returned -22

After reshape the data offset is changed. It selects backwards direction in this condition.
In function super_1_load it compares the available space of the underlying device with
sb->data_size. The new data offset gets bigger after reshape. So super_1_load returns -EINVAL.
rdev->sectors is updated in md_finish_reshape. Then sb->data_size is set in super_1_sync based
on rdev->sectors. So add md_finish_reshape in end_reshape.

Signed-off-by: Xiao Ni <xni@redhat.com>
Acked-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/raid5.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6722,12 +6722,10 @@ static void end_reshape(struct r5conf *c
 {
 
 	if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) {
-		struct md_rdev *rdev;
 
 		spin_lock_irq(&conf->device_lock);
 		conf->previous_raid_disks = conf->raid_disks;
-		rdev_for_each(rdev, conf->mddev)
-			rdev->data_offset = rdev->new_data_offset;
+		md_finish_reshape(conf->mddev);
 		smp_wmb();
 		conf->reshape_progress = MaxSector;
 		spin_unlock_irq(&conf->device_lock);

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

* [PATCH 3.18 32/60] s390/syscalls: Fix out of bounds arguments access
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (29 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 31/60] Raid5 should update rdev->sectors after reshape Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 34/60] f2fs: Dont clear SGID when inheriting ACLs Greg Kroah-Hartman
                   ` (27 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Zorro Lang, Jiri Olsa, Martin Schwidefsky

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

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

From: Jiri Olsa <jolsa@kernel.org>

commit c46fc0424ced3fb71208e72bd597d91b9169a781 upstream.

Zorro reported following crash while having enabled
syscall tracing (CONFIG_FTRACE_SYSCALLS):

  Unable to handle kernel pointer dereference at virtual ...
  Oops: 0011 [#1] SMP DEBUG_PAGEALLOC

  SNIP

  Call Trace:
  ([<000000000024d79c>] ftrace_syscall_enter+0xec/0x1d8)
   [<00000000001099c6>] do_syscall_trace_enter+0x236/0x2f8
   [<0000000000730f1c>] sysc_tracesys+0x1a/0x32
   [<000003fffcf946a2>] 0x3fffcf946a2
  INFO: lockdep is turned off.
  Last Breaking-Event-Address:
   [<000000000022dd44>] rb_event_data+0x34/0x40
  ---[ end trace 8c795f86b1b3f7b9 ]---

The crash happens in syscall_get_arguments function for
syscalls with zero arguments, that will try to access
first argument (args[0]) in event entry, but it's not
allocated.

Bail out of there are no arguments.

Reported-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/s390/include/asm/syscall.h |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/arch/s390/include/asm/syscall.h
+++ b/arch/s390/include/asm/syscall.h
@@ -64,6 +64,12 @@ static inline void syscall_get_arguments
 {
 	unsigned long mask = -1UL;
 
+	/*
+	 * No arguments for this syscall, there's nothing to do.
+	 */
+	if (!n)
+		return;
+
 	BUG_ON(i + n > 6);
 #ifdef CONFIG_COMPAT
 	if (test_tsk_thread_flag(task, TIF_31BIT))

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

* [PATCH 3.18 34/60] f2fs: Dont clear SGID when inheriting ACLs
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (30 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 32/60] s390/syscalls: Fix out of bounds arguments access Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 35/60] vfio: Fix group release deadlock Greg Kroah-Hartman
                   ` (26 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Jan Kara, Chao Yu, Jaegeuk Kim

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

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

From: Jaegeuk Kim <jaegeuk@kernel.org>

commit c925dc162f770578ff4a65ec9b08270382dba9e6 upstream.

This patch copies commit b7f8a09f80:
"btrfs: Don't clear SGID when inheriting ACLs" written by Jan.

Fixes: 073931017b49d9458aa351605b43a7e34598caef
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/f2fs/acl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -206,7 +206,7 @@ static int __f2fs_set_acl(struct inode *
 	switch (type) {
 	case ACL_TYPE_ACCESS:
 		name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
-		if (acl) {
+		if (acl && !ipage) {
 			error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
 			if (error)
 				return error;

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

* [PATCH 3.18 35/60] vfio: Fix group release deadlock
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (31 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 34/60] f2fs: Dont clear SGID when inheriting ACLs Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 36/60] vfio: New external user group/file match Greg Kroah-Hartman
                   ` (25 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Alex Williamson, Eric Auger

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

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

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

commit 811642d8d8a82c0cce8dc2debfdaf23c5a144839 upstream.

If vfio_iommu_group_notifier() acquires a group reference and that
reference becomes the last reference to the group, then vfio_group_put
introduces a deadlock code path where we're trying to unregister from
the iommu notifier chain from within a callout of that chain.  Use a
work_struct to release this reference asynchronously.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/vfio/vfio.c |   37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -278,6 +278,34 @@ static void vfio_group_put(struct vfio_g
 	kref_put_mutex(&group->kref, vfio_group_release, &vfio.group_lock);
 }
 
+struct vfio_group_put_work {
+	struct work_struct work;
+	struct vfio_group *group;
+};
+
+static void vfio_group_put_bg(struct work_struct *work)
+{
+	struct vfio_group_put_work *do_work;
+
+	do_work = container_of(work, struct vfio_group_put_work, work);
+
+	vfio_group_put(do_work->group);
+	kfree(do_work);
+}
+
+static void vfio_group_schedule_put(struct vfio_group *group)
+{
+	struct vfio_group_put_work *do_work;
+
+	do_work = kmalloc(sizeof(*do_work), GFP_KERNEL);
+	if (WARN_ON(!do_work))
+		return;
+
+	INIT_WORK(&do_work->work, vfio_group_put_bg);
+	do_work->group = group;
+	schedule_work(&do_work->work);
+}
+
 /* Assume group_lock or group reference is held */
 static void vfio_group_get(struct vfio_group *group)
 {
@@ -553,7 +581,14 @@ static int vfio_iommu_group_notifier(str
 		break;
 	}
 
-	vfio_group_put(group);
+	/*
+	 * If we're the last reference to the group, the group will be
+	 * released, which includes unregistering the iommu group notifier.
+	 * We hold a read-lock on that notifier list, unregistering needs
+	 * a write-lock... deadlock.  Release our reference asynchronously
+	 * to avoid that situation.
+	 */
+	vfio_group_schedule_put(group);
 	return NOTIFY_OK;
 }
 

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

* [PATCH 3.18 36/60] vfio: New external user group/file match
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (32 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 35/60] vfio: Fix group release deadlock Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 37/60] MIPS: Fix mips_atomic_set() retry condition Greg Kroah-Hartman
                   ` (24 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Alex Williamson, Eric Auger, Paolo Bonzini

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

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

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

commit 5d6dee80a1e94cc284d03e06d930e60e8d3ecf7d upstream.

At the point where the kvm-vfio pseudo device wants to release its
vfio group reference, we can't always acquire a new reference to make
that happen.  The group can be in a state where we wouldn't allow a
new reference to be added.  This new helper function allows a caller
to match a file to a group to facilitate this.  Given a file and
group, report if they match.  Thus the caller needs to already have a
group reference to match to the file.  This allows the deletion of a
group without acquiring a new reference.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/vfio/vfio.c  |    9 +++++++++
 include/linux/vfio.h |    2 ++
 virt/kvm/vfio.c      |   27 +++++++++++++++++++--------
 3 files changed, 30 insertions(+), 8 deletions(-)

--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -1436,6 +1436,15 @@ void vfio_group_put_external_user(struct
 }
 EXPORT_SYMBOL_GPL(vfio_group_put_external_user);
 
+bool vfio_external_group_match_file(struct vfio_group *test_group,
+				    struct file *filep)
+{
+	struct vfio_group *group = filep->private_data;
+
+	return (filep->f_op == &vfio_group_fops) && (group == test_group);
+}
+EXPORT_SYMBOL_GPL(vfio_external_group_match_file);
+
 int vfio_external_user_iommu_id(struct vfio_group *group)
 {
 	return iommu_group_id(group->iommu_group);
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -81,6 +81,8 @@ extern void vfio_unregister_iommu_driver
  */
 extern struct vfio_group *vfio_group_get_external_user(struct file *filep);
 extern void vfio_group_put_external_user(struct vfio_group *group);
+extern bool vfio_external_group_match_file(struct vfio_group *group,
+					   struct file *filep);
 extern int vfio_external_user_iommu_id(struct vfio_group *group);
 extern long vfio_external_check_extension(struct vfio_group *group,
 					  unsigned long arg);
--- a/virt/kvm/vfio.c
+++ b/virt/kvm/vfio.c
@@ -47,6 +47,22 @@ static struct vfio_group *kvm_vfio_group
 	return vfio_group;
 }
 
+static bool kvm_vfio_external_group_match_file(struct vfio_group *group,
+					       struct file *filep)
+{
+	bool ret, (*fn)(struct vfio_group *, struct file *);
+
+	fn = symbol_get(vfio_external_group_match_file);
+	if (!fn)
+		return false;
+
+	ret = fn(group, filep);
+
+	symbol_put(vfio_external_group_match_file);
+
+	return ret;
+}
+
 static void kvm_vfio_group_put_external_user(struct vfio_group *vfio_group)
 {
 	void (*fn)(struct vfio_group *);
@@ -169,18 +185,13 @@ static int kvm_vfio_set_group(struct kvm
 		if (!f.file)
 			return -EBADF;
 
-		vfio_group = kvm_vfio_group_get_external_user(f.file);
-		fdput(f);
-
-		if (IS_ERR(vfio_group))
-			return PTR_ERR(vfio_group);
-
 		ret = -ENOENT;
 
 		mutex_lock(&kv->lock);
 
 		list_for_each_entry(kvg, &kv->group_list, node) {
-			if (kvg->vfio_group != vfio_group)
+			if (!kvm_vfio_external_group_match_file(kvg->vfio_group,
+								f.file))
 				continue;
 
 			list_del(&kvg->node);
@@ -192,7 +203,7 @@ static int kvm_vfio_set_group(struct kvm
 
 		mutex_unlock(&kv->lock);
 
-		kvm_vfio_group_put_external_user(vfio_group);
+		fdput(f);
 
 		kvm_vfio_update_coherency(dev);
 

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

* [PATCH 3.18 37/60] MIPS: Fix mips_atomic_set() retry condition
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (33 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 36/60] vfio: New external user group/file match Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 38/60] MIPS: Fix mips_atomic_set() with EVA Greg Kroah-Hartman
                   ` (23 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, James Hogan, linux-mips, Ralf Baechle

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

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

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

commit 2ec420b26f7b6ff332393f0bb5a7d245f7ad87f0 upstream.

The inline asm retry check in the MIPS_ATOMIC_SET operation of the
sysmips system call has been backwards since commit f1e39a4a616c ("MIPS:
Rewrite sysmips(MIPS_ATOMIC_SET, ...) in C with inline assembler")
merged in v2.6.32, resulting in the non R10000_LLSC_WAR case retrying
until the operation was inatomic, before returning the new value that
was probably just written multiple times instead of the old value.

Invert the branch condition to fix that particular issue.

Fixes: f1e39a4a616c ("MIPS: Rewrite sysmips(MIPS_ATOMIC_SET, ...) in C with inline assembler")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/16148/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/mips/kernel/syscall.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -140,7 +140,7 @@ static inline int mips_atomic_set(unsign
 		"1:	ll	%[old], (%[addr])			\n"
 		"	move	%[tmp], %[new]				\n"
 		"2:	sc	%[tmp], (%[addr])			\n"
-		"	bnez	%[tmp], 4f				\n"
+		"	beqz	%[tmp], 4f				\n"
 		"3:							\n"
 		"	.subsection 2					\n"
 		"4:	b	1b					\n"

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

* [PATCH 3.18 38/60] MIPS: Fix mips_atomic_set() with EVA
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (34 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 37/60] MIPS: Fix mips_atomic_set() retry condition Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 39/60] MIPS: Negate error syscall return in trace Greg Kroah-Hartman
                   ` (22 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, James Hogan, linux-mips, Ralf Baechle

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

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

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

commit 4915e1b043d6286928207b1f6968197b50407294 upstream.

EVA linked loads (LLE) and conditional stores (SCE) should be used on
EVA kernels for the MIPS_ATOMIC_SET operation of the sysmips system
call, or else the atomic set will apply to the kernel view of the
virtual address space (potentially unmapped on EVA kernels) rather than
the user view (TLB mapped).

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/16151/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/mips/kernel/syscall.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -28,6 +28,7 @@
 #include <linux/elf.h>
 
 #include <asm/asm.h>
+#include <asm/asm-eva.h>
 #include <asm/branch.h>
 #include <asm/cachectl.h>
 #include <asm/cacheflush.h>
@@ -137,9 +138,11 @@ static inline int mips_atomic_set(unsign
 		__asm__ __volatile__ (
 		"	.set	arch=r4000				\n"
 		"	li	%[err], 0				\n"
-		"1:	ll	%[old], (%[addr])			\n"
+		"1:							\n"
+		user_ll("%[old]", "(%[addr])")
 		"	move	%[tmp], %[new]				\n"
-		"2:	sc	%[tmp], (%[addr])			\n"
+		"2:							\n"
+		user_sc("%[tmp]", "(%[addr])")
 		"	beqz	%[tmp], 4f				\n"
 		"3:							\n"
 		"	.subsection 2					\n"

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

* [PATCH 3.18 39/60] MIPS: Negate error syscall return in trace
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (35 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 38/60] MIPS: Fix mips_atomic_set() with EVA Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 40/60] x86/acpi: Prevent out of bound access caused by broken ACPI tables Greg Kroah-Hartman
                   ` (21 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, James Hogan, Steven Rostedt,
	Ingo Molnar, linux-mips, Ralf Baechle

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

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

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

commit 4f32a39d49b25eaa66d2420f1f03d371ea4cd906 upstream.

The sys_exit trace event takes a single return value for the system
call, which MIPS passes the value of the $v0 (result) register, however
MIPS returns positive error codes in $v0 with $a3 specifying that $v0
contains an error code. As a result erroring system calls are traced
returning positive error numbers that can't always be distinguished from
success.

Use regs_return_value() to negate the error code if $a3 is set.

Fixes: 1d7bf993e073 ("MIPS: ftrace: Add support for syscall tracepoints.")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/16651/
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/mips/kernel/ptrace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -802,7 +802,7 @@ asmlinkage void syscall_trace_leave(stru
 	audit_syscall_exit(regs);
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_sys_exit(regs, regs->regs[2]);
+		trace_sys_exit(regs, regs_return_value(regs));
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall_exit(regs, 0);

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

* [PATCH 3.18 40/60] x86/acpi: Prevent out of bound access caused by broken ACPI tables
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (36 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 39/60] MIPS: Negate error syscall return in trace Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 41/60] MIPS: Save static registers before sysmips Greg Kroah-Hartman
                   ` (20 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Seunghun Han, Thomas Gleixner,
	security, Rafael J. Wysocki, Ingo Molnar

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

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

From: Seunghun Han <kkamagui@gmail.com>

commit dad5ab0db8deac535d03e3fe3d8f2892173fa6a4 upstream.

The bus_irq argument of mp_override_legacy_irq() is used as the index into
the isa_irq_to_gsi[] array. The bus_irq argument originates from
ACPI_MADT_TYPE_IO_APIC and ACPI_MADT_TYPE_INTERRUPT items in the ACPI
tables, but is nowhere sanity checked.

That allows broken or malicious ACPI tables to overwrite memory, which
might cause malfunction, panic or arbitrary code execution.

Add a sanity check and emit a warning when that triggers.

[ tglx: Added warning and rewrote changelog ]

Signed-off-by: Seunghun Han <kkamagui@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: security@kernel.org
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/acpi/boot.c |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -316,6 +316,14 @@ static void __init mp_override_legacy_ir
 	struct mpc_intsrc mp_irq;
 
 	/*
+	 * Check bus_irq boundary.
+	 */
+	if (bus_irq >= NR_IRQS_LEGACY) {
+		pr_warn("Invalid bus_irq %u for legacy override\n", bus_irq);
+		return;
+	}
+
+	/*
 	 * Convert 'gsi' to 'ioapic.pin'.
 	 */
 	ioapic = mp_find_ioapic(gsi);

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

* [PATCH 3.18 41/60] MIPS: Save static registers before sysmips
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (37 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 40/60] x86/acpi: Prevent out of bound access caused by broken ACPI tables Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 42/60] MIPS: Actually decode JALX in `__compute_return_epc_for_insn Greg Kroah-Hartman
                   ` (19 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, James Hogan, linux-mips, Ralf Baechle

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

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

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

commit 49955d84cd9ccdca5a16a495e448e1a06fad9e49 upstream.

The MIPS sysmips system call handler may return directly from the
MIPS_ATOMIC_SET case (mips_atomic_set()) to syscall_exit. This path
restores the static (callee saved) registers, however they won't have
been saved on entry to the system call.

Use the save_static_function() macro to create a __sys_sysmips wrapper
function which saves the static registers before calling sys_sysmips, so
that the correct static register state is restored by syscall_exit.

Fixes: f1e39a4a616c ("MIPS: Rewrite sysmips(MIPS_ATOMIC_SET, ...) in C with inline assembler")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/16149/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/mips/kernel/scall32-o32.S |    2 +-
 arch/mips/kernel/scall64-64.S  |    2 +-
 arch/mips/kernel/scall64-n32.S |    2 +-
 arch/mips/kernel/scall64-o32.S |    2 +-
 arch/mips/kernel/syscall.c     |    6 ++++++
 5 files changed, 10 insertions(+), 4 deletions(-)

--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -361,7 +361,7 @@ EXPORT(sys_call_table)
 	PTR	sys_writev
 	PTR	sys_cacheflush
 	PTR	sys_cachectl
-	PTR	sys_sysmips
+	PTR	__sys_sysmips
 	PTR	sys_ni_syscall			/* 4150 */
 	PTR	sys_getsid
 	PTR	sys_fdatasync
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -318,7 +318,7 @@ EXPORT(sys_call_table)
 	PTR	sys_sched_getaffinity
 	PTR	sys_cacheflush
 	PTR	sys_cachectl
-	PTR	sys_sysmips
+	PTR	__sys_sysmips
 	PTR	sys_io_setup			/* 5200 */
 	PTR	sys_io_destroy
 	PTR	sys_io_getevents
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -307,7 +307,7 @@ EXPORT(sysn32_call_table)
 	PTR	compat_sys_sched_getaffinity
 	PTR	sys_cacheflush
 	PTR	sys_cachectl
-	PTR	sys_sysmips
+	PTR	__sys_sysmips
 	PTR	compat_sys_io_setup			/* 6200 */
 	PTR	sys_io_destroy
 	PTR	compat_sys_io_getevents
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -358,7 +358,7 @@ EXPORT(sys32_call_table)
 	PTR	compat_sys_writev
 	PTR	sys_cacheflush
 	PTR	sys_cachectl
-	PTR	sys_sysmips
+	PTR	__sys_sysmips
 	PTR	sys_ni_syscall			/* 4150 */
 	PTR	sys_getsid
 	PTR	sys_fdatasync
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -200,6 +200,12 @@ static inline int mips_atomic_set(unsign
 	unreachable();
 }
 
+/*
+ * mips_atomic_set() normally returns directly via syscall_exit potentially
+ * clobbering static registers, so be sure to preserve them.
+ */
+save_static_function(sys_sysmips);
+
 SYSCALL_DEFINE3(sysmips, long, cmd, long, arg1, long, arg2)
 {
 	switch (cmd) {

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

* [PATCH 3.18 42/60] MIPS: Actually decode JALX in `__compute_return_epc_for_insn
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (38 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 41/60] MIPS: Save static registers before sysmips Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 43/60] MIPS: Fix unaligned PC interpretation in `compute_return_epc Greg Kroah-Hartman
                   ` (18 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Maciej W. Rozycki, James Hogan,
	linux-mips, Ralf Baechle

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

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

From: Maciej W. Rozycki <macro@imgtec.com>

commit a9db101b735a9d49295326ae41f610f6da62b08c upstream.

Complement commit fb6883e5809c ("MIPS: microMIPS: Support handling of
delay slots.") and actually decode the regular MIPS JALX major
instruction opcode, the handling of which has been added with the said
commit for EPC calculation in `__compute_return_epc_for_insn'.

Fixes: fb6883e5809c ("MIPS: microMIPS: Support handling of delay slots.")
Signed-off-by: Maciej W. Rozycki <macro@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/16394/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/mips/kernel/branch.c |    1 +
 1 file changed, 1 insertion(+)

--- a/arch/mips/kernel/branch.c
+++ b/arch/mips/kernel/branch.c
@@ -493,6 +493,7 @@ int __compute_return_epc_for_insn(struct
 	/*
 	 * These are unconditional and in j_format.
 	 */
+	case jalx_op:
 	case jal_op:
 		regs->regs[31] = regs->cp0_epc + 8;
 	case j_op:

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

* [PATCH 3.18 43/60] MIPS: Fix unaligned PC interpretation in `compute_return_epc
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (39 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 42/60] MIPS: Actually decode JALX in `__compute_return_epc_for_insn Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 44/60] MIPS: math-emu: Prevent wrong ISA mode instruction emulation Greg Kroah-Hartman
                   ` (17 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Maciej W. Rozycki, James Hogan,
	linux-mips, Ralf Baechle

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

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

From: Maciej W. Rozycki <macro@imgtec.com>

commit 11a3799dbeb620bf0400b1fda5cc2c6bea55f20a upstream.

Fix a regression introduced with commit fb6883e5809c ("MIPS: microMIPS:
Support handling of delay slots.") and defer to `__compute_return_epc'
if the ISA bit is set in EPC with non-MIPS16, non-microMIPS hardware,
which will then arrange for a SIGBUS due to an unaligned instruction
reference.  Returning EPC here is never correct as the API defines this
function's result to be either a negative error code on failure or one
of 0 and BRANCH_LIKELY_TAKEN on success.

Fixes: fb6883e5809c ("MIPS: microMIPS: Support handling of delay slots.")
Signed-off-by: Maciej W. Rozycki <macro@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/16395/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/mips/include/asm/branch.h |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

--- a/arch/mips/include/asm/branch.h
+++ b/arch/mips/include/asm/branch.h
@@ -74,10 +74,7 @@ static inline int compute_return_epc(str
 			return __microMIPS_compute_return_epc(regs);
 		if (cpu_has_mips16)
 			return __MIPS16e_compute_return_epc(regs);
-		return regs->cp0_epc;
-	}
-
-	if (!delay_slot(regs)) {
+	} else if (!delay_slot(regs)) {
 		regs->cp0_epc += 4;
 		return 0;
 	}

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

* [PATCH 3.18 44/60] MIPS: math-emu: Prevent wrong ISA mode instruction emulation
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (40 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 43/60] MIPS: Fix unaligned PC interpretation in `compute_return_epc Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 45/60] Input: i8042 - fix crash at boot time Greg Kroah-Hartman
                   ` (16 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Maciej W. Rozycki, James Hogan,
	linux-mips, Ralf Baechle

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

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

From: Maciej W. Rozycki <macro@imgtec.com>

commit 13769ebad0c42738831787e27c7c7f982e7da579 upstream.

Terminate FPU emulation immediately whenever an ISA mode switch has been
observed.  This is so that we do not interpret machine code in the wrong
mode, for example when a regular MIPS FPU instruction has been placed in
a delay slot of a jump that switches into the MIPS16 mode, as with the
following code (taken from a GCC test suite case):

00400650 <set_fast_math>:
  400650:	3c020100 	lui	v0,0x100
  400654:	03e00008 	jr	ra
  400658:	44c2f800 	ctc1	v0,c1_fcsr
  40065c:	00000000 	nop

[...]

004012d0 <__libc_csu_init>:
  4012d0:	f000 6a02 	li	v0,2
  4012d4:	f150 0b1c 	la	v1,3f9430 <_DYNAMIC-0x6df0>
  4012d8:	f400 3240 	sll	v0,16
  4012dc:	e269      	addu	v0,v1
  4012de:	659a      	move	gp,v0
  4012e0:	f00c 64f6 	save	a0-a2,48,ra,s0-s1
  4012e4:	673c      	move	s1,gp
  4012e6:	f010 9978 	lw	v1,-32744(s1)
  4012ea:	d204      	sw	v0,16(sp)
  4012ec:	eb40      	jalr	v1
  4012ee:	653b      	move	t9,v1
  4012f0:	f010 997c 	lw	v1,-32740(s1)
  4012f4:	f030 9920 	lw	s1,-32736(s1)
  4012f8:	e32f      	subu	v1,s1
  4012fa:	326b      	sra	v0,v1,2
  4012fc:	d206      	sw	v0,24(sp)
  4012fe:	220c      	beqz	v0,401318 <__libc_csu_init+0x48>
  401300:	6800      	li	s0,0
  401302:	99e0      	lw	a3,0(s1)
  401304:	4801      	addiu	s0,1
  401306:	960e      	lw	a2,56(sp)
  401308:	4904      	addiu	s1,4
  40130a:	950d      	lw	a1,52(sp)
  40130c:	940c      	lw	a0,48(sp)
  40130e:	ef40      	jalr	a3
  401310:	653f      	move	t9,a3
  401312:	9206      	lw	v0,24(sp)
  401314:	ea0a      	cmp	v0,s0
  401316:	61f5      	btnez	401302 <__libc_csu_init+0x32>
  401318:	6476      	restore	48,ra,s0-s1
  40131a:	e8a0      	jrc	ra

Here `set_fast_math' is called from `40130e' (`40130f' with the ISA bit)
and emulation triggers for the CTC1 instruction.  As it is in a jump
delay slot emulation continues from `401312' (`401313' with the ISA
bit).  However we have no path to handle MIPS16 FPU code emulation,
because there are no MIPS16 FPU instructions.  So the default emulation
path is taken, interpreting a 32-bit word fetched by `get_user' from
`401313' as a regular MIPS instruction, which is:

  401313:	f5ea0a92	sdc1	$f10,2706(t7)

This makes the FPU emulator proceed with the supposed SDC1 instruction
and consequently makes the program considered here terminate with
SIGSEGV.

A similar although less severe issue exists with pure-microMIPS
processors in the case where similarly an FPU instruction is emulated in
a delay slot of a register jump that (incorrectly) switches into the
regular MIPS mode.  A subsequent instruction fetch from the jump's
target is supposed to cause an Address Error exception, however instead
we proceed with regular MIPS FPU emulation.

For simplicity then, always terminate the emulation loop whenever a mode
change is detected, denoted by an ISA mode bit flip.  As from commit
377cb1b6c16a ("MIPS: Disable MIPS16/microMIPS crap for platforms not
supporting these ASEs.") the result of `get_isa16_mode' can be hardcoded
to 0, so we need to examine the ISA mode bit by hand.

This complements commit 102cedc32a6e ("MIPS: microMIPS: Floating point
support.") which added JALX decoding to FPU emulation.

Fixes: 102cedc32a6e ("MIPS: microMIPS: Floating point support.")
Signed-off-by: Maciej W. Rozycki <macro@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/16393/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/mips/math-emu/cp1emu.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -1856,6 +1856,35 @@ dcopuop:
 	return 0;
 }
 
+/*
+ * Emulate FPU instructions.
+ *
+ * If we use FPU hardware, then we have been typically called to handle
+ * an unimplemented operation, such as where an operand is a NaN or
+ * denormalized.  In that case exit the emulation loop after a single
+ * iteration so as to let hardware execute any subsequent instructions.
+ *
+ * If we have no FPU hardware or it has been disabled, then continue
+ * emulating floating-point instructions until one of these conditions
+ * has occurred:
+ *
+ * - a non-FPU instruction has been encountered,
+ *
+ * - an attempt to emulate has ended with a signal,
+ *
+ * - the ISA mode has been switched.
+ *
+ * We need to terminate the emulation loop if we got switched to the
+ * MIPS16 mode, whether supported or not, so that we do not attempt
+ * to emulate a MIPS16 instruction as a regular MIPS FPU instruction.
+ * Similarly if we got switched to the microMIPS mode and only the
+ * regular MIPS mode is supported, so that we do not attempt to emulate
+ * a microMIPS instruction as a regular MIPS FPU instruction.  Or if
+ * we got switched to the regular MIPS mode and only the microMIPS mode
+ * is supported, so that we do not attempt to emulate a regular MIPS
+ * instruction that should cause an Address Error exception instead.
+ * For simplicity we always terminate upon an ISA mode switch.
+ */
 int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
 	int has_fpu, void *__user *fault_addr)
 {
@@ -1943,6 +1972,15 @@ int fpu_emulator_cop1Handler(struct pt_r
 			break;
 		if (sig)
 			break;
+		/*
+		 * We have to check for the ISA bit explicitly here,
+		 * because `get_isa16_mode' may return 0 if support
+		 * for code compression has been globally disabled,
+		 * or otherwise we may produce the wrong signal or
+		 * even proceed successfully where we must not.
+		 */
+		if ((xcp->cp0_epc ^ prevepc) & 0x1)
+			break;
 
 		cond_resched();
 	} while (xcp->cp0_epc > prevepc);

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

* [PATCH 3.18 45/60] Input: i8042 - fix crash at boot time
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (41 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 44/60] MIPS: math-emu: Prevent wrong ISA mode instruction emulation Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 46/60] NFS: only invalidate dentrys that are clearly invalid Greg Kroah-Hartman
                   ` (15 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Chen Hong, Dmitry Torokhov

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

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

From: Chen Hong <chenhong3@huawei.com>

commit 340d394a789518018f834ff70f7534fc463d3226 upstream.

The driver checks port->exists twice in i8042_interrupt(), first when
trying to assign temporary "serio" variable, and second time when deciding
whether it should call serio_interrupt(). The value of port->exists may
change between the 2 checks, and we may end up calling serio_interrupt()
with a NULL pointer:

BUG: unable to handle kernel NULL pointer dereference at 0000000000000050
IP: [<ffffffff8150feaf>] _spin_lock_irqsave+0x1f/0x40
PGD 0
Oops: 0002 [#1] SMP
last sysfs file:
CPU 0
Modules linked in:

Pid: 1, comm: swapper Not tainted 2.6.32-358.el6.x86_64 #1 QEMU Standard PC (i440FX + PIIX, 1996)
RIP: 0010:[<ffffffff8150feaf>]  [<ffffffff8150feaf>] _spin_lock_irqsave+0x1f/0x40
RSP: 0018:ffff880028203cc0  EFLAGS: 00010082
RAX: 0000000000010000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000282 RSI: 0000000000000098 RDI: 0000000000000050
RBP: ffff880028203cc0 R08: ffff88013e79c000 R09: ffff880028203ee0
R10: 0000000000000298 R11: 0000000000000282 R12: 0000000000000050
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000098
FS:  0000000000000000(0000) GS:ffff880028200000(0000) knlGS:0000000000000000
CS:  0010 DS: 0018 ES: 0018 CR0: 000000008005003b
CR2: 0000000000000050 CR3: 0000000001a85000 CR4: 00000000001407f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process swapper (pid: 1, threadinfo ffff88013e79c000, task ffff88013e79b500)
Stack:
ffff880028203d00 ffffffff813de186 ffffffffffffff02 0000000000000000
<d> 0000000000000000 0000000000000000 0000000000000000 0000000000000098
<d> ffff880028203d70 ffffffff813e0162 ffff880028203d20 ffffffff8103b8ac
Call Trace:
<IRQ>
 [<ffffffff813de186>] serio_interrupt+0x36/0xa0
[<ffffffff813e0162>] i8042_interrupt+0x132/0x3a0
[<ffffffff8103b8ac>] ? kvm_clock_read+0x1c/0x20
[<ffffffff8103b8b9>] ? kvm_clock_get_cycles+0x9/0x10
[<ffffffff810e1640>] handle_IRQ_event+0x60/0x170
[<ffffffff8103b154>] ? kvm_guest_apic_eoi_write+0x44/0x50
[<ffffffff810e3d8e>] handle_edge_irq+0xde/0x180
[<ffffffff8100de89>] handle_irq+0x49/0xa0
[<ffffffff81516c8c>] do_IRQ+0x6c/0xf0
[<ffffffff8100b9d3>] ret_from_intr+0x0/0x11
[<ffffffff81076f63>] ? __do_softirq+0x73/0x1e0
[<ffffffff8109b75b>] ? hrtimer_interrupt+0x14b/0x260
[<ffffffff8100c1cc>] ? call_softirq+0x1c/0x30
[<ffffffff8100de05>] ? do_softirq+0x65/0xa0
[<ffffffff81076d95>] ? irq_exit+0x85/0x90
[<ffffffff81516d80>] ? smp_apic_timer_interrupt+0x70/0x9b
[<ffffffff8100bb93>] ? apic_timer_interrupt+0x13/0x20

To avoid the issue let's change the second check to test whether serio is
NULL or not.

Also, let's take i8042_lock in i8042_start() and i8042_stop() instead of
trying to be overly smart and using memory barriers.

Signed-off-by: Chen Hong <chenhong3@huawei.com>
[dtor: take lock in i8042_start()/i8042_stop()]
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/input/serio/i8042.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -397,8 +397,10 @@ static int i8042_start(struct serio *ser
 {
 	struct i8042_port *port = serio->port_data;
 
+	spin_lock_irq(&i8042_lock);
 	port->exists = true;
-	mb();
+	spin_unlock_irq(&i8042_lock);
+
 	return 0;
 }
 
@@ -411,16 +413,20 @@ static void i8042_stop(struct serio *ser
 {
 	struct i8042_port *port = serio->port_data;
 
+	spin_lock_irq(&i8042_lock);
 	port->exists = false;
+	port->serio = NULL;
+	spin_unlock_irq(&i8042_lock);
 
 	/*
+	 * We need to make sure that interrupt handler finishes using
+	 * our serio port before we return from this function.
 	 * We synchronize with both AUX and KBD IRQs because there is
 	 * a (very unlikely) chance that AUX IRQ is raised for KBD port
 	 * and vice versa.
 	 */
 	synchronize_irq(I8042_AUX_IRQ);
 	synchronize_irq(I8042_KBD_IRQ);
-	port->serio = NULL;
 }
 
 /*
@@ -537,7 +543,7 @@ static irqreturn_t i8042_interrupt(int i
 
 	spin_unlock_irqrestore(&i8042_lock, flags);
 
-	if (likely(port->exists && !filtered))
+	if (likely(serio && !filtered))
 		serio_interrupt(serio, data, dfl);
 
  out:

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

* [PATCH 3.18 46/60] NFS: only invalidate dentrys that are clearly invalid.
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (42 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 45/60] Input: i8042 - fix crash at boot time Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 47/60] udf: Fix deadlock between writeback and udf_setsize() Greg Kroah-Hartman
                   ` (14 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, NeilBrown, Anna Schumaker

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

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

From: NeilBrown <neilb@suse.com>

commit cc89684c9a265828ce061037f1f79f4a68ccd3f7 upstream.

Since commit bafc9b754f75 ("vfs: More precise tests in d_invalidate")
in v3.18, a return of '0' from ->d_revalidate() will cause the dentry
to be invalidated even if it has filesystems mounted on or it or on a
descendant.  The mounted filesystem is unmounted.

This means we need to be careful not to return 0 unless the directory
referred to truly is invalid.  So -ESTALE or -ENOENT should invalidate
the directory.  Other errors such a -EPERM or -ERESTARTSYS should be
returned from ->d_revalidate() so they are propagated to the caller.

A particular problem can be demonstrated by:

1/ mount an NFS filesystem using NFSv3 on /mnt
2/ mount any other filesystem on /mnt/foo
3/ ls /mnt/foo
4/ turn off network, or otherwise make the server unable to respond
5/ ls /mnt/foo &
6/ cat /proc/$!/stack # note that nfs_lookup_revalidate is in the call stack
7/ kill -9 $! # this results in -ERESTARTSYS being returned
8/ observe that /mnt/foo has been unmounted.

This patch changes nfs_lookup_revalidate() to only treat
  -ESTALE from nfs_lookup_verify_inode() and
  -ESTALE or -ENOENT from ->lookup()
as indicating an invalid inode.  Other errors are returned.

Also nfs_check_inode_attributes() is changed to return -ESTALE rather
than -EIO.  This is consistent with the error returned in similar
circumstances from nfs_update_inode().

As this bug allows any user to unmount a filesystem mounted on an NFS
filesystem, this fix is suitable for stable kernels.

Fixes: bafc9b754f75 ("vfs: More precise tests in d_invalidate")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/nfs/dir.c   |   12 ++++++++----
 fs/nfs/inode.c |    4 ++--
 2 files changed, 10 insertions(+), 6 deletions(-)

--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1141,11 +1141,13 @@ static int nfs_lookup_revalidate(struct
 	/* Force a full look up iff the parent directory has changed */
 	if (!nfs_is_exclusive_create(dir, flags) &&
 	    nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU)) {
-
-		if (nfs_lookup_verify_inode(inode, flags)) {
+		error = nfs_lookup_verify_inode(inode, flags);
+		if (error) {
 			if (flags & LOOKUP_RCU)
 				return -ECHILD;
-			goto out_zap_parent;
+			if (error == -ESTALE)
+				goto out_zap_parent;
+			goto out_error;
 		}
 		goto out_valid;
 	}
@@ -1169,8 +1171,10 @@ static int nfs_lookup_revalidate(struct
 	trace_nfs_lookup_revalidate_enter(dir, dentry, flags);
 	error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label);
 	trace_nfs_lookup_revalidate_exit(dir, dentry, flags, error);
-	if (error)
+	if (error == -ESTALE || error == -ENOENT)
 		goto out_bad;
+	if (error)
+		goto out_error;
 	if (nfs_compare_fh(NFS_FH(inode), fhandle))
 		goto out_bad;
 	if ((error = nfs_refresh_inode(inode, fattr)) != 0)
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1177,9 +1177,9 @@ static int nfs_check_inode_attributes(st
 		return 0;
 	/* Has the inode gone and changed behind our back? */
 	if ((fattr->valid & NFS_ATTR_FATTR_FILEID) && nfsi->fileid != fattr->fileid)
-		return -EIO;
+		return -ESTALE;
 	if ((fattr->valid & NFS_ATTR_FATTR_TYPE) && (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT))
-		return -EIO;
+		return -ESTALE;
 
 	if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 &&
 			inode->i_version != fattr->change_attr)

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

* [PATCH 3.18 47/60] udf: Fix deadlock between writeback and udf_setsize()
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (43 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 46/60] NFS: only invalidate dentrys that are clearly invalid Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 48/60] target: Fix COMPARE_AND_WRITE caw_sem leak during se_cmd quiesce Greg Kroah-Hartman
                   ` (13 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Jan Kara

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

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

From: Jan Kara <jack@suse.cz>

commit f2e95355891153f66d4156bf3a142c6489cd78c6 upstream.

udf_setsize() called truncate_setsize() with i_data_sem held. Thus
truncate_pagecache() called from truncate_setsize() could lock a page
under i_data_sem which can deadlock as page lock ranks below
i_data_sem - e. g. writeback can hold page lock and try to acquire
i_data_sem to map a block.

Fix the problem by moving truncate_setsize() calls from under
i_data_sem. It is safe for us to change i_size without holding
i_data_sem as all the places that depend on i_size being stable already
hold inode_lock.

Fixes: 7e49b6f2480cb9a9e7322a91592e56a5c85361f5
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/udf/inode.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1237,8 +1237,8 @@ int udf_setsize(struct inode *inode, lof
 			return err;
 		}
 set_size:
-		truncate_setsize(inode, newsize);
 		up_write(&iinfo->i_data_sem);
+		truncate_setsize(inode, newsize);
 	} else {
 		if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
 			down_write(&iinfo->i_data_sem);
@@ -1255,9 +1255,9 @@ set_size:
 					  udf_get_block);
 		if (err)
 			return err;
+		truncate_setsize(inode, newsize);
 		down_write(&iinfo->i_data_sem);
 		udf_clear_extent_cache(inode);
-		truncate_setsize(inode, newsize);
 		udf_truncate_extents(inode);
 		up_write(&iinfo->i_data_sem);
 	}

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

* [PATCH 3.18 48/60] target: Fix COMPARE_AND_WRITE caw_sem leak during se_cmd quiesce
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (44 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 47/60] udf: Fix deadlock between writeback and udf_setsize() Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 50/60] Revert "perf/core: Drop kernel samples even though :u is specified" Greg Kroah-Hartman
                   ` (12 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Jiang Yi, Nicholas Bellinger

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

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

From: Jiang Yi <jiangyilism@gmail.com>

commit 1d6ef276594a781686058802996e09c8550fd767 upstream.

This patch addresses a COMPARE_AND_WRITE se_device->caw_sem leak,
that would be triggered during normal se_cmd shutdown or abort
via __transport_wait_for_tasks().

This would occur because target_complete_cmd() would catch this
early and do complete_all(&cmd->t_transport_stop_comp), but since
target_complete_ok_work() or target_complete_failure_work() are
never called to invoke se_cmd->transport_complete_callback(),
the COMPARE_AND_WRITE specific callbacks never release caw_sem.

To address this special case, go ahead and release caw_sem
directly from target_complete_cmd().

(Remove '&& success' from check, to release caw_sem regardless
 of scsi_status - nab)

Signed-off-by: Jiang Yi <jiangyilism@gmail.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/target/target_core_transport.c |    9 +++++++++
 1 file changed, 9 insertions(+)

--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -693,6 +693,15 @@ void target_complete_cmd(struct se_cmd *
 	if (cmd->transport_state & CMD_T_ABORTED ||
 	    cmd->transport_state & CMD_T_STOP) {
 		spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+		/*
+		 * If COMPARE_AND_WRITE was stopped by __transport_wait_for_tasks(),
+		 * release se_device->caw_sem obtained by sbc_compare_and_write()
+		 * since target_complete_ok_work() or target_complete_failure_work()
+		 * won't be called to invoke the normal CAW completion callbacks.
+		 */
+		if (cmd->se_cmd_flags & SCF_COMPARE_AND_WRITE) {
+			up(&dev->caw_sem);
+		}
 		complete_all(&cmd->t_transport_stop_comp);
 		return;
 	} else if (!success) {

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

* [PATCH 3.18 50/60] Revert "perf/core: Drop kernel samples even though :u is specified"
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (45 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 48/60] target: Fix COMPARE_AND_WRITE caw_sem leak during se_cmd quiesce Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 51/60] staging: rtl8188eu: add TL-WN722N v2 support Greg Kroah-Hartman
                   ` (11 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Kyle Huey, Peter Zijlstra, Jin Yao,
	Vince Weaver, Linus Torvalds, Will Deacon,
	Arnaldo Carvalho de Melo, Alexander Shishkin, Stephane Eranian,
	Namhyung Kim, Jiri Olsa, Ingo Molnar

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

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

From: Ingo Molnar <mingo@kernel.org>

commit 6a8a75f3235724c5941a33e287b2f98966ad14c5 upstream.

This reverts commit cc1582c231ea041fbc68861dfaf957eaf902b829.

This commit introduced a regression that broke rr-project, which uses sampling
events to receive a signal on overflow (but does not care about the contents
of the sample). These signals are critical to the correct operation of rr.

There's been some back and forth about how to fix it - but to not keep
applications in limbo queue up a revert.

Reported-by: Kyle Huey <me@kylehuey.com>
Acked-by: Kyle Huey <me@kylehuey.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20170628105600.GC5981@leverpostej
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/events/core.c |   21 ---------------------
 1 file changed, 21 deletions(-)

--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5761,21 +5761,6 @@ static void perf_log_throttle(struct per
 	perf_output_end(&handle);
 }
 
-static bool sample_is_allowed(struct perf_event *event, struct pt_regs *regs)
-{
-	/*
-	 * Due to interrupt latency (AKA "skid"), we may enter the
-	 * kernel before taking an overflow, even if the PMU is only
-	 * counting user events.
-	 * To avoid leaking information to userspace, we must always
-	 * reject kernel samples when exclude_kernel is set.
-	 */
-	if (event->attr.exclude_kernel && !user_mode(regs))
-		return false;
-
-	return true;
-}
-
 /*
  * Generic event overflow handling, sampling.
  */
@@ -5823,12 +5808,6 @@ static int __perf_event_overflow(struct
 	}
 
 	/*
-	 * For security, drop the skid kernel samples if necessary.
-	 */
-	if (!sample_is_allowed(event, regs))
-		return ret;
-
-	/*
 	 * XXX event_limit might not quite work as expected on inherited
 	 * events
 	 */

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

* [PATCH 3.18 51/60] staging: rtl8188eu: add TL-WN722N v2 support
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (46 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 50/60] Revert "perf/core: Drop kernel samples even though :u is specified" Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 52/60] drm/mst: Fix error handling during MST sideband message reception Greg Kroah-Hartman
                   ` (10 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Michael Gugino

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

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

From: Michael Gugino <michael.gugino.2@gmail.com>

commit 5a1d4c5dd4eb2f1f8a9b30e61762f3b3b564df70 upstream.

Add support for USB Device TP-Link TL-WN722N v2.
VendorID: 0x2357, ProductID: 0x010c

Signed-off-by: Michael Gugino <michael.gugino.2@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/staging/rtl8188eu/os_dep/usb_intf.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -48,6 +48,7 @@ static struct usb_device_id rtw_usb_id_t
 	{USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
 	{USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
 	{USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */
+	{USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */
 	{USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
 	{}	/* Terminating entry */
 };

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

* [PATCH 3.18 52/60] drm/mst: Fix error handling during MST sideband message reception
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (47 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 51/60] staging: rtl8188eu: add TL-WN722N v2 support Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 53/60] drm/mst: Avoid dereferencing a NULL mstb in drm_dp_mst_handle_up_req() Greg Kroah-Hartman
                   ` (9 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dave Airlie, Lyude, Daniel Vetter, Imre Deak

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

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

From: Imre Deak <imre.deak@intel.com>

commit 448421b5e93b9177c5698f0cf6f5e72d2995eeca upstream.

Handle any error due to partial reads, timeouts etc. to avoid parsing
uninitialized data subsequently. Also bail out if the parsing itself
fails.

Cc: Dave Airlie <airlied@redhat.com>
Cc: Lyude <lyude@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Lyude <lyude@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20170719114330.26540-2-imre.deak@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpu/drm/drm_dp_mst_topology.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -2081,11 +2081,17 @@ static void drm_dp_get_one_sb_msg(struct
 		ret = drm_dp_dpcd_read(mgr->aux, basereg + curreply,
 				    replyblock, len);
 		if (ret != len) {
-			DRM_DEBUG_KMS("failed to read a chunk\n");
+			DRM_DEBUG_KMS("failed to read a chunk (len %d, ret %d)\n",
+				      len, ret);
+			return;
 		}
+
 		ret = drm_dp_sideband_msg_build(msg, replyblock, len, false);
-		if (ret == false)
+		if (!ret) {
 			DRM_DEBUG_KMS("failed to build sideband msg\n");
+			return;
+		}
+
 		curreply += len;
 		replylen -= len;
 	}

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

* [PATCH 3.18 53/60] drm/mst: Avoid dereferencing a NULL mstb in drm_dp_mst_handle_up_req()
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (48 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 52/60] drm/mst: Fix error handling during MST sideband message reception Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 54/60] drm/mst: Avoid processing partially received up/down message transactions Greg Kroah-Hartman
                   ` (8 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dave Airlie, Lyude, Daniel Vetter, Imre Deak

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

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

From: Imre Deak <imre.deak@intel.com>

commit 7f8b3987da54cb4d41ad2545cd4d7958b9a36bdf upstream.

In case of an unknown broadcast message is sent mstb will remain unset,
so check for this.

Cc: Dave Airlie <airlied@redhat.com>
Cc: Lyude <lyude@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Lyude <lyude@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20170719114330.26540-3-imre.deak@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpu/drm/drm_dp_mst_topology.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -2209,7 +2209,9 @@ static int drm_dp_mst_handle_up_req(stru
 			DRM_DEBUG_KMS("Got RSN: pn: %d avail_pbn %d\n", msg.u.resource_stat.port_number, msg.u.resource_stat.available_pbn);
 		}
 
-		drm_dp_put_mst_branch_device(mstb);
+		if (mstb)
+			drm_dp_put_mst_branch_device(mstb);
+
 		memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx));
 	}
 	return ret;

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

* [PATCH 3.18 54/60] drm/mst: Avoid processing partially received up/down message transactions
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (49 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 53/60] drm/mst: Avoid dereferencing a NULL mstb in drm_dp_mst_handle_up_req() Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 55/60] KVM: PPC: Book3S HV: Context-switch EBB registers properly Greg Kroah-Hartman
                   ` (7 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dave Airlie, Lyude, Daniel Vetter, Imre Deak

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

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

From: Imre Deak <imre.deak@intel.com>

commit 636c4c3e762b62aa93632c645ca65879285b16e3 upstream.

Currently we may process up/down message transactions containing
uninitialized data. This can happen if there was an error during the
reception of any message in the transaction, but we happened to receive
the last message correctly with the end-of-message flag set.

To avoid this abort the reception of the transaction when the first
error is detected, rejecting any messages until a message with the
start-of-message flag is received (which will start a new transaction).
This is also what the DP 1.4 spec 2.11.8.2 calls for in this case.

In addtion this also prevents receiving bogus transactions without the
first message with the the start-of-message flag set.

v2:
- unchanged
v3:
- git add the part that actually skips messages after an error in
  drm_dp_sideband_msg_build()

Cc: Dave Airlie <airlied@redhat.com>
Cc: Lyude <lyude@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Lyude <lyude@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20170719134632.13366-1-imre.deak@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpu/drm/drm_dp_mst_topology.c |   31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -330,6 +330,13 @@ static bool drm_dp_sideband_msg_build(st
 			return false;
 		}
 
+		/*
+		 * ignore out-of-order messages or messages that are part of a
+		 * failed transaction
+		 */
+		if (!recv_hdr.somt && !msg->have_somt)
+			return false;
+
 		/* get length contained in this portion */
 		msg->curchunk_len = recv_hdr.msg_len;
 		msg->curchunk_hdrlen = hdrlen;
@@ -2049,7 +2056,7 @@ out_unlock:
 }
 EXPORT_SYMBOL(drm_dp_mst_topology_mgr_resume);
 
-static void drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up)
+static bool drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up)
 {
 	int len;
 	u8 replyblock[32];
@@ -2064,12 +2071,12 @@ static void drm_dp_get_one_sb_msg(struct
 			       replyblock, len);
 	if (ret != len) {
 		DRM_DEBUG_KMS("failed to read DPCD down rep %d %d\n", len, ret);
-		return;
+		return false;
 	}
 	ret = drm_dp_sideband_msg_build(msg, replyblock, len, true);
 	if (!ret) {
 		DRM_DEBUG_KMS("sideband msg build failed %d\n", replyblock[0]);
-		return;
+		return false;
 	}
 	replylen = msg->curchunk_len + msg->curchunk_hdrlen;
 
@@ -2083,25 +2090,30 @@ static void drm_dp_get_one_sb_msg(struct
 		if (ret != len) {
 			DRM_DEBUG_KMS("failed to read a chunk (len %d, ret %d)\n",
 				      len, ret);
-			return;
+			return false;
 		}
 
 		ret = drm_dp_sideband_msg_build(msg, replyblock, len, false);
 		if (!ret) {
 			DRM_DEBUG_KMS("failed to build sideband msg\n");
-			return;
+			return false;
 		}
 
 		curreply += len;
 		replylen -= len;
 	}
+	return true;
 }
 
 static int drm_dp_mst_handle_down_rep(struct drm_dp_mst_topology_mgr *mgr)
 {
 	int ret = 0;
 
-	drm_dp_get_one_sb_msg(mgr, false);
+	if (!drm_dp_get_one_sb_msg(mgr, false)) {
+		memset(&mgr->down_rep_recv, 0,
+		       sizeof(struct drm_dp_sideband_msg_rx));
+		return 0;
+	}
 
 	if (mgr->down_rep_recv.have_eomt) {
 		struct drm_dp_sideband_msg_tx *txmsg;
@@ -2157,7 +2169,12 @@ static int drm_dp_mst_handle_down_rep(st
 static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr)
 {
 	int ret = 0;
-	drm_dp_get_one_sb_msg(mgr, true);
+
+	if (!drm_dp_get_one_sb_msg(mgr, true)) {
+		memset(&mgr->up_req_recv, 0,
+		       sizeof(struct drm_dp_sideband_msg_rx));
+		return 0;
+	}
 
 	if (mgr->up_req_recv.have_eomt) {
 		struct drm_dp_sideband_msg_req_body msg;

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

* [PATCH 3.18 55/60] KVM: PPC: Book3S HV: Context-switch EBB registers properly
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (50 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 54/60] drm/mst: Avoid processing partially received up/down message transactions Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 56/60] of: device: Export of_device_{get_modalias, uvent_modalias} to modules Greg Kroah-Hartman
                   ` (6 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Paul Mackerras

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

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

From: Paul Mackerras <paulus@ozlabs.org>

commit ca8efa1df1d15a1795a2da57f9f6aada6ed6b946 upstream.

This adds code to save the values of three SPRs (special-purpose
registers) used by userspace to control event-based branches (EBBs),
which are essentially interrupts that get delivered directly to
userspace.  These registers are loaded up with guest values when
entering the guest, and their values are saved when exiting the
guest, but we were not saving the host values and restoring them
before going back to userspace.

On POWER8 this would only affect userspace programs which explicitly
request the use of EBBs and also use the KVM_RUN ioctl, since the
only source of EBBs on POWER8 is the PMU, and there is an explicit
enable bit in the PMU registers (and those PMU registers do get
properly context-switched between host and guest).  On POWER9 there
is provision for externally-generated EBBs, and these are not subject
to the control in the PMU registers.

Since these registers only affect userspace, we can save them when
we first come in from userspace and restore them before returning to
userspace, rather than saving/restoring the host values on every
guest entry/exit.  Similarly, we don't need to worry about their
values on offline secondary threads since they execute in the context
of the idle task, which never executes in userspace.

Fixes: b005255e12a3 ("KVM: PPC: Book3S HV: Context-switch new POWER8 SPRs", 2014-01-08)
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


---
 arch/powerpc/kvm/book3s_hv.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -1950,6 +1950,7 @@ static int kvmppc_vcpu_run_hv(struct kvm
 {
 	int r;
 	int srcu_idx;
+	unsigned long ebb_regs[3] = {};	/* shut up GCC */
 
 	if (!vcpu->arch.sane) {
 		run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
@@ -1999,6 +2000,14 @@ static int kvmppc_vcpu_run_hv(struct kvm
 	flush_fp_to_thread(current);
 	flush_altivec_to_thread(current);
 	flush_vsx_to_thread(current);
+
+	/* Save userspace EBB register values */
+	if (cpu_has_feature(CPU_FTR_ARCH_207S)) {
+		ebb_regs[0] = mfspr(SPRN_EBBHR);
+		ebb_regs[1] = mfspr(SPRN_EBBRR);
+		ebb_regs[2] = mfspr(SPRN_BESCR);
+	}
+
 	vcpu->arch.wqp = &vcpu->arch.vcore->wq;
 	vcpu->arch.pgdir = current->mm->pgd;
 	vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST;
@@ -2018,6 +2027,13 @@ static int kvmppc_vcpu_run_hv(struct kvm
 		}
 	} while (is_kvmppc_resume_guest(r));
 
+	/* Restore userspace EBB register values */
+	if (cpu_has_feature(CPU_FTR_ARCH_207S)) {
+		mtspr(SPRN_EBBHR, ebb_regs[0]);
+		mtspr(SPRN_EBBRR, ebb_regs[1]);
+		mtspr(SPRN_BESCR, ebb_regs[2]);
+	}
+
  out:
 	vcpu->arch.state = KVMPPC_VCPU_NOTREADY;
 	atomic_dec(&vcpu->kvm->arch.vcpus_running);

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

* [PATCH 3.18 56/60] of: device: Export of_device_{get_modalias, uvent_modalias} to modules
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (51 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 55/60] KVM: PPC: Book3S HV: Context-switch EBB registers properly Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 57/60] spmi: Include OF based modalias in device uevent Greg Kroah-Hartman
                   ` (5 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Rob Herring, devicetree,
	Stephen Boyd, Peter Chen

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

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

From: Stephen Boyd <stephen.boyd@linaro.org>

commit 7a3b7cd332db08546f3cdd984f11773e0d1999e7 upstream.

The ULPI bus can be built as a module, and it will soon be
calling these functions when it supports probing devices from DT.
Export them so they can be used by the ULPI module.

Acked-by: Rob Herring <robh@kernel.org>
Cc: <devicetree@vger.kernel.org>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/of/device.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -128,6 +128,7 @@ ssize_t of_device_get_modalias(struct de
 
 	return tsize;
 }
+EXPORT_SYMBOL_GPL(of_device_get_modalias);
 
 /**
  * of_device_uevent - Display OF related uevent information
@@ -190,3 +191,4 @@ int of_device_uevent_modalias(struct dev
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(of_device_uevent_modalias);

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

* [PATCH 3.18 57/60] spmi: Include OF based modalias in device uevent
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (52 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 56/60] of: device: Export of_device_{get_modalias, uvent_modalias} to modules Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 58/60] tracing: Fix kmemleak in instance_rmdir Greg Kroah-Hartman
                   ` (4 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Rob Clark, Stephen Boyd, Bjorn Andersson

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

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

From: Bjorn Andersson <bjorn.andersson@linaro.org>

commit d50daa2af2618dab6d21634e65a5fbcf4ae437d6 upstream.

Include the OF-based modalias in the uevent sent when registering SPMI
devices, so that user space has a chance to autoload the kernel module
for the device.

Tested-by: Rob Clark <robdclark@gmail.com>
Reported-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/spmi/spmi.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

--- a/drivers/spmi/spmi.c
+++ b/drivers/spmi/spmi.c
@@ -353,11 +353,23 @@ static int spmi_drv_remove(struct device
 	return 0;
 }
 
+static int spmi_drv_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+	int ret;
+
+	ret = of_device_uevent_modalias(dev, env);
+	if (ret != -ENODEV)
+		return ret;
+
+	return 0;
+}
+
 static struct bus_type spmi_bus_type = {
 	.name		= "spmi",
 	.match		= spmi_device_match,
 	.probe		= spmi_drv_probe,
 	.remove		= spmi_drv_remove,
+	.uevent		= spmi_drv_uevent,
 };
 
 /**

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

* [PATCH 3.18 58/60] tracing: Fix kmemleak in instance_rmdir
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (53 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 57/60] spmi: Include OF based modalias in device uevent Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 59/60] alarmtimer: dont rate limit one-shot timers Greg Kroah-Hartman
                   ` (3 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Chunyu Hu, Steven Rostedt (VMware)

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

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

From: Chunyu Hu <chuhu@redhat.com>

commit db9108e054700c96322b0f0028546aa4e643cf0b upstream.

Hit the kmemleak when executing instance_rmdir, it forgot releasing
mem of tracing_cpumask. With this fix, the warn does not appear any
more.

unreferenced object 0xffff93a8dfaa7c18 (size 8):
  comm "mkdir", pid 1436, jiffies 4294763622 (age 9134.308s)
  hex dump (first 8 bytes):
    ff ff ff ff ff ff ff ff                          ........
  backtrace:
    [<ffffffff88b6567a>] kmemleak_alloc+0x4a/0xa0
    [<ffffffff8861ea41>] __kmalloc_node+0xf1/0x280
    [<ffffffff88b505d3>] alloc_cpumask_var_node+0x23/0x30
    [<ffffffff88b5060e>] alloc_cpumask_var+0xe/0x10
    [<ffffffff88571ab0>] instance_mkdir+0x90/0x240
    [<ffffffff886e5100>] tracefs_syscall_mkdir+0x40/0x70
    [<ffffffff886565c9>] vfs_mkdir+0x109/0x1b0
    [<ffffffff8865b1d0>] SyS_mkdir+0xd0/0x100
    [<ffffffff88403857>] do_syscall_64+0x67/0x150
    [<ffffffff88b710e7>] return_from_SYSCALL_64+0x0/0x6a
    [<ffffffffffffffff>] 0xffffffffffffffff

Link: http://lkml.kernel.org/r/1500546969-12594-1-git-send-email-chuhu@redhat.com

Fixes: ccfe9e42e451 ("tracing: Make tracing_cpumask available for all instances")
Signed-off-by: Chunyu Hu <chuhu@redhat.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/trace/trace.c |    1 +
 1 file changed, 1 insertion(+)

--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6405,6 +6405,7 @@ static int instance_delete(const char *n
 	debugfs_remove_recursive(tr->dir);
 	free_trace_buffers(tr);
 
+	free_cpumask_var(tr->tracing_cpumask);
 	kfree(tr->name);
 	kfree(tr);
 

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

* [PATCH 3.18 59/60] alarmtimer: dont rate limit one-shot timers
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (54 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 58/60] tracing: Fix kmemleak in instance_rmdir Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-25 19:16 ` [PATCH 3.18 60/60] MIPS: Send SIGILL for BPOSGE32 in `__compute_return_epc_for_insn Greg Kroah-Hartman
                   ` (2 subsequent siblings)
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Ben Fennema, Greg Hackmann,
	John Stultz, Thomas Gleixner

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

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

From: Greg Hackmann <ghackmann@google.com>

Commit ff86bf0c65f1 ("alarmtimer: Rate limit periodic intervals") sets a
minimum bound on the alarm timer interval.  This minimum bound shouldn't
be applied if the interval is 0.  Otherwise, one-shot timers will be
converted into periodic ones.

Fixes: ff86bf0c65f1 ("alarmtimer: Rate limit periodic intervals")
Reported-by: Ben Fennema <fennema@google.com>
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Cc: stable@vger.kernel.org
Cc: John Stultz <john.stultz@linaro.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/time/alarmtimer.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -619,7 +619,8 @@ static int alarm_timer_set(struct k_itim
 	 * Rate limit to the tick as a hot fix to prevent DOS. Will be
 	 * mopped up later.
 	 */
-	if (ktime_to_ns(timr->it.alarm.interval) < TICK_NSEC)
+	if (timr->it.alarm.interval.tv64 &&
+			ktime_to_ns(timr->it.alarm.interval) < TICK_NSEC)
 		timr->it.alarm.interval = ktime_set(0, TICK_NSEC);
 
 	exp = timespec_to_ktime(new_setting->it_value);

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

* [PATCH 3.18 60/60] MIPS: Send SIGILL for BPOSGE32 in `__compute_return_epc_for_insn
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (55 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 59/60] alarmtimer: dont rate limit one-shot timers Greg Kroah-Hartman
@ 2017-07-25 19:16 ` Greg Kroah-Hartman
  2017-07-26  3:10 ` [PATCH 3.18 00/60] 3.18.63-stable review Guenter Roeck
  2017-07-26 14:23 ` Shuah Khan
  58 siblings, 0 replies; 60+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-25 19:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Maciej W. Rozycki, James Hogan,
	linux-mips, Ralf Baechle

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

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

From: Maciej W. Rozycki <macro@imgtec.com>

commit 7b82c1058ac1f8f8b9f2b8786b1f710a57a870a8 upstream.

Fix commit e50c0a8fa60d ("Support the MIPS32 / MIPS64 DSP ASE.") and
send SIGILL rather than SIGBUS whenever an unimplemented BPOSGE32 DSP
ASE instruction has been encountered in `__compute_return_epc_for_insn'
as our Reserved Instruction exception handler would in response to an
attempt to actually execute the instruction.  Sending SIGBUS only makes
sense for the unaligned PC case, since moved to `__compute_return_epc'.
Adjust function documentation accordingly, correct formatting and use
`pr_info' rather than `printk' as the other exit path already does.

Fixes: e50c0a8fa60d ("Support the MIPS32 / MIPS64 DSP ASE.")
Signed-off-by: Maciej W. Rozycki <macro@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: stable@vger.kernel.org # 2.6.14+
Patchwork: https://patchwork.linux-mips.org/patch/16396/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/mips/kernel/branch.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- a/arch/mips/kernel/branch.c
+++ b/arch/mips/kernel/branch.c
@@ -396,7 +396,7 @@ int __MIPS16e_compute_return_epc(struct
  *
  * @regs:	Pointer to pt_regs
  * @insn:	branch instruction to decode
- * @returns:	-EFAULT on error and forces SIGBUS, and on success
+ * @returns:	-EFAULT on error and forces SIGILL, and on success
  *		returns 0 or BRANCH_LIKELY_TAKEN as appropriate after
  *		evaluating the branch.
  */
@@ -633,8 +633,9 @@ int __compute_return_epc_for_insn(struct
 	return ret;
 
 sigill:
-	printk("%s: DSP branch but not DSP ASE - sending SIGBUS.\n", current->comm);
-	force_sig(SIGBUS, current);
+	pr_info("%s: DSP branch but not DSP ASE - sending SIGILL.\n",
+		current->comm);
+	force_sig(SIGILL, current);
 	return -EFAULT;
 }
 EXPORT_SYMBOL_GPL(__compute_return_epc_for_insn);

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

* Re: [PATCH 3.18 00/60] 3.18.63-stable review
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (56 preceding siblings ...)
  2017-07-25 19:16 ` [PATCH 3.18 60/60] MIPS: Send SIGILL for BPOSGE32 in `__compute_return_epc_for_insn Greg Kroah-Hartman
@ 2017-07-26  3:10 ` Guenter Roeck
  2017-07-26 14:23 ` Shuah Khan
  58 siblings, 0 replies; 60+ messages in thread
From: Guenter Roeck @ 2017-07-26  3:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: torvalds, akpm, shuahkh, patches, ben.hutchings, stable

On 07/25/2017 12:15 PM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 3.18.63 release.
> There are 60 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Thu Jul 27 19:15:49 UTC 2017.
> Anything received after that time might be too late.
> 

Build results:
	total: 135 pass: 135 fail: 0
Qemu test results:
	total: 111 pass: 111 fail: 0

Details are available at http://kerneltests.org/builders.

Guenter

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

* Re: [PATCH 3.18 00/60] 3.18.63-stable review
  2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
                   ` (57 preceding siblings ...)
  2017-07-26  3:10 ` [PATCH 3.18 00/60] 3.18.63-stable review Guenter Roeck
@ 2017-07-26 14:23 ` Shuah Khan
  58 siblings, 0 replies; 60+ messages in thread
From: Shuah Khan @ 2017-07-26 14:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: torvalds, akpm, linux, patches, ben.hutchings, stable, Shuah Khan

On 07/25/2017 01:15 PM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 3.18.63 release.
> There are 60 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Thu Jul 27 19:15:49 UTC 2017.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
> 	kernel.org/pub/linux/kernel/v3.x/stable-review/patch-3.18.63-rc1.gz
> or in the git tree and branch at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-3.18.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled and booted on my test system. No dmesg regressions.

thanks,
-- Shuah

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

end of thread, other threads:[~2017-07-26 14:23 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 01/60] disable new gcc-7.1.1 warnings for now Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 03/60] x86/rtc: Remove duplicate const specifier Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 04/60] [media] ir-core: fix gcc-7 warning on bool arithmetic Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 05/60] CIFS: Fix handle_cancelled_mid callback initialization Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 06/60] ath9k: fix tx99 use after free Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 07/60] ath9k: fix tx99 bus error Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 08/60] NFC: fix broken device allocation Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 09/60] nfc: Ensure presence of required attributes in the activate_target handler Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 10/60] nfc: Fix the sockaddr length sanitization in llcp_sock_connect Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 11/60] include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 12/60] stddef.h: move offsetofend inside #ifndef/#endif guard, neaten Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 13/60] NFC: Add sockaddr length checks before accessing sa_family in bind handlers Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 14/60] Bluetooth: use constant time memory comparison for secret values Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 15/60] ASoC: compress: Derive substream from stream based on direction Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 16/60] PM / Domains: Fix unsafe iteration over modified list of device links Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 17/60] PM / Domains: Fix unsafe iteration over modified list of domain providers Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 18/60] scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 19/60] powerpc/64: Fix atomic64_inc_not_zero() to return an int Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 20/60] powerpc: Fix emulation of mcrf in emulate_step() Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 21/60] powerpc: Fix emulation of mfocrf " Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 22/60] powerpc/asm: Mark cr0 as clobbered in mftb() Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 23/60] af_key: Fix sadb_x_ipsecrequest parsing Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 24/60] PCI/PM: Restore the status of PCI devices across hibernation Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 25/60] xhci: fix 20000ms port resume timeout Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 26/60] xhci: Fix NULL pointer dereference when cleaning up streams for removed host Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 27/60] usb: storage: return on error to avoid a null pointer dereference Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 28/60] USB: cdc-acm: add device-id for quirky printer Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 29/60] usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 30/60] md: dont use flush_signals in userspace processes Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 31/60] Raid5 should update rdev->sectors after reshape Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 32/60] s390/syscalls: Fix out of bounds arguments access Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 34/60] f2fs: Dont clear SGID when inheriting ACLs Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 35/60] vfio: Fix group release deadlock Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 36/60] vfio: New external user group/file match Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 37/60] MIPS: Fix mips_atomic_set() retry condition Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 38/60] MIPS: Fix mips_atomic_set() with EVA Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 39/60] MIPS: Negate error syscall return in trace Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 40/60] x86/acpi: Prevent out of bound access caused by broken ACPI tables Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 41/60] MIPS: Save static registers before sysmips Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 42/60] MIPS: Actually decode JALX in `__compute_return_epc_for_insn Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 43/60] MIPS: Fix unaligned PC interpretation in `compute_return_epc Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 44/60] MIPS: math-emu: Prevent wrong ISA mode instruction emulation Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 45/60] Input: i8042 - fix crash at boot time Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 46/60] NFS: only invalidate dentrys that are clearly invalid Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 47/60] udf: Fix deadlock between writeback and udf_setsize() Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 48/60] target: Fix COMPARE_AND_WRITE caw_sem leak during se_cmd quiesce Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 50/60] Revert "perf/core: Drop kernel samples even though :u is specified" Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 51/60] staging: rtl8188eu: add TL-WN722N v2 support Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 52/60] drm/mst: Fix error handling during MST sideband message reception Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 53/60] drm/mst: Avoid dereferencing a NULL mstb in drm_dp_mst_handle_up_req() Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 54/60] drm/mst: Avoid processing partially received up/down message transactions Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 55/60] KVM: PPC: Book3S HV: Context-switch EBB registers properly Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 56/60] of: device: Export of_device_{get_modalias, uvent_modalias} to modules Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 57/60] spmi: Include OF based modalias in device uevent Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 58/60] tracing: Fix kmemleak in instance_rmdir Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 59/60] alarmtimer: dont rate limit one-shot timers Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 60/60] MIPS: Send SIGILL for BPOSGE32 in `__compute_return_epc_for_insn Greg Kroah-Hartman
2017-07-26  3:10 ` [PATCH 3.18 00/60] 3.18.63-stable review Guenter Roeck
2017-07-26 14:23 ` Shuah Khan

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).