All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4.12 00/10] 4.12.2-stable review
@ 2017-07-13 15:40 Greg Kroah-Hartman
  2017-07-13 15:40 ` [PATCH 4.12 01/10] mqueue: fix a use-after-free in sys_mq_notify() Greg Kroah-Hartman
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-13 15:40 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, torvalds, akpm, linux, shuahkh, patches,
	ben.hutchings, stable

This is the start of the stable review cycle for the 4.12.2 release.
There are 10 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 Sat Jul 15 15:40:02 UTC 2017.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:
	kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.12.2-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.12.y
and the diffstat can be found below.

thanks,

greg k-h

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

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

Mikulas Patocka <mpatocka@redhat.com>
    x86/mm/pat: Don't report PAT on CPUs that don't support it

Chao Yu <yuchao0@huawei.com>
    ext4: check return value of kstrtoull correctly in reserved_clusters_store

Jason A. Donenfeld <Jason@zx2c4.com>
    crypto: rsa-pkcs1pad - use constant time memory comparison for MACs

Horia Geantă <horia.geanta@nxp.com>
    crypto: caam - fix gfp allocation flags (part I)

Ian Abbott <abbotti@mev.co.uk>
    staging: comedi: fix clean-up of comedi_class in comedi_init()

Malcolm Priestley <tvboxspy@gmail.com>
    staging: vt6556: vnt_start Fix missing call to vnt_key_init_table.

Kirill Tkhai <ktkhai@virtuozzo.com>
    locking/rwsem-spinlock: Fix EINTR branch in __down_write_common()

Eric W. Biederman <ebiederm@xmission.com>
    proc: Fix proc_sys_prune_dcache to hold a sb reference

Peter Senna Tschudin <peter.senna@collabora.com>
    imx-serial: RX DMA startup latency

Cong Wang <xiyou.wangcong@gmail.com>
    mqueue: fix a use-after-free in sys_mq_notify()


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

Diffstat:

 Makefile                             |  4 ++--
 arch/x86/include/asm/pat.h           |  1 +
 arch/x86/kernel/setup.c              |  7 ++++++
 arch/x86/mm/pat.c                    | 28 ++++++++++-------------
 crypto/rsa-pkcs1pad.c                |  2 +-
 drivers/crypto/caam/caamalg.c        |  3 +--
 drivers/staging/comedi/comedi_fops.c |  1 +
 drivers/staging/vt6656/main_usb.c    |  3 +++
 drivers/tty/serial/imx.c             | 26 +++++-----------------
 fs/ext4/sysfs.c                      |  2 +-
 fs/proc/internal.h                   |  2 +-
 fs/proc/proc_sysctl.c                | 43 +++++++++++++++++++++++++-----------
 include/linux/sysctl.h               |  2 +-
 ipc/mqueue.c                         |  4 +++-
 kernel/locking/rwsem-spinlock.c      |  4 ++--
 15 files changed, 71 insertions(+), 61 deletions(-)

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

* [PATCH 4.12 01/10] mqueue: fix a use-after-free in sys_mq_notify()
  2017-07-13 15:40 [PATCH 4.12 00/10] 4.12.2-stable review Greg Kroah-Hartman
@ 2017-07-13 15:40 ` Greg Kroah-Hartman
  2017-07-13 15:40 ` [PATCH 4.12 02/10] imx-serial: RX DMA startup latency Greg Kroah-Hartman
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-13 15:40 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, GeneBlue, Cong Wang, Andrew Morton,
	Manfred Spraul, Linus Torvalds

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

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

From: Cong Wang <xiyou.wangcong@gmail.com>

commit f991af3daabaecff34684fd51fac80319d1baad1 upstream.

The retry logic for netlink_attachskb() inside sys_mq_notify()
is nasty and vulnerable:

1) The sock refcnt is already released when retry is needed
2) The fd is controllable by user-space because we already
   release the file refcnt

so we when retry but the fd has been just closed by user-space
during this small window, we end up calling netlink_detachskb()
on the error path which releases the sock again, later when
the user-space closes this socket a use-after-free could be
triggered.

Setting 'sock' to NULL here should be sufficient to fix it.

Reported-by: GeneBlue <geneblue.mail@gmail.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 ipc/mqueue.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -1253,8 +1253,10 @@ retry:
 
 			timeo = MAX_SCHEDULE_TIMEOUT;
 			ret = netlink_attachskb(sock, nc, &timeo, NULL);
-			if (ret == 1)
+			if (ret == 1) {
+				sock = NULL;
 				goto retry;
+			}
 			if (ret) {
 				sock = NULL;
 				nc = NULL;

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

* [PATCH 4.12 02/10] imx-serial: RX DMA startup latency
  2017-07-13 15:40 [PATCH 4.12 00/10] 4.12.2-stable review Greg Kroah-Hartman
  2017-07-13 15:40 ` [PATCH 4.12 01/10] mqueue: fix a use-after-free in sys_mq_notify() Greg Kroah-Hartman
