All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4.8 00/57] 4.8.4-stable review
@ 2016-10-21  9:17 ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 03/57] serial: 8250_dw: Check the data->pclk when get apb_pclk Greg Kroah-Hartman
                     ` (50 more replies)
  0 siblings, 51 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, torvalds, akpm, linux, shuah.kh, patches,
	ben.hutchings, stable

This is the start of the stable review cycle for the 4.8.4 release.
There are 57 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 Sun Oct 23 09:14:19 UTC 2016.
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/v4.x/stable-review/patch-4.8.4-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-4.8.y
and the diffstat can be found below.

thanks,

greg k-h

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

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

Glauber Costa <glauber@scylladb.com>
    cfq: fix starvation of asynchronous writes

Vishal Verma <vishal.l.verma@intel.com>
    acpi, nfit: check for the correct event code in notifications

Laszlo Ersek <lersek@redhat.com>
    drm: virtio: reinstate drm_virtio_set_busid()

David Howells <dhowells@redhat.com>
    cachefiles: Fix attempt to read i_blocks after deleting file [ver #2]

Miklos Szeredi <mszeredi@redhat.com>
    vfs: move permission checking into notify_change() for utimes(NULL)

Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    dlm: free workqueues after the connections

Marcelo Cerri <marcelo.cerri@canonical.com>
    crypto: vmx - Fix memory corruption caused by p8_ghash

Marcelo Cerri <marcelo.cerri@canonical.com>
    crypto: ghash-generic - move common definitions to a new header file

Jan Kara <jack@suse.cz>
    ext4: unmap metadata when zeroing blocks

gmail <yngsion@gmail.com>
    ext4: release bh in make_indexed_dir

Ross Zwisler <ross.zwisler@linux.intel.com>
    ext4: allow DAX writeback for hole punch

Eric Biggers <ebiggers@google.com>
    ext4: fix memory leak when symlink decryption fails

Fabian Frederick <fabf@skynet.be>
    ext4: fix memory leak in ext4_insert_range()

wangguang <wang.guang55@zte.com.cn>
    ext4: bugfix for mmaped pages in mpage_release_unused_pages()

Daeho Jeong <daeho.jeong@samsung.com>
    ext4: reinforce check of i_dtime when clearing high fields of uid and gid

Eric Whitney <enwlinux@gmail.com>
    ext4: enforce online defrag restriction for encrypted files

Jan Kara <jack@suse.cz>
    jbd2: fix lockdep annotation in add_transaction_credits()

Wei Fang <fangwei1@huawei.com>
    vfs,mm: fix a dead loop in truncate_inode_pages_range()

Gerald Schaefer <gerald.schaefer@de.ibm.com>
    mm/hugetlb: fix memory offline with hugepage size > memory block size

Manfred Spraul <manfred@colorfullife.com>
    ipc/sem.c: fix complex_count vs. simple op race

Brian King <brking@linux.vnet.ibm.com>
    scsi: ibmvfc: Fix I/O hang when port is not mapped

Borislav Petkov <bp@alien8.de>
    scsi: arcmsr: Simplify user_len checking

Dan Carpenter <dan.carpenter@oracle.com>
    scsi: arcmsr: Buffer overflow in arcmsr_iop_message_xfer()

Eric W. Biederman <ebiederm@xmission.com>
    autofs: Fix automounts by using current_real_cred()->uid

Justin Maggard <jmaggard10@gmail.com>
    async_pq_val: fix DMA memory leak

Mike Galbraith <efault@gmx.de>
    reiserfs: Unlock superblock before calling reiserfs_quota_on_mount()

Nicolas Iooss <nicolas.iooss_linux@m4x.org>
    ASoC: Intel: Atom: add a missing star in a memcpy call

John Hsu <KCHSU0@nuvoton.com>
    ASoC: nau8825: fix bug in FLL parameter

Rafał Miłecki <rafal@milecki.pl>
    brcmfmac: use correct skb freeing helper when deleting flowring

Rafał Miłecki <rafal@milecki.pl>
    brcmfmac: fix memory leak in brcmf_fill_bss_param

Nicolas Iooss <nicolas.iooss_linux@m4x.org>
    brcmfmac: fix pmksa->bssid usage

Johannes Weiner <hannes@cmpxchg.org>
    mm: filemap: don't plant shadow entries without radix tree node

Dave Chinner <david@fromorbit.com>
    xfs: change mailing list address

Guilherme G Piccoli <gpiccoli@linux.vnet.ibm.com>
    i40e: avoid NULL pointer dereference and recursive errors on early PCI error

Johannes Weiner <hannes@cmpxchg.org>
    mm: filemap: fix mapping->nrpages double accounting in fuse

Miklos Szeredi <mszeredi@redhat.com>
    fuse: fix killing s[ug]id in setattr

Miklos Szeredi <mszeredi@redhat.com>
    fuse: invalidate dir dentry after chmod

Miklos Szeredi <mszeredi@redhat.com>
    fuse: listxattr: verify xattr list

Marcin Wojtas <mw@semihalf.com>
    clk: mvebu: dynamically allocate resources in Armada CP110 system controller

Marcin Wojtas <mw@semihalf.com>
    clk: mvebu: fix setting unwanted flags in CP110 gate clock

Mike Marciniszyn <mike.marciniszyn@intel.com>
    IB/hfi1: Fix defered ack race with qp destroy

Peng Fan <van.freenix@gmail.com>
    drivers: base: dma-mapping: page align the size when unmap_kernel_range

Alexander Usyskin <alexander.usyskin@intel.com>
    mei: amthif: fix deadlock in initialization during a reset

Junjie Mao <junjie.mao@enight.me>
    btrfs: assign error values to the correct bio structs

Omar Sandoval <osandov@fb.com>
    Btrfs: catch invalid free space trees

Omar Sandoval <osandov@fb.com>
    Btrfs: fix mount -o clear_cache,space_cache=v2

Omar Sandoval <osandov@fb.com>
    Btrfs: fix free space tree bitmaps on big-endian systems

Christian Lamparter <chunkeey@googlemail.com>
    carl9170: fix debugfs crashes

Christian Lamparter <chunkeey@googlemail.com>
    b43legacy: fix debugfs crash

Christian Lamparter <chunkeey@googlemail.com>
    b43: fix debugfs crash

Christian Lamparter <chunkeey@googlemail.com>
    debugfs: introduce a public file_operations accessor

Vineet Gupta <vgupta@synopsys.com>
    ARCv2: fix local_save_flags

Yuriy Kolerov <yuriy.kolerov@synopsys.com>
    ARCv2: intc: Use kflag if STATUS32.IE must be reset

Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    serial: 8250_port: fix runtime PM use in __do_stop_tx_rs485()

Kefeng Wang <wangkefeng.wang@huawei.com>
    serial: 8250_dw: Check the data->pclk when get apb_pclk

Richard Genoud <richard.genoud@gmail.com>
    BUG: atmel_serial: Interrupts not disabled on close

Sascha Hauer <s.hauer@pengutronix.de>
    serial: imx: Fix DCD reading


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

Diffstat:

 MAINTAINERS                                        |   7 +-
 Makefile                                           |   4 +-
 arch/arc/include/asm/irqflags-arcv2.h              |   2 +-
 arch/arc/kernel/intc-arcv2.c                       |   2 +-
 block/cfq-iosched.c                                |  13 +-
 crypto/async_tx/async_pq.c                         |   8 +-
 crypto/ghash-generic.c                             |  13 +-
 drivers/acpi/nfit/core.c                           |   3 +
 drivers/acpi/nfit/nfit.h                           |   4 +
 drivers/base/dma-mapping.c                         |   2 +-
 drivers/clk/mvebu/cp110-system-controller.c        |  31 +++--
 drivers/crypto/vmx/ghash.c                         |  31 ++---
 drivers/gpu/drm/virtio/virtgpu_drm_bus.c           |  10 ++
 drivers/gpu/drm/virtio/virtgpu_drv.c               |   1 +
 drivers/gpu/drm/virtio/virtgpu_drv.h               |   1 +
 drivers/infiniband/hw/hfi1/rc.c                    |   5 +-
 drivers/misc/mei/amthif.c                          |  12 +-
 drivers/misc/mei/bus.c                             |   2 -
 drivers/net/ethernet/intel/i40e/i40e_main.c        |   6 +
 drivers/net/wireless/ath/carl9170/debug.c          |   6 +-
 drivers/net/wireless/broadcom/b43/debugfs.c        |   6 +-
 drivers/net/wireless/broadcom/b43legacy/debugfs.c  |   6 +-
 .../broadcom/brcm80211/brcmfmac/cfg80211.c         |   9 +-
 .../broadcom/brcm80211/brcmfmac/flowring.c         |   9 +-
 drivers/scsi/arcmsr/arcmsr_hba.c                   |  12 +-
 drivers/scsi/ibmvscsi/ibmvfc.c                     |   1 -
 drivers/tty/serial/8250/8250_dw.c                  |   2 +-
 drivers/tty/serial/8250/8250_port.c                |  11 +-
 drivers/tty/serial/atmel_serial.c                  |   5 +-
 drivers/tty/serial/imx.c                           |   3 +-
 fs/attr.c                                          |  15 +++
 fs/autofs4/waitq.c                                 |   4 +-
 fs/btrfs/compression.c                             |   4 +-
 fs/btrfs/ctree.h                                   |   3 +-
 fs/btrfs/disk-io.c                                 |  33 +++--
 fs/btrfs/extent_io.c                               |  64 +++++++---
 fs/btrfs/extent_io.h                               |  22 ++++
 fs/btrfs/free-space-tree.c                         |  19 +--
 fs/cachefiles/interface.c                          |   8 +-
 fs/cachefiles/internal.h                           |   3 +-
 fs/cachefiles/namei.c                              |   8 +-
 fs/debugfs/file.c                                  |  13 +-
 fs/dlm/lowcomms.c                                  |   8 +-
 fs/ext4/extents.c                                  |   3 +
 fs/ext4/inode.c                                    |  24 ++--
 fs/ext4/move_extent.c                              |   7 ++
 fs/ext4/namei.c                                    |  14 +--
 fs/ext4/symlink.c                                  |   3 +-
 fs/fuse/dir.c                                      |  59 ++++++++-
 fs/jbd2/transaction.c                              |   6 +-
 fs/reiserfs/super.c                                |  12 +-
 fs/utimes.c                                        |  17 +--
 include/crypto/ghash.h                             |  23 ++++
 include/linux/debugfs.h                            |  17 +++
 include/linux/fs.h                                 |   1 +
 include/linux/radix-tree.h                         |   6 +-
 include/linux/sem.h                                |   1 +
 include/uapi/linux/btrfs.h                         |  12 +-
 ipc/sem.c                                          | 138 +++++++++++++--------
 lib/radix-tree.c                                   |  14 +--
 mm/filemap.c                                       |  51 +++++---
 mm/hugetlb.c                                       |  13 +-
 sound/soc/codecs/nau8825.c                         |   2 +-
 sound/soc/intel/atom/sst/sst_pvt.c                 |  14 +--
 64 files changed, 581 insertions(+), 287 deletions(-)

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

* [PATCH 4.8 03/57] serial: 8250_dw: Check the data->pclk when get apb_pclk
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 04/57] serial: 8250_port: fix runtime PM use in __do_stop_tx_rs485() Greg Kroah-Hartman
                     ` (49 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Kefeng Wang, Andy Shevchenko

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

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

From: Kefeng Wang <wangkefeng.wang@huawei.com>

commit e16b46f190a22587898b331f9d58583b0b166c9a upstream.

It should check the data->pclk, not data->clk when get apb_pclk.

Fixes: c8ed99d4f6a8("serial: 8250_dw: Add support for deferred probing")
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/tty/serial/8250/8250_dw.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -462,7 +462,7 @@ static int dw8250_probe(struct platform_
 	}
 
 	data->pclk = devm_clk_get(&pdev->dev, "apb_pclk");
-	if (IS_ERR(data->clk) && PTR_ERR(data->clk) == -EPROBE_DEFER) {
+	if (IS_ERR(data->pclk) && PTR_ERR(data->pclk) == -EPROBE_DEFER) {
 		err = -EPROBE_DEFER;
 		goto err_clk;
 	}

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

* [PATCH 4.8 04/57] serial: 8250_port: fix runtime PM use in __do_stop_tx_rs485()
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 03/57] serial: 8250_dw: Check the data->pclk when get apb_pclk Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 05/57] ARCv2: intc: Use kflag if STATUS32.IE must be reset Greg Kroah-Hartman
                     ` (48 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Matwey V. Kornilov, Yegor Yefremov,
	Andy Shevchenko

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

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

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

commit b3965767d86cf4534dfe1affbde0453d3224ed7f upstream.

There are calls to serial8250_rpm_{get|put}() in __do_stop_tx_rs485() that are
certainly placed in a wrong location. I dunno how it had been tested with
runtime PM enabled because it is obvious "sleep in atomic context" error.

Besides that serial8250_rpm_get() is called immediately after an IO just
happened. It implies that the device is already powered on, see implementation
of serial8250_em485_rts_after_send() and serial8250_clear_fifos() for the
details.

There is no bug have been seen due to, as I can guess, use of auto suspend mode
when scheduled transaction to suspend is invoked quite lately than it's needed
for a few writes to the port. It might be possible to trigger a warning if
stop_tx_timer fires when device is suspended.

Refactor the code to use runtime PM only in case of timer function.

Fixes: 0c66940d584d ("tty/serial/8250: fix RS485 half-duplex RX")
Cc: "Matwey V. Kornilov" <matwey@sai.msu.ru>
Tested-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/tty/serial/8250/8250_port.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1414,12 +1414,8 @@ static void __do_stop_tx_rs485(struct ua
 	if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX)) {
 		serial8250_clear_fifos(p);
 
-		serial8250_rpm_get(p);
-
 		p->ier |= UART_IER_RLSI | UART_IER_RDI;
 		serial_port_out(&p->port, UART_IER, p->ier);
-
-		serial8250_rpm_put(p);
 	}
 }
 
@@ -1429,6 +1425,7 @@ static void serial8250_em485_handle_stop
 	struct uart_8250_em485 *em485 = p->em485;
 	unsigned long flags;
 
+	serial8250_rpm_get(p);
 	spin_lock_irqsave(&p->port.lock, flags);
 	if (em485 &&
 	    em485->active_timer == &em485->stop_tx_timer) {
@@ -1436,6 +1433,7 @@ static void serial8250_em485_handle_stop
 		em485->active_timer = NULL;
 	}
 	spin_unlock_irqrestore(&p->port.lock, flags);
+	serial8250_rpm_put(p);
 }
 
 static void __stop_tx_rs485(struct uart_8250_port *p)
@@ -1475,7 +1473,7 @@ static inline void __stop_tx(struct uart
 		unsigned char lsr = serial_in(p, UART_LSR);
 		/*
 		 * To provide required timeing and allow FIFO transfer,
-		 * __stop_tx_rs485 must be called only when both FIFO and
+		 * __stop_tx_rs485() must be called only when both FIFO and
 		 * shift register are empty. It is for device driver to enable
 		 * interrupt on TEMT.
 		 */
@@ -1484,9 +1482,10 @@ static inline void __stop_tx(struct uart
 
 		del_timer(&em485->start_tx_timer);
 		em485->active_timer = NULL;
+
+		__stop_tx_rs485(p);
 	}
 	__do_stop_tx(p);
-	__stop_tx_rs485(p);
 }
 
 static void serial8250_stop_tx(struct uart_port *port)

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

* [PATCH 4.8 05/57] ARCv2: intc: Use kflag if STATUS32.IE must be reset
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 03/57] serial: 8250_dw: Check the data->pclk when get apb_pclk Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 04/57] serial: 8250_port: fix runtime PM use in __do_stop_tx_rs485() Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 06/57] ARCv2: fix local_save_flags Greg Kroah-Hartman
                     ` (47 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Yuriy Kolerov, Vineet Gupta

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

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

From: Yuriy Kolerov <yuriy.kolerov@synopsys.com>

commit bc0c7ece6191d89f435e4e4016f74167430c6c21 upstream.

In the end of "arc_init_IRQ" STATUS32.IE flag is going to be affected by
"flag" instruction but "flag" never touches IE flag on ARCv2. So "kflag"
instruction must be used instead of "flag".

Signed-off-by: Yuriy Kolerov <yuriy.kolerov@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arc/kernel/intc-arcv2.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/arc/kernel/intc-arcv2.c
+++ b/arch/arc/kernel/intc-arcv2.c
@@ -74,7 +74,7 @@ void arc_init_IRQ(void)
 	tmp = read_aux_reg(0xa);
 	tmp |= STATUS_AD_MASK | (irq_prio << 1);
 	tmp &= ~STATUS_IE_MASK;
-	asm volatile("flag %0	\n"::"r"(tmp));
+	asm volatile("kflag %0	\n"::"r"(tmp));
 }
 
 static void arcv2_irq_mask(struct irq_data *data)

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