@ 2017-07-13 15:40 ` Greg Kroah-Hartman
  2017-07-13 15:40 ` [PATCH 4.12 03/10] proc: Fix proc_sys_prune_dcache to hold a sb reference Greg Kroah-Hartman
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-13 15:40 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Peter Senna Tschudin, Sascha Hauer,
	Fabio Estevam

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

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

From: Peter Senna Tschudin <peter.senna@collabora.com>

commit 4dec2f119e86f9c91e60cdd8f0cc057452e331a9 upstream.

18a4208 introduced a change to reduce the RX DMA latency on the first reception
when the serial port was opened for reading. However it was claiming a hardirq
unsafe lock after a hardirq safe lock which is not allowed and causes lockdep
to complain verbosely.

This patch changes the code to always start RX DMA earlier, instead of
relying on the flags used to open the serial port removing the code that
was looking for the serial file flags.

Signed-off-by: Peter Senna Tschudin <peter.senna@collabora.com>
Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/tty/serial/imx.c |   26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1340,29 +1340,13 @@ static int imx_startup(struct uart_port
 	imx_enable_ms(&sport->port);
 
 	/*
-	 * If the serial port is opened for reading start RX DMA immediately
-	 * instead of waiting for RX FIFO interrupts. In our iMX53 the average
-	 * delay for the first reception dropped from approximately 35000
-	 * microseconds to 1000 microseconds.
+	 * Start RX DMA immediately instead of waiting for RX FIFO interrupts.
+	 * In our iMX53 the average delay for the first reception dropped from
+	 * approximately 35000 microseconds to 1000 microseconds.
 	 */
 	if (sport->dma_is_enabled) {
-		struct tty_struct *tty = sport->port.state->port.tty;
-		struct tty_file_private *file_priv;
-		int readcnt = 0;
-
-		spin_lock(&tty->files_lock);
-
-		if (!list_empty(&tty->tty_files))
-			list_for_each_entry(file_priv, &tty->tty_files, list)
-				if (!(file_priv->file->f_flags & O_WRONLY))
-					readcnt++;
-
-		spin_unlock(&tty->files_lock);
-
-		if (readcnt > 0) {
-			imx_disable_rx_int(sport);
-			start_rx_dma(sport);
-		}
+		imx_disable_rx_int(sport);
+		start_rx_dma(sport);
 	}
 
 	spin_unlock_irqrestore(&sport->port.lock, flags);

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

* [PATCH 4.12 03/10] proc: Fix proc_sys_prune_dcache to hold a sb reference
  2017-07-13 15:40 [PATCH 4.12 00/10] 4.12.2-stable review Greg Kroah-Hartman
  2017-07-13 15:40 ` [PATCH 4.12 01/10] mqueue: fix a use-after-free in sys_mq_notify() Greg Kroah-Hartman
  2017-07-13 15:40 ` [PATCH 4.12 02/10] imx-serial: RX DMA startup latency Greg Kroah-Hartman
@ 2017-07-13 15:40 ` Greg Kroah-Hartman
  2017-07-13 15:40 ` [PATCH 4.12 04/10] locking/rwsem-spinlock: Fix EINTR branch in __down_write_common() Greg Kroah-Hartman
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-13 15:40 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andrei Vagin, Andrei Vagin,
	Eric W. Biederman

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

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

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

commit 2fd1d2c4ceb2248a727696962cf3370dc9f5a0a4 upstream.

Andrei Vagin writes:
FYI: This bug has been reproduced on 4.11.7
> BUG: Dentry ffff895a3dd01240{i=4e7c09a,n=lo}  still in use (1) [unmount of proc proc]
> ------------[ cut here ]------------
> WARNING: CPU: 1 PID: 13588 at fs/dcache.c:1445 umount_check+0x6e/0x80
> CPU: 1 PID: 13588 Comm: kworker/1:1 Not tainted 4.11.7-200.fc25.x86_64 #1
> Hardware name: CompuLab sbc-flt1/fitlet, BIOS SBCFLT_0.08.04 06/27/2015
> Workqueue: events proc_cleanup_work
> Call Trace:
>  dump_stack+0x63/0x86
>  __warn+0xcb/0xf0
>  warn_slowpath_null+0x1d/0x20
>  umount_check+0x6e/0x80
>  d_walk+0xc6/0x270
>  ? dentry_free+0x80/0x80
>  do_one_tree+0x26/0x40
>  shrink_dcache_for_umount+0x2d/0x90
>  generic_shutdown_super+0x1f/0xf0
>  kill_anon_super+0x12/0x20
>  proc_kill_sb+0x40/0x50
>  deactivate_locked_super+0x43/0x70
>  deactivate_super+0x5a/0x60
>  cleanup_mnt+0x3f/0x90
>  mntput_no_expire+0x13b/0x190
>  kern_unmount+0x3e/0x50
>  pid_ns_release_proc+0x15/0x20
>  proc_cleanup_work+0x15/0x20
>  process_one_work+0x197/0x450
>  worker_thread+0x4e/0x4a0
>  kthread+0x109/0x140
>  ? process_one_work+0x450/0x450
>  ? kthread_park+0x90/0x90
>  ret_from_fork+0x2c/0x40
> ---[ end trace e1c109611e5d0b41 ]---
> VFS: Busy inodes after unmount of proc. Self-destruct in 5 seconds.  Have a nice day...
> BUG: unable to handle kernel NULL pointer dereference at           (null)
> IP: _raw_spin_lock+0xc/0x30
> PGD 0

Fix this by taking a reference to the super block in proc_sys_prune_dcache.

The superblock reference is the core of the fix however the sysctl_inodes
list is converted to a hlist so that hlist_del_init_rcu may be used.  This
allows proc_sys_prune_dache to remove inodes the sysctl_inodes list, while
not causing problems for proc_sys_evict_inode when if it later choses to
remove the inode from the sysctl_inodes list.  Removing inodes from the
sysctl_inodes list allows proc_sys_prune_dcache to have a progress
guarantee, while still being able to drop all locks.  The fact that
head->unregistering is set in start_unregistering ensures that no more
inodes will be added to the the sysctl_inodes list.

Previously the code did a dance where it delayed calling iput until the
next entry in the list was being considered to ensure the inode remained on
the sysctl_inodes list until the next entry was walked to.  The structure
of the loop in this patch does not need that so is much easier to
understand and maintain.

Reported-by: Andrei Vagin <avagin@gmail.com>
Tested-by: Andrei Vagin <avagin@openvz.org>
Fixes: ace0c791e6c3 ("proc/sysctl: Don't grab i_lock under sysctl_lock.")
Fixes: d6cffbbe9a7e ("proc/sysctl: prune stale dentries during unregistering")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/proc/internal.h     |    2 +-
 fs/proc/proc_sysctl.c  |   43 ++++++++++++++++++++++++++++++-------------
 include/linux/sysctl.h |    2 +-
 3 files changed, 32 insertions(+), 15 deletions(-)

--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -67,7 +67,7 @@ struct proc_inode {
 	struct proc_dir_entry *pde;
 	struct ctl_table_header *sysctl;
 	struct ctl_table *sysctl_entry;
-	struct list_head sysctl_inodes;
+	struct hlist_node sysctl_inodes;
 	const struct proc_ns_operations *ns_ops;
 	struct inode vfs_inode;
 };
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -191,7 +191,7 @@ static void init_header(struct ctl_table
 	head->set = set;
 	head->parent = NULL;
 	head->node = node;
-	INIT_LIST_HEAD(&head->inodes);
+	INIT_HLIST_HEAD(&head->inodes);
 	if (node) {
 		struct ctl_table *entry;
 		for (entry = table; entry->procname; entry++, node++)
@@ -261,25 +261,42 @@ static void unuse_table(struct ctl_table
 			complete(p->unregistering);
 }
 
-/* called under sysctl_lock */
 static void proc_sys_prune_dcache(struct ctl_table_header *head)
 {
-	struct inode *inode, *prev = NULL;
+	struct inode *inode;
 	struct proc_inode *ei;
+	struct hlist_node *node;
+	struct super_block *sb;
 
 	rcu_read_lock();
-	list_for_each_entry_rcu(ei, &head->inodes, sysctl_inodes) {
-		inode = igrab(&ei->vfs_inode);
-		if (inode) {
-			rcu_read_unlock();
-			iput(prev);
-			prev = inode;
-			d_prune_aliases(inode);
+	for (;;) {
+		node = hlist_first_rcu(&head->inodes);
+		if (!node)
+			break;
+		ei = hlist_entry(node, struct proc_inode, sysctl_inodes);
+		spin_lock(&sysctl_lock);
+		hlist_del_init_rcu(&ei->sysctl_inodes);
+		spin_unlock(&sysctl_lock);
+
+		inode = &ei->vfs_inode;
+		sb = inode->i_sb;
+		if (!atomic_inc_not_zero(&sb->s_active))
+			continue;
+		inode = igrab(inode);
+		rcu_read_unlock();
+		if (unlikely(!inode)) {
+			deactivate_super(sb);
 			rcu_read_lock();
+			continue;
 		}
+
+		d_prune_aliases(inode);
+		iput(inode);
+		deactivate_super(sb);
+
+		rcu_read_lock();
 	}
 	rcu_read_unlock();
-	iput(prev);
 }
 
 /* called under sysctl_lock, will reacquire if has to wait */
@@ -461,7 +478,7 @@ static struct inode *proc_sys_make_inode
 	}
 	ei->sysctl = head;
 	ei->sysctl_entry = table;
-	list_add_rcu(&ei->sysctl_inodes, &head->inodes);
+	hlist_add_head_rcu(&ei->sysctl_inodes, &head->inodes);
 	head->count++;
 	spin_unlock(&sysctl_lock);
 
@@ -489,7 +506,7 @@ out:
 void proc_sys_evict_inode(struct inode *inode, struct ctl_table_header *head)
 {
 	spin_lock(&sysctl_lock);
-	list_del_rcu(&PROC_I(inode)->sysctl_inodes);
+	hlist_del_init_rcu(&PROC_I(inode)->sysctl_inodes);
 	if (!--head->count)
 		kfree_rcu(head, rcu);
 	spin_unlock(&sysctl_lock);
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -143,7 +143,7 @@ struct ctl_table_header
 	struct ctl_table_set *set;
 	struct ctl_dir *parent;
 	struct ctl_node *node;
-	struct list_head inodes; /* head for proc_inode->sysctl_inodes */
+	struct hlist_head inodes; /* head for proc_inode->sysctl_inodes */
 };
 
 struct ctl_dir {

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

* [PATCH 4.12 04/10] locking/rwsem-spinlock: Fix EINTR branch in __down_write_common()
  2017-07-13 15:40 [PATCH 4.12 00/10] 4.12.2-stable review Greg Kroah-Hartman
                   ` (2 preceding siblings ...)
  2017-07-13 15:40 ` [PATCH 4.12 03/10] proc: Fix proc_sys_prune_dcache to hold a sb reference Greg Kroah-Hartman
@ 2017-07-13 15:40 ` Greg Kroah-Hartman
  2017-07-13 15:40 ` [PATCH 4.12 05/10] staging: vt6556: vnt_start Fix missing call to vnt_key_init_table Greg Kroah-Hartman
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-13 15:40 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Kirill Tkhai, Peter Zijlstra,
	Linus Torvalds, Niklas Cassel, Peter Zijlstra (Intel),
	Thomas Gleixner, Ingo Molnar

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

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

From: Kirill Tkhai <ktkhai@virtuozzo.com>

commit a0c4acd2c220376b4e9690e75782d0c0afdaab9f upstream.

If a writer could been woken up, the above branch

	if (sem->count == 0)
		break;

would have moved us to taking the sem. So, it's
not the time to wake a writer now, and only readers
are allowed now. Thus, 0 must be passed to __rwsem_do_wake().

Next, __rwsem_do_wake() wakes readers unconditionally.
But we mustn't do that if the sem is owned by writer
in the moment. Otherwise, writer and reader own the sem
the same time, which leads to memory corruption in
callers.

rwsem-xadd.c does not need that, as:

  1) the similar check is made lockless there,
  2) in __rwsem_mark_wake::try_reader_grant we test,

that sem is not owned by writer.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Niklas Cassel <niklas.cassel@axis.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 17fcbd590d0c "locking/rwsem: Fix down_write_killable() for CONFIG_RWSEM_GENERIC_SPINLOCK=y"
Link: http://lkml.kernel.org/r/149762063282.19811.9129615532201147826.stgit@localhost.localdomain
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/locking/rwsem-spinlock.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/kernel/locking/rwsem-spinlock.c
+++ b/kernel/locking/rwsem-spinlock.c
@@ -231,8 +231,8 @@ int __sched __down_write_common(struct r
 
 out_nolock:
 	list_del(&waiter.list);
-	if (!list_empty(&sem->wait_list))
-		__rwsem_do_wake(sem, 1);
+	if (!list_empty(&sem->wait_list) && sem->count >= 0)
+		__rwsem_do_wake(sem, 0);
 	raw_spin_unlock_irqrestore(&sem->wait_lock, flags);
 
 	return -EINTR;

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

* [PATCH 4.12 05/10] staging: vt6556: vnt_start Fix missing call to vnt_key_init_table.
  2017-07-13 15:40 [PATCH 4.12 00/10] 4.12.2-stable review Greg Kroah-Hartman
                   ` (3 preceding siblings ...)
  2017-07-13 15:40 ` [PATCH 4.12 04/10] locking/rwsem-spinlock: Fix EINTR branch in __down_write_common() Greg Kroah-Hartman
@ 2017-07-13 15:40 ` Greg Kroah-Hartman
  2017-07-13 15:40 ` [PATCH 4.12 06/10] staging: comedi: fix clean-up of comedi_class in comedi_init() Greg Kroah-Hartman
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-13 15:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Malcolm Priestley

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

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

From: Malcolm Priestley <tvboxspy@gmail.com>

commit dc32190f2cd41c7dba25363ea7d618d4f5172b4e upstream.

The key table is not intialized correctly without this call.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/staging/vt6656/main_usb.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -513,6 +513,9 @@ static int vnt_start(struct ieee80211_hw
 		goto free_all;
 	}
 
+	if (vnt_key_init_table(priv))
+		goto free_all;
+
 	priv->int_interval = 1;  /* bInterval is set to 1 */
 
 	vnt_int_start_interrupt(priv);

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

* [PATCH 4.12 06/10] staging: comedi: fix clean-up of comedi_class in comedi_init()
  2017-07-13 15:40 [PATCH 4.12 00/10] 4.12.2-stable review Greg Kroah-Hartman
                   ` (4 preceding siblings ...)
  2017-07-13 15:40 ` [PATCH 4.12 05/10] staging: vt6556: vnt_start Fix missing call to vnt_key_init_table Greg Kroah-Hartman
@ 2017-07-13 15:40 ` Greg Kroah-Hartman
  2017-07-13 15:40 ` [PATCH 4.12 09/10] ext4: check return value of kstrtoull correctly in reserved_clusters_store Greg Kroah-Hartman
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-13 15:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Ian Abbott

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

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

From: Ian Abbott <abbotti@mev.co.uk>

commit a9332e9ad09c2644c99058fcf6ae2f355e93ce74 upstream.

There is a clean-up bug in the core comedi module initialization
functions, `comedi_init()`.  If the `comedi_num_legacy_minors` module
parameter is non-zero (and valid), it creates that many "legacy" devices
and registers them in SysFS.  A failure causes the function to clean up
and return an error.  Unfortunately, it fails to destroy the "comedi"
class that was created earlier.  Fix it by adding a call to
`class_destroy(comedi_class)` at the appropriate place in the clean-up
sequence.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/staging/comedi/comedi_fops.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -2915,6 +2915,7 @@ static int __init comedi_init(void)
 		dev = comedi_alloc_board_minor(NULL);
 		if (IS_ERR(dev)) {
 			comedi_cleanup_board_minors();
+			class_destroy(comedi_class);
 			cdev_del(&comedi_cdev);
 			unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
 						 COMEDI_NUM_MINORS);

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

* [PATCH 4.12 09/10] ext4: check return value of kstrtoull correctly in reserved_clusters_store
  2017-07-13 15:40 [PATCH 4.12 00/10] 4.12.2-stable review Greg Kroah-Hartman
                   ` (5 preceding siblings ...)
  2017-07-13 15:40 ` [PATCH 4.12 06/10] staging: comedi: fix clean-up of comedi_class in comedi_init() Greg Kroah-Hartman
@ 2017-07-13 15:40 ` Greg Kroah-Hartman
  2017-07-13 15:40 ` [PATCH 4.12 10/10] x86/mm/pat: Dont report PAT on CPUs that dont support it Greg Kroah-Hartman
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-13 15:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Chao Yu, Miao Xie, Theodore Tso

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

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

From: Chao Yu <yuchao0@huawei.com>

commit 1ea1516fbbab2b30bf98c534ecaacba579a35208 upstream.

kstrtoull returns 0 on success, however, in reserved_clusters_store we
will return -EINVAL if kstrtoull returns 0, it makes us fail to update
reserved_clusters value through sysfs.

Fixes: 76d33bca5581b1dd5c3157fa168db849a784ada4
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Miao Xie <miaoxie@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -100,7 +100,7 @@ static ssize_t reserved_clusters_store(s
 	int ret;
 
 	ret = kstrtoull(skip_spaces(buf), 0, &val);
-	if (!ret || val >= clusters)
+	if (ret || val >= clusters)
 		return -EINVAL;
 
 	atomic64_set(&sbi->s_resv_clusters, val);

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

* [PATCH 4.12 10/10] x86/mm/pat: Dont report PAT on CPUs that dont support it
  2017-07-13 15:40 [PATCH 4.12 00/10] 4.12.2-stable review Greg Kroah-Hartman
                   ` (6 preceding siblings ...)
  2017-07-13 15:40 ` [PATCH 4.12 09/10] ext4: check return value of kstrtoull correctly in reserved_clusters_store Greg Kroah-Hartman
@ 2017-07-13 15:40 ` Greg Kroah-Hartman
  2017-07-14  2:08 ` [PATCH 4.12 00/10] 4.12.2-stable review Guenter Roeck
       [not found] ` <5967ef32.9386df0a.5bac9.3877@mx.google.com>
  9 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-13 15:40 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mikulas Patocka, Thomas Gleixner,
	Bernhard Held, Denys Vlasenko, Peter Zijlstra, Brian Gerst,
	Luis R. Rodriguez, Borislav Petkov, Andy Lutomirski,
	Josh Poimboeuf, Andrew Morton, Linus Torvalds

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

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

From: Mikulas Patocka <mpatocka@redhat.com>

commit 99c13b8c8896d7bcb92753bf0c63a8de4326e78d upstream.

The pat_enabled() logic is broken on CPUs which do not support PAT and
where the initialization code fails to call pat_init(). Due to that the
enabled flag stays true and pat_enabled() returns true wrongfully.

As a consequence the mappings, e.g. for Xorg, are set up with the wrong
caching mode and the required MTRR setups are omitted.

To cure this the following changes are required:

  1) Make pat_enabled() return true only if PAT initialization was
     invoked and successful.

  2) Invoke init_cache_modes() unconditionally in setup_arch() and
     remove the extra callsites in pat_disable() and the pat disabled
     code path in pat_init().

Also rename __pat_enabled to pat_disabled to reflect the real purpose of
this variable.

Fixes: 9cd25aac1f44 ("x86/mm/pat: Emulate PAT when it is disabled")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Bernhard Held <berny156@gmx.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: "Luis R. Rodriguez" <mcgrof@suse.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1707041749300.3456@file01.intranet.prod.int.rdu2.redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/include/asm/pat.h |    1 +
 arch/x86/kernel/setup.c    |    7 +++++++
 arch/x86/mm/pat.c          |   28 ++++++++++++----------------
 3 files changed, 20 insertions(+), 16 deletions(-)

--- a/arch/x86/include/asm/pat.h
+++ b/arch/x86/include/asm/pat.h
@@ -7,6 +7,7 @@
 bool pat_enabled(void);
 void pat_disable(const char *reason);
 extern void pat_init(void);
+extern void init_cache_modes(void);
 
 extern int reserve_memtype(u64 start, u64 end,
 		enum page_cache_mode req_pcm, enum page_cache_mode *ret_pcm);
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1076,6 +1076,13 @@ void __init setup_arch(char **cmdline_p)
 	max_possible_pfn = max_pfn;
 
 	/*
+	 * This call is required when the CPU does not support PAT. If
+	 * mtrr_bp_init() invoked it already via pat_init() the call has no
+	 * effect.
+	 */
+	init_cache_modes();
+
+	/*
 	 * Define random base addresses for memory sections after max_pfn is
 	 * defined and before each memory section base is used.
 	 */
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -37,14 +37,14 @@
 #undef pr_fmt
 #define pr_fmt(fmt) "" fmt
 
-static bool boot_cpu_done;
-
-static int __read_mostly __pat_enabled = IS_ENABLED(CONFIG_X86_PAT);
-static void init_cache_modes(void);
+static bool __read_mostly boot_cpu_done;
+static bool __read_mostly pat_disabled = !IS_ENABLED(CONFIG_X86_PAT);
+static bool __read_mostly pat_initialized;
+static bool __read_mostly init_cm_done;
 
 void pat_disable(const char *reason)
 {
-	if (!__pat_enabled)
+	if (pat_disabled)
 		return;
 
 	if (boot_cpu_done) {
@@ -52,10 +52,8 @@ void pat_disable(const char *reason)
 		return;
 	}
 
-	__pat_enabled = 0;
+	pat_disabled = true;
 	pr_info("x86/PAT: %s\n", reason);
-
-	init_cache_modes();
 }
 
 static int __init nopat(char *str)
@@ -67,7 +65,7 @@ early_param("nopat", nopat);
 
 bool pat_enabled(void)
 {
-	return !!__pat_enabled;
+	return pat_initialized;
 }
 EXPORT_SYMBOL_GPL(pat_enabled);
 
@@ -205,6 +203,8 @@ static void __init_cache_modes(u64 pat)
 		update_cache_mode_entry(i, cache);
 	}
 	pr_info("x86/PAT: Configuration [0-7]: %s\n", pat_msg);
+
+	init_cm_done = true;
 }
 
 #define PAT(x, y)	((u64)PAT_ ## y << ((x)*8))
@@ -225,6 +225,7 @@ static void pat_bsp_init(u64 pat)
 	}
 
 	wrmsrl(MSR_IA32_CR_PAT, pat);
+	pat_initialized = true;
 
 	__init_cache_modes(pat);
 }
@@ -242,10 +243,9 @@ static void pat_ap_init(u64 pat)
 	wrmsrl(MSR_IA32_CR_PAT, pat);
 }
 
-static void init_cache_modes(void)
+void init_cache_modes(void)
 {
 	u64 pat = 0;
-	static int init_cm_done;
 
 	if (init_cm_done)
 		return;
@@ -287,8 +287,6 @@ static void init_cache_modes(void)
 	}
 
 	__init_cache_modes(pat);
-
-	init_cm_done = 1;
 }
 
 /**
@@ -306,10 +304,8 @@ void pat_init(void)
 	u64 pat;
 	struct cpuinfo_x86 *c = &boot_cpu_data;
 
-	if (!pat_enabled()) {
-		init_cache_modes();
+	if (pat_disabled)
 		return;
-	}
 
 	if ((c->x86_vendor == X86_VENDOR_INTEL) &&
 	    (((c->x86 == 0x6) && (c->x86_model <= 0xd)) ||

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

* Re: [PATCH 4.12 00/10] 4.12.2-stable review
  2017-07-13 15:40 [PATCH 4.12 00/10] 4.12.2-stable review Greg Kroah-Hartman
                   ` (7 preceding siblings ...)
  2017-07-13 15:40 ` [PATCH 4.12 10/10] x86/mm/pat: Dont report PAT on CPUs that dont support it Greg Kroah-Hartman
@ 2017-07-14  2:08 ` Guenter Roeck
  2017-07-14  9:51   ` Greg Kroah-Hartman
       [not found] ` <5967ef32.9386df0a.5bac9.3877@mx.google.com>
  9 siblings, 1 reply; 14+ messages in thread
From: Guenter Roeck @ 2017-07-14  2:08 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: torvalds, akpm, shuahkh, patches, ben.hutchings, stable

On 07/13/2017 08:40 AM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.12.2 release.
> There are 10 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 Sat Jul 15 15:40:02 UTC 2017.
> Anything received after that time might be too late.
> 

Build results:
	total: 145 pass: 145 fail: 0
Qemu test results:
	total: 122 pass: 122 fail: 0

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

Guenter

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

* Re: [PATCH 4.12 00/10] 4.12.2-stable review
  2017-07-14  2:08 ` [PATCH 4.12 00/10] 4.12.2-stable review Guenter Roeck
@ 2017-07-14  9:51   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-14  9:51 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-kernel, torvalds, akpm, shuahkh, patches, ben.hutchings, stable

On Thu, Jul 13, 2017 at 07:08:54PM -0700, Guenter Roeck wrote:
> On 07/13/2017 08:40 AM, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.12.2 release.
> > There are 10 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 Sat Jul 15 15:40:02 UTC 2017.
> > Anything received after that time might be too late.
> > 
> 
> Build results:
> 	total: 145 pass: 145 fail: 0
> Qemu test results:
> 	total: 122 pass: 122 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] 14+ messages in thread

* Re: [PATCH 4.12 00/10] 4.12.2-stable review
       [not found] ` <5967ef32.9386df0a.5bac9.3877@mx.google.com>
@ 2017-07-14  9:52   ` Greg Kroah-Hartman
  2017-07-14 11:17   ` Mark Brown
  1 sibling, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-14  9:52 UTC (permalink / raw)
  To: kernelci.org bot
  Cc: linux-kernel, torvalds, akpm, linux, shuahkh, patches,
	ben.hutchings, stable

On Thu, Jul 13, 2017 at 03:07:46PM -0700, kernelci.org bot wrote:
> stable-rc/linux-4.12.y boot: 226 boots: 5 failed, 216 passed with 4 offline, 1 conflict (v4.12.1-11-g28917cd49df9)

Should I be concerned about these 5 failures?  No other test systems
shows any problems...

thanks,

greg k-h

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

* Re: [PATCH 4.12 00/10] 4.12.2-stable review
       [not found] ` <5967ef32.9386df0a.5bac9.3877@mx.google.com>
  2017-07-14  9:52   ` Greg Kroah-Hartman
@ 2017-07-14 11:17   ` Mark Brown
  2017-07-14 11:43     ` Greg Kroah-Hartman
  1 sibling, 1 reply; 14+ messages in thread
From: Mark Brown @ 2017-07-14 11:17 UTC (permalink / raw)
  To: kernelci.org bot
  Cc: Greg Kroah-Hartman, linux-kernel, torvalds, akpm, linux, shuahkh,
	patches, ben.hutchings, stable

[-- Attachment #1: Type: text/plain, Size: 911 bytes --]

On Thu, Jul 13, 2017 at 03:07:46PM -0700, kernelci.org bot wrote:

> 
>     multi_v7_defconfig
>         imx6ul-pico-hobbit_rootfs:nfs: 1 failed lab
> 
>     mvebu_v5_defconfig
>         kirkwood-openblocks_a7_rootfs:nfs: 1 failed lab
> 
>     multi_v7_defconfig+CONFIG_PROVE_LOCKING=y
>         omap4-panda: 1 failed lab

These look at first glance labs were having a bad day.

>         sun5i-r8-chip: 1 failed lab

This one isn't immediately obvious to me, the kernel got to the end of
boot then nothing from userspace:

    https://storage.kernelci.org/stable-rc/linux-4.12.y/v4.12.1-11-g28917cd49df9/arm/multi_v7_defconfig+CONFIG_PROVE_LOCKING=y/lab-free-electrons/boot-sun5i-r8-chip.html

>     multi_v7_defconfig+CONFIG_SMP=n
>         sun5i-r8-chip: 1 failed lab

Same board, same symptoms.  It's not booting in -next either in a
similar way so I'd not worry about it for now.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 4.12 00/10] 4.12.2-stable review
  2017-07-14 11:17   ` Mark Brown
@ 2017-07-14 11:43     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-14 11:43 UTC (permalink / raw)
  To: Mark Brown
  Cc: kernelci.org bot, linux-kernel, torvalds, akpm, linux, shuahkh,
	patches, ben.hutchings, stable

On Fri, Jul 14, 2017 at 12:17:03PM +0100, Mark Brown wrote:
> On Thu, Jul 13, 2017 at 03:07:46PM -0700, kernelci.org bot wrote:
> 
> > 
> >     multi_v7_defconfig
> >         imx6ul-pico-hobbit_rootfs:nfs: 1 failed lab
> > 
> >     mvebu_v5_defconfig
> >         kirkwood-openblocks_a7_rootfs:nfs: 1 failed lab
> > 
> >     multi_v7_defconfig+CONFIG_PROVE_LOCKING=y
> >         omap4-panda: 1 failed lab
> 
> These look at first glance labs were having a bad day.
> 
> >         sun5i-r8-chip: 1 failed lab
> 
> This one isn't immediately obvious to me, the kernel got to the end of
> boot then nothing from userspace:
> 
>     https://storage.kernelci.org/stable-rc/linux-4.12.y/v4.12.1-11-g28917cd49df9/arm/multi_v7_defconfig+CONFIG_PROVE_LOCKING=y/lab-free-electrons/boot-sun5i-r8-chip.html
> 
> >     multi_v7_defconfig+CONFIG_SMP=n
> >         sun5i-r8-chip: 1 failed lab
> 
> Same board, same symptoms.  It's not booting in -next either in a
> similar way so I'd not worry about it for now.

Ok, thanks for looking into these.

greg k-h

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

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

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-13 15:40 [PATCH 4.12 00/10] 4.12.2-stable review Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.12 01/10] mqueue: fix a use-after-free in sys_mq_notify() Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.12 02/10] imx-serial: RX DMA startup latency Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.12 03/10] proc: Fix proc_sys_prune_dcache to hold a sb reference Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.12 04/10] locking/rwsem-spinlock: Fix EINTR branch in __down_write_common() Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.12 05/10] staging: vt6556: vnt_start Fix missing call to vnt_key_init_table Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.12 06/10] staging: comedi: fix clean-up of comedi_class in comedi_init() Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.12 09/10] ext4: check return value of kstrtoull correctly in reserved_clusters_store Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.12 10/10] x86/mm/pat: Dont report PAT on CPUs that dont support it Greg Kroah-Hartman
2017-07-14  2:08 ` [PATCH 4.12 00/10] 4.12.2-stable review Guenter Roeck
2017-07-14  9:51   ` Greg Kroah-Hartman
     [not found] ` <5967ef32.9386df0a.5bac9.3877@mx.google.com>
2017-07-14  9:52   ` Greg Kroah-Hartman
2017-07-14 11:17   ` Mark Brown
2017-07-14 11:43     ` Greg Kroah-Hartman

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.