* [PATCH 4.8 06/57] ARCv2: fix local_save_flags
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (2 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 05/57] ARCv2: intc: Use kflag if STATUS32.IE must be reset Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 07/57] debugfs: introduce a public file_operations accessor Greg Kroah-Hartman
                     ` (46 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Evgeny Voevodin, Vineet Gupta

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

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

From: Vineet Gupta <vgupta@synopsys.com>

commit cd5d38b052384daa2893e9a1d94900d5a20ed4b5 upstream.

Commit d9676fa152c83b ("ARCv2: Enable LOCKDEP"), changed
local_save_flags() to not return raw STATUS32 but encoded in the form
such that it could be fed directly to CLRI/SETI instructions.
However the STATUS32.E[] was not captured correctly as it corresponds to
bits [4:1] in the register and not [3:0]

Fixes: d9676fa152c83b ("ARCv2: Enable LOCKDEP")
Cc: Evgeny Voevodin <evgeny.voevodin@intel.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arc/include/asm/irqflags-arcv2.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/arc/include/asm/irqflags-arcv2.h
+++ b/arch/arc/include/asm/irqflags-arcv2.h
@@ -112,7 +112,7 @@ static inline long arch_local_save_flags
 	 */
 	temp = (1 << 5) |
 		((!!(temp & STATUS_IE_MASK)) << CLRI_STATUS_IE_BIT) |
-		(temp & CLRI_STATUS_E_MASK);
+		((temp >> 1) & CLRI_STATUS_E_MASK);
 	return temp;
 }
 

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

* [PATCH 4.8 07/57] debugfs: introduce a public file_operations accessor
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (3 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 06/57] ARCv2: fix local_save_flags Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 08/57] b43: fix debugfs crash Greg Kroah-Hartman
                     ` (45 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Nicolai Stange, Christian Lamparter

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

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

From: Christian Lamparter <chunkeey@googlemail.com>

commit 86f0e06767dda7863d6d2a8f0b3b857e6ea876a0 upstream.

This patch introduces an accessor which can be used
by the users of debugfs (drivers, fs, ...) to get the
original file_operations struct. It also removes the
REAL_FOPS_DEREF macro in file.c and converts the code
to use the public version.

Previously, REAL_FOPS_DEREF was only available within
the file.c of debugfs. But having a public getter
available for debugfs users is important as some
drivers (carl9170 and b43) use the pointer of the
original file_operations in conjunction with container_of()
within their debugfs implementations.

Reviewed-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/debugfs/file.c       |   13 +++++--------
 include/linux/debugfs.h |   17 +++++++++++++++++
 2 files changed, 22 insertions(+), 8 deletions(-)

--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -97,9 +97,6 @@ EXPORT_SYMBOL_GPL(debugfs_use_file_finis
 
 #define F_DENTRY(filp) ((filp)->f_path.dentry)
 
-#define REAL_FOPS_DEREF(dentry)					\
-	((const struct file_operations *)(dentry)->d_fsdata)
-
 static int open_proxy_open(struct inode *inode, struct file *filp)
 {
 	const struct dentry *dentry = F_DENTRY(filp);
@@ -112,7 +109,7 @@ static int open_proxy_open(struct inode
 		goto out;
 	}
 
-	real_fops = REAL_FOPS_DEREF(dentry);
+	real_fops = debugfs_real_fops(filp);
 	real_fops = fops_get(real_fops);
 	if (!real_fops) {
 		/* Huh? Module did not clean up after itself at exit? */
@@ -143,7 +140,7 @@ static ret_type full_proxy_ ## name(prot
 {									\
 	const struct dentry *dentry = F_DENTRY(filp);			\
 	const struct file_operations *real_fops =			\
-		REAL_FOPS_DEREF(dentry);				\
+		debugfs_real_fops(filp);				\
 	int srcu_idx;							\
 	ret_type r;							\
 									\
@@ -176,7 +173,7 @@ static unsigned int full_proxy_poll(stru
 				struct poll_table_struct *wait)
 {
 	const struct dentry *dentry = F_DENTRY(filp);
-	const struct file_operations *real_fops = REAL_FOPS_DEREF(dentry);
+	const struct file_operations *real_fops = debugfs_real_fops(filp);
 	int srcu_idx;
 	unsigned int r = 0;
 
@@ -193,7 +190,7 @@ static unsigned int full_proxy_poll(stru
 static int full_proxy_release(struct inode *inode, struct file *filp)
 {
 	const struct dentry *dentry = F_DENTRY(filp);
-	const struct file_operations *real_fops = REAL_FOPS_DEREF(dentry);
+	const struct file_operations *real_fops = debugfs_real_fops(filp);
 	const struct file_operations *proxy_fops = filp->f_op;
 	int r = 0;
 
@@ -241,7 +238,7 @@ static int full_proxy_open(struct inode
 		goto out;
 	}
 
-	real_fops = REAL_FOPS_DEREF(dentry);
+	real_fops = debugfs_real_fops(filp);
 	real_fops = fops_get(real_fops);
 	if (!real_fops) {
 		/* Huh? Module did not cleanup after itself at exit? */
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -45,6 +45,23 @@ extern struct dentry *arch_debugfs_dir;
 
 extern struct srcu_struct debugfs_srcu;
 
+/**
+ * debugfs_real_fops - getter for the real file operation
+ * @filp: a pointer to a struct file
+ *
+ * Must only be called under the protection established by
+ * debugfs_use_file_start().
+ */
+static inline const struct file_operations *debugfs_real_fops(struct file *filp)
+	__must_hold(&debugfs_srcu)
+{
+	/*
+	 * Neither the pointer to the struct file_operations, nor its
+	 * contents ever change -- srcu_dereference() is not needed here.
+	 */
+	return filp->f_path.dentry->d_fsdata;
+}
+
 #if defined(CONFIG_DEBUG_FS)
 
 struct dentry *debugfs_create_file(const char *name, umode_t mode,

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

* [PATCH 4.8 08/57] b43: fix debugfs crash
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (4 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 07/57] debugfs: introduce a public file_operations accessor Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 09/57] b43legacy: " Greg Kroah-Hartman
                     ` (44 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Nicolai Stange, Christian Lamparter

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

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

From: Christian Lamparter <chunkeey@googlemail.com>

commit 51b275a6fe5601834b717351d6cbdb89bd1f308b upstream.

This patch fixes a crash that happens because b43's
debugfs code expects file->f_op to be a pointer to
its own b43_debugfs_fops struct. This is no longer
the case since commit 9fd4dcece43a
("debugfs: prevent access to possibly dead file_operations at file open")

Reviewed-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/wireless/broadcom/b43/debugfs.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/drivers/net/wireless/broadcom/b43/debugfs.c
+++ b/drivers/net/wireless/broadcom/b43/debugfs.c
@@ -524,7 +524,8 @@ static ssize_t b43_debugfs_read(struct f
 		goto out_unlock;
 	}
 
-	dfops = container_of(file->f_op, struct b43_debugfs_fops, fops);
+	dfops = container_of(debugfs_real_fops(file),
+			     struct b43_debugfs_fops, fops);
 	if (!dfops->read) {
 		err = -ENOSYS;
 		goto out_unlock;
@@ -585,7 +586,8 @@ static ssize_t b43_debugfs_write(struct
 		goto out_unlock;
 	}
 
-	dfops = container_of(file->f_op, struct b43_debugfs_fops, fops);
+	dfops = container_of(debugfs_real_fops(file),
+			     struct b43_debugfs_fops, fops);
 	if (!dfops->write) {
 		err = -ENOSYS;
 		goto out_unlock;

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

* [PATCH 4.8 09/57] b43legacy: fix debugfs crash
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (5 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 08/57] b43: fix debugfs crash Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 10/57] carl9170: fix debugfs crashes Greg Kroah-Hartman
                     ` (43 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Nicolai Stange, Christian Lamparter

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

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

From: Christian Lamparter <chunkeey@googlemail.com>

commit 9c4a45b17e094a090e96beb1138e34c2a10c6b8c upstream.

This patch fixes a crash that happens because b43legacy's
debugfs code expects file->f_op to be a pointer to its own
b43legacy_debugfs_fops struct. This is no longer the case
since commit 9fd4dcece43a
("debugfs: prevent access to possibly dead file_operations at file open")

Reviewed-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/wireless/broadcom/b43legacy/debugfs.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/drivers/net/wireless/broadcom/b43legacy/debugfs.c
+++ b/drivers/net/wireless/broadcom/b43legacy/debugfs.c
@@ -221,7 +221,8 @@ static ssize_t b43legacy_debugfs_read(st
 		goto out_unlock;
 	}
 
-	dfops = container_of(file->f_op, struct b43legacy_debugfs_fops, fops);
+	dfops = container_of(debugfs_real_fops(file),
+			     struct b43legacy_debugfs_fops, fops);
 	if (!dfops->read) {
 		err = -ENOSYS;
 		goto out_unlock;
@@ -287,7 +288,8 @@ static ssize_t b43legacy_debugfs_write(s
 		goto out_unlock;
 	}
 
-	dfops = container_of(file->f_op, struct b43legacy_debugfs_fops, fops);
+	dfops = container_of(debugfs_real_fops(file),
+			     struct b43legacy_debugfs_fops, fops);
 	if (!dfops->write) {
 		err = -ENOSYS;
 		goto out_unlock;

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

* [PATCH 4.8 10/57] carl9170: fix debugfs crashes
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (6 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 09/57] b43legacy: " Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 14/57] btrfs: assign error values to the correct bio structs Greg Kroah-Hartman
                     ` (42 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Ben Greear, Christian Lamparter

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

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

From: Christian Lamparter <chunkeey@googlemail.com>

commit 6ee6d1cb391ca85b419f8d18bdfb1f020a5e859c upstream.

Ben Greear reported:
> I see lots of instability as soon as I load up the carl9710 NIC.
> My application is going to be poking at it's debugfs files...
>
> BUG: KASAN: slab-out-of-bounds in carl9170_debugfs_read+0xd5/0x2a0
> [carl9170] at addr 0xffff8801bc1208b0
> Read of size 8 by task btserver/5888
> =======================================================================
> BUG kmalloc-256 (Tainted: G        W      ): kasan: bad access detected
> -----------------------------------------------------------------------
>
> INFO: Allocated in seq_open+0x50/0x100 age=2690 cpu=2 pid=772
>...

This breakage was caused by the introduction of intermediate
fops in debugfs by commit 9fd4dcece43a
("debugfs: prevent access to possibly dead file_operations at file open")

Thankfully, the original/real fops are still available in d_fsdata.

Reported-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/wireless/ath/carl9170/debug.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/drivers/net/wireless/ath/carl9170/debug.c
+++ b/drivers/net/wireless/ath/carl9170/debug.c
@@ -75,7 +75,8 @@ static ssize_t carl9170_debugfs_read(str
 
 	if (!ar)
 		return -ENODEV;
-	dfops = container_of(file->f_op, struct carl9170_debugfs_fops, fops);
+	dfops = container_of(debugfs_real_fops(file),
+			     struct carl9170_debugfs_fops, fops);
 
 	if (!dfops->read)
 		return -ENOSYS;
@@ -127,7 +128,8 @@ static ssize_t carl9170_debugfs_write(st
 
 	if (!ar)
 		return -ENODEV;
-	dfops = container_of(file->f_op, struct carl9170_debugfs_fops, fops);
+	dfops = container_of(debugfs_real_fops(file),
+			     struct carl9170_debugfs_fops, fops);
 
 	if (!dfops->write)
 		return -ENOSYS;

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

* [PATCH 4.8 14/57] btrfs: assign error values to the correct bio structs
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (7 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 10/57] carl9170: fix debugfs crashes Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 15/57] mei: amthif: fix deadlock in initialization during a reset Greg Kroah-Hartman
                     ` (41 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Junjie Mao, David Sterba, Linus Torvalds

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

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

From: Junjie Mao <junjie.mao@enight.me>

commit 14155cafeadda946376260e2ad5d39a0528a332f upstream.

Fixes: 4246a0b63bd8 ("block: add a bi_error field to struct bio")
Signed-off-by: Junjie Mao <junjie.mao@enight.me>
Acked-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -698,7 +698,7 @@ int btrfs_submit_compressed_read(struct
 
 			ret = btrfs_map_bio(root, comp_bio, mirror_num, 0);
 			if (ret) {
-				bio->bi_error = ret;
+				comp_bio->bi_error = ret;
 				bio_endio(comp_bio);
 			}
 
@@ -728,7 +728,7 @@ int btrfs_submit_compressed_read(struct
 
 	ret = btrfs_map_bio(root, comp_bio, mirror_num, 0);
 	if (ret) {
-		bio->bi_error = ret;
+		comp_bio->bi_error = ret;
 		bio_endio(comp_bio);
 	}
 

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

* [PATCH 4.8 15/57] mei: amthif: fix deadlock in initialization during a reset
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (8 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 14/57] btrfs: assign error values to the correct bio structs Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 16/57] drivers: base: dma-mapping: page align the size when unmap_kernel_range Greg Kroah-Hartman
                     ` (40 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Alexander Usyskin, Tomas Winkler

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

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

From: Alexander Usyskin <alexander.usyskin@intel.com>

commit e728ae271f4cf71218ec06a6daf61b79466cb466 upstream.

The device lock was unnecessary obtained in bus rescan work before the
amthif client search.  That causes incorrect lock ordering and task
hang:
...
[88004.613213] INFO: task kworker/1:14:21832 blocked for more than 120 seconds.
...
[88004.645934] Workqueue: events mei_cl_bus_rescan_work
...

The correct lock order is
 cl_bus_lock
  device_lock
   me_clients_rwsem

Move device_lock into amthif init function that called
after me_clients_rwsem is released.

This fixes regression introduced by commit:
commit 025fb792bac3 ("mei: split amthif client init from end of clients enumeration")

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/misc/mei/amthif.c |   12 +++++++++---
 drivers/misc/mei/bus.c    |    2 --
 2 files changed, 9 insertions(+), 5 deletions(-)

--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -67,8 +67,12 @@ int mei_amthif_host_init(struct mei_devi
 	struct mei_cl *cl = &dev->iamthif_cl;
 	int ret;
 
-	if (mei_cl_is_connected(cl))
-		return 0;
+	mutex_lock(&dev->device_lock);
+
+	if (mei_cl_is_connected(cl)) {
+		ret = 0;
+		goto out;
+	}
 
 	dev->iamthif_state = MEI_IAMTHIF_IDLE;
 
@@ -77,11 +81,13 @@ int mei_amthif_host_init(struct mei_devi
 	ret = mei_cl_link(cl);
 	if (ret < 0) {
 		dev_err(dev->dev, "amthif: failed cl_link %d\n", ret);
-		return ret;
+		goto out;
 	}
 
 	ret = mei_cl_connect(cl, me_cl, NULL);
 
+out:
+	mutex_unlock(&dev->device_lock);
 	return ret;
 }
 
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -983,12 +983,10 @@ void mei_cl_bus_rescan_work(struct work_
 		container_of(work, struct mei_device, bus_rescan_work);
 	struct mei_me_client *me_cl;
 
-	mutex_lock(&bus->device_lock);
 	me_cl = mei_me_cl_by_uuid(bus, &mei_amthif_guid);
 	if (me_cl)
 		mei_amthif_host_init(bus, me_cl);
 	mei_me_cl_put(me_cl);
-	mutex_unlock(&bus->device_lock);
 
 	mei_cl_bus_rescan(bus);
 }

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

* [PATCH 4.8 16/57] drivers: base: dma-mapping: page align the size when unmap_kernel_range
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (9 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 15/57] mei: amthif: fix deadlock in initialization during a reset Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 17/57] IB/hfi1: Fix defered ack race with qp destroy Greg Kroah-Hartman
                     ` (39 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Peng Fan

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

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

From: Peng Fan <van.freenix@gmail.com>

commit 85714108e673cdebf1b96abfd50fb02a29e37577 upstream.

When dma_common_free_remap, the input parameter 'size' may not
be page aligned. And, met kernel warning when doing iommu dma
for usb on i.MX8 platform:
"
WARNING: CPU: 0 PID: 869 at mm/vmalloc.c:70 vunmap_page_range+0x1cc/0x1d0()
Modules linked in:
CPU: 0 PID: 869 Comm: kworker/u8:2 Not tainted 4.1.12-00444-gc5f9d1d-dirty #147
Hardware name: Freescale i.MX8DV Sabreauto (DT)
Workqueue: ci_otg ci_otg_work
Call trace:
[<ffffffc000089920>] dump_backtrace+0x0/0x124
[<ffffffc000089a54>] show_stack+0x10/0x1c
[<ffffffc0006d1e6c>] dump_stack+0x84/0xc8
[<ffffffc0000b4568>] warn_slowpath_common+0x98/0xd0
[<ffffffc0000b4664>] warn_slowpath_null+0x14/0x20
[<ffffffc000170348>] vunmap_page_range+0x1c8/0x1d0
[<ffffffc000170388>] unmap_kernel_range+0x20/0x88
[<ffffffc000460ad0>] dma_common_free_remap+0x74/0x84
[<ffffffc0000940d8>] __iommu_free_attrs+0x9c/0x178
[<ffffffc0005032bc>] ehci_mem_cleanup+0x140/0x194
[<ffffffc000503548>] ehci_stop+0x8c/0xdc
[<ffffffc0004e8258>] usb_remove_hcd+0xf0/0x1cc
[<ffffffc000516bc0>] host_stop+0x1c/0x58
[<ffffffc000514240>] ci_otg_work+0xdc/0x120
[<ffffffc0000c9c34>] process_one_work+0x134/0x33c
[<ffffffc0000c9f78>] worker_thread+0x13c/0x47c
[<ffffffc0000cf43c>] kthread+0xd8/0xf0
"

For dma_common_pages_remap:
dma_common_pages_remap
   |->get_vm_area_caller
        |->__get_vm_area_node
            |->size = PAGE_ALIGN(size);   Round up to page aligned

So, in dma_common_free_remap, we also need a page aligned size,
pass 'PAGE_ALIGN(size)' to unmap_kernel_range.

Signed-off-by: Peng Fan <van.freenix@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/base/dma-mapping.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -334,7 +334,7 @@ void dma_common_free_remap(void *cpu_add
 		return;
 	}
 
-	unmap_kernel_range((unsigned long)cpu_addr, size);
+	unmap_kernel_range((unsigned long)cpu_addr, PAGE_ALIGN(size));
 	vunmap(cpu_addr);
 }
 #endif

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

* [PATCH 4.8 17/57] IB/hfi1: Fix defered ack race with qp destroy
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (10 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 16/57] drivers: base: dma-mapping: page align the size when unmap_kernel_range Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 18/57] clk: mvebu: fix setting unwanted flags in CP110 gate clock Greg Kroah-Hartman
                     ` (38 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dennis Dalessandro, Mike Marciniszyn,
	Doug Ledford

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

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

From: Mike Marciniszyn <mike.marciniszyn@intel.com>

commit 72f53af2651957b0b9d6dead72a393eaf9a2c3be upstream.

There is a a bug in defered ack stuff that causes a race with the
destroy of a QP.

A packet causes a defered ack to be pended by putting the QP
into an rcd queue.

A return from the driver interrupt processing will process that rcd
queue of QPs and attempt to do a direct send of the ack.   At this
point no locks are held and the above QP could now be put in the reset
state in the qp destroy logic.   A refcount protects the QP while it
is in the rcd queue so it isn't going anywhere yet.

If the direct send fails to allocate a pio buffer,
hfi1_schedule_send() is called to trigger sending an ack from the
send engine. There is no state test in that code path.

The refcount is then dropped from the driver.c caller
potentially allowing the qp destroy to continue from its
refcount wait in parallel with the workqueue scheduling of the qp.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/infiniband/hw/hfi1/rc.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/drivers/infiniband/hw/hfi1/rc.c
+++ b/drivers/infiniband/hw/hfi1/rc.c
@@ -932,8 +932,10 @@ void hfi1_send_rc_ack(struct hfi1_ctxtda
 	return;
 
 queue_ack:
-	this_cpu_inc(*ibp->rvp.rc_qacks);
 	spin_lock_irqsave(&qp->s_lock, flags);
+	if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK))
+		goto unlock;
+	this_cpu_inc(*ibp->rvp.rc_qacks);
 	qp->s_flags |= RVT_S_ACK_PENDING | RVT_S_RESP_PENDING;
 	qp->s_nak_state = qp->r_nak_state;
 	qp->s_ack_psn = qp->r_ack_psn;
@@ -942,6 +944,7 @@ queue_ack:
 
 	/* Schedule the send tasklet. */
 	hfi1_schedule_send(qp);
+unlock:
 	spin_unlock_irqrestore(&qp->s_lock, flags);
 }
 

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

* [PATCH 4.8 18/57] clk: mvebu: fix setting unwanted flags in CP110 gate clock
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (11 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 17/57] IB/hfi1: Fix defered ack race with qp destroy Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 19/57] clk: mvebu: dynamically allocate resources in Armada CP110 system controller Greg Kroah-Hartman
                     ` (37 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Marcin Wojtas, Stephen Boyd

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

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

From: Marcin Wojtas <mw@semihalf.com>

commit ad715b268a501533ecb2e891a624841d1bb5137c upstream.

Armada CP110 system controller comprises its own routine responsble
for registering gate clocks. Among others 'flags' field in
struct clk_init_data was not set, using a random values, which
may cause an unpredicted behavior.

This patch fixes the problem by resetting all fields of clk_init_data
before assigning values for all gated clocks of Armada 7k/8k SoCs family.

Fixes: d3da3eaef7f4 ("clk: mvebu: new driver for Armada CP110 system ...")
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/clk/mvebu/cp110-system-controller.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/clk/mvebu/cp110-system-controller.c
+++ b/drivers/clk/mvebu/cp110-system-controller.c
@@ -142,6 +142,8 @@ static struct clk *cp110_register_gate(c
 	if (!gate)
 		return ERR_PTR(-ENOMEM);
 
+	memset(&init, 0, sizeof(init));
+
 	init.name = name;
 	init.ops = &cp110_gate_ops;
 	init.parent_names = &parent_name;

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

* [PATCH 4.8 19/57] clk: mvebu: dynamically allocate resources in Armada CP110 system controller
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (12 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 18/57] clk: mvebu: fix setting unwanted flags in CP110 gate clock Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 20/57] fuse: listxattr: verify xattr list Greg Kroah-Hartman
                     ` (36 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Marcin Wojtas, Thomas Petazzoni,
	Stephen Boyd

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

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

From: Marcin Wojtas <mw@semihalf.com>

commit a0245eb76ad0f652f1eb14f48ca2d3c4391aef66 upstream.

Original commit, which added support for Armada CP110 system controller
used global variables for storing all clock information. It worked
fine for Armada 7k SoC, with single CP110 block. After dual-CP110 Armada 8k
was introduced, the data got overwritten and corrupted.

This patch fixes the issue by allocating resources dynamically in the
driver probe and storing it as platform drvdata.

Fixes: d3da3eaef7f4 ("clk: mvebu: new driver for Armada CP110 system ...")
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/clk/mvebu/cp110-system-controller.c |   29 +++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

--- a/drivers/clk/mvebu/cp110-system-controller.c
+++ b/drivers/clk/mvebu/cp110-system-controller.c
@@ -81,13 +81,6 @@ enum {
 #define CP110_GATE_EIP150		25
 #define CP110_GATE_EIP197		26
 
-static struct clk *cp110_clks[CP110_CLK_NUM];
-
-static struct clk_onecell_data cp110_clk_data = {
-	.clks = cp110_clks,
-	.clk_num = CP110_CLK_NUM,
-};
-
 struct cp110_gate_clk {
 	struct clk_hw hw;
 	struct regmap *regmap;
@@ -196,7 +189,8 @@ static int cp110_syscon_clk_probe(struct
 	struct regmap *regmap;
 	struct device_node *np = pdev->dev.of_node;
 	const char *ppv2_name, *apll_name, *core_name, *eip_name, *nand_name;
-	struct clk *clk;
+	struct clk_onecell_data *cp110_clk_data;
+	struct clk *clk, **cp110_clks;
 	u32 nand_clk_ctrl;
 	int i, ret;
 
@@ -209,6 +203,20 @@ static int cp110_syscon_clk_probe(struct
 	if (ret)
 		return ret;
 
+	cp110_clks = devm_kcalloc(&pdev->dev, sizeof(struct clk *),
+				  CP110_CLK_NUM, GFP_KERNEL);
+	if (!cp110_clks)
+		return -ENOMEM;
+
+	cp110_clk_data = devm_kzalloc(&pdev->dev,
+				      sizeof(*cp110_clk_data),
+				      GFP_KERNEL);
+	if (!cp110_clk_data)
+		return -ENOMEM;
+
+	cp110_clk_data->clks = cp110_clks;
+	cp110_clk_data->clk_num = CP110_CLK_NUM;
+
 	/* Register the APLL which is the root of the clk tree */
 	of_property_read_string_index(np, "core-clock-output-names",
 				      CP110_CORE_APLL, &apll_name);
@@ -336,10 +344,12 @@ static int cp110_syscon_clk_probe(struct
 		cp110_clks[CP110_MAX_CORE_CLOCKS + i] = clk;
 	}
 
-	ret = of_clk_add_provider(np, cp110_of_clk_get, &cp110_clk_data);
+	ret = of_clk_add_provider(np, cp110_of_clk_get, cp110_clk_data);
 	if (ret)
 		goto fail_clk_add;
 
+	platform_set_drvdata(pdev, cp110_clks);
+
 	return 0;
 
 fail_clk_add:
@@ -366,6 +376,7 @@ fail0:
 
 static int cp110_syscon_clk_remove(struct platform_device *pdev)
 {
+	struct clk **cp110_clks = platform_get_drvdata(pdev);
 	int i;
 
 	of_clk_del_provider(pdev->dev.of_node);

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

* [PATCH 4.8 20/57] fuse: listxattr: verify xattr list
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (13 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 19/57] clk: mvebu: dynamically allocate resources in Armada CP110 system controller Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 22/57] fuse: fix killing s[ug]id in setattr Greg Kroah-Hartman
                     ` (35 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Miklos Szeredi

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

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

From: Miklos Szeredi <mszeredi@redhat.com>

commit cb3ae6d25a5471be62bfe6ac1fccc0e91edeaba0 upstream.

Make sure userspace filesystem is returning a well formed list of xattr
names (zero or more nonzero length, null terminated strings).

[Michael Theall: only verify in the nonzero size case]

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/fuse/dir.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1801,6 +1801,23 @@ static ssize_t fuse_getxattr(struct dent
 	return ret;
 }
 
+static int fuse_verify_xattr_list(char *list, size_t size)
+{
+	size_t origsize = size;
+
+	while (size) {
+		size_t thislen = strnlen(list, size);
+
+		if (!thislen || thislen == size)
+			return -EIO;
+
+		size -= thislen + 1;
+		list += thislen + 1;
+	}
+
+	return origsize;
+}
+
 static ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size)
 {
 	struct inode *inode = d_inode(entry);
@@ -1836,6 +1853,8 @@ static ssize_t fuse_listxattr(struct den
 	ret = fuse_simple_request(fc, &args);
 	if (!ret && !size)
 		ret = outarg.size;
+	if (ret > 0 && size)
+		ret = fuse_verify_xattr_list(list, ret);
 	if (ret == -ENOSYS) {
 		fc->no_listxattr = 1;
 		ret = -EOPNOTSUPP;

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

* [PATCH 4.8 22/57] fuse: fix killing s[ug]id in setattr
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (14 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 20/57] fuse: listxattr: verify xattr list Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 23/57] mm: filemap: fix mapping->nrpages double accounting in fuse Greg Kroah-Hartman
                     ` (34 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Miklos Szeredi

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

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

From: Miklos Szeredi <mszeredi@redhat.com>

commit a09f99eddef44035ec764075a37bace8181bec38 upstream.

Fuse allowed VFS to set mode in setattr in order to clear suid/sgid on
chown and truncate, and (since writeback_cache) write.  The problem with
this is that it'll potentially restore a stale mode.

The poper fix would be to let the filesystems do the suid/sgid clearing on
the relevant operations.  Possibly some are already doing it but there's no
way we can detect this.

So fix this by refreshing and recalculating the mode.  Do this only if
ATTR_KILL_S[UG]ID is set to not destroy performance for writes.  This is
still racy but the size of the window is reduced.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/fuse/dir.c |   32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1702,16 +1702,40 @@ error:
 static int fuse_setattr(struct dentry *entry, struct iattr *attr)
 {
 	struct inode *inode = d_inode(entry);
+	struct file *file = (attr->ia_valid & ATTR_FILE) ? attr->ia_file : NULL;
 	int ret;
 
 	if (!fuse_allow_current_process(get_fuse_conn(inode)))
 		return -EACCES;
 
-	if (attr->ia_valid & ATTR_FILE)
-		ret = fuse_do_setattr(inode, attr, attr->ia_file);
-	else
-		ret = fuse_do_setattr(inode, attr, NULL);
+	if (attr->ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID)) {
+		int kill;
 
+		attr->ia_valid &= ~(ATTR_KILL_SUID | ATTR_KILL_SGID |
+				    ATTR_MODE);
+		/*
+		 * ia_mode calculation may have used stale i_mode.  Refresh and
+		 * recalculate.
+		 */
+		ret = fuse_do_getattr(inode, NULL, file);
+		if (ret)
+			return ret;
+
+		attr->ia_mode = inode->i_mode;
+		kill = should_remove_suid(entry);
+		if (kill & ATTR_KILL_SUID) {
+			attr->ia_valid |= ATTR_MODE;
+			attr->ia_mode &= ~S_ISUID;
+		}
+		if (kill & ATTR_KILL_SGID) {
+			attr->ia_valid |= ATTR_MODE;
+			attr->ia_mode &= ~S_ISGID;
+		}
+	}
+	if (!attr->ia_valid)
+		return 0;
+
+	ret = fuse_do_setattr(inode, attr, file);
 	if (!ret) {
 		/* Directory mode changed, may need to revalidate access */
 		if (d_is_dir(entry) && (attr->ia_valid & ATTR_MODE))

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

* [PATCH 4.8 23/57] mm: filemap: fix mapping->nrpages double accounting in fuse
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (15 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 22/57] fuse: fix killing s[ug]id in setattr Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 24/57] i40e: avoid NULL pointer dereference and recursive errors on early PCI error Greg Kroah-Hartman
                     ` (33 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Johannes Weiner, Andrew Morton,
	Miklos Szeredi, Linus Torvalds

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

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

From: Johannes Weiner <hannes@cmpxchg.org>

commit 3ddf40e8c31964b744ff10abb48c8e36a83ec6e7 upstream.

Commit 22f2ac51b6d6 ("mm: workingset: fix crash in shadow node shrinker
caused by replace_page_cache_page()") switched replace_page_cache() from
raw radix tree operations to page_cache_tree_insert() but didn't take
into account that the latter function, unlike the raw radix tree op,
handles mapping->nrpages.  As a result, that counter is bumped for each
page replacement rather than balanced out even.

The mapping->nrpages counter is used to skip needless radix tree walks
when invalidating, truncating, syncing inodes without pages, as well as
statistics for userspace.  Since the error is positive, we'll do more
page cache tree walks than necessary; we won't miss a necessary one.
And we'll report more buffer pages to userspace than there are.  The
error is limited to fuse inodes.

Fixes: 22f2ac51b6d6 ("mm: workingset: fix crash in shadow node shrinker caused by replace_page_cache_page()")
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/filemap.c |    1 -
 1 file changed, 1 deletion(-)

--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -619,7 +619,6 @@ int replace_page_cache_page(struct page
 		__delete_from_page_cache(old, NULL);
 		error = page_cache_tree_insert(mapping, new, NULL);
 		BUG_ON(error);
-		mapping->nrpages++;
 
 		/*
 		 * hugetlb pages do not participate in page cache accounting.

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

* [PATCH 4.8 24/57] i40e: avoid NULL pointer dereference and recursive errors on early PCI error
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (16 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 23/57] mm: filemap: fix mapping->nrpages double accounting in fuse Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 25/57] xfs: change mailing list address Greg Kroah-Hartman
                     ` (32 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Guilherme G Piccoli, Jacob Keller,
	Andrew Bowers, Jeff Kirsher, David S. Miller

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

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

From: Guilherme G Piccoli <gpiccoli@linux.vnet.ibm.com>

commit edfc23ee3e0ebbb6713d7574ab1b00abff178f6c upstream.

Although rare, it's possible to hit PCI error early on device
probe, meaning possibly some structs are not entirely initialized,
and some might even be completely uninitialized, leading to NULL
pointer dereference.

The i40e driver currently presents a "bad" behavior if device hits
such early PCI error: firstly, the struct i40e_pf might not be
attached to pci_dev yet, leading to a NULL pointer dereference on
access to pf->state.

Even checking if the struct is NULL and avoiding the access in that
case isn't enough, since the driver cannot recover from PCI error
that early; in our experiments we saw multiple failures on kernel
log, like:

  [549.664] i40e 0007:01:00.1: Initial pf_reset failed: -15
  [549.664] i40e: probe of 0007:01:00.1 failed with error -15
  [...]
  [871.644] i40e 0007:01:00.1: The driver for the device stopped because the
  device firmware failed to init. Try updating your NVM image.
  [871.644] i40e: probe of 0007:01:00.1 failed with error -32
  [...]
  [872.516] i40e 0007:01:00.0: ARQ: Unknown event 0x0000 ignored

Between the first probe failure (error -15) and the second (error -32)
another PCI error happened due to the first bad probe. Also, driver
started to flood console with those ARQ event messages.

This patch will prevent these issues by allowing error recovery
mechanism to remove the failed device from the system instead of
trying to recover from early PCI errors during device probe.

Signed-off-by: Guilherme G Piccoli <gpiccoli@linux.vnet.ibm.com>
Acked-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/ethernet/intel/i40e/i40e_main.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -11360,6 +11360,12 @@ static pci_ers_result_t i40e_pci_error_d
 
 	dev_info(&pdev->dev, "%s: error %d\n", __func__, error);
 
+	if (!pf) {
+		dev_info(&pdev->dev,
+			 "Cannot recover - error happened during device probe\n");
+		return PCI_ERS_RESULT_DISCONNECT;
+	}
+
 	/* shutdown all operations */
 	if (!test_bit(__I40E_SUSPENDED, &pf->state)) {
 		rtnl_lock();

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

* [PATCH 4.8 25/57] xfs: change mailing list address
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (17 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 24/57] i40e: avoid NULL pointer dereference and recursive errors on early PCI error Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 26/57] mm: filemap: dont plant shadow entries without radix tree node Greg Kroah-Hartman
                     ` (31 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Dave Chinner

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

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

From: Dave Chinner <david@fromorbit.com>

commit 541d48f05fa1c19a4a968d38df685529e728a20a upstream.

oss.sgi.com is going away, move contact details over to vger.

Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 MAINTAINERS |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12951,11 +12951,10 @@ F:	arch/x86/xen/*swiotlb*
 F:	drivers/xen/*swiotlb*
 
 XFS FILESYSTEM
-P:	Silicon Graphics Inc
 M:	Dave Chinner <david@fromorbit.com>
-M:	xfs@oss.sgi.com
-L:	xfs@oss.sgi.com
-W:	http://oss.sgi.com/projects/xfs
+M:	linux-xfs@vger.kernel.org
+L:	linux-xfs@vger.kernel.org
+W:	http://xfs.org/
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs.git
 S:	Supported
 F:	Documentation/filesystems/xfs.txt

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

* [PATCH 4.8 26/57] mm: filemap: dont plant shadow entries without radix tree node
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (18 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 25/57] xfs: change mailing list address Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 27/57] brcmfmac: fix pmksa->bssid usage Greg Kroah-Hartman
                     ` (30 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Johannes Weiner, Jan Kara,
	Andrew Morton, Linus Torvalds

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

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

From: Johannes Weiner <hannes@cmpxchg.org>

commit d3798ae8c6f3767c726403c2ca6ecc317752c9dd upstream.

When the underflow checks were added to workingset_node_shadow_dec(),
they triggered immediately:

  kernel BUG at ./include/linux/swap.h:276!
  invalid opcode: 0000 [#1] SMP
  Modules linked in: isofs usb_storage fuse xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 tun nf_conntrack_netbios_ns nf_conntrack_broadcast ip6t_REJECT nf_reject_ipv6
   soundcore wmi acpi_als pinctrl_sunrisepoint kfifo_buf tpm_tis industrialio acpi_pad pinctrl_intel tpm_tis_core tpm nfsd auth_rpcgss nfs_acl lockd grace sunrpc dm_crypt
  CPU: 0 PID: 20929 Comm: blkid Not tainted 4.8.0-rc8-00087-gbe67d60ba944 #1
  Hardware name: System manufacturer System Product Name/Z170-K, BIOS 1803 05/06/2016
  task: ffff8faa93ecd940 task.stack: ffff8faa7f478000
  RIP: page_cache_tree_insert+0xf1/0x100
  Call Trace:
    __add_to_page_cache_locked+0x12e/0x270
    add_to_page_cache_lru+0x4e/0xe0
    mpage_readpages+0x112/0x1d0
    blkdev_readpages+0x1d/0x20
    __do_page_cache_readahead+0x1ad/0x290
    force_page_cache_readahead+0xaa/0x100
    page_cache_sync_readahead+0x3f/0x50
    generic_file_read_iter+0x5af/0x740
    blkdev_read_iter+0x35/0x40
    __vfs_read+0xe1/0x130
    vfs_read+0x96/0x130
    SyS_read+0x55/0xc0
    entry_SYSCALL_64_fastpath+0x13/0x8f
  Code: 03 00 48 8b 5d d8 65 48 33 1c 25 28 00 00 00 44 89 e8 75 19 48 83 c4 18 5b 41 5c 41 5d 41 5e 5d c3 0f 0b 41 bd ef ff ff ff eb d7 <0f> 0b e8 88 68 ef ff 0f 1f 84 00
  RIP  page_cache_tree_insert+0xf1/0x100

This is a long-standing bug in the way shadow entries are accounted in
the radix tree nodes. The shrinker needs to know when radix tree nodes
contain only shadow entries, no pages, so node->count is split in half
to count shadows in the upper bits and pages in the lower bits.

Unfortunately, the radix tree implementation doesn't know of this and
assumes all entries are in node->count. When there is a shadow entry
directly in root->rnode and the tree is later extended, the radix tree
implementation will copy that entry into the new node and and bump its
node->count, i.e. increases the page count bits. Once the shadow gets
removed and we subtract from the upper counter, node->count underflows
and triggers the warning. Afterwards, without node->count reaching 0
again, the radix tree node is leaked.

Limit shadow entries to when we have actual radix tree nodes and can
count them properly. That means we lose the ability to detect refaults
from files that had only the first page faulted in at eviction time.

Fixes: 449dd6984d0e ("mm: keep page cache radix tree nodes in check")
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reported-and-tested-by: Linus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: 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/radix-tree.h |    6 ++---
 lib/radix-tree.c           |   14 ++-----------
 mm/filemap.c               |   46 +++++++++++++++++++++++++++++----------------
 3 files changed, 36 insertions(+), 30 deletions(-)

--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -280,9 +280,9 @@ bool __radix_tree_delete_node(struct rad
 			      struct radix_tree_node *node);
 void *radix_tree_delete_item(struct radix_tree_root *, unsigned long, void *);
 void *radix_tree_delete(struct radix_tree_root *, unsigned long);
-struct radix_tree_node *radix_tree_replace_clear_tags(
-				struct radix_tree_root *root,
-				unsigned long index, void *entry);
+void radix_tree_clear_tags(struct radix_tree_root *root,
+			   struct radix_tree_node *node,
+			   void **slot);
 unsigned int radix_tree_gang_lookup(struct radix_tree_root *root,
 			void **results, unsigned long first_index,
 			unsigned int max_items);
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -1583,15 +1583,10 @@ void *radix_tree_delete(struct radix_tre
 }
 EXPORT_SYMBOL(radix_tree_delete);
 
-struct radix_tree_node *radix_tree_replace_clear_tags(
-			struct radix_tree_root *root,
-			unsigned long index, void *entry)
+void radix_tree_clear_tags(struct radix_tree_root *root,
+			   struct radix_tree_node *node,
+			   void **slot)
 {
-	struct radix_tree_node *node;
-	void **slot;
-
-	__radix_tree_lookup(root, index, &node, &slot);
-
 	if (node) {
 		unsigned int tag, offset = get_slot_offset(node, slot);
 		for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++)
@@ -1600,9 +1595,6 @@ struct radix_tree_node *radix_tree_repla
 		/* Clear root node tags */
 		root->gfp_mask &= __GFP_BITS_MASK;
 	}
-
-	radix_tree_replace_slot(slot, entry);
-	return node;
 }
 
 /**
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -169,33 +169,35 @@ static int page_cache_tree_insert(struct
 static void page_cache_tree_delete(struct address_space *mapping,
 				   struct page *page, void *shadow)
 {
-	struct radix_tree_node *node;
 	int i, nr = PageHuge(page) ? 1 : hpage_nr_pages(page);
 
 	VM_BUG_ON_PAGE(!PageLocked(page), page);
 	VM_BUG_ON_PAGE(PageTail(page), page);
 	VM_BUG_ON_PAGE(nr != 1 && shadow, page);
 
-	if (shadow) {
-		mapping->nrexceptional += nr;
-		/*
-		 * Make sure the nrexceptional update is committed before
-		 * the nrpages update so that final truncate racing
-		 * with reclaim does not see both counters 0 at the
-		 * same time and miss a shadow entry.
-		 */
-		smp_wmb();
-	}
-	mapping->nrpages -= nr;
-
 	for (i = 0; i < nr; i++) {
-		node = radix_tree_replace_clear_tags(&mapping->page_tree,
-				page->index + i, shadow);
+		struct radix_tree_node *node;
+		void **slot;
+
+		__radix_tree_lookup(&mapping->page_tree, page->index + i,
+				    &node, &slot);
+
+		radix_tree_clear_tags(&mapping->page_tree, node, slot);
+
 		if (!node) {
 			VM_BUG_ON_PAGE(nr != 1, page);
-			return;
+			/*
+			 * We need a node to properly account shadow
+			 * entries. Don't plant any without. XXX
+			 */
+			shadow = NULL;
 		}
 
+		radix_tree_replace_slot(slot, shadow);
+
+		if (!node)
+			break;
+
 		workingset_node_pages_dec(node);
 		if (shadow)
 			workingset_node_shadows_inc(node);
@@ -219,6 +221,18 @@ static void page_cache_tree_delete(struc
 					&node->private_list);
 		}
 	}
+
+	if (shadow) {
+		mapping->nrexceptional += nr;
+		/*
+		 * Make sure the nrexceptional update is committed before
+		 * the nrpages update so that final truncate racing
+		 * with reclaim does not see both counters 0 at the
+		 * same time and miss a shadow entry.
+		 */
+		smp_wmb();
+	}
+	mapping->nrpages -= nr;
 }
 
 /*

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

* [PATCH 4.8 27/57] brcmfmac: fix pmksa->bssid usage
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (19 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 26/57] mm: filemap: dont plant shadow entries without radix tree node Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 30/57] ASoC: nau8825: fix bug in FLL parameter Greg Kroah-Hartman
                     ` (29 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Nicolas Iooss, Kalle Valo

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

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

From: Nicolas Iooss <nicolas.iooss_linux@m4x.org>

commit 7703773ef1d85b40433902a8da20167331597e4a upstream.

The struct cfg80211_pmksa defines its bssid field as:

    const u8 *bssid;

contrary to struct brcmf_pmksa, which uses:

    u8 bssid[ETH_ALEN];

Therefore in brcmf_cfg80211_del_pmksa(), &pmksa->bssid takes the address
of this field (of type u8**), not the one of its content (which would be
u8*).  Remove the & operator to make brcmf_dbg("%pM") and memcmp()
behave as expected.

This bug have been found using a custom static checker (which checks the
usage of %p... attributes at build time).  It has been introduced in
commit 6c404f34f2bd ("brcmfmac: Cleanup pmksa cache handling code"),
which replaced pmksa->bssid by &pmksa->bssid while refactoring the code,
without modifying struct cfg80211_pmksa definition.

Replace &pmk[i].bssid with pmk[i].bssid too to make the code clearer,
this change does not affect the semantic.

Fixes: 6c404f34f2bd ("brcmfmac: Cleanup pmksa cache handling code")
Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -3884,11 +3884,11 @@ brcmf_cfg80211_del_pmksa(struct wiphy *w
 	if (!check_vif_up(ifp->vif))
 		return -EIO;
 
-	brcmf_dbg(CONN, "del_pmksa - PMK bssid = %pM\n", &pmksa->bssid);
+	brcmf_dbg(CONN, "del_pmksa - PMK bssid = %pM\n", pmksa->bssid);
 
 	npmk = le32_to_cpu(cfg->pmk_list.npmk);
 	for (i = 0; i < npmk; i++)
-		if (!memcmp(&pmksa->bssid, &pmk[i].bssid, ETH_ALEN))
+		if (!memcmp(pmksa->bssid, pmk[i].bssid, ETH_ALEN))
 			break;
 
 	if ((npmk > 0) && (i < npmk)) {

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

* [PATCH 4.8 30/57] ASoC: nau8825: fix bug in FLL parameter
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (20 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 27/57] brcmfmac: fix pmksa->bssid usage Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 31/57] ASoC: Intel: Atom: add a missing star in a memcpy call Greg Kroah-Hartman
                     ` (28 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, John Hsu, Mark Brown

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

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

From: John Hsu <KCHSU0@nuvoton.com>

commit a8961cae29c38e225120c40c3340dbde2f552e60 upstream.

In the FLL parameter calculation, the FVCO should choose the maximum one.
The patch is to fix the bug about the wrong FVCO chosen.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/soc/codecs/nau8825.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -1907,7 +1907,7 @@ static int nau8825_calc_fll_param(unsign
 	/* Calculate the FLL 10-bit integer input and the FLL 16-bit fractional
 	 * input based on FDCO, FREF and FLL ratio.
 	 */
-	fvco = div_u64(fvco << 16, fref * fll_param->ratio);
+	fvco = div_u64(fvco_max << 16, fref * fll_param->ratio);
 	fll_param->fll_int = (fvco >> 16) & 0x3FF;
 	fll_param->fll_frac = fvco & 0xFFFF;
 	return 0;

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

* [PATCH 4.8 31/57] ASoC: Intel: Atom: add a missing star in a memcpy call
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (21 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 30/57] ASoC: nau8825: fix bug in FLL parameter Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 32/57] reiserfs: Unlock superblock before calling reiserfs_quota_on_mount() Greg Kroah-Hartman
                     ` (27 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Nicolas Iooss, Mark Brown

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

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

From: Nicolas Iooss <nicolas.iooss_linux@m4x.org>

commit 61ab0d403bbd9d5f6e000e3b5734049141b91f6f upstream.

In sst_prepare_and_post_msg(), when a response is received in "block",
the following code gets executed:

    *data = kzalloc(block->size, GFP_KERNEL);
    memcpy(data, (void *) block->data, block->size);

The memcpy() call overwrites the content of the *data pointer instead of
filling the newly-allocated memory (which pointer is hold by *data).
Fix this by merging kzalloc+memcpy into a single kmemdup() call.

Thanks Joe Perches for suggesting using kmemdup()

Fixes: 60dc8dbacb00 ("ASoC: Intel: sst: Add some helper functions")
Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/soc/intel/atom/sst/sst_pvt.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

--- a/sound/soc/intel/atom/sst/sst_pvt.c
+++ b/sound/soc/intel/atom/sst/sst_pvt.c
@@ -279,17 +279,15 @@ int sst_prepare_and_post_msg(struct inte
 
 	if (response) {
 		ret = sst_wait_timeout(sst, block);
-		if (ret < 0) {
+		if (ret < 0)
 			goto out;
-		} else if(block->data) {
-			if (!data)
-				goto out;
-			*data = kzalloc(block->size, GFP_KERNEL);
-			if (!(*data)) {
+
+		if (data && block->data) {
+			*data = kmemdup(block->data, block->size, GFP_KERNEL);
+			if (!*data) {
 				ret = -ENOMEM;
 				goto out;
-			} else
-				memcpy(data, (void *) block->data, block->size);
+			}
 		}
 	}
 out:

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

* [PATCH 4.8 32/57] reiserfs: Unlock superblock before calling reiserfs_quota_on_mount()
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (22 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 31/57] ASoC: Intel: Atom: add a missing star in a memcpy call Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 33/57] async_pq_val: fix DMA memory leak Greg Kroah-Hartman
                     ` (26 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mike Galbraith, Frederic Weisbecker,
	Mike Galbraith, Jan Kara

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

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

From: Mike Galbraith <efault@gmx.de>

commit 420902c9d086848a7548c83e0a49021514bd71b7 upstream.

If we hold the superblock lock while calling reiserfs_quota_on_mount(), we can
deadlock our own worker - mount blocks kworker/3:2, sleeps forever more.

crash> ps|grep UN
    715      2   3  ffff880220734d30  UN   0.0       0      0  [kworker/3:2]
   9369   9341   2  ffff88021ffb7560  UN   1.3  493404 123184  Xorg
   9665   9664   3  ffff880225b92ab0  UN   0.0   47368    812  udisks-daemon
  10635  10403   3  ffff880222f22c70  UN   0.0   14904    936  mount
crash> bt ffff880220734d30
PID: 715    TASK: ffff880220734d30  CPU: 3   COMMAND: "kworker/3:2"
 #0 [ffff8802244c3c20] schedule at ffffffff8144584b
 #1 [ffff8802244c3cc8] __rt_mutex_slowlock at ffffffff814472b3
 #2 [ffff8802244c3d28] rt_mutex_slowlock at ffffffff814473f5
 #3 [ffff8802244c3dc8] reiserfs_write_lock at ffffffffa05f28fd [reiserfs]
 #4 [ffff8802244c3de8] flush_async_commits at ffffffffa05ec91d [reiserfs]
 #5 [ffff8802244c3e08] process_one_work at ffffffff81073726
 #6 [ffff8802244c3e68] worker_thread at ffffffff81073eba
 #7 [ffff8802244c3ec8] kthread at ffffffff810782e0
 #8 [ffff8802244c3f48] kernel_thread_helper at ffffffff81450064
crash> rd ffff8802244c3cc8 10
ffff8802244c3cc8:  ffffffff814472b3 ffff880222f23250   .rD.....P2."....
ffff8802244c3cd8:  0000000000000000 0000000000000286   ................
ffff8802244c3ce8:  ffff8802244c3d30 ffff880220734d80   0=L$.....Ms ....
ffff8802244c3cf8:  ffff880222e8f628 0000000000000000   (.."............
ffff8802244c3d08:  0000000000000000 0000000000000002   ................
crash> struct rt_mutex ffff880222e8f628
struct rt_mutex {
  wait_lock = {
    raw_lock = {
      slock = 65537
    }
  },
  wait_list = {
    node_list = {
      next = 0xffff8802244c3d48,
      prev = 0xffff8802244c3d48
    }
  },
  owner = 0xffff880222f22c71,
  save_state = 0
}
crash> bt 0xffff880222f22c70
PID: 10635  TASK: ffff880222f22c70  CPU: 3   COMMAND: "mount"
 #0 [ffff8802216a9868] schedule at ffffffff8144584b
 #1 [ffff8802216a9910] schedule_timeout at ffffffff81446865
 #2 [ffff8802216a99a0] wait_for_common at ffffffff81445f74
 #3 [ffff8802216a9a30] flush_work at ffffffff810712d3
 #4 [ffff8802216a9ab0] schedule_on_each_cpu at ffffffff81074463
 #5 [ffff8802216a9ae0] invalidate_bdev at ffffffff81178aba
 #6 [ffff8802216a9af0] vfs_load_quota_inode at ffffffff811a3632
 #7 [ffff8802216a9b50] dquot_quota_on_mount at ffffffff811a375c
 #8 [ffff8802216a9b80] finish_unfinished at ffffffffa05dd8b0 [reiserfs]
 #9 [ffff8802216a9cc0] reiserfs_fill_super at ffffffffa05de825 [reiserfs]
    RIP: 00007f7b9303997a  RSP: 00007ffff443c7a8  RFLAGS: 00010202
    RAX: 00000000000000a5  RBX: ffffffff8144ef12  RCX: 00007f7b932e9ee0
    RDX: 00007f7b93d9a400  RSI: 00007f7b93d9a3e0  RDI: 00007f7b93d9a3c0
    RBP: 00007f7b93d9a2c0   R8: 00007f7b93d9a550   R9: 0000000000000001
    R10: ffffffffc0ed040e  R11: 0000000000000202  R12: 000000000000040e
    R13: 0000000000000000  R14: 00000000c0ed040e  R15: 00007ffff443ca20
    ORIG_RAX: 00000000000000a5  CS: 0033  SS: 002b

Signed-off-by: Mike Galbraith <efault@gmx.de>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Mike Galbraith <mgalbraith@suse.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/reiserfs/super.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -190,7 +190,15 @@ static int remove_save_link_only(struct
 static int reiserfs_quota_on_mount(struct super_block *, int);
 #endif
 
-/* look for uncompleted unlinks and truncates and complete them */
+/*
+ * Look for uncompleted unlinks and truncates and complete them
+ *
+ * Called with superblock write locked.  If quotas are enabled, we have to
+ * release/retake lest we call dquot_quota_on_mount(), proceed to
+ * schedule_on_each_cpu() in invalidate_bdev() and deadlock waiting for the per
+ * cpu worklets to complete flush_async_commits() that in turn wait for the
+ * superblock write lock.
+ */
 static int finish_unfinished(struct super_block *s)
 {
 	INITIALIZE_PATH(path);
@@ -237,7 +245,9 @@ static int finish_unfinished(struct supe
 				quota_enabled[i] = 0;
 				continue;
 			}
+			reiserfs_write_unlock(s);
 			ret = reiserfs_quota_on_mount(s, i);
+			reiserfs_write_lock(s);
 			if (ret < 0)
 				reiserfs_warning(s, "reiserfs-2500",
 						 "cannot turn on journaled "

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

* [PATCH 4.8 33/57] async_pq_val: fix DMA memory leak
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (23 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 32/57] reiserfs: Unlock superblock before calling reiserfs_quota_on_mount() Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 34/57] autofs: Fix automounts by using current_real_cred()->uid Greg Kroah-Hartman
                     ` (25 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Justin Maggard, Dan Williams, Vinod Koul

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

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

From: Justin Maggard <jmaggard10@gmail.com>

commit c84750906b4818d4929fbf73a4ae6c113b94f52b upstream.

Add missing dmaengine_unmap_put(), so we don't OOM during RAID6 sync.

Fixes: 1786b943dad0 ("async_pq_val: convert to dmaengine_unmap_data")
Signed-off-by: Justin Maggard <jmaggard@netgear.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 crypto/async_tx/async_pq.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/crypto/async_tx/async_pq.c
+++ b/crypto/async_tx/async_pq.c
@@ -368,8 +368,6 @@ async_syndrome_val(struct page **blocks,
 
 		dma_set_unmap(tx, unmap);
 		async_tx_submit(chan, tx, submit);
-
-		return tx;
 	} else {
 		struct page *p_src = P(blocks, disks);
 		struct page *q_src = Q(blocks, disks);
@@ -424,9 +422,11 @@ async_syndrome_val(struct page **blocks,
 		submit->cb_param = cb_param_orig;
 		submit->flags = flags_orig;
 		async_tx_sync_epilog(submit);
-
-		return NULL;
+		tx = NULL;
 	}
+	dmaengine_unmap_put(unmap);
+
+	return tx;
 }
 EXPORT_SYMBOL_GPL(async_syndrome_val);
 

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

* [PATCH 4.8 34/57] autofs:  Fix automounts by using current_real_cred()->uid
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (24 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 33/57] async_pq_val: fix DMA memory leak Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 35/57] scsi: arcmsr: Buffer overflow in arcmsr_iop_message_xfer() Greg Kroah-Hartman
                     ` (24 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Seth Forshee, Eric W. Biederman

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

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

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

commit 069d5ac9ae0d271903cc4607890616418118379a upstream.

Seth Forshee reports that in 4.8-rcN some automounts are failing
because the requesting the automount changed.

The relevant call path is:
follow_automount()
    ->d_automount
    autofs4_d_automount
       autofs4_mount_wait
           autofs4_wait

In autofs4_wait wq_uid and wq_gid are set to current_uid() and
current_gid respectively.  With follow_automount now overriding creds
uid that we export to userspace changes and that breaks existing
setups.

To remove the regression set wq_uid and wq_gid from
current_real_cred()->uid and current_real_cred()->gid respectively.
This restores the current behavior as current->real_cred is identical
to current->cred except when override creds are used.

Fixes: aeaa4a79ff6a ("fs: Call d_automount with the filesystems creds")
Reported-by: Seth Forshee <seth.forshee@canonical.com>
Tested-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -431,8 +431,8 @@ int autofs4_wait(struct autofs_sb_info *
 		memcpy(&wq->name, &qstr, sizeof(struct qstr));
 		wq->dev = autofs4_get_dev(sbi);
 		wq->ino = autofs4_get_ino(sbi);
-		wq->uid = current_uid();
-		wq->gid = current_gid();
+		wq->uid = current_real_cred()->uid;
+		wq->gid = current_real_cred()->gid;
 		wq->pid = pid;
 		wq->tgid = tgid;
 		wq->status = -EINTR; /* Status return if interrupted */

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

* [PATCH 4.8 35/57] scsi: arcmsr: Buffer overflow in arcmsr_iop_message_xfer()
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (25 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 34/57] autofs: Fix automounts by using current_real_cred()->uid Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 36/57] scsi: arcmsr: Simplify user_len checking Greg Kroah-Hartman
                     ` (23 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Marco Grassi, Dan Carpenter,
	Tomas Henzl, Martin K. Petersen

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

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

From: Dan Carpenter <dan.carpenter@oracle.com>

commit 7bc2b55a5c030685b399bb65b6baa9ccc3d1f167 upstream.

We need to put an upper bound on "user_len" so the memcpy() doesn't
overflow.

Reported-by: Marco Grassi <marco.gra@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/arcmsr/arcmsr_hba.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -2388,7 +2388,8 @@ static int arcmsr_iop_message_xfer(struc
 	}
 	case ARCMSR_MESSAGE_WRITE_WQBUFFER: {
 		unsigned char *ver_addr;
-		int32_t user_len, cnt2end;
+		uint32_t user_len;
+		int32_t cnt2end;
 		uint8_t *pQbuffer, *ptmpuserbuffer;
 		ver_addr = kmalloc(ARCMSR_API_DATA_BUFLEN, GFP_ATOMIC);
 		if (!ver_addr) {
@@ -2397,6 +2398,11 @@ static int arcmsr_iop_message_xfer(struc
 		}
 		ptmpuserbuffer = ver_addr;
 		user_len = pcmdmessagefld->cmdmessage.Length;
+		if (user_len > ARCMSR_API_DATA_BUFLEN) {
+			retvalue = ARCMSR_MESSAGE_FAIL;
+			kfree(ver_addr);
+			goto message_out;
+		}
 		memcpy(ptmpuserbuffer,
 			pcmdmessagefld->messagedatabuffer, user_len);
 		spin_lock_irqsave(&acb->wqbuffer_lock, flags);

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

* [PATCH 4.8 36/57] scsi: arcmsr: Simplify user_len checking
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (26 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 35/57] scsi: arcmsr: Buffer overflow in arcmsr_iop_message_xfer() Greg Kroah-Hartman
@ 2016-10-21  9:17   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 37/57] scsi: ibmvfc: Fix I/O hang when port is not mapped Greg Kroah-Hartman
                     ` (22 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Borislav Petkov, Marco Grassi,
	Dan Carpenter, Tomas Henzl, Martin K. Petersen,
	Johannes Thumshirn

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

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

From: Borislav Petkov <bp@alien8.de>

commit 4bd173c30792791a6daca8c64793ec0a4ae8324f upstream.

Do the user_len check first and then the ver_addr allocation so that we
can save us the kfree() on the error path when user_len is >
ARCMSR_API_DATA_BUFLEN.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Marco Grassi <marco.gra@gmail.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Tomas Henzl <thenzl@redhat.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/arcmsr/arcmsr_hba.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -2391,18 +2391,20 @@ static int arcmsr_iop_message_xfer(struc
 		uint32_t user_len;
 		int32_t cnt2end;
 		uint8_t *pQbuffer, *ptmpuserbuffer;
-		ver_addr = kmalloc(ARCMSR_API_DATA_BUFLEN, GFP_ATOMIC);
-		if (!ver_addr) {
+
+		user_len = pcmdmessagefld->cmdmessage.Length;
+		if (user_len > ARCMSR_API_DATA_BUFLEN) {
 			retvalue = ARCMSR_MESSAGE_FAIL;
 			goto message_out;
 		}
-		ptmpuserbuffer = ver_addr;
-		user_len = pcmdmessagefld->cmdmessage.Length;
-		if (user_len > ARCMSR_API_DATA_BUFLEN) {
+
+		ver_addr = kmalloc(ARCMSR_API_DATA_BUFLEN, GFP_ATOMIC);
+		if (!ver_addr) {
 			retvalue = ARCMSR_MESSAGE_FAIL;
-			kfree(ver_addr);
 			goto message_out;
 		}
+		ptmpuserbuffer = ver_addr;
+
 		memcpy(ptmpuserbuffer,
 			pcmdmessagefld->messagedatabuffer, user_len);
 		spin_lock_irqsave(&acb->wqbuffer_lock, flags);

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

* [PATCH 4.8 37/57] scsi: ibmvfc: Fix I/O hang when port is not mapped
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (27 preceding siblings ...)
  2016-10-21  9:17   ` [PATCH 4.8 36/57] scsi: arcmsr: Simplify user_len checking Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 38/57] ipc/sem.c: fix complex_count vs. simple op race Greg Kroah-Hartman
                     ` (21 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Brian King, Tyrel Datwyler,
	Martin K. Petersen

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

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

From: Brian King <brking@linux.vnet.ibm.com>

commit 07d0e9a847401ffd2f09bd450d41644cd090e81d upstream.

If a VFC port gets unmapped in the VIOS, it may not respond with a CRQ
init complete following H_REG_CRQ. If this occurs, we can end up having
called scsi_block_requests and not a resulting unblock until the init
complete happens, which may never occur, and we end up hanging I/O
requests.  This patch ensures the host action stay set to
IBMVFC_HOST_ACTION_TGT_DEL so we move all rports into devloss state and
unblock unless we receive an init complete.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Acked-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/ibmvscsi/ibmvfc.c |    1 -
 1 file changed, 1 deletion(-)

--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -717,7 +717,6 @@ static int ibmvfc_reset_crq(struct ibmvf
 	spin_lock_irqsave(vhost->host->host_lock, flags);
 	vhost->state = IBMVFC_NO_CRQ;
 	vhost->logged_in = 0;
-	ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_NONE);
 
 	/* Clean out the queue */
 	memset(crq->msgs, 0, PAGE_SIZE);

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

* [PATCH 4.8 38/57] ipc/sem.c: fix complex_count vs. simple op race
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (28 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 37/57] scsi: ibmvfc: Fix I/O hang when port is not mapped Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 39/57] mm/hugetlb: fix memory offline with hugepage size > memory block size Greg Kroah-Hartman
                     ` (20 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, felixh, H. Peter Anvin,
	Peter Zijlstra, Davidlohr Bueso, Thomas Gleixner, Ingo Molnar,
	1vier1, Andrew Morton, Linus Torvalds

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

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

From: Manfred Spraul <manfred@colorfullife.com>

commit 5864a2fd3088db73d47942370d0f7210a807b9bc upstream.

Commit 6d07b68ce16a ("ipc/sem.c: optimize sem_lock()") introduced a
race:

sem_lock has a fast path that allows parallel simple operations.
There are two reasons why a simple operation cannot run in parallel:
 - a non-simple operations is ongoing (sma->sem_perm.lock held)
 - a complex operation is sleeping (sma->complex_count != 0)

As both facts are stored independently, a thread can bypass the current
checks by sleeping in the right positions.  See below for more details
(or kernel bugzilla 105651).

The patch fixes that by creating one variable (complex_mode)
that tracks both reasons why parallel operations are not possible.

The patch also updates stale documentation regarding the locking.

With regards to stable kernels:
The patch is required for all kernels that include the
commit 6d07b68ce16a ("ipc/sem.c: optimize sem_lock()") (3.10?)

The alternative is to revert the patch that introduced the race.

The patch is safe for backporting, i.e. it makes no assumptions
about memory barriers in spin_unlock_wait().

Background:
Here is the race of the current implementation:

Thread A: (simple op)
- does the first "sma->complex_count == 0" test

Thread B: (complex op)
- does sem_lock(): This includes an array scan. But the scan can't
  find Thread A, because Thread A does not own sem->lock yet.
- the thread does the operation, increases complex_count,
  drops sem_lock, sleeps

Thread A:
- spin_lock(&sem->lock), spin_is_locked(sma->sem_perm.lock)
- sleeps before the complex_count test

Thread C: (complex op)
- does sem_lock (no array scan, complex_count==1)
- wakes up Thread B.
- decrements complex_count

Thread A:
- does the complex_count test

Bug:
Now both thread A and thread C operate on the same array, without
any synchronization.

Fixes: 6d07b68ce16a ("ipc/sem.c: optimize sem_lock()")
Link: http://lkml.kernel.org/r/1469123695-5661-1-git-send-email-manfred@colorfullife.com
Reported-by: <felixh@informatik.uni-bremen.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: <1vier1@web.de>
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/sem.h |    1 
 ipc/sem.c           |  138 +++++++++++++++++++++++++++++++---------------------
 2 files changed, 84 insertions(+), 55 deletions(-)

--- a/include/linux/sem.h
+++ b/include/linux/sem.h
@@ -21,6 +21,7 @@ struct sem_array {
 	struct list_head	list_id;	/* undo requests on this array */
 	int			sem_nsems;	/* no. of semaphores in array */
 	int			complex_count;	/* pending complex operations */
+	bool			complex_mode;	/* no parallel simple ops */
 };
 
 #ifdef CONFIG_SYSVIPC
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -162,14 +162,21 @@ static int sysvipc_sem_proc_show(struct
 
 /*
  * Locking:
+ * a) global sem_lock() for read/write
  *	sem_undo.id_next,
  *	sem_array.complex_count,
- *	sem_array.pending{_alter,_cont},
- *	sem_array.sem_undo: global sem_lock() for read/write
- *	sem_undo.proc_next: only "current" is allowed to read/write that field.
+ *	sem_array.complex_mode
+ *	sem_array.pending{_alter,_const},
+ *	sem_array.sem_undo
  *
+ * b) global or semaphore sem_lock() for read/write:
  *	sem_array.sem_base[i].pending_{const,alter}:
- *		global or semaphore sem_lock() for read/write
+ *	sem_array.complex_mode (for read)
+ *
+ * c) special:
+ *	sem_undo_list.list_proc:
+ *	* undo_list->lock for write
+ *	* rcu for read
  */
 
 #define sc_semmsl	sem_ctls[0]
@@ -260,30 +267,61 @@ static void sem_rcu_free(struct rcu_head
 }
 
 /*
- * Wait until all currently ongoing simple ops have completed.
+ * Enter the mode suitable for non-simple operations:
  * Caller must own sem_perm.lock.
- * New simple ops cannot start, because simple ops first check
- * that sem_perm.lock is free.
- * that a) sem_perm.lock is free and b) complex_count is 0.
  */
-static void sem_wait_array(struct sem_array *sma)
+static void complexmode_enter(struct sem_array *sma)
 {
 	int i;
 	struct sem *sem;
 
-	if (sma->complex_count)  {
-		/* The thread that increased sma->complex_count waited on
-		 * all sem->lock locks. Thus we don't need to wait again.
-		 */
+	if (sma->complex_mode)  {
+		/* We are already in complex_mode. Nothing to do */
 		return;
 	}
 
+	/* We need a full barrier after seting complex_mode:
+	 * The write to complex_mode must be visible
+	 * before we read the first sem->lock spinlock state.
+	 */
+	smp_store_mb(sma->complex_mode, true);
+
 	for (i = 0; i < sma->sem_nsems; i++) {
 		sem = sma->sem_base + i;
 		spin_unlock_wait(&sem->lock);
 	}
+	/*
+	 * spin_unlock_wait() is not a memory barriers, it is only a
+	 * control barrier. The code must pair with spin_unlock(&sem->lock),
+	 * thus just the control barrier is insufficient.
+	 *
+	 * smp_rmb() is sufficient, as writes cannot pass the control barrier.
+	 */
+	smp_rmb();
+}
+
+/*
+ * Try to leave the mode that disallows simple operations:
+ * Caller must own sem_perm.lock.
+ */
+static void complexmode_tryleave(struct sem_array *sma)
+{
+	if (sma->complex_count)  {
+		/* Complex ops are sleeping.
+		 * We must stay in complex mode
+		 */
+		return;
+	}
+	/*
+	 * Immediately after setting complex_mode to false,
+	 * a simple op can start. Thus: all memory writes
+	 * performed by the current operation must be visible
+	 * before we set complex_mode to false.
+	 */
+	smp_store_release(&sma->complex_mode, false);
 }
 
+#define SEM_GLOBAL_LOCK	(-1)
 /*
  * If the request contains only one semaphore operation, and there are
  * no complex transactions pending, lock only the semaphore involved.
@@ -300,56 +338,42 @@ static inline int sem_lock(struct sem_ar
 		/* Complex operation - acquire a full lock */
 		ipc_lock_object(&sma->sem_perm);
 
-		/* And wait until all simple ops that are processed
-		 * right now have dropped their locks.
-		 */
-		sem_wait_array(sma);
-		return -1;
+		/* Prevent parallel simple ops */
+		complexmode_enter(sma);
+		return SEM_GLOBAL_LOCK;
 	}
 
 	/*
 	 * Only one semaphore affected - try to optimize locking.
-	 * The rules are:
-	 * - optimized locking is possible if no complex operation
-	 *   is either enqueued or processed right now.
-	 * - The test for enqueued complex ops is simple:
-	 *      sma->complex_count != 0
-	 * - Testing for complex ops that are processed right now is
-	 *   a bit more difficult. Complex ops acquire the full lock
-	 *   and first wait that the running simple ops have completed.
-	 *   (see above)
-	 *   Thus: If we own a simple lock and the global lock is free
-	 *	and complex_count is now 0, then it will stay 0 and
-	 *	thus just locking sem->lock is sufficient.
+	 * Optimized locking is possible if no complex operation
+	 * is either enqueued or processed right now.
+	 *
+	 * Both facts are tracked by complex_mode.
 	 */
 	sem = sma->sem_base + sops->sem_num;
 
-	if (sma->complex_count == 0) {
+	/*
+	 * Initial check for complex_mode. Just an optimization,
+	 * no locking, no memory barrier.
+	 */
+	if (!sma->complex_mode) {
 		/*
 		 * It appears that no complex operation is around.
 		 * Acquire the per-semaphore lock.
 		 */
 		spin_lock(&sem->lock);
 
-		/* Then check that the global lock is free */
-		if (!spin_is_locked(&sma->sem_perm.lock)) {
-			/*
-			 * We need a memory barrier with acquire semantics,
-			 * otherwise we can race with another thread that does:
-			 *	complex_count++;
-			 *	spin_unlock(sem_perm.lock);
-			 */
-			smp_acquire__after_ctrl_dep();
+		/*
+		 * See 51d7d5205d33
+		 * ("powerpc: Add smp_mb() to arch_spin_is_locked()"):
+		 * A full barrier is required: the write of sem->lock
+		 * must be visible before the read is executed
+		 */
+		smp_mb();
 
-			/*
-			 * Now repeat the test of complex_count:
-			 * It can't change anymore until we drop sem->lock.
-			 * Thus: if is now 0, then it will stay 0.
-			 */
-			if (sma->complex_count == 0) {
-				/* fast path successful! */
-				return sops->sem_num;
-			}
+		if (!smp_load_acquire(&sma->complex_mode)) {
+			/* fast path successful! */
+			return sops->sem_num;
 		}
 		spin_unlock(&sem->lock);
 	}
@@ -369,15 +393,16 @@ static inline int sem_lock(struct sem_ar
 		/* Not a false alarm, thus complete the sequence for a
 		 * full lock.
 		 */
-		sem_wait_array(sma);
-		return -1;
+		complexmode_enter(sma);
+		return SEM_GLOBAL_LOCK;
 	}
 }
 
 static inline void sem_unlock(struct sem_array *sma, int locknum)
 {
-	if (locknum == -1) {
+	if (locknum == SEM_GLOBAL_LOCK) {
 		unmerge_queues(sma);
+		complexmode_tryleave(sma);
 		ipc_unlock_object(&sma->sem_perm);
 	} else {
 		struct sem *sem = sma->sem_base + locknum;
@@ -529,6 +554,7 @@ static int newary(struct ipc_namespace *
 	}
 
 	sma->complex_count = 0;
+	sma->complex_mode = true; /* dropped by sem_unlock below */
 	INIT_LIST_HEAD(&sma->pending_alter);
 	INIT_LIST_HEAD(&sma->pending_const);
 	INIT_LIST_HEAD(&sma->list_id);
@@ -2184,10 +2210,10 @@ static int sysvipc_sem_proc_show(struct
 	/*
 	 * The proc interface isn't aware of sem_lock(), it calls
 	 * ipc_lock_object() directly (in sysvipc_find_ipc).
-	 * In order to stay compatible with sem_lock(), we must wait until
-	 * all simple semop() calls have left their critical regions.
+	 * In order to stay compatible with sem_lock(), we must
+	 * enter / leave complex_mode.
 	 */
-	sem_wait_array(sma);
+	complexmode_enter(sma);
 
 	sem_otime = get_semotime(sma);
 
@@ -2204,6 +2230,8 @@ static int sysvipc_sem_proc_show(struct
 		   sem_otime,
 		   sma->sem_ctime);
 
+	complexmode_tryleave(sma);
+
 	return 0;
 }
 #endif

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

* [PATCH 4.8 39/57] mm/hugetlb: fix memory offline with hugepage size > memory block size
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (29 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 38/57] ipc/sem.c: fix complex_count vs. simple op race Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 40/57] vfs,mm: fix a dead loop in truncate_inode_pages_range() Greg Kroah-Hartman
                     ` (19 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Gerald Schaefer, Michal Hocko,
	Naoya Horiguchi, Kirill A . Shutemov, Vlastimil Babka,
	Mike Kravetz, Aneesh Kumar K . V, Martin Schwidefsky,
	Heiko Carstens, Rui Teng, Dave Hansen, Andrew Morton,
	Linus Torvalds

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

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

From: Gerald Schaefer <gerald.schaefer@de.ibm.com>

commit 2247bb335ab9c40058484cac36ea74ee652f3b7b upstream.

Patch series "mm/hugetlb: memory offline issues with hugepages", v4.

This addresses several issues with hugepages and memory offline.  While
the first patch fixes a panic, and is therefore rather important, the
last patch is just a performance optimization.

The second patch fixes a theoretical issue with reserved hugepages,
while still leaving some ugly usability issue, see description.

This patch (of 3):

dissolve_free_huge_pages() will either run into the VM_BUG_ON() or a
list corruption and addressing exception when trying to set a memory
block offline that is part (but not the first part) of a "gigantic"
hugetlb page with a size > memory block size.

When no other smaller hugetlb page sizes are present, the VM_BUG_ON()
will trigger directly.  In the other case we will run into an addressing
exception later, because dissolve_free_huge_page() will not work on the
head page of the compound hugetlb page which will result in a NULL
hstate from page_hstate().

To fix this, first remove the VM_BUG_ON() because it is wrong, and then
use the compound head page in dissolve_free_huge_page().  This means
that an unused pre-allocated gigantic page that has any part of itself
inside the memory block that is going offline will be dissolved
completely.  Losing an unused gigantic hugepage is preferable to failing
the memory offline, for example in the situation where a (possibly
faulty) memory DIMM needs to go offline.

Fixes: c8721bbb ("mm: memory-hotplug: enable memory hotplug to handle hugepage")
Link: http://lkml.kernel.org/r/20160926172811.94033-2-gerald.schaefer@de.ibm.com
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Rui Teng <rui.teng@linux.vnet.ibm.com>
Cc: Dave Hansen <dave.hansen@linux.intel.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>

---
 mm/hugetlb.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1443,13 +1443,14 @@ static void dissolve_free_huge_page(stru
 {
 	spin_lock(&hugetlb_lock);
 	if (PageHuge(page) && !page_count(page)) {
-		struct hstate *h = page_hstate(page);
-		int nid = page_to_nid(page);
-		list_del(&page->lru);
+		struct page *head = compound_head(page);
+		struct hstate *h = page_hstate(head);
+		int nid = page_to_nid(head);
+		list_del(&head->lru);
 		h->free_huge_pages--;
 		h->free_huge_pages_node[nid]--;
 		h->max_huge_pages--;
-		update_and_free_page(h, page);
+		update_and_free_page(h, head);
 	}
 	spin_unlock(&hugetlb_lock);
 }
@@ -1457,7 +1458,8 @@ static void dissolve_free_huge_page(stru
 /*
  * Dissolve free hugepages in a given pfn range. Used by memory hotplug to
  * make specified memory blocks removable from the system.
- * Note that start_pfn should aligned with (minimum) hugepage size.
+ * Note that this will dissolve a free gigantic hugepage completely, if any
+ * part of it lies within the given range.
  */
 void dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn)
 {
@@ -1466,7 +1468,6 @@ void dissolve_free_huge_pages(unsigned l
 	if (!hugepages_supported())
 		return;
 
-	VM_BUG_ON(!IS_ALIGNED(start_pfn, 1 << minimum_order));
 	for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order)
 		dissolve_free_huge_page(pfn_to_page(pfn));
 }

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

* [PATCH 4.8 40/57] vfs,mm: fix a dead loop in truncate_inode_pages_range()
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (30 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 39/57] mm/hugetlb: fix memory offline with hugepage size > memory block size Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 41/57] jbd2: fix lockdep annotation in add_transaction_credits() Greg Kroah-Hartman
                     ` (18 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Wei Fang, Christoph Hellwig,
	Dave Chinner, Al Viro, Andrew Morton, Linus Torvalds

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

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

From: Wei Fang <fangwei1@huawei.com>

commit c2a9737f45e27d8263ff9643f994bda9bac0b944 upstream.

We triggered a deadloop in truncate_inode_pages_range() on 32 bits
architecture with the test case bellow:

	...
	fd = open();
	write(fd, buf, 4096);
	preadv64(fd, &iovec, 1, 0xffffffff000);
	ftruncate(fd, 0);
	...

Then ftruncate() will not return forever.

The filesystem used in this case is ubifs, but it can be triggered on
many other filesystems.

When preadv64() is called with offset=0xffffffff000, a page with
index=0xffffffff will be added to the radix tree of ->mapping.  Then
this page can be found in ->mapping with pagevec_lookup().  After that,
truncate_inode_pages_range(), which is called in ftruncate(), will fall
into an infinite loop:

 - find a page with index=0xffffffff, since index>=end, this page won't
   be truncated

 - index++, and index become 0

 - the page with index=0xffffffff will be found again

The data type of index is unsigned long, so index won't overflow to 0 on
64 bits architecture in this case, and the dead loop won't happen.

Since truncate_inode_pages_range() is executed with holding lock of
inode->i_rwsem, any operation related with this lock will be blocked,
and a hung task will happen, e.g.:

  INFO: task truncate_test:3364 blocked for more than 120 seconds.
  ...
     call_rwsem_down_write_failed+0x17/0x30
     generic_file_write_iter+0x32/0x1c0
     ubifs_write_iter+0xcc/0x170
     __vfs_write+0xc4/0x120
     vfs_write+0xb2/0x1b0
     SyS_write+0x46/0xa0

The page with index=0xffffffff added to ->mapping is useless.  Fix this
by checking the read position before allocating pages.

Link: http://lkml.kernel.org/r/1475151010-40166-1-git-send-email-fangwei1@huawei.com
Signed-off-by: Wei Fang <fangwei1@huawei.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/filemap.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1687,6 +1687,10 @@ static ssize_t do_generic_file_read(stru
 	unsigned int prev_offset;
 	int error = 0;
 
+	if (unlikely(*ppos >= inode->i_sb->s_maxbytes))
+		return -EINVAL;
+	iov_iter_truncate(iter, inode->i_sb->s_maxbytes);
+
 	index = *ppos >> PAGE_SHIFT;
 	prev_index = ra->prev_pos >> PAGE_SHIFT;
 	prev_offset = ra->prev_pos & (PAGE_SIZE-1);

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

* [PATCH 4.8 41/57] jbd2: fix lockdep annotation in add_transaction_credits()
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (31 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 40/57] vfs,mm: fix a dead loop in truncate_inode_pages_range() Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 42/57] ext4: enforce online defrag restriction for encrypted files Greg Kroah-Hartman
                     ` (17 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Thomas Gleixner, Jan Kara, Theodore Tso

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

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

From: Jan Kara <jack@suse.cz>

commit e03a9976afce6634826d56c33531dd10bb9a9166 upstream.

Thomas has reported a lockdep splat hitting in
add_transaction_credits(). The problem is that that function calls
jbd2_might_wait_for_commit() while holding j_state_lock which is wrong
(we do not really wait for transaction commit while holding that lock).

Fix the problem by moving jbd2_might_wait_for_commit() into places where
we are ready to wait for transaction commit and thus j_state_lock is
unlocked.

Fixes: 1eaa566d368b214d99cbb973647c1b0b8102a9ae
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/jbd2/transaction.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -159,6 +159,7 @@ static void wait_transaction_locked(jour
 	read_unlock(&journal->j_state_lock);
 	if (need_to_start)
 		jbd2_log_start_commit(journal, tid);
+	jbd2_might_wait_for_commit(journal);
 	schedule();
 	finish_wait(&journal->j_wait_transaction_locked, &wait);
 }
@@ -182,8 +183,6 @@ static int add_transaction_credits(journ
 	int needed;
 	int total = blocks + rsv_blocks;
 
-	jbd2_might_wait_for_commit(journal);
-
 	/*
 	 * If the current transaction is locked down for commit, wait
 	 * for the lock to be released.
@@ -214,6 +213,7 @@ static int add_transaction_credits(journ
 		if (atomic_read(&journal->j_reserved_credits) + total >
 		    journal->j_max_transaction_buffers) {
 			read_unlock(&journal->j_state_lock);
+			jbd2_might_wait_for_commit(journal);
 			wait_event(journal->j_wait_reserved,
 				   atomic_read(&journal->j_reserved_credits) + total <=
 				   journal->j_max_transaction_buffers);
@@ -238,6 +238,7 @@ static int add_transaction_credits(journ
 	if (jbd2_log_space_left(journal) < jbd2_space_needed(journal)) {
 		atomic_sub(total, &t->t_outstanding_credits);
 		read_unlock(&journal->j_state_lock);
+		jbd2_might_wait_for_commit(journal);
 		write_lock(&journal->j_state_lock);
 		if (jbd2_log_space_left(journal) < jbd2_space_needed(journal))
 			__jbd2_log_wait_for_space(journal);
@@ -255,6 +256,7 @@ static int add_transaction_credits(journ
 		sub_reserved_credits(journal, rsv_blocks);
 		atomic_sub(total, &t->t_outstanding_credits);
 		read_unlock(&journal->j_state_lock);
+		jbd2_might_wait_for_commit(journal);
 		wait_event(journal->j_wait_reserved,
 			 atomic_read(&journal->j_reserved_credits) + rsv_blocks
 			 <= journal->j_max_transaction_buffers / 2);

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

* [PATCH 4.8 42/57] ext4: enforce online defrag restriction for encrypted files
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (32 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 41/57] jbd2: fix lockdep annotation in add_transaction_credits() Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 43/57] ext4: reinforce check of i_dtime when clearing high fields of uid and gid Greg Kroah-Hartman
                     ` (16 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Eric Whitney, Theodore Tso

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

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

From: Eric Whitney <enwlinux@gmail.com>

commit 14fbd4aa613bd5110556c281799ce36dc6f3ba97 upstream.

Online defragging of encrypted files is not currently implemented.
However, the move extent ioctl can still return successfully when
called.  For example, this occurs when xfstest ext4/020 is run on an
encrypted file system, resulting in a corrupted test file and a
corresponding test failure.

Until the proper functionality is implemented, fail the move extent
ioctl if either the original or donor file is encrypted.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/ext4/move_extent.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -598,6 +598,13 @@ ext4_move_extents(struct file *o_filp, s
 		return -EOPNOTSUPP;
 	}
 
+	if (ext4_encrypted_inode(orig_inode) ||
+	    ext4_encrypted_inode(donor_inode)) {
+		ext4_msg(orig_inode->i_sb, KERN_ERR,
+			 "Online defrag not supported for encrypted files");
+		return -EOPNOTSUPP;
+	}
+
 	/* Protect orig and donor inodes against a truncate */
 	lock_two_nondirectories(orig_inode, donor_inode);
 

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

* [PATCH 4.8 43/57] ext4: reinforce check of i_dtime when clearing high fields of uid and gid
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (33 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 42/57] ext4: enforce online defrag restriction for encrypted files Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 45/57] ext4: fix memory leak in ext4_insert_range() Greg Kroah-Hartman
                     ` (15 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Daeho Jeong, Hobin Woo, Theodore Tso

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

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

From: Daeho Jeong <daeho.jeong@samsung.com>

commit 93e3b4e6631d2a74a8cf7429138096862ff9f452 upstream.

Now, ext4_do_update_inode() clears high 16-bit fields of uid/gid
of deleted and evicted inode to fix up interoperability with old
kernels. However, it checks only i_dtime of an inode to determine
whether the inode was deleted and evicted, and this is very risky,
because i_dtime can be used for the pointer maintaining orphan inode
list, too. We need to further check whether the i_dtime is being
used for the orphan inode list even if the i_dtime is not NULL.

We found that high 16-bit fields of uid/gid of inode are unintentionally
and permanently cleared when the inode truncation is just triggered,
but not finished, and the inode metadata, whose high uid/gid bits are
cleared, is written on disk, and the sudden power-off follows that
in order.

Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
Signed-off-by: Hobin Woo <hobin.woo@samsung.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4814,14 +4814,14 @@ static int ext4_do_update_inode(handle_t
  * Fix up interoperability with old kernels. Otherwise, old inodes get
  * re-used with the upper 16 bits of the uid/gid intact
  */
-		if (!ei->i_dtime) {
+		if (ei->i_dtime && list_empty(&ei->i_orphan)) {
+			raw_inode->i_uid_high = 0;
+			raw_inode->i_gid_high = 0;
+		} else {
 			raw_inode->i_uid_high =
 				cpu_to_le16(high_16_bits(i_uid));
 			raw_inode->i_gid_high =
 				cpu_to_le16(high_16_bits(i_gid));
-		} else {
-			raw_inode->i_uid_high = 0;
-			raw_inode->i_gid_high = 0;
 		}
 	} else {
 		raw_inode->i_uid_low = cpu_to_le16(fs_high2lowuid(i_uid));

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

* [PATCH 4.8 45/57] ext4: fix memory leak in ext4_insert_range()
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (34 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 43/57] ext4: reinforce check of i_dtime when clearing high fields of uid and gid Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 46/57] ext4: fix memory leak when symlink decryption fails Greg Kroah-Hartman
                     ` (14 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Fabian Frederick, Theodore Tso

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

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

From: Fabian Frederick <fabf@skynet.be>

commit edf15aa180d7b98fe16bd3eda42f9dd0e60dee20 upstream.

Running xfstests generic/013 with kmemleak gives the following:

unreferenced object 0xffff8801d3d27de0 (size 96):
  comm "fsstress", pid 4941, jiffies 4294860168 (age 53.485s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff818eaaf3>] kmemleak_alloc+0x23/0x40
    [<ffffffff81179805>] __kmalloc+0xf5/0x1d0
    [<ffffffff8122ef5c>] ext4_find_extent+0x1ec/0x2f0
    [<ffffffff8123530c>] ext4_insert_range+0x34c/0x4a0
    [<ffffffff81235942>] ext4_fallocate+0x4e2/0x8b0
    [<ffffffff81181334>] vfs_fallocate+0x134/0x210
    [<ffffffff8118203f>] SyS_fallocate+0x3f/0x60
    [<ffffffff818efa9b>] entry_SYSCALL_64_fastpath+0x13/0x8f
    [<ffffffffffffffff>] 0xffffffffffffffff

Problem seems mitigated by dropping refs and freeing path
when there's no path[depth].p_ext

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/ext4/extents.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5734,6 +5734,9 @@ int ext4_insert_range(struct inode *inod
 			up_write(&EXT4_I(inode)->i_data_sem);
 			goto out_stop;
 		}
+	} else {
+		ext4_ext_drop_refs(path);
+		kfree(path);
 	}
 
 	ret = ext4_es_remove_extent(inode, offset_lblk,

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

* [PATCH 4.8 46/57] ext4: fix memory leak when symlink decryption fails
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (35 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 45/57] ext4: fix memory leak in ext4_insert_range() Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 47/57] ext4: allow DAX writeback for hole punch Greg Kroah-Hartman
                     ` (13 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Eric Biggers, Theodore Tso

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

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

From: Eric Biggers <ebiggers@google.com>

commit dcce7a46c6f28f41447272fb44348ead8f584573 upstream.

This bug was introduced in v4.8-rc1.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/ext4/symlink.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/fs/ext4/symlink.c
+++ b/fs/ext4/symlink.c
@@ -65,13 +65,12 @@ static const char *ext4_encrypted_get_li
 	res = fscrypt_fname_alloc_buffer(inode, cstr.len, &pstr);
 	if (res)
 		goto errout;
+	paddr = pstr.name;
 
 	res = fscrypt_fname_disk_to_usr(inode, 0, 0, &cstr, &pstr);
 	if (res < 0)
 		goto errout;
 
-	paddr = pstr.name;
-
 	/* Null-terminate the name */
 	if (res <= pstr.len)
 		paddr[res] = '\0';

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

* [PATCH 4.8 47/57] ext4: allow DAX writeback for hole punch
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (36 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 46/57] ext4: fix memory leak when symlink decryption fails Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 48/57] ext4: release bh in make_indexed_dir Greg Kroah-Hartman
                     ` (12 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Ross Zwisler, Jan Kara, Theodore Tso

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

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

From: Ross Zwisler <ross.zwisler@linux.intel.com>

commit cca32b7eeb4ea24fa6596650e06279ad9130af98 upstream.

Currently when doing a DAX hole punch with ext4 we fail to do a writeback.
This is because the logic around filemap_write_and_wait_range() in
ext4_punch_hole() only looks for dirty page cache pages in the radix tree,
not for dirty DAX exceptional entries.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3892,7 +3892,7 @@ int ext4_update_disksize_before_punch(st
 }
 
 /*
- * ext4_punch_hole: punches a hole in a file by releaseing the blocks
+ * ext4_punch_hole: punches a hole in a file by releasing the blocks
  * associated with the given offset and length
  *
  * @inode:  File inode
@@ -3921,7 +3921,7 @@ int ext4_punch_hole(struct inode *inode,
 	 * Write out all dirty pages to avoid race conditions
 	 * Then release them.
 	 */
-	if (mapping->nrpages && mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
+	if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
 		ret = filemap_write_and_wait_range(mapping, offset,
 						   offset + length - 1);
 		if (ret)

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

* [PATCH 4.8 48/57] ext4: release bh in make_indexed_dir
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (37 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 47/57] ext4: allow DAX writeback for hole punch Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 49/57] ext4: unmap metadata when zeroing blocks Greg Kroah-Hartman
                     ` (11 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, yangsheng, Theodore Tso

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

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

From: gmail <yngsion@gmail.com>

commit e81d44778d1d57bbaef9e24c4eac7c8a7a401d40 upstream.

The commit 6050d47adcad: "ext4: bail out from make_indexed_dir() on
first error" could end up leaking bh2 in the error path.

[ Also avoid renaming bh2 to bh, which just confuses things --tytso ]

Signed-off-by: yangsheng <yngsion@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/ext4/namei.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2044,33 +2044,31 @@ static int make_indexed_dir(handle_t *ha
 	frame->entries = entries;
 	frame->at = entries;
 	frame->bh = bh;
-	bh = bh2;
 
 	retval = ext4_handle_dirty_dx_node(handle, dir, frame->bh);
 	if (retval)
 		goto out_frames;	
-	retval = ext4_handle_dirty_dirent_node(handle, dir, bh);
+	retval = ext4_handle_dirty_dirent_node(handle, dir, bh2);
 	if (retval)
 		goto out_frames;	
 
-	de = do_split(handle,dir, &bh, frame, &fname->hinfo);
+	de = do_split(handle,dir, &bh2, frame, &fname->hinfo);
 	if (IS_ERR(de)) {
 		retval = PTR_ERR(de);
 		goto out_frames;
 	}
-	dx_release(frames);
 
-	retval = add_dirent_to_buf(handle, fname, dir, inode, de, bh);
-	brelse(bh);
-	return retval;
+	retval = add_dirent_to_buf(handle, fname, dir, inode, de, bh2);
 out_frames:
 	/*
 	 * Even if the block split failed, we have to properly write
 	 * out all the changes we did so far. Otherwise we can end up
 	 * with corrupted filesystem.
 	 */
-	ext4_mark_inode_dirty(handle, dir);
+	if (retval)
+		ext4_mark_inode_dirty(handle, dir);
 	dx_release(frames);
+	brelse(bh2);
 	return retval;
 }
 

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

* [PATCH 4.8 49/57] ext4: unmap metadata when zeroing blocks
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (38 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 48/57] ext4: release bh in make_indexed_dir Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 50/57] crypto: ghash-generic - move common definitions to a new header file Greg Kroah-Hartman
                     ` (10 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Jan Kara, Theodore Tso

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

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

From: Jan Kara <jack@suse.cz>

commit 9b623df614576680cadeaa4d7e0b5884de8f7c17 upstream.

When zeroing blocks for DAX allocations, we also have to unmap aliases
in the block device mappings.  Otherwise writeback can overwrite zeros
with stale data from block device page cache.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/ext4/inode.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -647,11 +647,19 @@ found:
 		/*
 		 * We have to zeroout blocks before inserting them into extent
 		 * status tree. Otherwise someone could look them up there and
-		 * use them before they are really zeroed.
+		 * use them before they are really zeroed. We also have to
+		 * unmap metadata before zeroing as otherwise writeback can
+		 * overwrite zeros with stale data from block device.
 		 */
 		if (flags & EXT4_GET_BLOCKS_ZERO &&
 		    map->m_flags & EXT4_MAP_MAPPED &&
 		    map->m_flags & EXT4_MAP_NEW) {
+			ext4_lblk_t i;
+
+			for (i = 0; i < map->m_len; i++) {
+				unmap_underlying_metadata(inode->i_sb->s_bdev,
+							  map->m_pblk + i);
+			}
 			ret = ext4_issue_zeroout(inode, map->m_lblk,
 						 map->m_pblk, map->m_len);
 			if (ret) {

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

* [PATCH 4.8 50/57] crypto: ghash-generic - move common definitions to a new header file
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (39 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 49/57] ext4: unmap metadata when zeroing blocks Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 51/57] crypto: vmx - Fix memory corruption caused by p8_ghash Greg Kroah-Hartman
                     ` (9 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Marcelo Cerri, Herbert Xu

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

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

From: Marcelo Cerri <marcelo.cerri@canonical.com>

commit a397ba829d7f8aff4c90af3704573a28ccd61a59 upstream.

Move common values and types used by ghash-generic to a new header file
so drivers can directly use ghash-generic as a fallback implementation.

Fixes: cc333cd68dfa ("crypto: vmx - Adding GHASH routines for VMX module")
Signed-off-by: Marcelo Cerri <marcelo.cerri@canonical.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 crypto/ghash-generic.c |   13 +------------
 include/crypto/ghash.h |   23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 12 deletions(-)

--- a/crypto/ghash-generic.c
+++ b/crypto/ghash-generic.c
@@ -14,24 +14,13 @@
 
 #include <crypto/algapi.h>
 #include <crypto/gf128mul.h>
+#include <crypto/ghash.h>
 #include <crypto/internal/hash.h>
 #include <linux/crypto.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 
-#define GHASH_BLOCK_SIZE	16
-#define GHASH_DIGEST_SIZE	16
-
-struct ghash_ctx {
-	struct gf128mul_4k *gf128;
-};
-
-struct ghash_desc_ctx {
-	u8 buffer[GHASH_BLOCK_SIZE];
-	u32 bytes;
-};
-
 static int ghash_init(struct shash_desc *desc)
 {
 	struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
--- /dev/null
+++ b/include/crypto/ghash.h
@@ -0,0 +1,23 @@
+/*
+ * Common values for GHASH algorithms
+ */
+
+#ifndef __CRYPTO_GHASH_H__
+#define __CRYPTO_GHASH_H__
+
+#include <linux/types.h>
+#include <crypto/gf128mul.h>
+
+#define GHASH_BLOCK_SIZE	16
+#define GHASH_DIGEST_SIZE	16
+
+struct ghash_ctx {
+	struct gf128mul_4k *gf128;
+};
+
+struct ghash_desc_ctx {
+	u8 buffer[GHASH_BLOCK_SIZE];
+	u32 bytes;
+};
+
+#endif

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

* [PATCH 4.8 51/57] crypto: vmx - Fix memory corruption caused by p8_ghash
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (40 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 50/57] crypto: ghash-generic - move common definitions to a new header file Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 52/57] dlm: free workqueues after the connections Greg Kroah-Hartman
                     ` (8 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Jan Stancek, Marcelo Cerri, Herbert Xu

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

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

From: Marcelo Cerri <marcelo.cerri@canonical.com>

commit 80da44c29d997e28c4442825f35f4ac339813877 upstream.

This patch changes the p8_ghash driver to use ghash-generic as a fixed
fallback implementation. This allows the correct value of descsize to be
defined directly in its shash_alg structure and avoids problems with
incorrect buffer sizes when its state is exported or imported.

Reported-by: Jan Stancek <jstancek@redhat.com>
Fixes: cc333cd68dfa ("crypto: vmx - Adding GHASH routines for VMX module")
Signed-off-by: Marcelo Cerri <marcelo.cerri@canonical.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/crypto/vmx/ghash.c |   31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

--- a/drivers/crypto/vmx/ghash.c
+++ b/drivers/crypto/vmx/ghash.c
@@ -26,16 +26,13 @@
 #include <linux/hardirq.h>
 #include <asm/switch_to.h>
 #include <crypto/aes.h>
+#include <crypto/ghash.h>
 #include <crypto/scatterwalk.h>
 #include <crypto/internal/hash.h>
 #include <crypto/b128ops.h>
 
 #define IN_INTERRUPT in_interrupt()
 
-#define GHASH_BLOCK_SIZE (16)
-#define GHASH_DIGEST_SIZE (16)
-#define GHASH_KEY_LEN (16)
-
 void gcm_init_p8(u128 htable[16], const u64 Xi[2]);
 void gcm_gmult_p8(u64 Xi[2], const u128 htable[16]);
 void gcm_ghash_p8(u64 Xi[2], const u128 htable[16],
@@ -55,16 +52,11 @@ struct p8_ghash_desc_ctx {
 
 static int p8_ghash_init_tfm(struct crypto_tfm *tfm)
 {
-	const char *alg;
+	const char *alg = "ghash-generic";
 	struct crypto_shash *fallback;
 	struct crypto_shash *shash_tfm = __crypto_shash_cast(tfm);
 	struct p8_ghash_ctx *ctx = crypto_tfm_ctx(tfm);
 
-	if (!(alg = crypto_tfm_alg_name(tfm))) {
-		printk(KERN_ERR "Failed to get algorithm name.\n");
-		return -ENOENT;
-	}
-
 	fallback = crypto_alloc_shash(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
 	if (IS_ERR(fallback)) {
 		printk(KERN_ERR
@@ -78,10 +70,18 @@ static int p8_ghash_init_tfm(struct cryp
 	crypto_shash_set_flags(fallback,
 			       crypto_shash_get_flags((struct crypto_shash
 						       *) tfm));
-	ctx->fallback = fallback;
 
-	shash_tfm->descsize = sizeof(struct p8_ghash_desc_ctx)
-	    + crypto_shash_descsize(fallback);
+	/* Check if the descsize defined in the algorithm is still enough. */
+	if (shash_tfm->descsize < sizeof(struct p8_ghash_desc_ctx)
+	    + crypto_shash_descsize(fallback)) {
+		printk(KERN_ERR
+		       "Desc size of the fallback implementation (%s) does not match the expected value: %lu vs %u\n",
+		       alg,
+		       shash_tfm->descsize - sizeof(struct p8_ghash_desc_ctx),
+		       crypto_shash_descsize(fallback));
+		return -EINVAL;
+	}
+	ctx->fallback = fallback;
 
 	return 0;
 }
@@ -113,7 +113,7 @@ static int p8_ghash_setkey(struct crypto
 {
 	struct p8_ghash_ctx *ctx = crypto_tfm_ctx(crypto_shash_tfm(tfm));
 
-	if (keylen != GHASH_KEY_LEN)
+	if (keylen != GHASH_BLOCK_SIZE)
 		return -EINVAL;
 
 	preempt_disable();
@@ -211,7 +211,8 @@ struct shash_alg p8_ghash_alg = {
 	.update = p8_ghash_update,
 	.final = p8_ghash_final,
 	.setkey = p8_ghash_setkey,
-	.descsize = sizeof(struct p8_ghash_desc_ctx),
+	.descsize = sizeof(struct p8_ghash_desc_ctx)
+		+ sizeof(struct ghash_desc_ctx),
 	.base = {
 		 .cra_name = "ghash",
 		 .cra_driver_name = "p8_ghash",

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

* [PATCH 4.8 52/57] dlm: free workqueues after the connections
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (41 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 51/57] crypto: vmx - Fix memory corruption caused by p8_ghash Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 53/57] vfs: move permission checking into notify_change() for utimes(NULL) Greg Kroah-Hartman
                     ` (7 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Marcelo Ricardo Leitner, David Teigland

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

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

From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

commit 3a8db79889ce16930aff19b818f5b09651bb7644 upstream.

After backporting commit ee44b4bc054a ("dlm: use sctp 1-to-1 API")
series to a kernel with an older workqueue which didn't use RCU yet, it
was noticed that we are freeing the workqueues in dlm_lowcomms_stop()
too early as free_conn() will try to access that memory for canceling
the queued works if any.

This issue was introduced by commit 0d737a8cfd83 as before it such
attempt to cancel the queued works wasn't performed, so the issue was
not present.

This patch fixes it by simply inverting the free order.

Fixes: 0d737a8cfd83 ("dlm: fix race while closing connections")
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/dlm/lowcomms.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -1656,16 +1656,12 @@ void dlm_lowcomms_stop(void)
 	mutex_lock(&connections_lock);
 	dlm_allow_conn = 0;
 	foreach_conn(stop_conn);
+	clean_writequeues();
+	foreach_conn(free_conn);
 	mutex_unlock(&connections_lock);
 
 	work_stop();
 
-	mutex_lock(&connections_lock);
-	clean_writequeues();
-
-	foreach_conn(free_conn);
-
-	mutex_unlock(&connections_lock);
 	kmem_cache_destroy(con_cache);
 }
 

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

* [PATCH 4.8 53/57] vfs: move permission checking into notify_change() for utimes(NULL)
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (42 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 52/57] dlm: free workqueues after the connections Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 54/57] cachefiles: Fix attempt to read i_blocks after deleting file [ver #2] Greg Kroah-Hartman
                     ` (6 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Aihua Zhang, Miklos Szeredi

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

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

From: Miklos Szeredi <mszeredi@redhat.com>

commit f2b20f6ee842313a0d681dbbf7f87b70291a6a3b upstream.

This fixes a bug where the permission was not properly checked in
overlayfs.  The testcase is ltp/utimensat01.

It is also cleaner and safer to do the permission checking in the vfs
helper instead of the caller.

This patch introduces an additional ia_valid flag ATTR_TOUCH (since
touch(1) is the most obvious user of utimes(NULL)) that is passed into
notify_change whenever the conditions for this special permission checking
mode are met.

Reported-by: Aihua Zhang <zhangaihua1@huawei.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Tested-by: Aihua Zhang <zhangaihua1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/attr.c          |   15 +++++++++++++++
 fs/utimes.c        |   17 +----------------
 include/linux/fs.h |    1 +
 3 files changed, 17 insertions(+), 16 deletions(-)

--- a/fs/attr.c
+++ b/fs/attr.c
@@ -202,6 +202,21 @@ int notify_change(struct dentry * dentry
 			return -EPERM;
 	}
 
+	/*
+	 * If utimes(2) and friends are called with times == NULL (or both
+	 * times are UTIME_NOW), then we need to check for write permission
+	 */
+	if (ia_valid & ATTR_TOUCH) {
+		if (IS_IMMUTABLE(inode))
+			return -EPERM;
+
+		if (!inode_owner_or_capable(inode)) {
+			error = inode_permission(inode, MAY_WRITE);
+			if (error)
+				return error;
+		}
+	}
+
 	if ((ia_valid & ATTR_MODE)) {
 		umode_t amode = attr->ia_mode;
 		/* Flag setting protected by i_mutex */
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -87,21 +87,7 @@ static int utimes_common(struct path *pa
 		 */
 		newattrs.ia_valid |= ATTR_TIMES_SET;
 	} else {
-		/*
-		 * If times is NULL (or both times are UTIME_NOW),
-		 * then we need to check permissions, because
-		 * inode_change_ok() won't do it.
-		 */
-		error = -EPERM;
-                if (IS_IMMUTABLE(inode))
-			goto mnt_drop_write_and_out;
-
-		error = -EACCES;
-		if (!inode_owner_or_capable(inode)) {
-			error = inode_permission(inode, MAY_WRITE);
-			if (error)
-				goto mnt_drop_write_and_out;
-		}
+		newattrs.ia_valid |= ATTR_TOUCH;
 	}
 retry_deleg:
 	inode_lock(inode);
@@ -113,7 +99,6 @@ retry_deleg:
 			goto retry_deleg;
 	}
 
-mnt_drop_write_and_out:
 	mnt_drop_write(path->mnt);
 out:
 	return error;
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -224,6 +224,7 @@ typedef int (dio_iodone_t)(struct kiocb
 #define ATTR_KILL_PRIV	(1 << 14)
 #define ATTR_OPEN	(1 << 15) /* Truncating from open(O_TRUNC) */
 #define ATTR_TIMES_SET	(1 << 16)
+#define ATTR_TOUCH	(1 << 17)
 
 /*
  * Whiteout is represented by a char device.  The following constants define the

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

* [PATCH 4.8 54/57] cachefiles: Fix attempt to read i_blocks after deleting file [ver #2]
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (43 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 53/57] vfs: move permission checking into notify_change() for utimes(NULL) Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 55/57] drm: virtio: reinstate drm_virtio_set_busid() Greg Kroah-Hartman
                     ` (5 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Jianhong Yin, David Howells,
	Jeff Layton, Steve Dickson, Al Viro

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

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

From: David Howells <dhowells@redhat.com>

commit a818101d7b92e76db2f9a597e4830734767473b9 upstream.

An NULL-pointer dereference happens in cachefiles_mark_object_inactive()
when it tries to read i_blocks so that it can tell the cachefilesd daemon
how much space it's making available.

The problem is that cachefiles_drop_object() calls
cachefiles_mark_object_inactive() after calling cachefiles_delete_object()
because the object being marked active staves off attempts to (re-)use the
file at that filename until after it has been deleted.  This means that
d_inode is NULL by the time we come to try to access it.

To fix the problem, have the caller of cachefiles_mark_object_inactive()
supply the number of blocks freed up.

Without this, the following oops may occur:

BUG: unable to handle kernel NULL pointer dereference at 0000000000000098
IP: [<ffffffffa06c5cc1>] cachefiles_mark_object_inactive+0x61/0xb0 [cachefiles]
...
CPU: 11 PID: 527 Comm: kworker/u64:4 Tainted: G          I    ------------   3.10.0-470.el7.x86_64 #1
Hardware name: Hewlett-Packard HP Z600 Workstation/0B54h, BIOS 786G4 v03.19 03/11/2011
Workqueue: fscache_object fscache_object_work_func [fscache]
task: ffff880035edaf10 ti: ffff8800b77c0000 task.ti: ffff8800b77c0000
RIP: 0010:[<ffffffffa06c5cc1>] cachefiles_mark_object_inactive+0x61/0xb0 [cachefiles]
RSP: 0018:ffff8800b77c3d70  EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff8800bf6cc400 RCX: 0000000000000034
RDX: 0000000000000000 RSI: ffff880090ffc710 RDI: ffff8800bf761ef8
RBP: ffff8800b77c3d88 R08: 2000000000000000 R09: 0090ffc710000000
R10: ff51005d2ff1c400 R11: 0000000000000000 R12: ffff880090ffc600
R13: ffff8800bf6cc520 R14: ffff8800bf6cc400 R15: ffff8800bf6cc498
FS:  0000000000000000(0000) GS:ffff8800bb8c0000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 0000000000000098 CR3: 00000000019ba000 CR4: 00000000000007e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Stack:
 ffff880090ffc600 ffff8800bf6cc400 ffff8800867df140 ffff8800b77c3db0
 ffffffffa06c48cb ffff880090ffc600 ffff880090ffc180 ffff880090ffc658
 ffff8800b77c3df0 ffffffffa085d846 ffff8800a96b8150 ffff880090ffc600
Call Trace:
 [<ffffffffa06c48cb>] cachefiles_drop_object+0x6b/0xf0 [cachefiles]
 [<ffffffffa085d846>] fscache_drop_object+0xd6/0x1e0 [fscache]
 [<ffffffffa085d615>] fscache_object_work_func+0xa5/0x200 [fscache]
 [<ffffffff810a605b>] process_one_work+0x17b/0x470
 [<ffffffff810a6e96>] worker_thread+0x126/0x410
 [<ffffffff810a6d70>] ? rescuer_thread+0x460/0x460
 [<ffffffff810ae64f>] kthread+0xcf/0xe0
 [<ffffffff810ae580>] ? kthread_create_on_node+0x140/0x140
 [<ffffffff81695418>] ret_from_fork+0x58/0x90
 [<ffffffff810ae580>] ? kthread_create_on_node+0x140/0x140

The oopsing code shows:

	callq  0xffffffff810af6a0 <wake_up_bit>
	mov    0xf8(%r12),%rax
	mov    0x30(%rax),%rax
	mov    0x98(%rax),%rax   <---- oops here
	lock add %rax,0x130(%rbx)

where this is:

	d_backing_inode(object->dentry)->i_blocks

Fixes: a5b3a80b899bda0f456f1246c4c5a1191ea01519 (CacheFiles: Provide read-and-reset release counters for cachefilesd)
Reported-by: Jianhong Yin <jiyin@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Steve Dickson <steved@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/cachefiles/interface.c |    8 +++++++-
 fs/cachefiles/internal.h  |    3 ++-
 fs/cachefiles/namei.c     |    8 ++++----
 3 files changed, 13 insertions(+), 6 deletions(-)

--- a/fs/cachefiles/interface.c
+++ b/fs/cachefiles/interface.c
@@ -253,6 +253,8 @@ static void cachefiles_drop_object(struc
 	struct cachefiles_object *object;
 	struct cachefiles_cache *cache;
 	const struct cred *saved_cred;
+	struct inode *inode;
+	blkcnt_t i_blocks = 0;
 
 	ASSERT(_object);
 
@@ -279,6 +281,10 @@ static void cachefiles_drop_object(struc
 		    _object != cache->cache.fsdef
 		    ) {
 			_debug("- retire object OBJ%x", object->fscache.debug_id);
+			inode = d_backing_inode(object->dentry);
+			if (inode)
+				i_blocks = inode->i_blocks;
+
 			cachefiles_begin_secure(cache, &saved_cred);
 			cachefiles_delete_object(cache, object);
 			cachefiles_end_secure(cache, saved_cred);
@@ -292,7 +298,7 @@ static void cachefiles_drop_object(struc
 
 	/* note that the object is now inactive */
 	if (test_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags))
-		cachefiles_mark_object_inactive(cache, object);
+		cachefiles_mark_object_inactive(cache, object, i_blocks);
 
 	dput(object->dentry);
 	object->dentry = NULL;
--- a/fs/cachefiles/internal.h
+++ b/fs/cachefiles/internal.h
@@ -160,7 +160,8 @@ extern char *cachefiles_cook_key(const u
  * namei.c
  */
 extern void cachefiles_mark_object_inactive(struct cachefiles_cache *cache,
-					    struct cachefiles_object *object);
+					    struct cachefiles_object *object,
+					    blkcnt_t i_blocks);
 extern int cachefiles_delete_object(struct cachefiles_cache *cache,
 				    struct cachefiles_object *object);
 extern int cachefiles_walk_to_object(struct cachefiles_object *parent,
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -261,10 +261,9 @@ requeue:
  * Mark an object as being inactive.
  */
 void cachefiles_mark_object_inactive(struct cachefiles_cache *cache,
-				     struct cachefiles_object *object)
+				     struct cachefiles_object *object,
+				     blkcnt_t i_blocks)
 {
-	blkcnt_t i_blocks = d_backing_inode(object->dentry)->i_blocks;
-
 	write_lock(&cache->active_lock);
 	rb_erase(&object->active_node, &cache->active_nodes);
 	clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags);
@@ -707,7 +706,8 @@ mark_active_timed_out:
 
 check_error:
 	_debug("check error %d", ret);
-	cachefiles_mark_object_inactive(cache, object);
+	cachefiles_mark_object_inactive(
+		cache, object, d_backing_inode(object->dentry)->i_blocks);
 release_dentry:
 	dput(object->dentry);
 	object->dentry = NULL;

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

* [PATCH 4.8 55/57] drm: virtio: reinstate drm_virtio_set_busid()
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (44 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 54/57] cachefiles: Fix attempt to read i_blocks after deleting file [ver #2] Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18   ` [PATCH 4.8 56/57] acpi, nfit: check for the correct event code in notifications Greg Kroah-Hartman
                     ` (4 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Daniel Vetter, Emil Velikov,
	Gerd Hoffmann, Gustavo Padovan, Hans de Goede, Joachim Frieben,
	Laszlo Ersek, Dave Airlie

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

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

From: Laszlo Ersek <lersek@redhat.com>

commit c2cbc38b9715bd8318062e600668fc30e5a3fbfa upstream.

Before commit a325725633c2 ("drm: Lobotomize set_busid nonsense for !pci
drivers"), several DRM drivers for platform devices used to expose an
explicit "drm_driver.set_busid" callback, invariably backed by
drm_platform_set_busid().

Commit a325725633c2 removed drm_platform_set_busid(), along with the
referring .set_busid field initializations. This was justified because
interchangeable functionality had been implemented in drm_dev_alloc() /
drm_dev_init(), which DRM_IOCTL_SET_VERSION would rely on going forward.

However, commit a325725633c2 also removed drm_virtio_set_busid(), for
which the same consolidation was not appropriate: this .set_busid callback
had been implemented with drm_pci_set_busid(), and not
drm_platform_set_busid(). The error regressed Xorg/xserver on QEMU's
"virtio-vga" card; the drmGetBusid() function from libdrm would no longer
return stable PCI identifiers like "pci:0000:00:02.0", but rather unstable
platform ones like "virtio0".

Reinstate drm_virtio_set_busid() with judicious use of

  git checkout -p a325725633c2^ -- drivers/gpu/drm/virtio

Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Joachim Frieben <jfrieben@hotmail.com>
Reported-by: Joachim Frieben <jfrieben@hotmail.com>
Fixes: a325725633c26aa66ab940f762a6b0778edf76c0
Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1366842
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpu/drm/virtio/virtgpu_drm_bus.c |   10 ++++++++++
 drivers/gpu/drm/virtio/virtgpu_drv.c     |    1 +
 drivers/gpu/drm/virtio/virtgpu_drv.h     |    1 +
 3 files changed, 12 insertions(+)

--- a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
@@ -27,6 +27,16 @@
 
 #include "virtgpu_drv.h"
 
+int drm_virtio_set_busid(struct drm_device *dev, struct drm_master *master)
+{
+	struct pci_dev *pdev = dev->pdev;
+
+	if (pdev) {
+		return drm_pci_set_busid(dev, master);
+	}
+	return 0;
+}
+
 static void virtio_pci_kick_out_firmware_fb(struct pci_dev *pci_dev)
 {
 	struct apertures_struct *ap;
--- a/drivers/gpu/drm/virtio/virtgpu_drv.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
@@ -117,6 +117,7 @@ static const struct file_operations virt
 
 static struct drm_driver driver = {
 	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER | DRIVER_ATOMIC,
+	.set_busid = drm_virtio_set_busid,
 	.load = virtio_gpu_driver_load,
 	.unload = virtio_gpu_driver_unload,
 	.open = virtio_gpu_driver_open,
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -49,6 +49,7 @@
 #define DRIVER_PATCHLEVEL 1
 
 /* virtgpu_drm_bus.c */
+int drm_virtio_set_busid(struct drm_device *dev, struct drm_master *master);
 int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev);
 
 struct virtio_gpu_object {

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

* [PATCH 4.8 56/57] acpi, nfit: check for the correct event code in notifications
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (45 preceding siblings ...)
  2016-10-21  9:18   ` [PATCH 4.8 55/57] drm: virtio: reinstate drm_virtio_set_busid() Greg Kroah-Hartman
@ 2016-10-21  9:18   ` Greg Kroah-Hartman
  2016-10-21  9:18     ` Greg Kroah-Hartman
                     ` (3 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, linux-acpi, Dan Williams,
	Linda Knippers, Vishal Verma

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

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

From: Vishal Verma <vishal.l.verma@intel.com>

commit c09f12186d6b03b798832d95289af76495990192 upstream.

Commit 209851649dc4 "acpi: nfit: Add support for hot-add" added
support for _FIT notifications, but it neglected to verify the
notification event code matches the one in the ACPI spec for
"NFIT Update". Currently there is only one code in the spec, but
once additional codes are added, older kernels (without this fix)
will misbehave by assuming all event notifications are for an
NFIT Update.

Fixes: 209851649dc4 ("acpi: nfit: Add support for hot-add")
Cc: <linux-acpi@vger.kernel.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Reported-by: Linda Knippers <linda.knippers@hpe.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/acpi/nfit/core.c |    3 +++
 drivers/acpi/nfit/nfit.h |    4 ++++
 2 files changed, 7 insertions(+)

--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -2689,6 +2689,9 @@ static void acpi_nfit_notify(struct acpi
 
 	dev_dbg(dev, "%s: event: %d\n", __func__, event);
 
+	if (event != NFIT_NOTIFY_UPDATE)
+		return;
+
 	device_lock(dev);
 	if (!dev->driver) {
 		/* dev->driver may be null if we're being removed */
--- a/drivers/acpi/nfit/nfit.h
+++ b/drivers/acpi/nfit/nfit.h
@@ -78,6 +78,10 @@ enum {
 	NFIT_ARS_TIMEOUT = 90,
 };
 
+enum nfit_root_notifiers {
+	NFIT_NOTIFY_UPDATE = 0x80,
+};
+
 struct nfit_spa {
 	struct list_head list;
 	struct nd_region *nd_region;

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

* [PATCH 4.8 57/57] cfq: fix starvation of asynchronous writes
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
@ 2016-10-21  9:18     ` Greg Kroah-Hartman
  2016-10-21  9:17   ` [PATCH 4.8 04/57] serial: 8250_port: fix runtime PM use in __do_stop_tx_rs485() Greg Kroah-Hartman
                       ` (49 subsequent siblings)
  50 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Glauber Costa, Jens Axboe,
	linux-block, Jens Axboe

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

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

From: Glauber Costa <glauber@scylladb.com>

commit 3932a86b4b9d1f0b049d64d4591ce58ad18b44ec upstream.

While debugging timeouts happening in my application workload (ScyllaDB), I have
observed calls to open() taking a long time, ranging everywhere from 2 seconds -
the first ones that are enough to time out my application - to more than 30
seconds.

The problem seems to happen because XFS may block on pending metadata updates
under certain circumnstances, and that's confirmed with the following backtrace
taken by the offcputime tool (iovisor/bcc):

    ffffffffb90c57b1 finish_task_switch
    ffffffffb97dffb5 schedule
    ffffffffb97e310c schedule_timeout
    ffffffffb97e1f12 __down
    ffffffffb90ea821 down
    ffffffffc046a9dc xfs_buf_lock
    ffffffffc046abfb _xfs_buf_find
    ffffffffc046ae4a xfs_buf_get_map
    ffffffffc046babd xfs_buf_read_map
    ffffffffc0499931 xfs_trans_read_buf_map
    ffffffffc044a561 xfs_da_read_buf
    ffffffffc0451390 xfs_dir3_leaf_read.constprop.16
    ffffffffc0452b90 xfs_dir2_leaf_lookup_int
    ffffffffc0452e0f xfs_dir2_leaf_lookup
    ffffffffc044d9d3 xfs_dir_lookup
    ffffffffc047d1d9 xfs_lookup
    ffffffffc0479e53 xfs_vn_lookup
    ffffffffb925347a path_openat
    ffffffffb9254a71 do_filp_open
    ffffffffb9242a94 do_sys_open
    ffffffffb9242b9e sys_open
    ffffffffb97e42b2 entry_SYSCALL_64_fastpath
    00007fb0698162ed [unknown]

Inspecting my run with blktrace, I can see that the xfsaild kthread exhibit very
high "Dispatch wait" times, on the dozens of seconds range and consistent with
the open() times I have saw in that run.

Still from the blktrace output, we can after searching a bit, identify the
request that wasn't dispatched:

  8,0   11      152    81.092472813   804  A  WM 141698288 + 8 <- (8,1) 141696240
  8,0   11      153    81.092472889   804  Q  WM 141698288 + 8 [xfsaild/sda1]
  8,0   11      154    81.092473207   804  G  WM 141698288 + 8 [xfsaild/sda1]
  8,0   11      206    81.092496118   804  I  WM 141698288 + 8 (   22911) [xfsaild/sda1]
  <==== 'I' means Inserted (into the IO scheduler) ===================================>
  8,0    0   289372    96.718761435     0  D  WM 141698288 + 8 (15626265317) [swapper/0]
  <==== Only 15s later the CFQ scheduler dispatches the request ======================>

As we can see above, in this particular example CFQ took 15 seconds to dispatch
this request. Going back to the full trace, we can see that the xfsaild queue
had plenty of opportunity to run, and it was selected as the active queue many
times. It would just always be preempted by something else (example):

  8,0    1        0    81.117912979     0  m   N cfq1618SN / insert_request
  8,0    1        0    81.117913419     0  m   N cfq1618SN / add_to_rr
  8,0    1        0    81.117914044     0  m   N cfq1618SN / preempt
  8,0    1        0    81.117914398     0  m   N cfq767A  / slice expired t=1
  8,0    1        0    81.117914755     0  m   N cfq767A  / resid=40
  8,0    1        0    81.117915340     0  m   N / served: vt=1948520448 min_vt=1948520448
  8,0    1        0    81.117915858     0  m   N cfq767A  / sl_used=1 disp=0 charge=0 iops=1 sect=0

where cfq767 is the xfsaild queue and cfq1618 corresponds to one of the ScyllaDB
IO dispatchers.

The requests preempting the xfsaild queue are synchronous requests. That's a
characteristic of ScyllaDB workloads, as we only ever issue O_DIRECT requests.
While it can be argued that preempting ASYNC requests in favor of SYNC is part
of the CFQ logic, I don't believe that doing so for 15+ seconds is anyone's
goal.

Moreover, unless I am misunderstanding something, that breaks the expectation
set by the "fifo_expire_async" tunable, which in my system is set to the
default.

Looking at the code, it seems to me that the issue is that after we make
an async queue active, there is no guarantee that it will execute any request.

When the queue itself tests if it cfq_may_dispatch() it can bail if it sees SYNC
requests in flight. An incoming request from another queue can also preempt it
in such situation before we have the chance to execute anything (as seen in the
trace above).

This patch sets the must_dispatch flag if we notice that we have requests
that are already fifo_expired. This flag is always cleared after
cfq_dispatch_request() returns from cfq_dispatch_requests(), so it won't pin
the queue for subsequent requests (unless they are themselves expired)

Care is taken during preempt to still allow rt requests to preempt us
regardless.

Testing my workload with this patch applied produces much better results.
>From the application side I see no timeouts, and the open() latency histogram
generated by systemtap looks much better, with the worst outlier at 131ms:

Latency histogram of xfs_buf_lock acquisition (microseconds):
 value |-------------------------------------------------- count
     0 |                                                     11
     1 |@@@@                                                161
     2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  1966
     4 |@                                                    54
     8 |                                                     36
    16 |                                                      7
    32 |                                                      0
    64 |                                                      0
       ~
  1024 |                                                      0
  2048 |                                                      0
  4096 |                                                      1
  8192 |                                                      1
 16384 |                                                      2
 32768 |                                                      0
 65536 |                                                      0
131072 |                                                      1
262144 |                                                      0
524288 |                                                      0

Signed-off-by: Glauber Costa <glauber@scylladb.com>
CC: Jens Axboe <axboe@kernel.dk>
CC: linux-block@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Glauber Costa <glauber@scylladb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 block/cfq-iosched.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -3042,7 +3042,6 @@ static struct request *cfq_check_fifo(st
 	if (ktime_get_ns() < rq->fifo_time)
 		rq = NULL;
 
-	cfq_log_cfqq(cfqq->cfqd, cfqq, "fifo=%p", rq);
 	return rq;
 }
 
@@ -3420,6 +3419,9 @@ static bool cfq_may_dispatch(struct cfq_
 {
 	unsigned int max_dispatch;
 
+	if (cfq_cfqq_must_dispatch(cfqq))
+		return true;
+
 	/*
 	 * Drain async requests before we start sync IO
 	 */
@@ -3511,15 +3513,20 @@ static bool cfq_dispatch_request(struct
 
 	BUG_ON(RB_EMPTY_ROOT(&cfqq->sort_list));
 
+	rq = cfq_check_fifo(cfqq);
+	if (rq)
+		cfq_mark_cfqq_must_dispatch(cfqq);
+
 	if (!cfq_may_dispatch(cfqd, cfqq))
 		return false;
 
 	/*
 	 * follow expired path, else get first next available
 	 */
-	rq = cfq_check_fifo(cfqq);
 	if (!rq)
 		rq = cfqq->next_rq;
+	else
+		cfq_log_cfqq(cfqq->cfqd, cfqq, "fifo=%p", rq);
 
 	/*
 	 * insert request into driver dispatch list
@@ -3989,7 +3996,7 @@ cfq_should_preempt(struct cfq_data *cfqd
 	 * if the new request is sync, but the currently running queue is
 	 * not, let the sync request have priority.
 	 */
-	if (rq_is_sync(rq) && !cfq_cfqq_sync(cfqq))
+	if (rq_is_sync(rq) && !cfq_cfqq_sync(cfqq) && !cfq_cfqq_must_dispatch(cfqq))
 		return true;
 
 	/*

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

* [PATCH 4.8 57/57] cfq: fix starvation of asynchronous writes
@ 2016-10-21  9:18     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-21  9:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Glauber Costa, Jens Axboe,
	linux-block, Jens Axboe

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

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

From: Glauber Costa <glauber@scylladb.com>

commit 3932a86b4b9d1f0b049d64d4591ce58ad18b44ec upstream.

While debugging timeouts happening in my application workload (ScyllaDB), I have
observed calls to open() taking a long time, ranging everywhere from 2 seconds -
the first ones that are enough to time out my application - to more than 30
seconds.

The problem seems to happen because XFS may block on pending metadata updates
under certain circumnstances, and that's confirmed with the following backtrace
taken by the offcputime tool (iovisor/bcc):

    ffffffffb90c57b1 finish_task_switch
    ffffffffb97dffb5 schedule
    ffffffffb97e310c schedule_timeout
    ffffffffb97e1f12 __down
    ffffffffb90ea821 down
    ffffffffc046a9dc xfs_buf_lock
    ffffffffc046abfb _xfs_buf_find
    ffffffffc046ae4a xfs_buf_get_map
    ffffffffc046babd xfs_buf_read_map
    ffffffffc0499931 xfs_trans_read_buf_map
    ffffffffc044a561 xfs_da_read_buf
    ffffffffc0451390 xfs_dir3_leaf_read.constprop.16
    ffffffffc0452b90 xfs_dir2_leaf_lookup_int
    ffffffffc0452e0f xfs_dir2_leaf_lookup
    ffffffffc044d9d3 xfs_dir_lookup
    ffffffffc047d1d9 xfs_lookup
    ffffffffc0479e53 xfs_vn_lookup
    ffffffffb925347a path_openat
    ffffffffb9254a71 do_filp_open
    ffffffffb9242a94 do_sys_open
    ffffffffb9242b9e sys_open
    ffffffffb97e42b2 entry_SYSCALL_64_fastpath
    00007fb0698162ed [unknown]

Inspecting my run with blktrace, I can see that the xfsaild kthread exhibit very
high "Dispatch wait" times, on the dozens of seconds range and consistent with
the open() times I have saw in that run.

Still from the blktrace output, we can after searching a bit, identify the
request that wasn't dispatched:

  8,0   11      152    81.092472813   804  A  WM 141698288 + 8 <- (8,1) 141696240
  8,0   11      153    81.092472889   804  Q  WM 141698288 + 8 [xfsaild/sda1]
  8,0   11      154    81.092473207   804  G  WM 141698288 + 8 [xfsaild/sda1]
  8,0   11      206    81.092496118   804  I  WM 141698288 + 8 (   22911) [xfsaild/sda1]
  <==== 'I' means Inserted (into the IO scheduler) ===================================>
  8,0    0   289372    96.718761435     0  D  WM 141698288 + 8 (15626265317) [swapper/0]
  <==== Only 15s later the CFQ scheduler dispatches the request ======================>

As we can see above, in this particular example CFQ took 15 seconds to dispatch
this request. Going back to the full trace, we can see that the xfsaild queue
had plenty of opportunity to run, and it was selected as the active queue many
times. It would just always be preempted by something else (example):

  8,0    1        0    81.117912979     0  m   N cfq1618SN / insert_request
  8,0    1        0    81.117913419     0  m   N cfq1618SN / add_to_rr
  8,0    1        0    81.117914044     0  m   N cfq1618SN / preempt
  8,0    1        0    81.117914398     0  m   N cfq767A  / slice expired t=1
  8,0    1        0    81.117914755     0  m   N cfq767A  / resid=40
  8,0    1        0    81.117915340     0  m   N / served: vt=1948520448 min_vt=1948520448
  8,0    1        0    81.117915858     0  m   N cfq767A  / sl_used=1 disp=0 charge=0 iops=1 sect=0

where cfq767 is the xfsaild queue and cfq1618 corresponds to one of the ScyllaDB
IO dispatchers.

The requests preempting the xfsaild queue are synchronous requests. That's a
characteristic of ScyllaDB workloads, as we only ever issue O_DIRECT requests.
While it can be argued that preempting ASYNC requests in favor of SYNC is part
of the CFQ logic, I don't believe that doing so for 15+ seconds is anyone's
goal.

Moreover, unless I am misunderstanding something, that breaks the expectation
set by the "fifo_expire_async" tunable, which in my system is set to the
default.

Looking at the code, it seems to me that the issue is that after we make
an async queue active, there is no guarantee that it will execute any request.

When the queue itself tests if it cfq_may_dispatch() it can bail if it sees SYNC
requests in flight. An incoming request from another queue can also preempt it
in such situation before we have the chance to execute anything (as seen in the
trace above).

This patch sets the must_dispatch flag if we notice that we have requests
that are already fifo_expired. This flag is always cleared after
cfq_dispatch_request() returns from cfq_dispatch_requests(), so it won't pin
the queue for subsequent requests (unless they are themselves expired)

Care is taken during preempt to still allow rt requests to preempt us
regardless.

Testing my workload with this patch applied produces much better results.
>>From the application side I see no timeouts, and the open() latency histogram
generated by systemtap looks much better, with the worst outlier at 131ms:

Latency histogram of xfs_buf_lock acquisition (microseconds):
 value |-------------------------------------------------- count
     0 |                                                     11
     1 |@@@@                                                161
     2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  1966
     4 |@                                                    54
     8 |                                                     36
    16 |                                                      7
    32 |                                                      0
    64 |                                                      0
       ~
  1024 |                                                      0
  2048 |                                                      0
  4096 |                                                      1
  8192 |                                                      1
 16384 |                                                      2
 32768 |                                                      0
 65536 |                                                      0
131072 |                                                      1
262144 |                                                      0
524288 |                                                      0

Signed-off-by: Glauber Costa <glauber@scylladb.com>
CC: Jens Axboe <axboe@kernel.dk>
CC: linux-block@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Glauber Costa <glauber@scylladb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 block/cfq-iosched.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -3042,7 +3042,6 @@ static struct request *cfq_check_fifo(st
 	if (ktime_get_ns() < rq->fifo_time)
 		rq = NULL;
 
-	cfq_log_cfqq(cfqq->cfqd, cfqq, "fifo=%p", rq);
 	return rq;
 }
 
@@ -3420,6 +3419,9 @@ static bool cfq_may_dispatch(struct cfq_
 {
 	unsigned int max_dispatch;
 
+	if (cfq_cfqq_must_dispatch(cfqq))
+		return true;
+
 	/*
 	 * Drain async requests before we start sync IO
 	 */
@@ -3511,15 +3513,20 @@ static bool cfq_dispatch_request(struct
 
 	BUG_ON(RB_EMPTY_ROOT(&cfqq->sort_list));
 
+	rq = cfq_check_fifo(cfqq);
+	if (rq)
+		cfq_mark_cfqq_must_dispatch(cfqq);
+
 	if (!cfq_may_dispatch(cfqd, cfqq))
 		return false;
 
 	/*
 	 * follow expired path, else get first next available
 	 */
-	rq = cfq_check_fifo(cfqq);
 	if (!rq)
 		rq = cfqq->next_rq;
+	else
+		cfq_log_cfqq(cfqq->cfqd, cfqq, "fifo=%p", rq);
 
 	/*
 	 * insert request into driver dispatch list
@@ -3989,7 +3996,7 @@ cfq_should_preempt(struct cfq_data *cfqd
 	 * if the new request is sync, but the currently running queue is
 	 * not, let the sync request have priority.
 	 */
-	if (rq_is_sync(rq) && !cfq_cfqq_sync(cfqq))
+	if (rq_is_sync(rq) && !cfq_cfqq_sync(cfqq) && !cfq_cfqq_must_dispatch(cfqq))
 		return true;
 
 	/*



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

* Re: [PATCH 4.8 00/57] 4.8.4-stable review
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (47 preceding siblings ...)
  2016-10-21  9:18     ` Greg Kroah-Hartman
@ 2016-10-21 15:46   ` Shuah Khan
  2016-10-22  9:56     ` Greg Kroah-Hartman
  2016-10-21 19:17   ` Guenter Roeck
  2016-10-21 21:02   ` Rafael J. Wysocki
  50 siblings, 1 reply; 57+ messages in thread
From: Shuah Khan @ 2016-10-21 15:46 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: torvalds, akpm, linux, patches, ben.hutchings, stable, Shuah Khan

On 10/21/2016 03:17 AM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.8.4 release.
> There are 57 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 Sun Oct 23 09:14:19 UTC 2016.
> 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/v4.x/stable-review/patch-4.8.4-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-4.8.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

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

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America(Silicon Valley)
shuah.kh@samsung.com

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

* Re: [PATCH 4.8 00/57] 4.8.4-stable review
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (48 preceding siblings ...)
  2016-10-21 15:46   ` [PATCH 4.8 00/57] 4.8.4-stable review Shuah Khan
@ 2016-10-21 19:17   ` Guenter Roeck
  2016-10-22  9:56     ` Greg Kroah-Hartman
  2016-10-21 21:02   ` Rafael J. Wysocki
  50 siblings, 1 reply; 57+ messages in thread
From: Guenter Roeck @ 2016-10-21 19:17 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, torvalds, akpm, shuah.kh, patches, ben.hutchings, stable

On Fri, Oct 21, 2016 at 11:17:23AM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.8.4 release.
> There are 57 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 Sun Oct 23 09:14:19 UTC 2016.
> Anything received after that time might be too late.
> 
Build results:
        total: 149 pass: 149 fail: 0
Qemu test results:
        total: 110 pass: 110 fail: 0
		                        
Details are available at http://kerneltests.org/builders.

Guenter         

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

* Re: [PATCH 4.8 00/57] 4.8.4-stable review
  2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
                     ` (49 preceding siblings ...)
  2016-10-21 19:17   ` Guenter Roeck
@ 2016-10-21 21:02   ` Rafael J. Wysocki
  2016-10-22  9:58     ` Greg Kroah-Hartman
  50 siblings, 1 reply; 57+ messages in thread
From: Rafael J. Wysocki @ 2016-10-21 21:02 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, torvalds, akpm, linux, shuah.kh, patches,
	ben.hutchings, stable

On Friday, October 21, 2016 11:17:23 AM Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.8.4 release.
> There are 57 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 Sun Oct 23 09:14:19 UTC 2016.
> Anything received after that time might be too late.

Please also add commit c6fe46a79ecd "cpufreq: fix overflow in
cpufreq_table_find_index_dl()" to this series.

This is needed to fix a regression in an earlier somewhat broken fix that went
into previous 4.8.y unfortunately.

Thanks,
Rafael

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

* Re: [PATCH 4.8 00/57] 4.8.4-stable review
  2016-10-21 19:17   ` Guenter Roeck
@ 2016-10-22  9:56     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-22  9:56 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-kernel, torvalds, akpm, shuah.kh, patches, ben.hutchings, stable

On Fri, Oct 21, 2016 at 12:17:48PM -0700, Guenter Roeck wrote:
> On Fri, Oct 21, 2016 at 11:17:23AM +0200, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.8.4 release.
> > There are 57 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 Sun Oct 23 09:14:19 UTC 2016.
> > Anything received after that time might be too late.
> > 
> Build results:
>         total: 149 pass: 149 fail: 0
> Qemu test results:
>         total: 110 pass: 110 fail: 0
> 		                        
> Details are available at http://kerneltests.org/builders.

Thanks for testing all of these and letting me know.

greg k-h

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

* Re: [PATCH 4.8 00/57] 4.8.4-stable review
  2016-10-21 15:46   ` [PATCH 4.8 00/57] 4.8.4-stable review Shuah Khan
@ 2016-10-22  9:56     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-22  9:56 UTC (permalink / raw)
  To: Shuah Khan
  Cc: linux-kernel, torvalds, akpm, linux, patches, ben.hutchings, stable

On Fri, Oct 21, 2016 at 09:46:15AM -0600, Shuah Khan wrote:
> On 10/21/2016 03:17 AM, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.8.4 release.
> > There are 57 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 Sun Oct 23 09:14:19 UTC 2016.
> > 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/v4.x/stable-review/patch-4.8.4-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-4.8.y
> > and the diffstat can be found below.
> > 
> > thanks,
> > 
> > greg k-h
> > 
> 
> Compiled and booted on my test system. No dmesg regressions.

Thanks again for testing all of these kernels and letting me know.

greg k-h

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

* Re: [PATCH 4.8 00/57] 4.8.4-stable review
  2016-10-21 21:02   ` Rafael J. Wysocki
@ 2016-10-22  9:58     ` Greg Kroah-Hartman
  2016-10-23  0:04       ` Rafael J. Wysocki
  0 siblings, 1 reply; 57+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-22  9:58 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-kernel, torvalds, akpm, linux, shuah.kh, patches,
	ben.hutchings, stable

On Fri, Oct 21, 2016 at 11:02:13PM +0200, Rafael J. Wysocki wrote:
> On Friday, October 21, 2016 11:17:23 AM Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.8.4 release.
> > There are 57 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 Sun Oct 23 09:14:19 UTC 2016.
> > Anything received after that time might be too late.
> 
> Please also add commit c6fe46a79ecd "cpufreq: fix overflow in
> cpufreq_table_find_index_dl()" to this series.
> 
> This is needed to fix a regression in an earlier somewhat broken fix that went
> into previous 4.8.y unfortunately.

Really?  It doesn't apply to 4.8-stable at all.  I haven't applied
899bb6642f2a2f2cd3f77abd6c5a14550e3b37e6 to the 4.8-stable tree yet, so
why should I add it at this point in time?

confused,

greg k-h

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

* Re: [PATCH 4.8 00/57] 4.8.4-stable review
  2016-10-22  9:58     ` Greg Kroah-Hartman
@ 2016-10-23  0:04       ` Rafael J. Wysocki
  0 siblings, 0 replies; 57+ messages in thread
From: Rafael J. Wysocki @ 2016-10-23  0:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, torvalds, akpm, linux, shuah.kh, patches,
	ben.hutchings, stable

On Saturday, October 22, 2016 11:58:51 AM Greg Kroah-Hartman wrote:
> On Fri, Oct 21, 2016 at 11:02:13PM +0200, Rafael J. Wysocki wrote:
> > On Friday, October 21, 2016 11:17:23 AM Greg Kroah-Hartman wrote:
> > > This is the start of the stable review cycle for the 4.8.4 release.
> > > There are 57 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 Sun Oct 23 09:14:19 UTC 2016.
> > > Anything received after that time might be too late.
> > 
> > Please also add commit c6fe46a79ecd "cpufreq: fix overflow in
> > cpufreq_table_find_index_dl()" to this series.
> > 
> > This is needed to fix a regression in an earlier somewhat broken fix that went
> > into previous 4.8.y unfortunately.
> 
> Really?  It doesn't apply to 4.8-stable at all.  I haven't applied
> 899bb6642f2a2f2cd3f77abd6c5a14550e3b37e6 to the 4.8-stable tree yet,

OK

In that case please make sure that it doesn't go in without c6fe46a79ecd.

> so why should I add it at this point in time?

Clearly, no need. :-)

Thanks,
Rafael

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

end of thread, other threads:[~2016-10-22 23:57 UTC | newest]

Thread overview: 57+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20161021092156uscas1p2448161ce8162a8e99cfe189d1b435176@uscas1p2.samsung.com>
2016-10-21  9:17 ` [PATCH 4.8 00/57] 4.8.4-stable review Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 03/57] serial: 8250_dw: Check the data->pclk when get apb_pclk Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 04/57] serial: 8250_port: fix runtime PM use in __do_stop_tx_rs485() Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 05/57] ARCv2: intc: Use kflag if STATUS32.IE must be reset Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 06/57] ARCv2: fix local_save_flags Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 07/57] debugfs: introduce a public file_operations accessor Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 08/57] b43: fix debugfs crash Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 09/57] b43legacy: " Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 10/57] carl9170: fix debugfs crashes Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 14/57] btrfs: assign error values to the correct bio structs Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 15/57] mei: amthif: fix deadlock in initialization during a reset Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 16/57] drivers: base: dma-mapping: page align the size when unmap_kernel_range Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 17/57] IB/hfi1: Fix defered ack race with qp destroy Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 18/57] clk: mvebu: fix setting unwanted flags in CP110 gate clock Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 19/57] clk: mvebu: dynamically allocate resources in Armada CP110 system controller Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 20/57] fuse: listxattr: verify xattr list Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 22/57] fuse: fix killing s[ug]id in setattr Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 23/57] mm: filemap: fix mapping->nrpages double accounting in fuse Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 24/57] i40e: avoid NULL pointer dereference and recursive errors on early PCI error Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 25/57] xfs: change mailing list address Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 26/57] mm: filemap: dont plant shadow entries without radix tree node Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 27/57] brcmfmac: fix pmksa->bssid usage Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 30/57] ASoC: nau8825: fix bug in FLL parameter Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 31/57] ASoC: Intel: Atom: add a missing star in a memcpy call Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 32/57] reiserfs: Unlock superblock before calling reiserfs_quota_on_mount() Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 33/57] async_pq_val: fix DMA memory leak Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 34/57] autofs: Fix automounts by using current_real_cred()->uid Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 35/57] scsi: arcmsr: Buffer overflow in arcmsr_iop_message_xfer() Greg Kroah-Hartman
2016-10-21  9:17   ` [PATCH 4.8 36/57] scsi: arcmsr: Simplify user_len checking Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 37/57] scsi: ibmvfc: Fix I/O hang when port is not mapped Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 38/57] ipc/sem.c: fix complex_count vs. simple op race Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 39/57] mm/hugetlb: fix memory offline with hugepage size > memory block size Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 40/57] vfs,mm: fix a dead loop in truncate_inode_pages_range() Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 41/57] jbd2: fix lockdep annotation in add_transaction_credits() Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 42/57] ext4: enforce online defrag restriction for encrypted files Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 43/57] ext4: reinforce check of i_dtime when clearing high fields of uid and gid Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 45/57] ext4: fix memory leak in ext4_insert_range() Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 46/57] ext4: fix memory leak when symlink decryption fails Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 47/57] ext4: allow DAX writeback for hole punch Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 48/57] ext4: release bh in make_indexed_dir Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 49/57] ext4: unmap metadata when zeroing blocks Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 50/57] crypto: ghash-generic - move common definitions to a new header file Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 51/57] crypto: vmx - Fix memory corruption caused by p8_ghash Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 52/57] dlm: free workqueues after the connections Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 53/57] vfs: move permission checking into notify_change() for utimes(NULL) Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 54/57] cachefiles: Fix attempt to read i_blocks after deleting file [ver #2] Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 55/57] drm: virtio: reinstate drm_virtio_set_busid() Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 56/57] acpi, nfit: check for the correct event code in notifications Greg Kroah-Hartman
2016-10-21  9:18   ` [PATCH 4.8 57/57] cfq: fix starvation of asynchronous writes Greg Kroah-Hartman
2016-10-21  9:18     ` Greg Kroah-Hartman
2016-10-21 15:46   ` [PATCH 4.8 00/57] 4.8.4-stable review Shuah Khan
2016-10-22  9:56     ` Greg Kroah-Hartman
2016-10-21 19:17   ` Guenter Roeck
2016-10-22  9:56     ` Greg Kroah-Hartman
2016-10-21 21:02   ` Rafael J. Wysocki
2016-10-22  9:58     ` Greg Kroah-Hartman
2016-10-23  0:04       ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.