All of lore.kernel.org
 help / color / mirror / Atom feed
* [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers
@ 2018-01-18 20:59 Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] bcache: Make gc wakeup sane, remove set_task_state() Sasha Levin
                   ` (295 more replies)
  0 siblings, 296 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Johannes Thumshirn, Linus Torvalds, Sasha Levin

From: Johannes Thumshirn <jthumshirn@suse.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit fd3fc0b4d7305fa7246622dcc0dec69c42443f45 ]

Don't crash the machine just because of an empty transfer. Use WARN_ON()
combined with returning an error.

Found by Dmitry Vyukov and syzkaller.

[ Changed to "WARN_ON_ONCE()". Al has a patch that should fix the root
  cause, but a BUG_ON() is not acceptable in any case, and a WARN_ON()
  might still be a cause of excessive log spamming.

  NOTE! If this warning ever triggers, we may end up leaking resources,
  since this doesn't bother to try to clean the command up. So this
  WARN_ON_ONCE() triggering does imply real problems. But BUG_ON() is
  much worse.

  People really need to stop using BUG_ON() for "this shouldn't ever
  happen". It makes pretty much any bug worse.     - Linus ]

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: James Bottomley <jejb@linux.vnet.ibm.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/scsi/scsi_lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 17fbf1d3eadc..8ef1d5e6619a 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1119,7 +1119,8 @@ int scsi_init_io(struct scsi_cmnd *cmd)
 	bool is_mq = (rq->mq_ctx != NULL);
 	int error;
 
-	BUG_ON(!rq->nr_phys_segments);
+	if (WARN_ON_ONCE(!rq->nr_phys_segments))
+		return -EINVAL;
 
 	error = scsi_init_sgtable(rq, &cmd->sdb);
 	if (error)
-- 
2.11.0

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

* [added to the 4.1 stable tree] bcache: Make gc wakeup sane, remove set_task_state()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] rtc: interface: ignore expired timers when enqueuing new timers Sasha Levin
                   ` (294 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Kent Overstreet, Sasha Levin

From: Kent Overstreet <kent.overstreet@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit be628be09563f8f6e81929efbd7cf3f45c344416 ]

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/md/bcache/bcache.h  |  4 ++--
 drivers/md/bcache/btree.c   | 40 ++++++++++++++++++++--------------------
 drivers/md/bcache/btree.h   |  3 +--
 drivers/md/bcache/request.c |  4 +---
 drivers/md/bcache/super.c   |  2 ++
 5 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index dfdd1908641c..f8a1d20c73f4 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -441,7 +441,7 @@ struct cache {
 	 * until a gc finishes - otherwise we could pointlessly burn a ton of
 	 * cpu
 	 */
-	unsigned		invalidate_needs_gc:1;
+	unsigned		invalidate_needs_gc;
 
 	bool			discard; /* Get rid of? */
 
@@ -611,8 +611,8 @@ struct cache_set {
 
 	/* Counts how many sectors bio_insert has added to the cache */
 	atomic_t		sectors_to_gc;
+	wait_queue_head_t	gc_wait;
 
-	wait_queue_head_t	moving_gc_wait;
 	struct keybuf		moving_gc_keys;
 	/* Number of moving GC bios in flight */
 	struct semaphore	moving_in_flight;
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 43829d9493f7..f0b75d54951a 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -1762,33 +1762,34 @@ static void bch_btree_gc(struct cache_set *c)
 	bch_moving_gc(c);
 }
 
-static int bch_gc_thread(void *arg)
+static bool gc_should_run(struct cache_set *c)
 {
-	struct cache_set *c = arg;
 	struct cache *ca;
 	unsigned i;
 
-	while (1) {
-again:
-		bch_btree_gc(c);
+	for_each_cache(ca, c, i)
+		if (ca->invalidate_needs_gc)
+			return true;
 
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (kthread_should_stop())
-			break;
+	if (atomic_read(&c->sectors_to_gc) < 0)
+		return true;
 
-		mutex_lock(&c->bucket_lock);
+	return false;
+}
 
-		for_each_cache(ca, c, i)
-			if (ca->invalidate_needs_gc) {
-				mutex_unlock(&c->bucket_lock);
-				set_current_state(TASK_RUNNING);
-				goto again;
-			}
+static int bch_gc_thread(void *arg)
+{
+	struct cache_set *c = arg;
 
-		mutex_unlock(&c->bucket_lock);
+	while (1) {
+		wait_event_interruptible(c->gc_wait,
+			   kthread_should_stop() || gc_should_run(c));
 
-		try_to_freeze();
-		schedule();
+		if (kthread_should_stop())
+			break;
+
+		set_gc_sectors(c);
+		bch_btree_gc(c);
 	}
 
 	return 0;
@@ -1796,11 +1797,10 @@ static int bch_gc_thread(void *arg)
 
 int bch_gc_thread_start(struct cache_set *c)
 {
-	c->gc_thread = kthread_create(bch_gc_thread, c, "bcache_gc");
+	c->gc_thread = kthread_run(bch_gc_thread, c, "bcache_gc");
 	if (IS_ERR(c->gc_thread))
 		return PTR_ERR(c->gc_thread);
 
-	set_task_state(c->gc_thread, TASK_INTERRUPTIBLE);
 	return 0;
 }
 
diff --git a/drivers/md/bcache/btree.h b/drivers/md/bcache/btree.h
index 5c391fa01bed..9b80417cd547 100644
--- a/drivers/md/bcache/btree.h
+++ b/drivers/md/bcache/btree.h
@@ -260,8 +260,7 @@ void bch_initial_mark_key(struct cache_set *, int, struct bkey *);
 
 static inline void wake_up_gc(struct cache_set *c)
 {
-	if (c->gc_thread)
-		wake_up_process(c->gc_thread);
+	wake_up(&c->gc_wait);
 }
 
 #define MAP_DONE	0
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index ab43faddb447..a9864ef73ec6 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -193,10 +193,8 @@ static void bch_data_insert_start(struct closure *cl)
 	struct data_insert_op *op = container_of(cl, struct data_insert_op, cl);
 	struct bio *bio = op->bio, *n;
 
-	if (atomic_sub_return(bio_sectors(bio), &op->c->sectors_to_gc) < 0) {
-		set_gc_sectors(op->c);
+	if (atomic_sub_return(bio_sectors(bio), &op->c->sectors_to_gc) < 0)
 		wake_up_gc(op->c);
-	}
 
 	if (op->bypass)
 		return bch_data_invalidate(cl);
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 8e5666ac8a6a..b911a7d7a06b 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1523,6 +1523,7 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
 	mutex_init(&c->bucket_lock);
 	init_waitqueue_head(&c->btree_cache_wait);
 	init_waitqueue_head(&c->bucket_wait);
+	init_waitqueue_head(&c->gc_wait);
 	sema_init(&c->uuid_write_mutex, 1);
 
 	spin_lock_init(&c->btree_gc_time.lock);
@@ -1581,6 +1582,7 @@ static void run_cache_set(struct cache_set *c)
 
 	for_each_cache(ca, c, i)
 		c->nbuckets += ca->sb.nbuckets;
+	set_gc_sectors(c);
 
 	if (CACHE_SYNC(&c->sb)) {
 		LIST_HEAD(journal);
-- 
2.11.0

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

* [added to the 4.1 stable tree] rtc: interface: ignore expired timers when enqueuing new timers
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] bcache: Make gc wakeup sane, remove set_task_state() Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net/llc: avoid BUG_ON() in skb_orphan() Sasha Levin
                   ` (293 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Colin Ian King, Alexandre Belloni, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 2b2f5ff00f63847d95adad6289bd8b05f5983dd5 ]

This patch fixes a RTC wakealarm issue, namely, the event fires during
hibernate and is not cleared from the list, causing hwclock to block.

The current enqueuing does not trigger an alarm if any expired timers
already exist on the timerqueue. This can occur when a RTC wake alarm
is used to wake a machine out of hibernate and the resumed state has
old expired timers that have not been removed from the timer queue.
This fix skips over any expired timers and triggers an alarm if there
are no pending timers on the timerqueue. Note that the skipped expired
timer will get reaped later on, so there is no need to clean it up
immediately.

The issue can be reproduced by putting a machine into hibernate and
waking it with the RTC wakealarm.  Running the example RTC test program
from tools/testing/selftests/timers/rtctest.c after the hibernate will
block indefinitely.  With the fix, it no longer blocks after the
hibernate resume.

BugLink: http://bugs.launchpad.net/bugs/1333569

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/rtc/interface.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 166fc60d8b55..faa81ac2d481 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -793,9 +793,23 @@ EXPORT_SYMBOL_GPL(rtc_irq_set_freq);
  */
 static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
 {
+	struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue);
+	struct rtc_time tm;
+	ktime_t now;
+
 	timer->enabled = 1;
+	__rtc_read_time(rtc, &tm);
+	now = rtc_tm_to_ktime(tm);
+
+	/* Skip over expired timers */
+	while (next) {
+		if (next->expires.tv64 >= now.tv64)
+			break;
+		next = timerqueue_iterate_next(next);
+	}
+
 	timerqueue_add(&rtc->timerqueue, &timer->node);
-	if (&timer->node == timerqueue_getnext(&rtc->timerqueue)) {
+	if (!next) {
 		struct rtc_wkalrm alarm;
 		int err;
 		alarm.time = rtc_ktime_to_tm(timer->node.expires);
-- 
2.11.0

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

* [added to the 4.1 stable tree] net/llc: avoid BUG_ON() in skb_orphan()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] bcache: Make gc wakeup sane, remove set_task_state() Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] rtc: interface: ignore expired timers when enqueuing new timers Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] packet: fix races in fanout_add() Sasha Levin
                   ` (292 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Dumazet, David S . Miller, Sasha Levin

From: Eric Dumazet <edumazet@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 8b74d439e1697110c5e5c600643e823eb1dd0762 ]

It seems nobody used LLC since linux-3.12.

Fortunately fuzzers like syzkaller still know how to run this code,
otherwise it would be no fun.

Setting skb->sk without skb->destructor leads to all kinds of
bugs, we now prefer to be very strict about it.

Ideally here we would use skb_set_owner() but this helper does not exist yet,
only CAN seems to have a private helper for that.

Fixes: 376c7311bdb6 ("net: add a temporary sanity check in skb_orphan()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/llc/llc_conn.c | 3 +++
 net/llc/llc_sap.c  | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c
index 81a61fce3afb..841026e02ce8 100644
--- a/net/llc/llc_conn.c
+++ b/net/llc/llc_conn.c
@@ -821,7 +821,10 @@ void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb)
 		 * another trick required to cope with how the PROCOM state
 		 * machine works. -acme
 		 */
+		skb_orphan(skb);
+		sock_hold(sk);
 		skb->sk = sk;
+		skb->destructor = sock_efree;
 	}
 	if (!sock_owned_by_user(sk))
 		llc_conn_rcv(sk, skb);
diff --git a/net/llc/llc_sap.c b/net/llc/llc_sap.c
index d0e1e804ebd7..5404d0d195cc 100644
--- a/net/llc/llc_sap.c
+++ b/net/llc/llc_sap.c
@@ -290,7 +290,10 @@ static void llc_sap_rcv(struct llc_sap *sap, struct sk_buff *skb,
 
 	ev->type   = LLC_SAP_EV_TYPE_PDU;
 	ev->reason = 0;
+	skb_orphan(skb);
+	sock_hold(sk);
 	skb->sk = sk;
+	skb->destructor = sock_efree;
 	llc_sap_state_process(sap, skb);
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] packet: fix races in fanout_add()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (2 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net/llc: avoid BUG_ON() in skb_orphan() Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] irda: Fix lockdep annotations in hashbin_delete() Sasha Levin
                   ` (291 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Dumazet, David S . Miller, Sasha Levin

From: Eric Dumazet <edumazet@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit d199fab63c11998a602205f7ee7ff7c05c97164b ]

Multiple threads can call fanout_add() at the same time.

We need to grab fanout_mutex earlier to avoid races that could
lead to one thread freeing po->rollover that was set by another thread.

Do the same in fanout_release(), for peace of mind, and to help us
finding lockdep issues earlier.

Fixes: dc99f600698d ("packet: Add fanout support.")
Fixes: 0648ab70afe6 ("packet: rollover prepare: per-socket state")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/packet/af_packet.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 4cd7e27e3fc4..88cec9576e93 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1447,13 +1447,16 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags)
 		return -EINVAL;
 	}
 
+	mutex_lock(&fanout_mutex);
+
+	err = -EINVAL;
 	if (!po->running)
-		return -EINVAL;
+		goto out;
 
+	err = -EALREADY;
 	if (po->fanout)
-		return -EALREADY;
+		goto out;
 
-	mutex_lock(&fanout_mutex);
 	match = NULL;
 	list_for_each_entry(f, &fanout_list, list) {
 		if (f->id == id &&
@@ -1509,17 +1512,16 @@ static void fanout_release(struct sock *sk)
 	struct packet_sock *po = pkt_sk(sk);
 	struct packet_fanout *f;
 
-	f = po->fanout;
-	if (!f)
-		return;
-
 	mutex_lock(&fanout_mutex);
-	po->fanout = NULL;
+	f = po->fanout;
+	if (f) {
+		po->fanout = NULL;
 
-	if (atomic_dec_and_test(&f->sk_ref)) {
-		list_del(&f->list);
-		dev_remove_pack(&f->prot_hook);
-		kfree(f);
+		if (atomic_dec_and_test(&f->sk_ref)) {
+			list_del(&f->list);
+			dev_remove_pack(&f->prot_hook);
+			kfree(f);
+		}
 	}
 	mutex_unlock(&fanout_mutex);
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] irda: Fix lockdep annotations in hashbin_delete().
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (3 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] packet: fix races in fanout_add() Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: socket: fix recvmmsg not returning error from sock_error Sasha Levin
                   ` (290 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David S. Miller, Sasha Levin

From: "David S. Miller" <davem@davemloft.net>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 4c03b862b12f980456f9de92db6d508a4999b788 ]

A nested lock depth was added to the hasbin_delete() code but it
doesn't actually work some well and results in tons of lockdep splats.

Fix the code instead to properly drop the lock around the operation
and just keep peeking the head of the hashbin queue.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/irda/irqueue.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/net/irda/irqueue.c b/net/irda/irqueue.c
index acbe61c7e683..160dc89335e2 100644
--- a/net/irda/irqueue.c
+++ b/net/irda/irqueue.c
@@ -383,9 +383,6 @@ EXPORT_SYMBOL(hashbin_new);
  *    for deallocating this structure if it's complex. If not the user can
  *    just supply kfree, which should take care of the job.
  */
-#ifdef CONFIG_LOCKDEP
-static int hashbin_lock_depth = 0;
-#endif
 int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
 {
 	irda_queue_t* queue;
@@ -396,22 +393,27 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
 	IRDA_ASSERT(hashbin->magic == HB_MAGIC, return -1;);
 
 	/* Synchronize */
-	if ( hashbin->hb_type & HB_LOCK ) {
-		spin_lock_irqsave_nested(&hashbin->hb_spinlock, flags,
-					 hashbin_lock_depth++);
-	}
+	if (hashbin->hb_type & HB_LOCK)
+		spin_lock_irqsave(&hashbin->hb_spinlock, flags);
 
 	/*
 	 *  Free the entries in the hashbin, TODO: use hashbin_clear when
 	 *  it has been shown to work
 	 */
 	for (i = 0; i < HASHBIN_SIZE; i ++ ) {
-		queue = dequeue_first((irda_queue_t**) &hashbin->hb_queue[i]);
-		while (queue ) {
-			if (free_func)
-				(*free_func)(queue);
-			queue = dequeue_first(
-				(irda_queue_t**) &hashbin->hb_queue[i]);
+		while (1) {
+			queue = dequeue_first((irda_queue_t**) &hashbin->hb_queue[i]);
+
+			if (!queue)
+				break;
+
+			if (free_func) {
+				if (hashbin->hb_type & HB_LOCK)
+					spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
+				free_func(queue);
+				if (hashbin->hb_type & HB_LOCK)
+					spin_lock_irqsave(&hashbin->hb_spinlock, flags);
+			}
 		}
 	}
 
@@ -420,12 +422,8 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
 	hashbin->magic = ~HB_MAGIC;
 
 	/* Release lock */
-	if ( hashbin->hb_type & HB_LOCK) {
+	if (hashbin->hb_type & HB_LOCK)
 		spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
-#ifdef CONFIG_LOCKDEP
-		hashbin_lock_depth--;
-#endif
-	}
 
 	/*
 	 *  Free the hashbin structure
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: socket: fix recvmmsg not returning error from sock_error
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (4 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] irda: Fix lockdep annotations in hashbin_delete() Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] [media] uvcvideo: Fix a wrong macro Sasha Levin
                   ` (289 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Maxime Jayat, David S . Miller, Sasha Levin

From: Maxime Jayat <maxime.jayat@mobile-devices.fr>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e623a9e9dec29ae811d11f83d0074ba254aba374 ]

Commit 34b88a68f26a ("net: Fix use after free in the recvmmsg exit path"),
changed the exit path of recvmmsg to always return the datagrams
variable and modified the error paths to set the variable to the error
code returned by recvmsg if necessary.

However in the case sock_error returned an error, the error code was
then ignored, and recvmmsg returned 0.

Change the error path of recvmmsg to correctly return the error code
of sock_error.

The bug was triggered by using recvmmsg on a CAN interface which was
not up. Linux 4.6 and later return 0 in this case while earlier
releases returned -ENETDOWN.

Fixes: 34b88a68f26a ("net: Fix use after free in the recvmmsg exit path")
Signed-off-by: Maxime Jayat <maxime.jayat@mobile-devices.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/socket.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/socket.c b/net/socket.c
index e66e4f357506..8327df0448f4 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2192,8 +2192,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 		return err;
 
 	err = sock_error(sock->sk);
-	if (err)
+	if (err) {
+		datagrams = err;
 		goto out_put;
+	}
 
 	entry = mmsg;
 	compat_entry = (struct compat_mmsghdr __user *)mmsg;
-- 
2.11.0

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

* [added to the 4.1 stable tree] [media] uvcvideo: Fix a wrong macro
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (5 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: socket: fix recvmmsg not returning error from sock_error Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] ext4: preserve the needs_recovery flag when the journal is aborted Sasha Levin
                   ` (288 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Guennadi Liakhovetski, Guennadi Liakhovetski, Laurent Pinchart,
	Mauro Carvalho Chehab, Sasha Levin

From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 17c341ec0115837a610b2da15e32546e26068234 ]

Don't mix up UVC_BUF_STATE_* and VB2_BUF_STATE_* codes.

Fixes: 6998b6fb4b1c ("[media] uvcvideo: Use videobuf2-vmalloc")

Cc: stable@vger.kernel.org
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/media/usb/uvc/uvc_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index 87a19f33e460..6d072cae6134 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -399,7 +399,7 @@ struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
 		nextbuf = NULL;
 	spin_unlock_irqrestore(&queue->irqlock, flags);
 
-	buf->state = buf->error ? VB2_BUF_STATE_ERROR : UVC_BUF_STATE_DONE;
+	buf->state = buf->error ? UVC_BUF_STATE_ERROR : UVC_BUF_STATE_DONE;
 	vb2_set_plane_payload(&buf->buf, 0, buf->bytesused);
 	vb2_buffer_done(&buf->buf, VB2_BUF_STATE_DONE);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] ext4: preserve the needs_recovery flag when the journal is aborted
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (6 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] [media] uvcvideo: Fix a wrong macro Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] sd: get disk reference in sd_check_events() Sasha Levin
                   ` (287 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Theodore Ts'o, Sasha Levin

From: Theodore Ts'o <tytso@mit.edu>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 97abd7d4b5d9c48ec15c425485f054e1c15e591b ]

If the journal is aborted, the needs_recovery feature flag should not
be removed.  Otherwise, it's the journal might not get replayed and
this could lead to more data getting lost.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/ext4/super.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 807b1df8e134..b29a7ef4953e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -774,6 +774,7 @@ static void ext4_put_super(struct super_block *sb)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	struct ext4_super_block *es = sbi->s_es;
+	int aborted = 0;
 	int i, err;
 
 	ext4_unregister_li_request(sb);
@@ -783,9 +784,10 @@ static void ext4_put_super(struct super_block *sb)
 	destroy_workqueue(sbi->rsv_conversion_wq);
 
 	if (sbi->s_journal) {
+		aborted = is_journal_aborted(sbi->s_journal);
 		err = jbd2_journal_destroy(sbi->s_journal);
 		sbi->s_journal = NULL;
-		if (err < 0)
+		if ((err < 0) && !aborted)
 			ext4_abort(sb, "Couldn't clean up the journal");
 	}
 
@@ -796,7 +798,7 @@ static void ext4_put_super(struct super_block *sb)
 	ext4_ext_release(sb);
 	ext4_xattr_put_super(sb);
 
-	if (!(sb->s_flags & MS_RDONLY)) {
+	if (!(sb->s_flags & MS_RDONLY) && !aborted) {
 		EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
 		es->s_state = cpu_to_le16(sbi->s_mount_state);
 	}
-- 
2.11.0

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

* [added to the 4.1 stable tree] sd: get disk reference in sd_check_events()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (7 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] ext4: preserve the needs_recovery flag when the journal is aborted Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] iio: pressure: mpl3115: do not rely on structure field ordering Sasha Levin
                   ` (286 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Hannes Reinecke, Martin K . Petersen, Sasha Levin

From: Hannes Reinecke <hare@suse.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit eb72d0bb84eee5d0dc3044fd17b75e7101dabb57 ]

sd_check_events() is called asynchronously, and might race
with device removal. So always take a disk reference when
processing the event to avoid the device being removed while
the event is processed.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/scsi/sd.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 80cebe691fee..a678dd10905f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1383,11 +1383,15 @@ static int media_not_present(struct scsi_disk *sdkp,
  **/
 static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing)
 {
-	struct scsi_disk *sdkp = scsi_disk(disk);
-	struct scsi_device *sdp = sdkp->device;
+	struct scsi_disk *sdkp = scsi_disk_get(disk);
+	struct scsi_device *sdp;
 	struct scsi_sense_hdr *sshdr = NULL;
 	int retval;
 
+	if (!sdkp)
+		return 0;
+
+	sdp = sdkp->device;
 	SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_check_events\n"));
 
 	/*
@@ -1444,6 +1448,7 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing)
 	kfree(sshdr);
 	retval = sdp->changed ? DISK_EVENT_MEDIA_CHANGE : 0;
 	sdp->changed = 0;
+	scsi_disk_put(sdkp);
 	return retval;
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] iio: pressure: mpl3115: do not rely on structure field ordering
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (8 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] sd: get disk reference in sd_check_events() Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] iio: pressure: mpl115: " Sasha Levin
                   ` (285 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Peter Rosin, Jonathan Cameron, Sasha Levin

From: Peter Rosin <peda@axentia.se>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 9cf6cdba586ced75c69b8314b88b2d2f5ce9b3ed ]

Fixes a regression triggered by a change in the layout of
struct iio_chan_spec, but the real bug is in the driver which assumed
a specific structure layout in the first place. Hint: the two bits were
not OR:ed together as implied by the indentation prior to this patch,
there was a comma between them, which accidentally moved the ..._SCALE
bit to the next structure field. That field was .info_mask_shared_by_type
before the _available attributes was added by commit 51239600074b
("iio:core: add a callback to allow drivers to provide _available
attributes") and .info_mask_separate_available afterwards, and the
regression happened.

info_mask_shared_by_type is actually a better choice than the originally
intended info_mask_separate for the ..._SCALE bit since a constant is
returned from mpl3115_read_raw for the scale. Using
info_mask_shared_by_type also preserves the behavior from before the
regression and is therefore less likely to cause other interesting side
effects.

The above mentioned regression causes an unintended sysfs attibute to
show up that is not backed by code, in turn causing the following NULL
pointer defererence to happen on access.

Segmentation fault

Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = ecc3c000
[00000000] *pgd=87f91831
Internal error: Oops: 80000007 [#1] SMP ARM
Modules linked in:
CPU: 1 PID: 1051 Comm: cat Not tainted 4.10.0-rc5-00009-gffd8858-dirty #3
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
task: ed54ec00 task.stack: ee2bc000
PC is at 0x0
LR is at iio_read_channel_info_avail+0x40/0x280
pc : [<00000000>]    lr : [<c06fbc1c>]    psr: a0070013
sp : ee2bdda8  ip : 00000000  fp : ee2bddf4
r10: c0a53c74  r9 : ed79f000  r8 : ee8d1018
r7 : 00001000  r6 : 00000fff  r5 : ee8b9a00  r4 : ed79f000
r3 : ee2bddc4  r2 : ee2bddbc  r1 : c0a86dcc  r0 : ee8d1000
Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c5387d  Table: 3cc3c04a  DAC: 00000051
Process cat (pid: 1051, stack limit = 0xee2bc210)
Stack: (0xee2bdda8 to 0xee2be000)
dda0:                   ee2bddc0 00000002 c016d720 c016d394 ed54ec00 00000000
ddc0: 60070013 ed413780 00000001 edffd480 ee8b9a00 00000fff 00001000 ee8d1018
dde0: ed79f000 c0a53c74 ee2bde0c ee2bddf8 c0513c58 c06fbbe8 edffd480 edffd540
de00: ee2bde3c ee2bde10 c0293474 c0513c40 c02933e4 ee2bde60 00000001 ed413780
de20: 00000001 ed413780 00000000 edffd480 ee2bde4c ee2bde40 c0291d00 c02933f0
de40: ee2bde9c ee2bde50 c024679c c0291ce0 edffd4b0 b6e37000 00020000 ee2bdf78
de60: 00000000 00000000 ed54ec00 ed013200 00000817 c0a111fc edffd540 ed413780
de80: b6e37000 00020000 00020000 ee2bdf78 ee2bded4 ee2bdea0 c0292890 c0246604
dea0: c0117940 c016ba50 00000025 c0a111fc b6e37000 ed413780 ee2bdf78 00020000
dec0: ee2bc000 b6e37000 ee2bdf44 ee2bded8 c021d158 c0292770 c0117764 b6e36004
dee0: c0f0d7c4 ee2bdfb0 b6f89228 00021008 ee2bdfac ee2bdf00 c0101374 c0117770
df00: 00000000 00000000 ee2bc000 00000000 ee2bdf34 ee2bdf20 c016ba04 c0171080
df20: 00000000 00020000 ed413780 b6e37000 00000000 ee2bdf78 ee2bdf74 ee2bdf48
df40: c021e7a0 c021d130 c023e300 c023e280 ee2bdf74 00000000 00000000 ed413780
df60: ed413780 00020000 ee2bdfa4 ee2bdf78 c021e870 c021e71c 00000000 00000000
df80: 00020000 00020000 b6e37000 00000003 c0108084 00000000 00000000 ee2bdfa8
dfa0: c0107ee0 c021e838 00020000 00020000 00000003 b6e37000 00020000 0001a2b4
dfc0: 00020000 00020000 b6e37000 00000003 7fffe000 00000000 00000000 00020000
dfe0: 00000000 be98eb4c 0000c740 b6f1985c 60070010 00000003 00000000 00000000
Backtrace:
[<c06fbbdc>] (iio_read_channel_info_avail) from [<c0513c58>] (dev_attr_show+0x24/0x50)
 r10:c0a53c74 r9:ed79f000 r8:ee8d1018 r7:00001000 r6:00000fff r5:ee8b9a00
 r4:edffd480
[<c0513c34>] (dev_attr_show) from [<c0293474>] (sysfs_kf_seq_show+0x90/0x110)
 r5:edffd540 r4:edffd480
[<c02933e4>] (sysfs_kf_seq_show) from [<c0291d00>] (kernfs_seq_show+0x2c/0x30)
 r10:edffd480 r9:00000000 r8:ed413780 r7:00000001 r6:ed413780 r5:00000001
 r4:ee2bde60 r3:c02933e4
[<c0291cd4>] (kernfs_seq_show) from [<c024679c>] (seq_read+0x1a4/0x4e0)
[<c02465f8>] (seq_read) from [<c0292890>] (kernfs_fop_read+0x12c/0x1cc)
 r10:ee2bdf78 r9:00020000 r8:00020000 r7:b6e37000 r6:ed413780 r5:edffd540
 r4:c0a111fc
[<c0292764>] (kernfs_fop_read) from [<c021d158>] (__vfs_read+0x34/0x118)
 r10:b6e37000 r9:ee2bc000 r8:00020000 r7:ee2bdf78 r6:ed413780 r5:b6e37000
 r4:c0a111fc
[<c021d124>] (__vfs_read) from [<c021e7a0>] (vfs_read+0x90/0x11c)
 r8:ee2bdf78 r7:00000000 r6:b6e37000 r5:ed413780 r4:00020000
[<c021e710>] (vfs_read) from [<c021e870>] (SyS_read+0x44/0x90)
 r8:00020000 r7:ed413780 r6:ed413780 r5:00000000 r4:00000000
[<c021e82c>] (SyS_read) from [<c0107ee0>] (ret_fast_syscall+0x0/0x1c)
 r10:00000000 r8:c0108084 r7:00000003 r6:b6e37000 r5:00020000 r4:00020000
Code: bad PC value
---[ end trace 9c4938ccd0389004 ]---

Fixes: cc26ad455f57 ("iio: Add Freescale MPL3115A2 pressure / temperature sensor driver")
Fixes: 51239600074b ("iio:core: add a callback to allow drivers to provide _available attributes")
Reported-by: Ken Lin <ken.lin@advantech.com>
Tested-by: Ken Lin <ken.lin@advantech.com>
Signed-off-by: Peter Rosin <peda@axentia.se>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/iio/pressure/mpl3115.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c
index 01b2e0b18878..0f5b8767ec2e 100644
--- a/drivers/iio/pressure/mpl3115.c
+++ b/drivers/iio/pressure/mpl3115.c
@@ -182,7 +182,7 @@ static const struct iio_chan_spec mpl3115_channels[] = {
 	{
 		.type = IIO_PRESSURE,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-			BIT(IIO_CHAN_INFO_SCALE),
+		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
 		.scan_index = 0,
 		.scan_type = {
 			.sign = 'u',
@@ -195,7 +195,7 @@ static const struct iio_chan_spec mpl3115_channels[] = {
 	{
 		.type = IIO_TEMP,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-			BIT(IIO_CHAN_INFO_SCALE),
+		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
 		.scan_index = 1,
 		.scan_type = {
 			.sign = 's',
-- 
2.11.0

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

* [added to the 4.1 stable tree] iio: pressure: mpl115: do not rely on structure field ordering
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (9 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] iio: pressure: mpl3115: do not rely on structure field ordering Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] nfsd: special case truncates some more Sasha Levin
                   ` (284 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Peter Rosin, Jonathan Cameron, Sasha Levin

From: Peter Rosin <peda@axentia.se>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 6a6e1d56a0769795a36c0461c64bf5e5b9bbb4c0 ]

Fixes a regression triggered by a change in the layout of
struct iio_chan_spec, but the real bug is in the driver which assumed
a specific structure layout in the first place. Hint: the three bits were
not OR:ed together as implied by the indentation prior to this patch,
there was a comma between the first two, which accidentally moved the
..._SCALE and ..._OFFSET bits to the next structure field. That field
was .info_mask_shared_by_type before the _available attributes was added
by commit 51239600074b ("iio:core: add a callback to allow drivers to
provide _available attributes") and .info_mask_separate_available
afterwards, and the regression happened.

info_mask_shared_by_type is actually a better choice than the originally
intended info_mask_separate for the ..._SCALE and ..._OFFSET bits since
a constant is returned from mpl115_read_raw for the scale/offset. Using
info_mask_shared_by_type also preserves the behavior from before the
regression and is therefore less likely to cause other interesting side
effects.

The above mentioned regression causes unintended sysfs attibutes to
show up that are not backed by code, in turn causing a NULL pointer
defererence to happen on access.

Fixes: 3017d90e8931 ("iio: Add Freescale MPL115A2 pressure / temperature sensor driver")
Fixes: 51239600074b ("iio:core: add a callback to allow drivers to provide _available attributes")
Signed-off-by: Peter Rosin <peda@axentia.se>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/iio/pressure/mpl115.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/pressure/mpl115.c b/drivers/iio/pressure/mpl115.c
index a0d7deeac62f..3f90985d545e 100644
--- a/drivers/iio/pressure/mpl115.c
+++ b/drivers/iio/pressure/mpl115.c
@@ -136,6 +136,7 @@ static const struct iio_chan_spec mpl115_channels[] = {
 	{
 		.type = IIO_TEMP,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+		.info_mask_shared_by_type =
 			BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE),
 	},
 };
-- 
2.11.0

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

* [added to the 4.1 stable tree] nfsd: minor nfsd_setattr cleanup
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (11 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] nfsd: special case truncates some more Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: IP22: Reformat inline assembler code to modern standards Sasha Levin
                   ` (282 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Christoph Hellwig, J . Bruce Fields, Sasha Levin

From: Christoph Hellwig <hch@lst.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 758e99fefe1d9230111296956335cd35995c0eaf ]

Simplify exit paths, size_change use.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: stable@kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/nfsd/vfs.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 92de3747ea8b..11899f851129 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -369,7 +369,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
 	__be32		err;
 	int		host_err;
 	bool		get_write_count;
-	int		size_change = 0;
+	bool		size_change = (iap->ia_valid & ATTR_SIZE);
 
 	if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
 		accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE;
@@ -382,11 +382,11 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
 	/* Get inode */
 	err = fh_verify(rqstp, fhp, ftype, accmode);
 	if (err)
-		goto out;
+		return err;
 	if (get_write_count) {
 		host_err = fh_want_write(fhp);
 		if (host_err)
-			return nfserrno(host_err);
+			goto out;
 	}
 
 	dentry = fhp->fh_dentry;
@@ -397,19 +397,21 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
 		iap->ia_valid &= ~ATTR_MODE;
 
 	if (!iap->ia_valid)
-		goto out;
+		return 0;
 
 	nfsd_sanitize_attrs(inode, iap);
 
+	if (check_guard && guardtime != inode->i_ctime.tv_sec)
+		return nfserr_notsync;
+
 	/*
 	 * The size case is special, it changes the file in addition to the
 	 * attributes.
 	 */
-	if (iap->ia_valid & ATTR_SIZE) {
+	if (size_change) {
 		err = nfsd_get_write_access(rqstp, fhp, iap);
 		if (err)
-			goto out;
-		size_change = 1;
+			return err;
 
 		/*
 		 * RFC5661, Section 18.30.4:
@@ -424,23 +426,16 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
 
 	iap->ia_valid |= ATTR_CTIME;
 
-	if (check_guard && guardtime != inode->i_ctime.tv_sec) {
-		err = nfserr_notsync;
-		goto out_put_write_access;
-	}
-
 	fh_lock(fhp);
 	host_err = notify_change(dentry, iap, NULL);
 	fh_unlock(fhp);
-	err = nfserrno(host_err);
 
-out_put_write_access:
 	if (size_change)
 		put_write_access(inode);
-	if (!err)
-		err = nfserrno(commit_metadata(fhp));
 out:
-	return err;
+	if (!host_err)
+		host_err = commit_metadata(fhp);
+	return nfserrno(host_err);
 }
 
 #if defined(CONFIG_NFSD_V4)
-- 
2.11.0

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

* [added to the 4.1 stable tree] nfsd: special case truncates some more
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (10 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] iio: pressure: mpl115: " Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] nfsd: minor nfsd_setattr cleanup Sasha Levin
                   ` (283 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Christoph Hellwig, J . Bruce Fields, Sasha Levin

From: Christoph Hellwig <hch@lst.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 41f53350a0f36a7b8e31bec0d0ca907e028ab4cd ]

Both the NFS protocols and the Linux VFS use a setattr operation with a
bitmap of attributs to set to set various file attributes including the
file size and the uid/gid.

The Linux syscalls never mixes size updates with unrelated updates like
the uid/gid, and some file systems like XFS and GFS2 rely on the fact
that truncates might not update random other attributes, and many other
file systems handle the case but do not update the different attributes
in the same transaction.  NFSD on the other hand passes the attributes
it gets on the wire more or less directly through to the VFS, leading to
updates the file systems don't expect.  XFS at least has an assert on
the allowed attributes, which caught an unusual NFS client setting the
size and group at the same time.

To handle this issue properly this switches nfsd to call vfs_truncate
for size changes, and then handle all other attributes through
notify_change.  As a side effect this also means less boilerplace code
around the size change as we can now reuse the VFS code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/nfsd/vfs.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 11899f851129..5eaee287be23 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -406,13 +406,19 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
 
 	/*
 	 * The size case is special, it changes the file in addition to the
-	 * attributes.
+	 * attributes, and file systems don't expect it to be mixed with
+	 * "random" attribute changes.  We thus split out the size change
+	 * into a separate call to ->setattr, and do the rest as a separate
+	 * setattr call.
 	 */
 	if (size_change) {
 		err = nfsd_get_write_access(rqstp, fhp, iap);
 		if (err)
 			return err;
+	}
 
+	fh_lock(fhp);
+	if (size_change) {
 		/*
 		 * RFC5661, Section 18.30.4:
 		 *   Changing the size of a file with SETATTR indirectly
@@ -420,16 +426,30 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
 		 *
 		 * (and similar for the older RFCs)
 		 */
-		if (iap->ia_size != i_size_read(inode))
-			iap->ia_valid |= ATTR_MTIME;
+		struct iattr size_attr = {
+			.ia_valid	= ATTR_SIZE | ATTR_CTIME | ATTR_MTIME,
+			.ia_size	= iap->ia_size,
+		};
+
+		host_err = notify_change(dentry, &size_attr, NULL);
+		if (host_err)
+			goto out_unlock;
+		iap->ia_valid &= ~ATTR_SIZE;
+
+		/*
+		 * Avoid the additional setattr call below if the only other
+		 * attribute that the client sends is the mtime, as we update
+		 * it as part of the size change above.
+		 */
+		if ((iap->ia_valid & ~ATTR_MTIME) == 0)
+			goto out_unlock;
 	}
 
 	iap->ia_valid |= ATTR_CTIME;
-
-	fh_lock(fhp);
 	host_err = notify_change(dentry, iap, NULL);
-	fh_unlock(fhp);
 
+out_unlock:
+	fh_unlock(fhp);
 	if (size_change)
 		put_write_access(inode);
 out:
-- 
2.11.0

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

* [added to the 4.1 stable tree] MIPS: IP22: Reformat inline assembler code to modern standards.
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (12 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] nfsd: minor nfsd_setattr cleanup Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] scsi: lpfc: Correct WQ creation for pagesize Sasha Levin
                   ` (281 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Ralf Baechle, Sasha Levin

From: Ralf Baechle <ralf@linux-mips.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f9f1c8db1c37253805eaa32265e1e1af3ae7d0a4 ]

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/mips/mm/sc-ip22.c | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/arch/mips/mm/sc-ip22.c b/arch/mips/mm/sc-ip22.c
index dc7c5a5214a9..203e4661bc81 100644
--- a/arch/mips/mm/sc-ip22.c
+++ b/arch/mips/mm/sc-ip22.c
@@ -31,26 +31,29 @@ static inline void indy_sc_wipe(unsigned long first, unsigned long last)
 	unsigned long tmp;
 
 	__asm__ __volatile__(
-	".set\tpush\t\t\t# indy_sc_wipe\n\t"
-	".set\tnoreorder\n\t"
-	".set\tmips3\n\t"
-	".set\tnoat\n\t"
-	"mfc0\t%2, $12\n\t"
-	"li\t$1, 0x80\t\t\t# Go 64 bit\n\t"
-	"mtc0\t$1, $12\n\t"
-
-	"dli\t$1, 0x9000000080000000\n\t"
-	"or\t%0, $1\t\t\t# first line to flush\n\t"
-	"or\t%1, $1\t\t\t# last line to flush\n\t"
-	".set\tat\n\t"
-
-	"1:\tsw\t$0, 0(%0)\n\t"
-	"bne\t%0, %1, 1b\n\t"
-	" daddu\t%0, 32\n\t"
-
-	"mtc0\t%2, $12\t\t\t# Back to 32 bit\n\t"
-	"nop; nop; nop; nop;\n\t"
-	".set\tpop"
+	"	.set	push			# indy_sc_wipe		\n"
+	"	.set	noreorder					\n"
+	"	.set	mips3						\n"
+	"	.set	noat						\n"
+	"	mfc0	%2, $12						\n"
+	"	li	$1, 0x80		# Go 64 bit		\n"
+	"	mtc0	$1, $12						\n"
+	"								\n"
+	"	dli	$1, 0x9000000080000000				\n"
+	"	or	%0, $1			# first line to flush	\n"
+	"	or	%1, $1			# last line to flush	\n"
+	"	.set	at						\n"
+	"								\n"
+	"1:	sw	$0, 0(%0)					\n"
+	"	bne	%0, %1, 1b					\n"
+	"	 daddu	%0, 32						\n"
+	"								\n"
+	"	mtc0	%2, $12			# Back to 32 bit	\n"
+	"	nop				# pipeline hazard	\n"
+	"	nop							\n"
+	"	nop							\n"
+	"	nop							\n"
+	"	.set	pop						\n"
 	: "=r" (first), "=r" (last), "=&r" (tmp)
 	: "0" (first), "1" (last));
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] TTY: n_hdlc, fix lockdep false positive
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (14 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] scsi: lpfc: Correct WQ creation for pagesize Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] KVM: VMX: use correct vmcs_read/write for guest segment selector/base Sasha Levin
                   ` (279 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jiri Slaby, Greg Kroah-Hartman, Sasha Levin

From: Jiri Slaby <jslaby@suse.cz>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e9b736d88af1a143530565929390cadf036dc799 ]

The class of 4 n_hdls buf locks is the same because a single function
n_hdlc_buf_list_init is used to init all the locks. But since
flush_tx_queue takes n_hdlc->tx_buf_list.spinlock and then calls
n_hdlc_buf_put which takes n_hdlc->tx_free_buf_list.spinlock, lockdep
emits a warning:
=============================================
[ INFO: possible recursive locking detected ]
4.3.0-25.g91e30a7-default #1 Not tainted
---------------------------------------------
a.out/1248 is trying to acquire lock:
 (&(&list->spinlock)->rlock){......}, at: [<ffffffffa01fd020>] n_hdlc_buf_put+0x20/0x60 [n_hdlc]

but task is already holding lock:
 (&(&list->spinlock)->rlock){......}, at: [<ffffffffa01fdc07>] n_hdlc_tty_ioctl+0x127/0x1d0 [n_hdlc]

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&(&list->spinlock)->rlock);
  lock(&(&list->spinlock)->rlock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

2 locks held by a.out/1248:
 #0:  (&tty->ldisc_sem){++++++}, at: [<ffffffff814c9eb0>] tty_ldisc_ref_wait+0x20/0x50
 #1:  (&(&list->spinlock)->rlock){......}, at: [<ffffffffa01fdc07>] n_hdlc_tty_ioctl+0x127/0x1d0 [n_hdlc]
...
Call Trace:
...
 [<ffffffff81738fd0>] _raw_spin_lock_irqsave+0x50/0x70
 [<ffffffffa01fd020>] n_hdlc_buf_put+0x20/0x60 [n_hdlc]
 [<ffffffffa01fdc24>] n_hdlc_tty_ioctl+0x144/0x1d0 [n_hdlc]
 [<ffffffff814c25c1>] tty_ioctl+0x3f1/0xe40
...

Fix it by initializing the spin_locks separately. This removes also
reduntand memset of a freshly kzallocated space.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/tty/n_hdlc.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index 644ddb841d9f..a7fa016f31eb 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -159,7 +159,6 @@ struct n_hdlc {
 /*
  * HDLC buffer list manipulation functions
  */
-static void n_hdlc_buf_list_init(struct n_hdlc_buf_list *list);
 static void n_hdlc_buf_put(struct n_hdlc_buf_list *list,
 			   struct n_hdlc_buf *buf);
 static struct n_hdlc_buf *n_hdlc_buf_get(struct n_hdlc_buf_list *list);
@@ -853,10 +852,10 @@ static struct n_hdlc *n_hdlc_alloc(void)
 	if (!n_hdlc)
 		return NULL;
 
-	n_hdlc_buf_list_init(&n_hdlc->rx_free_buf_list);
-	n_hdlc_buf_list_init(&n_hdlc->tx_free_buf_list);
-	n_hdlc_buf_list_init(&n_hdlc->rx_buf_list);
-	n_hdlc_buf_list_init(&n_hdlc->tx_buf_list);
+	spin_lock_init(&n_hdlc->rx_free_buf_list.spinlock);
+	spin_lock_init(&n_hdlc->tx_free_buf_list.spinlock);
+	spin_lock_init(&n_hdlc->rx_buf_list.spinlock);
+	spin_lock_init(&n_hdlc->tx_buf_list.spinlock);
 	
 	/* allocate free rx buffer list */
 	for(i=0;i<DEFAULT_RX_BUF_COUNT;i++) {
@@ -885,16 +884,6 @@ static struct n_hdlc *n_hdlc_alloc(void)
 }	/* end of n_hdlc_alloc() */
 
 /**
- * n_hdlc_buf_list_init - initialize specified HDLC buffer list
- * @list - pointer to buffer list
- */
-static void n_hdlc_buf_list_init(struct n_hdlc_buf_list *list)
-{
-	memset(list, 0, sizeof(*list));
-	spin_lock_init(&list->spinlock);
-}	/* end of n_hdlc_buf_list_init() */
-
-/**
  * n_hdlc_buf_put - add specified HDLC buffer to tail of specified list
  * @list - pointer to buffer list
  * @buf	- pointer to buffer
-- 
2.11.0

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

* [added to the 4.1 stable tree] scsi: lpfc: Correct WQ creation for pagesize
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (13 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: IP22: Reformat inline assembler code to modern standards Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] TTY: n_hdlc, fix lockdep false positive Sasha Levin
                   ` (280 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: James Smart, Dick Kennedy, James Smart, Martin K . Petersen, Sasha Levin

From: James Smart <jsmart2021@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 8ea73db486cda442f0671f4bc9c03a76be398a28 ]

Correct WQ creation for pagesize

The driver was calculating the adapter command pagesize indicator from
the system pagesize. However, the buffers the driver allocates are only
one size (SLI4_PAGE_SIZE), so no calculation was necessary.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/scsi/lpfc/lpfc_hw4.h | 2 ++
 drivers/scsi/lpfc/lpfc_sli.c | 9 +++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index 1813c45946f4..3757a7399983 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -1180,6 +1180,7 @@ struct lpfc_mbx_wq_create {
 #define lpfc_mbx_wq_create_page_size_SHIFT	0
 #define lpfc_mbx_wq_create_page_size_MASK	0x000000FF
 #define lpfc_mbx_wq_create_page_size_WORD	word1
+#define LPFC_WQ_PAGE_SIZE_4096	0x1
 #define lpfc_mbx_wq_create_wqe_size_SHIFT	8
 #define lpfc_mbx_wq_create_wqe_size_MASK	0x0000000F
 #define lpfc_mbx_wq_create_wqe_size_WORD	word1
@@ -1251,6 +1252,7 @@ struct rq_context {
 #define lpfc_rq_context_page_size_SHIFT	0		/* Version 1 Only */
 #define lpfc_rq_context_page_size_MASK	0x000000FF
 #define lpfc_rq_context_page_size_WORD	word0
+#define	LPFC_RQ_PAGE_SIZE_4096	0x1
 	uint32_t reserved1;
 	uint32_t word2;
 #define lpfc_rq_context_cq_id_SHIFT	16
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 7ca27e5ef079..625e3ee877ee 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -13509,7 +13509,7 @@ lpfc_wq_create(struct lpfc_hba *phba, struct lpfc_queue *wq,
 			       LPFC_WQ_WQE_SIZE_128);
 			bf_set(lpfc_mbx_wq_create_page_size,
 			       &wq_create->u.request_1,
-			       (PAGE_SIZE/SLI4_PAGE_SIZE));
+			       LPFC_WQ_PAGE_SIZE_4096);
 			page = wq_create->u.request_1.page;
 			break;
 		}
@@ -13535,8 +13535,9 @@ lpfc_wq_create(struct lpfc_hba *phba, struct lpfc_queue *wq,
 			       LPFC_WQ_WQE_SIZE_128);
 			break;
 		}
-		bf_set(lpfc_mbx_wq_create_page_size, &wq_create->u.request_1,
-		       (PAGE_SIZE/SLI4_PAGE_SIZE));
+		bf_set(lpfc_mbx_wq_create_page_size,
+		       &wq_create->u.request_1,
+		       LPFC_WQ_PAGE_SIZE_4096);
 		page = wq_create->u.request_1.page;
 		break;
 	default:
@@ -13722,7 +13723,7 @@ lpfc_rq_create(struct lpfc_hba *phba, struct lpfc_queue *hrq,
 		       LPFC_RQE_SIZE_8);
 		bf_set(lpfc_rq_context_page_size,
 		       &rq_create->u.request.context,
-		       (PAGE_SIZE/SLI4_PAGE_SIZE));
+		       LPFC_RQ_PAGE_SIZE_4096);
 	} else {
 		switch (hrq->entry_count) {
 		default:
-- 
2.11.0

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

* [added to the 4.1 stable tree] tty: n_hdlc: get rid of racy n_hdlc.tbuf
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (16 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] KVM: VMX: use correct vmcs_read/write for guest segment selector/base Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] libceph: use BUG() instead of BUG_ON(1) Sasha Levin
                   ` (277 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Alexander Popov, Greg Kroah-Hartman, Sasha Levin

From: Alexander Popov <alex.popov@linux.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 82f2341c94d270421f383641b7cd670e474db56b ]

Currently N_HDLC line discipline uses a self-made singly linked list for
data buffers and has n_hdlc.tbuf pointer for buffer retransmitting after
an error.

The commit be10eb7589337e5defbe214dae038a53dd21add8
("tty: n_hdlc add buffer flushing") introduced racy access to n_hdlc.tbuf.
After tx error concurrent flush_tx_queue() and n_hdlc_send_frames() can put
one data buffer to tx_free_buf_list twice. That causes double free in
n_hdlc_release().

Let's use standard kernel linked list and get rid of n_hdlc.tbuf:
in case of tx error put current data buffer after the head of tx_buf_list.

Signed-off-by: Alexander Popov <alex.popov@linux.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/tty/n_hdlc.c | 132 +++++++++++++++++++++++++++------------------------
 1 file changed, 69 insertions(+), 63 deletions(-)

diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index a7fa016f31eb..6d1e2f746ab4 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -114,7 +114,7 @@
 #define DEFAULT_TX_BUF_COUNT 3
 
 struct n_hdlc_buf {
-	struct n_hdlc_buf *link;
+	struct list_head  list_item;
 	int		  count;
 	char		  buf[1];
 };
@@ -122,8 +122,7 @@ struct n_hdlc_buf {
 #define	N_HDLC_BUF_SIZE	(sizeof(struct n_hdlc_buf) + maxframe)
 
 struct n_hdlc_buf_list {
-	struct n_hdlc_buf *head;
-	struct n_hdlc_buf *tail;
+	struct list_head  list;
 	int		  count;
 	spinlock_t	  spinlock;
 };
@@ -136,7 +135,6 @@ struct n_hdlc_buf_list {
  * @backup_tty - TTY to use if tty gets closed
  * @tbusy - reentrancy flag for tx wakeup code
  * @woke_up - FIXME: describe this field
- * @tbuf - currently transmitting tx buffer
  * @tx_buf_list - list of pending transmit frame buffers
  * @rx_buf_list - list of received frame buffers
  * @tx_free_buf_list - list unused transmit frame buffers
@@ -149,7 +147,6 @@ struct n_hdlc {
 	struct tty_struct	*backup_tty;
 	int			tbusy;
 	int			woke_up;
-	struct n_hdlc_buf	*tbuf;
 	struct n_hdlc_buf_list	tx_buf_list;
 	struct n_hdlc_buf_list	rx_buf_list;
 	struct n_hdlc_buf_list	tx_free_buf_list;
@@ -159,6 +156,8 @@ struct n_hdlc {
 /*
  * HDLC buffer list manipulation functions
  */
+static void n_hdlc_buf_return(struct n_hdlc_buf_list *buf_list,
+						struct n_hdlc_buf *buf);
 static void n_hdlc_buf_put(struct n_hdlc_buf_list *list,
 			   struct n_hdlc_buf *buf);
 static struct n_hdlc_buf *n_hdlc_buf_get(struct n_hdlc_buf_list *list);
@@ -208,16 +207,9 @@ static void flush_tx_queue(struct tty_struct *tty)
 {
 	struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
 	struct n_hdlc_buf *buf;
-	unsigned long flags;
 
 	while ((buf = n_hdlc_buf_get(&n_hdlc->tx_buf_list)))
 		n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, buf);
- 	spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags);
-	if (n_hdlc->tbuf) {
-		n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, n_hdlc->tbuf);
-		n_hdlc->tbuf = NULL;
-	}
-	spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags);
 }
 
 static struct tty_ldisc_ops n_hdlc_ldisc = {
@@ -283,7 +275,6 @@ static void n_hdlc_release(struct n_hdlc *n_hdlc)
 		} else
 			break;
 	}
-	kfree(n_hdlc->tbuf);
 	kfree(n_hdlc);
 	
 }	/* end of n_hdlc_release() */
@@ -402,13 +393,7 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty)
 	n_hdlc->woke_up = 0;
 	spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags);
 
-	/* get current transmit buffer or get new transmit */
-	/* buffer from list of pending transmit buffers */
-		
-	tbuf = n_hdlc->tbuf;
-	if (!tbuf)
-		tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list);
-		
+	tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list);
 	while (tbuf) {
 		if (debuglevel >= DEBUG_LEVEL_INFO)	
 			printk("%s(%d)sending frame %p, count=%d\n",
@@ -420,7 +405,7 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty)
 
 		/* rollback was possible and has been done */
 		if (actual == -ERESTARTSYS) {
-			n_hdlc->tbuf = tbuf;
+			n_hdlc_buf_return(&n_hdlc->tx_buf_list, tbuf);
 			break;
 		}
 		/* if transmit error, throw frame away by */
@@ -435,10 +420,7 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty)
 					
 			/* free current transmit buffer */
 			n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, tbuf);
-			
-			/* this tx buffer is done */
-			n_hdlc->tbuf = NULL;
-			
+
 			/* wait up sleeping writers */
 			wake_up_interruptible(&tty->write_wait);
 	
@@ -448,10 +430,12 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty)
 			if (debuglevel >= DEBUG_LEVEL_INFO)	
 				printk("%s(%d)frame %p pending\n",
 					__FILE__,__LINE__,tbuf);
-					
-			/* buffer not accepted by driver */
-			/* set this buffer as pending buffer */
-			n_hdlc->tbuf = tbuf;
+
+			/*
+			 * the buffer was not accepted by driver,
+			 * return it back into tx queue
+			 */
+			n_hdlc_buf_return(&n_hdlc->tx_buf_list, tbuf);
 			break;
 		}
 	}
@@ -749,7 +733,8 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
 	int error = 0;
 	int count;
 	unsigned long flags;
-	
+	struct n_hdlc_buf *buf = NULL;
+
 	if (debuglevel >= DEBUG_LEVEL_INFO)	
 		printk("%s(%d)n_hdlc_tty_ioctl() called %d\n",
 			__FILE__,__LINE__,cmd);
@@ -763,8 +748,10 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
 		/* report count of read data available */
 		/* in next available frame (if any) */
 		spin_lock_irqsave(&n_hdlc->rx_buf_list.spinlock,flags);
-		if (n_hdlc->rx_buf_list.head)
-			count = n_hdlc->rx_buf_list.head->count;
+		buf = list_first_entry_or_null(&n_hdlc->rx_buf_list.list,
+						struct n_hdlc_buf, list_item);
+		if (buf)
+			count = buf->count;
 		else
 			count = 0;
 		spin_unlock_irqrestore(&n_hdlc->rx_buf_list.spinlock,flags);
@@ -776,8 +763,10 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
 		count = tty_chars_in_buffer(tty);
 		/* add size of next output frame in queue */
 		spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags);
-		if (n_hdlc->tx_buf_list.head)
-			count += n_hdlc->tx_buf_list.head->count;
+		buf = list_first_entry_or_null(&n_hdlc->tx_buf_list.list,
+						struct n_hdlc_buf, list_item);
+		if (buf)
+			count += buf->count;
 		spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock,flags);
 		error = put_user(count, (int __user *)arg);
 		break;
@@ -825,14 +814,14 @@ static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
 		poll_wait(filp, &tty->write_wait, wait);
 
 		/* set bits for operations that won't block */
-		if (n_hdlc->rx_buf_list.head)
+		if (!list_empty(&n_hdlc->rx_buf_list.list))
 			mask |= POLLIN | POLLRDNORM;	/* readable */
 		if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
 			mask |= POLLHUP;
 		if (tty_hung_up_p(filp))
 			mask |= POLLHUP;
 		if (!tty_is_writelocked(tty) &&
-				n_hdlc->tx_free_buf_list.head)
+				!list_empty(&n_hdlc->tx_free_buf_list.list))
 			mask |= POLLOUT | POLLWRNORM;	/* writable */
 	}
 	return mask;
@@ -856,7 +845,12 @@ static struct n_hdlc *n_hdlc_alloc(void)
 	spin_lock_init(&n_hdlc->tx_free_buf_list.spinlock);
 	spin_lock_init(&n_hdlc->rx_buf_list.spinlock);
 	spin_lock_init(&n_hdlc->tx_buf_list.spinlock);
-	
+
+	INIT_LIST_HEAD(&n_hdlc->rx_free_buf_list.list);
+	INIT_LIST_HEAD(&n_hdlc->tx_free_buf_list.list);
+	INIT_LIST_HEAD(&n_hdlc->rx_buf_list.list);
+	INIT_LIST_HEAD(&n_hdlc->tx_buf_list.list);
+
 	/* allocate free rx buffer list */
 	for(i=0;i<DEFAULT_RX_BUF_COUNT;i++) {
 		buf = kmalloc(N_HDLC_BUF_SIZE, GFP_KERNEL);
@@ -884,53 +878,65 @@ static struct n_hdlc *n_hdlc_alloc(void)
 }	/* end of n_hdlc_alloc() */
 
 /**
+ * n_hdlc_buf_return - put the HDLC buffer after the head of the specified list
+ * @buf_list - pointer to the buffer list
+ * @buf - pointer to the buffer
+ */
+static void n_hdlc_buf_return(struct n_hdlc_buf_list *buf_list,
+						struct n_hdlc_buf *buf)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&buf_list->spinlock, flags);
+
+	list_add(&buf->list_item, &buf_list->list);
+	buf_list->count++;
+
+	spin_unlock_irqrestore(&buf_list->spinlock, flags);
+}
+
+/**
  * n_hdlc_buf_put - add specified HDLC buffer to tail of specified list
- * @list - pointer to buffer list
+ * @buf_list - pointer to buffer list
  * @buf	- pointer to buffer
  */
-static void n_hdlc_buf_put(struct n_hdlc_buf_list *list,
+static void n_hdlc_buf_put(struct n_hdlc_buf_list *buf_list,
 			   struct n_hdlc_buf *buf)
 {
 	unsigned long flags;
-	spin_lock_irqsave(&list->spinlock,flags);
-	
-	buf->link=NULL;
-	if (list->tail)
-		list->tail->link = buf;
-	else
-		list->head = buf;
-	list->tail = buf;
-	(list->count)++;
-	
-	spin_unlock_irqrestore(&list->spinlock,flags);
-	
+
+	spin_lock_irqsave(&buf_list->spinlock, flags);
+
+	list_add_tail(&buf->list_item, &buf_list->list);
+	buf_list->count++;
+
+	spin_unlock_irqrestore(&buf_list->spinlock, flags);
 }	/* end of n_hdlc_buf_put() */
 
 /**
  * n_hdlc_buf_get - remove and return an HDLC buffer from list
- * @list - pointer to HDLC buffer list
+ * @buf_list - pointer to HDLC buffer list
  * 
  * Remove and return an HDLC buffer from the head of the specified HDLC buffer
  * list.
  * Returns a pointer to HDLC buffer if available, otherwise %NULL.
  */
-static struct n_hdlc_buf* n_hdlc_buf_get(struct n_hdlc_buf_list *list)
+static struct n_hdlc_buf *n_hdlc_buf_get(struct n_hdlc_buf_list *buf_list)
 {
 	unsigned long flags;
 	struct n_hdlc_buf *buf;
-	spin_lock_irqsave(&list->spinlock,flags);
-	
-	buf = list->head;
+
+	spin_lock_irqsave(&buf_list->spinlock, flags);
+
+	buf = list_first_entry_or_null(&buf_list->list,
+						struct n_hdlc_buf, list_item);
 	if (buf) {
-		list->head = buf->link;
-		(list->count)--;
+		list_del(&buf->list_item);
+		buf_list->count--;
 	}
-	if (!list->head)
-		list->tail = NULL;
-	
-	spin_unlock_irqrestore(&list->spinlock,flags);
+
+	spin_unlock_irqrestore(&buf_list->spinlock, flags);
 	return buf;
-	
 }	/* end of n_hdlc_buf_get() */
 
 static char hdlc_banner[] __initdata =
-- 
2.11.0

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

* [added to the 4.1 stable tree] KVM: VMX: use correct vmcs_read/write for guest segment selector/base
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (15 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] TTY: n_hdlc, fix lockdep false positive Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] tty: n_hdlc: get rid of racy n_hdlc.tbuf Sasha Levin
                   ` (278 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Chao Peng, Paolo Bonzini, Sasha Levin

From: Chao Peng <chao.p.peng@linux.intel.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 96794e4ed4d758272c486e1529e431efb7045265 ]

Guest segment selector is 16 bit field and guest segment base is natural
width field. Fix two incorrect invocations accordingly.

Without this patch, build fails when aggressive inlining is used with ICC.

Cc: stable@vger.kernel.org
Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/x86/kvm/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 665b10a55b30..50e0c4c6f69a 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3354,7 +3354,7 @@ static void fix_rmode_seg(int seg, struct kvm_segment *save)
 	}
 
 	vmcs_write16(sf->selector, var.selector);
-	vmcs_write32(sf->base, var.base);
+	vmcs_writel(sf->base, var.base);
 	vmcs_write32(sf->limit, var.limit);
 	vmcs_write32(sf->ar_bytes, vmx_segment_access_rights(&var));
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] s390: use correct input data address for setup_randomness
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (18 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] libceph: use BUG() instead of BUG_ON(1) Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] s390: make setup_randomness work Sasha Levin
                   ` (275 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Heiko Carstens, Martin Schwidefsky, Sasha Levin

From: Heiko Carstens <heiko.carstens@de.ibm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 4920e3cf77347d7d7373552d4839e8d832321313 ]

The current implementation of setup_randomness uses the stack address
and therefore the pointer to the SYSIB 3.2.2 block as input data
address. Furthermore the length of the input data is the number of
virtual-machine description blocks which is typically one.

This means that typically a single zero byte is fed to
add_device_randomness.

Fix both of these and use the address of the first virtual machine
description block as input data address and also use the correct
length.

Fixes: bcfcbb6bae64 ("s390: add system information as device randomness")
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/s390/kernel/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 86c33bb15867..208511437a28 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -803,7 +803,7 @@ static void __init setup_randomness(void)
 
 	vmms = (struct sysinfo_3_2_2 *) memblock_alloc(PAGE_SIZE, PAGE_SIZE);
 	if (stsi(vmms, 3, 2, 2) == 0 && vmms->count)
-		add_device_randomness(&vmms, vmms->count);
+		add_device_randomness(&vmms->vm, sizeof(vmms->vm[0]) * vmms->count);
 	memblock_free((unsigned long) vmms, PAGE_SIZE);
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] libceph: use BUG() instead of BUG_ON(1)
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (17 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] tty: n_hdlc: get rid of racy n_hdlc.tbuf Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] s390: use correct input data address for setup_randomness Sasha Levin
                   ` (276 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Arnd Bergmann, Ilya Dryomov, Sasha Levin

From: Arnd Bergmann <arnd@arndb.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit d24cdcd3e40a6825135498e11c20c7976b9bf545 ]

I ran into this compile warning, which is the result of BUG_ON(1)
not always leading to the compiler treating the code path as
unreachable:

    include/linux/ceph/osdmap.h: In function 'ceph_can_shift_osds':
    include/linux/ceph/osdmap.h:62:1: error: control reaches end of non-void function [-Werror=return-type]

Using BUG() here avoids the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 include/linux/ceph/osdmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/ceph/osdmap.h b/include/linux/ceph/osdmap.h
index e55c08bc3a96..0abc56140c83 100644
--- a/include/linux/ceph/osdmap.h
+++ b/include/linux/ceph/osdmap.h
@@ -49,7 +49,7 @@ static inline bool ceph_can_shift_osds(struct ceph_pg_pool_info *pool)
 	case CEPH_POOL_TYPE_EC:
 		return false;
 	default:
-		BUG_ON(1);
+		BUG();
 	}
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] s390: make setup_randomness work
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (19 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] s390: use correct input data address for setup_randomness Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] crypto: improve gcc optimization flags for serpent and wp512 Sasha Levin
                   ` (274 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Heiko Carstens, Martin Schwidefsky, Sasha Levin

From: Heiko Carstens <heiko.carstens@de.ibm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit da8fd820f389a0e29080b14c61bf5cf1d8ef5ca1 ]

Commit bcfcbb6bae64 ("s390: add system information as device
randomness") intended to add some virtual machine specific information
to the randomness pool.

Unfortunately it uses the page allocator before it is ready to use. In
result the page allocator always returns NULL and the setup_randomness
function never adds anything to the randomness pool.

To fix this use memblock_alloc and memblock_free instead.

Fixes: bcfcbb6bae64 ("s390: add system information as device randomness")
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/s390/kernel/setup.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 1942f22e6694..86c33bb15867 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -801,10 +801,10 @@ static void __init setup_randomness(void)
 {
 	struct sysinfo_3_2_2 *vmms;
 
-	vmms = (struct sysinfo_3_2_2 *) alloc_page(GFP_KERNEL);
-	if (vmms && stsi(vmms, 3, 2, 2) == 0 && vmms->count)
+	vmms = (struct sysinfo_3_2_2 *) memblock_alloc(PAGE_SIZE, PAGE_SIZE);
+	if (stsi(vmms, 3, 2, 2) == 0 && vmms->count)
 		add_device_randomness(&vmms, vmms->count);
-	free_page((unsigned long) vmms);
+	memblock_free((unsigned long) vmms, PAGE_SIZE);
 }
 
 /*
-- 
2.11.0

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

* [added to the 4.1 stable tree] crypto: improve gcc optimization flags for serpent and wp512
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (20 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] s390: make setup_randomness work Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: ip22: Fix ip28 build for modern gcc Sasha Levin
                   ` (273 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Arnd Bergmann, Herbert Xu, Sasha Levin

From: Arnd Bergmann <arnd@arndb.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 7d6e9105026788c497f0ab32fa16c82f4ab5ff61 ]

An ancient gcc bug (first reported in 2003) has apparently resurfaced
on MIPS, where kernelci.org reports an overly large stack frame in the
whirlpool hash algorithm:

crypto/wp512.c:987:1: warning: the frame size of 1112 bytes is larger than 1024 bytes [-Wframe-larger-than=]

With some testing in different configurations, I'm seeing large
variations in stack frames size up to 1500 bytes for what should have
around 300 bytes at most. I also checked the reference implementation,
which is essentially the same code but also comes with some test and
benchmarking infrastructure.

It seems that recent compiler versions on at least arm, arm64 and powerpc
have a partial fix for this problem, but enabling "-fsched-pressure", but
even with that fix they suffer from the issue to a certain degree. Some
testing on arm64 shows that the time needed to hash a given amount of
data is roughly proportional to the stack frame size here, which makes
sense given that the wp512 implementation is doing lots of loads for
table lookups, and the problem with the overly large stack is a result
of doing a lot more loads and stores for spilled registers (as seen from
inspecting the object code).

Disabling -fschedule-insns consistently fixes the problem for wp512,
in my collection of cross-compilers, the results are consistently better
or identical when comparing the stack sizes in this function, though
some architectures (notable x86) have schedule-insns disabled by
default.

The four columns are:
default: -O2
press:	 -O2 -fsched-pressure
nopress: -O2 -fschedule-insns -fno-sched-pressure
nosched: -O2 -no-schedule-insns (disables sched-pressure)

				default	press	nopress	nosched
alpha-linux-gcc-4.9.3		1136	848	1136	176
am33_2.0-linux-gcc-4.9.3	2100	2076	2100	2104
arm-linux-gnueabi-gcc-4.9.3	848	848	1048	352
cris-linux-gcc-4.9.3		272	272	272	272
frv-linux-gcc-4.9.3		1128	1000	1128	280
hppa64-linux-gcc-4.9.3		1128	336	1128	184
hppa-linux-gcc-4.9.3		644	308	644	276
i386-linux-gcc-4.9.3		352	352	352	352
m32r-linux-gcc-4.9.3		720	656	720	268
microblaze-linux-gcc-4.9.3	1108	604	1108	256
mips64-linux-gcc-4.9.3		1328	592	1328	208
mips-linux-gcc-4.9.3		1096	624	1096	240
powerpc64-linux-gcc-4.9.3	1088	432	1088	160
powerpc-linux-gcc-4.9.3		1080	584	1080	224
s390-linux-gcc-4.9.3		456	456	624	360
sh3-linux-gcc-4.9.3		292	292	292	292
sparc64-linux-gcc-4.9.3		992	240	992	208
sparc-linux-gcc-4.9.3		680	592	680	312
x86_64-linux-gcc-4.9.3		224	240	272	224
xtensa-linux-gcc-4.9.3		1152	704	1152	304

aarch64-linux-gcc-7.0.0		224	224	1104	208
arm-linux-gnueabi-gcc-7.0.1	824	824	1048	352
mips-linux-gcc-7.0.0		1120	648	1120	272
x86_64-linux-gcc-7.0.1		240	240	304	240

arm-linux-gnueabi-gcc-4.4.7	840			392
arm-linux-gnueabi-gcc-4.5.4	784	728	784	320
arm-linux-gnueabi-gcc-4.6.4	736	728	736	304
arm-linux-gnueabi-gcc-4.7.4	944	784	944	352
arm-linux-gnueabi-gcc-4.8.5	464	464	760	352
arm-linux-gnueabi-gcc-4.9.3	848	848	1048	352
arm-linux-gnueabi-gcc-5.3.1	824	824	1064	336
arm-linux-gnueabi-gcc-6.1.1	808	808	1056	344
arm-linux-gnueabi-gcc-7.0.1	824	824	1048	352

Trying the same test for serpent-generic, the picture is a bit different,
and while -fno-schedule-insns is generally better here than the default,
-fsched-pressure wins overall, so I picked that instead.

				default	press	nopress	nosched
alpha-linux-gcc-4.9.3		1392	864	1392	960
am33_2.0-linux-gcc-4.9.3	536	524	536	528
arm-linux-gnueabi-gcc-4.9.3	552	552	776	536
cris-linux-gcc-4.9.3		528	528	528	528
frv-linux-gcc-4.9.3		536	400	536	504
hppa64-linux-gcc-4.9.3		524	208	524	480
hppa-linux-gcc-4.9.3		768	472	768	508
i386-linux-gcc-4.9.3		564	564	564	564
m32r-linux-gcc-4.9.3		712	576	712	532
microblaze-linux-gcc-4.9.3	724	392	724	512
mips64-linux-gcc-4.9.3		720	384	720	496
mips-linux-gcc-4.9.3		728	384	728	496
powerpc64-linux-gcc-4.9.3	704	304	704	480
powerpc-linux-gcc-4.9.3		704	296	704	480
s390-linux-gcc-4.9.3		560	560	592	536
sh3-linux-gcc-4.9.3		540	540	540	540
sparc64-linux-gcc-4.9.3		544	352	544	496
sparc-linux-gcc-4.9.3		544	344	544	496
x86_64-linux-gcc-4.9.3		528	536	576	528
xtensa-linux-gcc-4.9.3		752	544	752	544

aarch64-linux-gcc-7.0.0		432	432	656	480
arm-linux-gnueabi-gcc-7.0.1	616	616	808	536
mips-linux-gcc-7.0.0		720	464	720	488
x86_64-linux-gcc-7.0.1		536	528	600	536

arm-linux-gnueabi-gcc-4.4.7	592			440
arm-linux-gnueabi-gcc-4.5.4	776	448	776	544
arm-linux-gnueabi-gcc-4.6.4	776	448	776	544
arm-linux-gnueabi-gcc-4.7.4	768	448	768	544
arm-linux-gnueabi-gcc-4.8.5	488	488	776	544
arm-linux-gnueabi-gcc-4.9.3	552	552	776	536
arm-linux-gnueabi-gcc-5.3.1	552	552	776	536
arm-linux-gnueabi-gcc-6.1.1	560	560	776	536
arm-linux-gnueabi-gcc-7.0.1	616	616	808	536

I did not do any runtime tests with serpent, so it is possible that stack
frame size does not directly correlate with runtime performance here and
it actually makes things worse, but it's more likely to help here, and
the reduced stack frame size is probably enough reason to apply the patch,
especially given that the crypto code is often used in deep call chains.

Link: https://kernelci.org/build/id/58797d7559b5149efdf6c3a9/logs/
Link: http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11488
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 crypto/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/crypto/Makefile b/crypto/Makefile
index 97b7d3ac87e7..16766ced6a44 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_CRYPTO_SHA1) += sha1_generic.o
 obj-$(CONFIG_CRYPTO_SHA256) += sha256_generic.o
 obj-$(CONFIG_CRYPTO_SHA512) += sha512_generic.o
 obj-$(CONFIG_CRYPTO_WP512) += wp512.o
+CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
 obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o
 obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
 obj-$(CONFIG_CRYPTO_ECB) += ecb.o
@@ -68,6 +69,7 @@ obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
 obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
 obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
 obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
+CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
 obj-$(CONFIG_CRYPTO_AES) += aes_generic.o
 obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
 obj-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
-- 
2.11.0

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

* [added to the 4.1 stable tree] MIPS: ip27: Disable qlge driver in defconfig
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (22 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: ip22: Fix ip28 build for modern gcc Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: ralink: Cosmetic change to prom_init() Sasha Levin
                   ` (271 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Arnd Bergmann, James Hogan, Sasha Levin

From: Arnd Bergmann <arnd@arndb.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit b617649468390713db1515ea79fc772d2eb897a8 ]

One of the last remaining failures in kernelci.org is for a gcc bug:

drivers/net/ethernet/qlogic/qlge/qlge_main.c:4819:1: error: insn does not satisfy its constraints:
drivers/net/ethernet/qlogic/qlge/qlge_main.c:4819:1: internal compiler error: in extract_constrain_insn, at recog.c:2190

This is apparently broken in gcc-6 but fixed in gcc-7, and I cannot
reproduce the problem here. However, it is clear that ip27_defconfig
does not actually need this driver as the platform has only PCI-X but
not PCIe, and the qlge adapter in turn is PCIe-only.

The driver was originally enabled in 2010 along with lots of other
drivers.

Fixes: 59d302b342e5 ("MIPS: IP27: Make defconfig useful again.")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/15197/
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/mips/configs/ip27_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/mips/configs/ip27_defconfig b/arch/mips/configs/ip27_defconfig
index 48e16d98b2cc..6ecc67f3736b 100644
--- a/arch/mips/configs/ip27_defconfig
+++ b/arch/mips/configs/ip27_defconfig
@@ -206,7 +206,6 @@ CONFIG_MLX4_EN=m
 # CONFIG_MLX4_DEBUG is not set
 CONFIG_TEHUTI=m
 CONFIG_BNX2X=m
-CONFIG_QLGE=m
 CONFIG_SFC=m
 CONFIG_BE2NET=m
 CONFIG_LIBERTAS_THINFIRM=m
-- 
2.11.0

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

* [added to the 4.1 stable tree] MIPS: ip22: Fix ip28 build for modern gcc
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (21 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] crypto: improve gcc optimization flags for serpent and wp512 Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: ip27: Disable qlge driver in defconfig Sasha Levin
                   ` (272 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Arnd Bergmann, Ralf Baechle, Sasha Levin

From: Arnd Bergmann <arnd@arndb.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 23ca9b522383d3b9b7991d8586db30118992af4a ]

kernelci reports a failure of the ip28_defconfig build after upgrading its
gcc version:

arch/mips/sgi-ip22/Platform:29: *** gcc doesn't support needed option -mr10k-cache-barrier=store.  Stop.

The problem apparently is that the -mr10k-cache-barrier=store option is now
rejected for CPUs other than r10k. Explicitly including the CPU in the
check fixes this and is safe because both options were introduced in
gcc-4.4.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/15049/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/mips/sgi-ip22/Platform | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/sgi-ip22/Platform b/arch/mips/sgi-ip22/Platform
index b7a4b7e04c38..e8f6b3a42a48 100644
--- a/arch/mips/sgi-ip22/Platform
+++ b/arch/mips/sgi-ip22/Platform
@@ -25,7 +25,7 @@ endif
 # Simplified: what IP22 does at 128MB+ in ksegN, IP28 does at 512MB+ in xkphys
 #
 ifdef CONFIG_SGI_IP28
-  ifeq ($(call cc-option-yn,-mr10k-cache-barrier=store), n)
+  ifeq ($(call cc-option-yn,-march=r10000 -mr10k-cache-barrier=store), n)
       $(error gcc doesn't support needed option -mr10k-cache-barrier=store)
   endif
 endif
-- 
2.11.0

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

* [added to the 4.1 stable tree] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (24 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: ralink: Cosmetic change to prom_init() Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: ralink: Remove unused rt*_wdt_reset functions Sasha Levin
                   ` (269 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Arnd Bergmann, Brian Norris, Sasha Levin

From: Arnd Bergmann <arnd@arndb.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 906b268477bc03daaa04f739844c120fe4dbc991 ]

kernelci.org reports a warning for this driver, as it copies a local
variable into a 'const char *' string:

    drivers/mtd/maps/pmcmsp-flash.c:149:30: warning: passing argument 1 of 'strncpy' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

Using kstrndup() simplifies the code and avoids the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/mtd/maps/pmcmsp-flash.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c
index 744ca5cacc9b..cf54420f943d 100644
--- a/drivers/mtd/maps/pmcmsp-flash.c
+++ b/drivers/mtd/maps/pmcmsp-flash.c
@@ -139,15 +139,13 @@ static int __init init_msp_flash(void)
 		}
 
 		msp_maps[i].bankwidth = 1;
-		msp_maps[i].name = kmalloc(7, GFP_KERNEL);
+		msp_maps[i].name = kstrndup(flash_name, 7, GFP_KERNEL);
 		if (!msp_maps[i].name) {
 			iounmap(msp_maps[i].virt);
 			kfree(msp_parts[i]);
 			goto cleanup_loop;
 		}
 
-		msp_maps[i].name = strncpy(msp_maps[i].name, flash_name, 7);
-
 		for (j = 0; j < pcnt; j++) {
 			part_name[5] = '0' + i;
 			part_name[7] = '0' + j;
-- 
2.11.0

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

* [added to the 4.1 stable tree] MIPS: ralink: Cosmetic change to prom_init().
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (23 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: ip27: Disable qlge driver in defconfig Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy Sasha Levin
                   ` (270 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: John Crispin, Ralf Baechle, Sasha Levin

From: John Crispin <john@phrozen.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 9c48568b3692f1a56cbf1935e4eea835e6b185b1 ]

Over the years the code has been changed various times leading to
argc/argv being defined in a different function to where we actually
use the variables. Clean this up by moving them to prom_init_cmdline().

Signed-off-by: John Crispin <john@phrozen.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14902/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/mips/ralink/prom.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/mips/ralink/prom.c b/arch/mips/ralink/prom.c
index 09419f67da39..bdfc253958f4 100644
--- a/arch/mips/ralink/prom.c
+++ b/arch/mips/ralink/prom.c
@@ -25,8 +25,10 @@ const char *get_system_type(void)
 	return soc_info.sys_type;
 }
 
-static __init void prom_init_cmdline(int argc, char **argv)
+static __init void prom_init_cmdline(void)
 {
+	int argc;
+	char **argv;
 	int i;
 
 	pr_debug("prom: fw_arg0=%08x fw_arg1=%08x fw_arg2=%08x fw_arg3=%08x\n",
@@ -55,14 +57,11 @@ static __init void prom_init_cmdline(int argc, char **argv)
 
 void __init prom_init(void)
 {
-	int argc;
-	char **argv;
-
 	prom_soc_init(&soc_info);
 
 	pr_info("SoC Type: %s\n", get_system_type());
 
-	prom_init_cmdline(argc, argv);
+	prom_init_cmdline();
 }
 
 void __init prom_free_prom_memory(void)
-- 
2.11.0

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

* [added to the 4.1 stable tree] cpmac: remove hopeless #warning
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (26 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: ralink: Remove unused rt*_wdt_reset functions Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: DEC: Avoid la pseudo-instruction in delay slots Sasha Levin
                   ` (267 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Arnd Bergmann, David S . Miller, Sasha Levin

From: Arnd Bergmann <arnd@arndb.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit d43e6fb4ac4abfe4ef7c102833ed02330ad701e0 ]

The #warning was present 10 years ago when the driver first got merged.
As the platform is rather obsolete by now, it seems very unlikely that
the warning will cause anyone to fix the code properly.

kernelci.org reports the warning for every build in the meantime, so
I think it's better to just turn it into a code comment to reduce
noise.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/ti/cpmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/cpmac.c b/drivers/net/ethernet/ti/cpmac.c
index dd9430043536..cf5ce371ec21 100644
--- a/drivers/net/ethernet/ti/cpmac.c
+++ b/drivers/net/ethernet/ti/cpmac.c
@@ -1235,7 +1235,7 @@ int cpmac_init(void)
 		goto fail_alloc;
 	}
 
-#warning FIXME: unhardcode gpio&reset bits
+	/* FIXME: unhardcode gpio&reset bits */
 	ar7_gpio_disable(26);
 	ar7_gpio_disable(27);
 	ar7_device_reset(AR7_RESET_BIT_CPMAC_LO);
-- 
2.11.0

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

* [added to the 4.1 stable tree] MIPS: ralink: Remove unused rt*_wdt_reset functions
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (25 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] cpmac: remove hopeless #warning Sasha Levin
                   ` (268 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Arnd Bergmann, Ralf Baechle, Sasha Levin

From: Arnd Bergmann <arnd@arndb.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 886f9c69fc68f56ddea34d3de51ac1fc2ac8dfbc ]

All pointers to these functions were removed, so now they produce
warnings:

arch/mips/ralink/rt305x.c:92:13: error: 'rt305x_wdt_reset' defined but not used [-Werror=unused-function]

This removes the functions. If we need them again, the patch can be
reverted later.

Fixes: f576fb6a0700 ("MIPS: ralink: cleanup the soc specific pinmux data")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: John Crispin <john@phrozen.org>
Cc: Colin Ian King <colin.king@canonical.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/15044/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/mips/ralink/rt288x.c | 10 ----------
 arch/mips/ralink/rt305x.c | 11 -----------
 arch/mips/ralink/rt3883.c | 10 ----------
 3 files changed, 31 deletions(-)

diff --git a/arch/mips/ralink/rt288x.c b/arch/mips/ralink/rt288x.c
index 738cec865f41..1bd7d704b01b 100644
--- a/arch/mips/ralink/rt288x.c
+++ b/arch/mips/ralink/rt288x.c
@@ -40,16 +40,6 @@ static struct rt2880_pmx_group rt2880_pinmux_data_act[] = {
 	{ 0 }
 };
 
-static void rt288x_wdt_reset(void)
-{
-	u32 t;
-
-	/* enable WDT reset output on pin SRAM_CS_N */
-	t = rt_sysc_r32(SYSC_REG_CLKCFG);
-	t |= CLKCFG_SRAM_CS_N_WDT;
-	rt_sysc_w32(t, SYSC_REG_CLKCFG);
-}
-
 void __init ralink_clk_init(void)
 {
 	unsigned long cpu_rate, wmac_rate = 40000000;
diff --git a/arch/mips/ralink/rt305x.c b/arch/mips/ralink/rt305x.c
index c40776ab67db..28bf6fbe8b04 100644
--- a/arch/mips/ralink/rt305x.c
+++ b/arch/mips/ralink/rt305x.c
@@ -91,17 +91,6 @@ static struct rt2880_pmx_group rt5350_pinmux_data[] = {
 	{ 0 }
 };
 
-static void rt305x_wdt_reset(void)
-{
-	u32 t;
-
-	/* enable WDT reset output on pin SRAM_CS_N */
-	t = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG);
-	t |= RT305X_SYSCFG_SRAM_CS0_MODE_WDT <<
-		RT305X_SYSCFG_SRAM_CS0_MODE_SHIFT;
-	rt_sysc_w32(t, SYSC_REG_SYSTEM_CONFIG);
-}
-
 static unsigned long rt5350_get_mem_size(void)
 {
 	void __iomem *sysc = (void __iomem *) KSEG1ADDR(RT305X_SYSC_BASE);
diff --git a/arch/mips/ralink/rt3883.c b/arch/mips/ralink/rt3883.c
index 5bda39fea483..d7998819954a 100644
--- a/arch/mips/ralink/rt3883.c
+++ b/arch/mips/ralink/rt3883.c
@@ -63,16 +63,6 @@ static struct rt2880_pmx_group rt3883_pinmux_data[] = {
 	{ 0 }
 };
 
-static void rt3883_wdt_reset(void)
-{
-	u32 t;
-
-	/* enable WDT reset output on GPIO 2 */
-	t = rt_sysc_r32(RT3883_SYSC_REG_SYSCFG1);
-	t |= RT3883_SYSCFG1_GPIO2_AS_WDT_OUT;
-	rt_sysc_w32(t, RT3883_SYSC_REG_SYSCFG1);
-}
-
 void __init ralink_clk_init(void)
 {
 	unsigned long cpu_rate, sys_rate;
-- 
2.11.0

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

* [added to the 4.1 stable tree] mvsas: fix misleading indentation
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (28 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: DEC: Avoid la pseudo-instruction in delay slots Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] dm: flush queued bios when process blocks to avoid deadlock Sasha Levin
                   ` (265 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Luis de Bethencourt, Martin K . Petersen, Sasha Levin

From: Luis de Bethencourt <luisbg@osg.samsung.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 7789cd39274c51bf475411fe22a8ee7255082809 ]

Fix a smatch warning:
drivers/scsi/mvsas/mv_sas.c:740 mvs_task_prep() warn: curly braces intended?

The code is correct, the indention is misleading. When the device is not
ready we want to return SAS_PHY_DOWN. But current indentation makes it
look like we only do so in the else branch of if (mvi_dev).

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/scsi/mvsas/mv_sas.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index 9c780740fb82..e712fe745955 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -737,8 +737,8 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf
 			mv_dprintk("device %016llx not ready.\n",
 				SAS_ADDR(dev->sas_addr));
 
-			rc = SAS_PHY_DOWN;
-			return rc;
+		rc = SAS_PHY_DOWN;
+		return rc;
 	}
 	tei.port = dev->port->lldd_port;
 	if (tei.port && !tei.port->port_attached && !tmf) {
-- 
2.11.0

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

* [added to the 4.1 stable tree] MIPS: DEC: Avoid la pseudo-instruction in delay slots
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (27 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] cpmac: remove hopeless #warning Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] mvsas: fix misleading indentation Sasha Levin
                   ` (266 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Ralf Baechle, Sasha Levin

From: Ralf Baechle <ralf@linux-mips.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 3021773c7c3e75e20b693931a19362681e744ea9 ]

When expanding the la or dla pseudo-instruction in a delay slot the GNU
assembler will complain should the pseudo-instruction expand to multiple
actual instructions, since only the first of them will be in the delay
slot leading to the pseudo-instruction being only partially executed if
the branch is taken. Use of PTR_LA in the dec int-handler.S leads to
such warnings:

  arch/mips/dec/int-handler.S: Assembler messages:
  arch/mips/dec/int-handler.S:149: Warning: macro instruction expanded into multiple instructions in a branch delay slot
  arch/mips/dec/int-handler.S:198: Warning: macro instruction expanded into multiple instructions in a branch delay slot

Avoid this by open coding the PTR_LA macros.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/mips/dec/int-handler.S | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/arch/mips/dec/int-handler.S b/arch/mips/dec/int-handler.S
index 8c6f508e59de..554d1da97743 100644
--- a/arch/mips/dec/int-handler.S
+++ b/arch/mips/dec/int-handler.S
@@ -146,7 +146,25 @@
 		/*
 		 * Find irq with highest priority
 		 */
-		 PTR_LA	t1,cpu_mask_nr_tbl
+		# open coded PTR_LA t1, cpu_mask_nr_tbl
+#if (_MIPS_SZPTR == 32)
+		# open coded la t1, cpu_mask_nr_tbl
+		lui	t1, %hi(cpu_mask_nr_tbl)
+		addiu	t1, %lo(cpu_mask_nr_tbl)
+
+#endif
+#if (_MIPS_SZPTR == 64)
+		# open coded dla t1, cpu_mask_nr_tbl
+		.set	push
+		.set	noat
+		lui	t1, %highest(cpu_mask_nr_tbl)
+		lui	AT, %hi(cpu_mask_nr_tbl)
+		daddiu	t1, t1, %higher(cpu_mask_nr_tbl)
+		daddiu	AT, AT, %lo(cpu_mask_nr_tbl)
+		dsll	t1, 32
+		daddu	t1, t1, AT
+		.set	pop
+#endif
 1:		lw	t2,(t1)
 		nop
 		and	t2,t0
@@ -195,7 +213,25 @@
 		/*
 		 * Find irq with highest priority
 		 */
-		 PTR_LA	t1,asic_mask_nr_tbl
+		# open coded PTR_LA t1,asic_mask_nr_tbl
+#if (_MIPS_SZPTR == 32)
+		# open coded la t1, asic_mask_nr_tbl
+		lui	t1, %hi(asic_mask_nr_tbl)
+		addiu	t1, %lo(asic_mask_nr_tbl)
+
+#endif
+#if (_MIPS_SZPTR == 64)
+		# open coded dla t1, asic_mask_nr_tbl
+		.set	push
+		.set	noat
+		lui	t1, %highest(asic_mask_nr_tbl)
+		lui	AT, %hi(asic_mask_nr_tbl)
+		daddiu	t1, t1, %higher(asic_mask_nr_tbl)
+		daddiu	AT, AT, %lo(asic_mask_nr_tbl)
+		dsll	t1, 32
+		daddu	t1, t1, AT
+		.set	pop
+#endif
 2:		lw	t2,(t1)
 		nop
 		and	t2,t0
-- 
2.11.0

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

* [added to the 4.1 stable tree] dm: flush queued bios when process blocks to avoid deadlock
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (29 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] mvsas: fix misleading indentation Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] ext4: don't BUG when truncating encrypted inodes on the orphan list Sasha Levin
                   ` (264 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Mikulas Patocka, Mike Snitzer, Sasha Levin

From: Mikulas Patocka <mpatocka@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit d67a5f4b5947aba4bfe9a80a2b86079c215ca755 ]

Commit df2cb6daa4 ("block: Avoid deadlocks with bio allocation by
stacking drivers") created a workqueue for every bio set and code
in bio_alloc_bioset() that tries to resolve some low-memory deadlocks
by redirecting bios queued on current->bio_list to the workqueue if the
system is low on memory.  However other deadlocks (see below **) may
happen, without any low memory condition, because generic_make_request
is queuing bios to current->bio_list (rather than submitting them).

** the related dm-snapshot deadlock is detailed here:
https://www.redhat.com/archives/dm-devel/2016-July/msg00065.html

Fix this deadlock by redirecting any bios on current->bio_list to the
bio_set's rescue workqueue on every schedule() call.  Consequently,
when the process blocks on a mutex, the bios queued on
current->bio_list are dispatched to independent workqueus and they can
complete without waiting for the mutex to be available.

The structure blk_plug contains an entry cb_list and this list can contain
arbitrary callback functions that are called when the process blocks.
To implement this fix DM (ab)uses the onstack plug's cb_list interface
to get its flush_current_bio_list() called at schedule() time.

This fixes the snapshot deadlock - if the map method blocks,
flush_current_bio_list() will be called and it redirects bios waiting
on current->bio_list to appropriate workqueues.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1267650
Depends-on: df2cb6daa4 ("block: Avoid deadlocks with bio allocation by stacking drivers")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/md/dm.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index d192ab2ed17c..c2a13fd9e0ca 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1435,11 +1435,62 @@ void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors)
 }
 EXPORT_SYMBOL_GPL(dm_accept_partial_bio);
 
+/*
+ * Flush current->bio_list when the target map method blocks.
+ * This fixes deadlocks in snapshot and possibly in other targets.
+ */
+struct dm_offload {
+	struct blk_plug plug;
+	struct blk_plug_cb cb;
+};
+
+static void flush_current_bio_list(struct blk_plug_cb *cb, bool from_schedule)
+{
+	struct dm_offload *o = container_of(cb, struct dm_offload, cb);
+	struct bio_list list;
+	struct bio *bio;
+
+	INIT_LIST_HEAD(&o->cb.list);
+
+	if (unlikely(!current->bio_list))
+		return;
+
+	list = *current->bio_list;
+	bio_list_init(current->bio_list);
+
+	while ((bio = bio_list_pop(&list))) {
+		struct bio_set *bs = bio->bi_pool;
+		if (unlikely(!bs) || bs == fs_bio_set) {
+			bio_list_add(current->bio_list, bio);
+			continue;
+		}
+
+		spin_lock(&bs->rescue_lock);
+		bio_list_add(&bs->rescue_list, bio);
+		queue_work(bs->rescue_workqueue, &bs->rescue_work);
+		spin_unlock(&bs->rescue_lock);
+	}
+}
+
+static void dm_offload_start(struct dm_offload *o)
+{
+	blk_start_plug(&o->plug);
+	o->cb.callback = flush_current_bio_list;
+	list_add(&o->cb.list, &current->plug->cb_list);
+}
+
+static void dm_offload_end(struct dm_offload *o)
+{
+	list_del(&o->cb.list);
+	blk_finish_plug(&o->plug);
+}
+
 static void __map_bio(struct dm_target_io *tio)
 {
 	int r;
 	sector_t sector;
 	struct mapped_device *md;
+	struct dm_offload o;
 	struct bio *clone = &tio->clone;
 	struct dm_target *ti = tio->ti;
 
@@ -1452,7 +1503,11 @@ static void __map_bio(struct dm_target_io *tio)
 	 */
 	atomic_inc(&tio->io->io_count);
 	sector = clone->bi_iter.bi_sector;
+
+	dm_offload_start(&o);
 	r = ti->type->map(ti, clone);
+	dm_offload_end(&o);
+
 	if (r == DM_MAPIO_REMAPPED) {
 		/* the bio has been remapped so dispatch it */
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] vxlan: correctly validate VXLAN ID against VXLAN_N_VID
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (31 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] ext4: don't BUG when truncating encrypted inodes on the orphan list Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] ipv4: mask tos for input route Sasha Levin
                   ` (262 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Matthias Schiffer, David S . Miller, Sasha Levin

From: Matthias Schiffer <mschiffer@universe-factory.net>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 4e37d6911f36545b286d15073f6f2222f840e81c ]

The incorrect check caused an off-by-one error: the maximum VID 0xffffff
was unusable.

Fixes: d342894c5d2f ("vxlan: virtual extensible lan")
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Acked-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/vxlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 422a9379a644..1ad3700ed9c7 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2432,7 +2432,7 @@ static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[])
 
 	if (data[IFLA_VXLAN_ID]) {
 		__u32 id = nla_get_u32(data[IFLA_VXLAN_ID]);
-		if (id >= VXLAN_VID_MASK)
+		if (id >= VXLAN_N_VID)
 			return -ERANGE;
 	}
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] ext4: don't BUG when truncating encrypted inodes on the orphan list
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (30 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] dm: flush queued bios when process blocks to avoid deadlock Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] vxlan: correctly validate VXLAN ID against VXLAN_N_VID Sasha Levin
                   ` (263 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Theodore Ts'o, Sasha Levin

From: Theodore Ts'o <tytso@mit.edu>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 0d06863f903ac5f4f6efb0273079d27de3e53a28 ]

Fix a BUG when the kernel tries to mount a file system constructed as
follows:

echo foo > foo.txt
mke2fs -Fq -t ext4 -O encrypt foo.img 100
debugfs -w foo.img << EOF
write foo.txt a
set_inode_field a i_flags 0x80800
set_super_value s_last_orphan 12
quit
EOF

root@kvm-xfstests:~# mount -o loop foo.img /mnt
[  160.238770] ------------[ cut here ]------------
[  160.240106] kernel BUG at /usr/projects/linux/ext4/fs/ext4/inode.c:3874!
[  160.240106] invalid opcode: 0000 [#1] SMP
[  160.240106] Modules linked in:
[  160.240106] CPU: 0 PID: 2547 Comm: mount Tainted: G        W       4.10.0-rc3-00034-gcdd33b941b67 #227
[  160.240106] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-1 04/01/2014
[  160.240106] task: f4518000 task.stack: f47b6000
[  160.240106] EIP: ext4_block_zero_page_range+0x1a7/0x2b4
[  160.240106] EFLAGS: 00010246 CPU: 0
[  160.240106] EAX: 00000001 EBX: f7be4b50 ECX: f47b7dc0 EDX: 00000007
[  160.240106] ESI: f43b05a8 EDI: f43babec EBP: f47b7dd0 ESP: f47b7dac
[  160.240106]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
[  160.240106] CR0: 80050033 CR2: bfd85b08 CR3: 34a00680 CR4: 000006f0
[  160.240106] Call Trace:
[  160.240106]  ext4_truncate+0x1e9/0x3e5
[  160.240106]  ext4_fill_super+0x286f/0x2b1e
[  160.240106]  ? set_blocksize+0x2e/0x7e
[  160.240106]  mount_bdev+0x114/0x15f
[  160.240106]  ext4_mount+0x15/0x17
[  160.240106]  ? ext4_calculate_overhead+0x39d/0x39d
[  160.240106]  mount_fs+0x58/0x115
[  160.240106]  vfs_kern_mount+0x4b/0xae
[  160.240106]  do_mount+0x671/0x8c3
[  160.240106]  ? _copy_from_user+0x70/0x83
[  160.240106]  ? strndup_user+0x31/0x46
[  160.240106]  SyS_mount+0x57/0x7b
[  160.240106]  do_int80_syscall_32+0x4f/0x61
[  160.240106]  entry_INT80_32+0x2f/0x2f
[  160.240106] EIP: 0xb76b919e
[  160.240106] EFLAGS: 00000246 CPU: 0
[  160.240106] EAX: ffffffda EBX: 08053838 ECX: 08052188 EDX: 080537e8
[  160.240106] ESI: c0ed0000 EDI: 00000000 EBP: 080537e8 ESP: bfa13660
[  160.240106]  DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b
[  160.240106] Code: 59 8b 00 a8 01 0f 84 09 01 00 00 8b 07 66 25 00 f0 66 3d 00 80 75 61 89 f8 e8 3e e2 ff ff 84 c0 74 56 83 bf 48 02 00 00 00 75 02 <0f> 0b 81 7d e8 00 10 00 00 74 02 0f 0b 8b 43 04 8b 53 08 31 c9
[  160.240106] EIP: ext4_block_zero_page_range+0x1a7/0x2b4 SS:ESP: 0068:f47b7dac
[  160.317241] ---[ end trace d6a773a375c810a5 ]---

The problem is that when the kernel tries to truncate an inode in
ext4_truncate(), it tries to clear any on-disk data beyond i_size.
Without the encryption key, it can't do that, and so it triggers a
BUG.

E2fsck does *not* provide this service, and in practice most file
systems have their orphan list processed by e2fsck, so to avoid
crashing, this patch skips this step if we don't have access to the
encryption key (which is the case when processing the orphan list; in
all other cases, we will have the encryption key, or the kernel
wouldn't have allowed the file to be opened).

An open question is whether the fact that e2fsck isn't clearing the
bytes beyond i_size causing problems --- and if we've lived with it
not doing it for so long, can we drop this from the kernel replay of
the orphan list in all cases (not just when we don't have the key for
encrypted inodes).

Addresses-Google-Bug: #35209576

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/ext4/inode.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 443ff49dc36f..c1feaf011515 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3531,6 +3531,10 @@ static int ext4_block_truncate_page(handle_t *handle,
 	unsigned blocksize;
 	struct inode *inode = mapping->host;
 
+	/* If we are processing an encrypted inode during orphan list handling */
+	if (ext4_encrypted_inode(inode) && !ext4_has_encryption_key(inode))
+		return 0;
+
 	blocksize = inode->i_sb->s_blocksize;
 	length = blocksize - (offset & (blocksize - 1));
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] vti6: return GRE_KEY for vti6
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (33 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] ipv4: mask tos for input route Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: don't call strlen() on the user buffer in packet_bind_spkt() Sasha Levin
                   ` (260 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David Forster, David S . Miller, Sasha Levin

From: David Forster <dforster@brocade.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 7dcdf941cdc96692ab99fd790c8cc68945514851 ]

Align vti6 with vti by returning GRE_KEY flag. This enables iproute2
to display tunnel keys on "ip -6 tunnel show"

Signed-off-by: David Forster <dforster@brocade.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv6/ip6_vti.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index 6ac448d8dd76..2ded71f4c299 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -681,6 +681,10 @@ vti6_parm_to_user(struct ip6_tnl_parm2 *u, const struct __ip6_tnl_parm *p)
 	u->link = p->link;
 	u->i_key = p->i_key;
 	u->o_key = p->o_key;
+	if (u->i_key)
+		u->i_flags |= GRE_KEY;
+	if (u->o_key)
+		u->o_flags |= GRE_KEY;
 	u->proto = p->proto;
 
 	memcpy(u->name, p->name, sizeof(u->name));
-- 
2.11.0

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

* [added to the 4.1 stable tree] ipv4: mask tos for input route
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (32 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] vxlan: correctly validate VXLAN ID against VXLAN_N_VID Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] vti6: return GRE_KEY for vti6 Sasha Levin
                   ` (261 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Julian Anastasov, David S . Miller, Sasha Levin

From: Julian Anastasov <ja@ssi.bg>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 6e28099d38c0e50d62c1afc054e37e573adf3d21 ]

Restore the lost masking of TOS in input route code to
allow ip rules to match it properly.

Problem [1] noticed by Shmulik Ladkani <shmulik.ladkani@gmail.com>

[1] http://marc.info/?t=137331755300040&r=1&w=2

Fixes: 89aef8921bfb ("ipv4: Delete routing cache.")
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv4/route.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 6141fef3a64b..8f29e29f18a1 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1887,6 +1887,7 @@ int ip_route_input_noref(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 {
 	int res;
 
+	tos &= IPTOS_RT_MASK;
 	rcu_read_lock();
 
 	/* Multicast recognition logic is moved from route cache to here.
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: don't call strlen() on the user buffer in packet_bind_spkt()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (34 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] vti6: return GRE_KEY for vti6 Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] l2tp: avoid use-after-free caused by l2tp_ip_backlog_recv Sasha Levin
                   ` (259 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Alexander Potapenko, David S . Miller, Sasha Levin

From: Alexander Potapenko <glider@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 540e2894f7905538740aaf122bd8e0548e1c34a4 ]

KMSAN (KernelMemorySanitizer, a new error detection tool) reports use of
uninitialized memory in packet_bind_spkt():
Acked-by: Eric Dumazet <edumazet@google.com>

==================================================================
BUG: KMSAN: use of unitialized memory
CPU: 0 PID: 1074 Comm: packet Not tainted 4.8.0-rc6+ #1891
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs
01/01/2011
 0000000000000000 ffff88006b6dfc08 ffffffff82559ae8 ffff88006b6dfb48
 ffffffff818a7c91 ffffffff85b9c870 0000000000000092 ffffffff85b9c550
 0000000000000000 0000000000000092 00000000ec400911 0000000000000002
Call Trace:
 [<     inline     >] __dump_stack lib/dump_stack.c:15
 [<ffffffff82559ae8>] dump_stack+0x238/0x290 lib/dump_stack.c:51
 [<ffffffff818a6626>] kmsan_report+0x276/0x2e0 mm/kmsan/kmsan.c:1003
 [<ffffffff818a783b>] __msan_warning+0x5b/0xb0
mm/kmsan/kmsan_instr.c:424
 [<     inline     >] strlen lib/string.c:484
 [<ffffffff8259b58d>] strlcpy+0x9d/0x200 lib/string.c:144
 [<ffffffff84b2eca4>] packet_bind_spkt+0x144/0x230
net/packet/af_packet.c:3132
 [<ffffffff84242e4d>] SYSC_bind+0x40d/0x5f0 net/socket.c:1370
 [<ffffffff84242a22>] SyS_bind+0x82/0xa0 net/socket.c:1356
 [<ffffffff8515991b>] entry_SYSCALL_64_fastpath+0x13/0x8f
arch/x86/entry/entry_64.o:?
chained origin: 00000000eba00911
 [<ffffffff810bb787>] save_stack_trace+0x27/0x50
arch/x86/kernel/stacktrace.c:67
 [<     inline     >] kmsan_save_stack_with_flags mm/kmsan/kmsan.c:322
 [<     inline     >] kmsan_save_stack mm/kmsan/kmsan.c:334
 [<ffffffff818a59f8>] kmsan_internal_chain_origin+0x118/0x1e0
mm/kmsan/kmsan.c:527
 [<ffffffff818a7773>] __msan_set_alloca_origin4+0xc3/0x130
mm/kmsan/kmsan_instr.c:380
 [<ffffffff84242b69>] SYSC_bind+0x129/0x5f0 net/socket.c:1356
 [<ffffffff84242a22>] SyS_bind+0x82/0xa0 net/socket.c:1356
 [<ffffffff8515991b>] entry_SYSCALL_64_fastpath+0x13/0x8f
arch/x86/entry/entry_64.o:?
origin description: ----address@SYSC_bind (origin=00000000eb400911)
==================================================================
(the line numbers are relative to 4.8-rc6, but the bug persists
upstream)

, when I run the following program as root:

=====================================
 #include <string.h>
 #include <sys/socket.h>
 #include <netpacket/packet.h>
 #include <net/ethernet.h>

 int main() {
   struct sockaddr addr;
   memset(&addr, 0xff, sizeof(addr));
   addr.sa_family = AF_PACKET;
   int fd = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ALL));
   bind(fd, &addr, sizeof(addr));
   return 0;
 }
=====================================

This happens because addr.sa_data copied from the userspace is not
zero-terminated, and copying it with strlcpy() in packet_bind_spkt()
results in calling strlen() on the kernel copy of that non-terminated
buffer.

Signed-off-by: Alexander Potapenko <glider@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/packet/af_packet.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 88cec9576e93..4bfdd9416e6c 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2781,7 +2781,7 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr,
 			    int addr_len)
 {
 	struct sock *sk = sock->sk;
-	char name[15];
+	char name[sizeof(uaddr->sa_data) + 1];
 
 	/*
 	 *	Check legality
@@ -2789,7 +2789,11 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr,
 
 	if (addr_len != sizeof(struct sockaddr))
 		return -EINVAL;
-	strlcpy(name, uaddr->sa_data, sizeof(name));
+	/* uaddr->sa_data comes from the userspace, it's not guaranteed to be
+	 * zero-terminated.
+	 */
+	memcpy(name, uaddr->sa_data, sizeof(uaddr->sa_data));
+	name[sizeof(uaddr->sa_data)] = 0;
 
 	return packet_do_bind(sk, name, 0, pkt_sk(sk)->num);
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] l2tp: avoid use-after-free caused by l2tp_ip_backlog_recv
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (35 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: don't call strlen() on the user buffer in packet_bind_spkt() Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] dccp: Unlock sock before calling sk_free() Sasha Levin
                   ` (258 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Paul Hüber, David S . Miller, Sasha Levin

From: Paul Hüber <phueber@kernsp.in>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 51fb60eb162ab84c5edf2ae9c63cf0b878e5547e ]

l2tp_ip_backlog_recv may not return -1 if the packet gets dropped.
The return value is passed up to ip_local_deliver_finish, which treats
negative values as an IP protocol number for resubmission.

Signed-off-by: Paul Hüber <phueber@kernsp.in>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/l2tp/l2tp_ip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index 44ee0683b14b..13c5a7ca0482 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -381,7 +381,7 @@ static int l2tp_ip_backlog_recv(struct sock *sk, struct sk_buff *skb)
 drop:
 	IP_INC_STATS(sock_net(sk), IPSTATS_MIB_INDISCARDS);
 	kfree_skb(skb);
-	return -1;
+	return 0;
 }
 
 /* Userspace will call sendmsg() on the tunnel socket to send L2TP
-- 
2.11.0

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

* [added to the 4.1 stable tree] tcp: fix various issues for sockets morphing to listen state
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (37 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] dccp: Unlock sock before calling sk_free() Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: fix socket refcounting in skb_complete_wifi_ack() Sasha Levin
                   ` (256 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Dumazet, David S . Miller, Sasha Levin

From: Eric Dumazet <edumazet@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 02b2faaf0af1d85585f6d6980e286d53612acfc2 ]

Dmitry Vyukov reported a divide by 0 triggered by syzkaller, exploiting
tcp_disconnect() path that was never really considered and/or used
before syzkaller ;)

I was not able to reproduce the bug, but it seems issues here are the
three possible actions that assumed they would never trigger on a
listener.

1) tcp_write_timer_handler
2) tcp_delack_timer_handler
3) MTU reduction

Only IPv6 MTU reduction was properly testing TCP_CLOSE and TCP_LISTEN
 states from tcp_v6_mtu_reduced()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv4/tcp_ipv4.c  | 7 +++++--
 net/ipv4/tcp_timer.c | 6 ++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 13b92d595138..23ea6cf1a4e5 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -271,10 +271,13 @@ EXPORT_SYMBOL(tcp_v4_connect);
  */
 void tcp_v4_mtu_reduced(struct sock *sk)
 {
-	struct dst_entry *dst;
 	struct inet_sock *inet = inet_sk(sk);
-	u32 mtu = tcp_sk(sk)->mtu_info;
+	struct dst_entry *dst;
+	u32 mtu;
 
+	if ((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE))
+		return;
+	mtu = tcp_sk(sk)->mtu_info;
 	dst = inet_csk_update_pmtu(sk, mtu);
 	if (!dst)
 		return;
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index c8f97858d6f6..f8c6b2343301 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -223,7 +223,8 @@ void tcp_delack_timer_handler(struct sock *sk)
 
 	sk_mem_reclaim_partial(sk);
 
-	if (sk->sk_state == TCP_CLOSE || !(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
+	if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) ||
+	    !(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
 		goto out;
 
 	if (time_after(icsk->icsk_ack.timeout, jiffies)) {
@@ -504,7 +505,8 @@ void tcp_write_timer_handler(struct sock *sk)
 	struct inet_connection_sock *icsk = inet_csk(sk);
 	int event;
 
-	if (sk->sk_state == TCP_CLOSE || !icsk->icsk_pending)
+	if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) ||
+	    !icsk->icsk_pending)
 		goto out;
 
 	if (time_after(icsk->icsk_timeout, jiffies)) {
-- 
2.11.0

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

* [added to the 4.1 stable tree] dccp: Unlock sock before calling sk_free()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (36 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] l2tp: avoid use-after-free caused by l2tp_ip_backlog_recv Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] tcp: fix various issues for sockets morphing to listen state Sasha Levin
                   ` (257 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Arnaldo Carvalho de Melo, David S . Miller, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit d5afb6f9b6bb2c57bd0c05e76e12489dc0d037d9 ]

The code where sk_clone() came from created a new socket and locked it,
but then, on the error path didn't unlock it.

This problem stayed there for a long while, till b0691c8ee7c2 ("net:
Unlock sock before calling sk_free()") fixed it, but unfortunately the
callers of sk_clone() (now sk_clone_locked()) were not audited and the
one in dccp_create_openreq_child() remained.

Now in the age of the syskaller fuzzer, this was finally uncovered, as
reported by Dmitry:

 ---- 8< ----

I've got the following report while running syzkaller fuzzer on
86292b33d4b7 ("Merge branch 'akpm' (patches from Andrew)")

  [ BUG: held lock freed! ]
  4.10.0+ #234 Not tainted
  -------------------------
  syz-executor6/6898 is freeing memory
  ffff88006286cac0-ffff88006286d3b7, with a lock still held there!
   (slock-AF_INET6){+.-...}, at: [<ffffffff8362c2c9>] spin_lock
  include/linux/spinlock.h:299 [inline]
   (slock-AF_INET6){+.-...}, at: [<ffffffff8362c2c9>]
  sk_clone_lock+0x3d9/0x12c0 net/core/sock.c:1504
  5 locks held by syz-executor6/6898:
   #0:  (sk_lock-AF_INET6){+.+.+.}, at: [<ffffffff839a34b4>] lock_sock
  include/net/sock.h:1460 [inline]
   #0:  (sk_lock-AF_INET6){+.+.+.}, at: [<ffffffff839a34b4>]
  inet_stream_connect+0x44/0xa0 net/ipv4/af_inet.c:681
   #1:  (rcu_read_lock){......}, at: [<ffffffff83bc1c2a>]
  inet6_csk_xmit+0x12a/0x5d0 net/ipv6/inet6_connection_sock.c:126
   #2:  (rcu_read_lock){......}, at: [<ffffffff8369b424>] __skb_unlink
  include/linux/skbuff.h:1767 [inline]
   #2:  (rcu_read_lock){......}, at: [<ffffffff8369b424>] __skb_dequeue
  include/linux/skbuff.h:1783 [inline]
   #2:  (rcu_read_lock){......}, at: [<ffffffff8369b424>]
  process_backlog+0x264/0x730 net/core/dev.c:4835
   #3:  (rcu_read_lock){......}, at: [<ffffffff83aeb5c0>]
  ip6_input_finish+0x0/0x1700 net/ipv6/ip6_input.c:59
   #4:  (slock-AF_INET6){+.-...}, at: [<ffffffff8362c2c9>] spin_lock
  include/linux/spinlock.h:299 [inline]
   #4:  (slock-AF_INET6){+.-...}, at: [<ffffffff8362c2c9>]
  sk_clone_lock+0x3d9/0x12c0 net/core/sock.c:1504

Fix it just like was done by b0691c8ee7c2 ("net: Unlock sock before calling
sk_free()").

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170301153510.GE15145@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/dccp/minisocks.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index 838f524cf11a..53c38641fe98 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -122,6 +122,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
 			/* It is still raw copy of parent, so invalidate
 			 * destructor and make plain sk_free() */
 			newsk->sk_destruct = NULL;
+			bh_unlock_sock(newsk);
 			sk_free(newsk);
 			return NULL;
 		}
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: fix socket refcounting in skb_complete_wifi_ack()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (38 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] tcp: fix various issues for sockets morphing to listen state Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: fix socket refcounting in skb_complete_tx_timestamp() Sasha Levin
                   ` (255 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Dumazet, David S . Miller, Sasha Levin

From: Eric Dumazet <edumazet@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit dd4f10722aeb10f4f582948839f066bebe44e5fb ]

TX skbs do not necessarily hold a reference on skb->sk->sk_refcnt
By the time TX completion happens, sk_refcnt might be already 0.

sock_hold()/sock_put() would then corrupt critical state, like
sk_wmem_alloc.

Fixes: bf7fa551e0ce ("mac80211: Resolve sk_refcnt/sk_wmem_alloc issue in wifi ack path")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Alexander Duyck <alexander.h.duyck@intel.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Soheil Hassas Yeganeh <soheil@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/core/skbuff.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 2894bb5b7e0a..6642accc628a 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3753,7 +3753,7 @@ void skb_complete_wifi_ack(struct sk_buff *skb, bool acked)
 {
 	struct sock *sk = skb->sk;
 	struct sock_exterr_skb *serr;
-	int err;
+	int err = 1;
 
 	skb->wifi_acked_valid = 1;
 	skb->wifi_acked = acked;
@@ -3763,14 +3763,15 @@ void skb_complete_wifi_ack(struct sk_buff *skb, bool acked)
 	serr->ee.ee_errno = ENOMSG;
 	serr->ee.ee_origin = SO_EE_ORIGIN_TXSTATUS;
 
-	/* take a reference to prevent skb_orphan() from freeing the socket */
-	sock_hold(sk);
-
-	err = sock_queue_err_skb(sk, skb);
+	/* Take a reference to prevent skb_orphan() from freeing the socket,
+	 * but only if the socket refcount is not zero.
+	 */
+	if (likely(atomic_inc_not_zero(&sk->sk_refcnt))) {
+		err = sock_queue_err_skb(sk, skb);
+		sock_put(sk);
+	}
 	if (err)
 		kfree_skb(skb);
-
-	sock_put(sk);
 }
 EXPORT_SYMBOL_GPL(skb_complete_wifi_ack);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: fix socket refcounting in skb_complete_tx_timestamp()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (39 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: fix socket refcounting in skb_complete_wifi_ack() Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] uapi: fix linux/packet_diag.h userspace compilation error Sasha Levin
                   ` (254 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Dumazet, David S . Miller, Sasha Levin

From: Eric Dumazet <edumazet@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 9ac25fc063751379cb77434fef9f3b088cd3e2f7 ]

TX skbs do not necessarily hold a reference on skb->sk->sk_refcnt
By the time TX completion happens, sk_refcnt might be already 0.

sock_hold()/sock_put() would then corrupt critical state, like
sk_wmem_alloc and lead to leaks or use after free.

Fixes: 62bccb8cdb69 ("net-timestamp: Make the clone operation stand-alone from phy timestamping")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Alexander Duyck <alexander.h.duyck@intel.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Soheil Hassas Yeganeh <soheil@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/core/skbuff.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 6642accc628a..97a1fa140a9b 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3696,13 +3696,14 @@ void skb_complete_tx_timestamp(struct sk_buff *skb,
 	if (!skb_may_tx_timestamp(sk, false))
 		return;
 
-	/* take a reference to prevent skb_orphan() from freeing the socket */
-	sock_hold(sk);
-
-	*skb_hwtstamps(skb) = *hwtstamps;
-	__skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND);
-
-	sock_put(sk);
+	/* Take a reference to prevent skb_orphan() from freeing the socket,
+	 * but only if the socket refcount is not zero.
+	 */
+	if (likely(atomic_inc_not_zero(&sk->sk_refcnt))) {
+		*skb_hwtstamps(skb) = *hwtstamps;
+		__skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND);
+		sock_put(sk);
+	}
 }
 EXPORT_SYMBOL_GPL(skb_complete_tx_timestamp);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] uapi: fix linux/packet_diag.h userspace compilation error
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (40 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: fix socket refcounting in skb_complete_tx_timestamp() Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] act_connmark: avoid crashing on malformed nlattrs with null parms Sasha Levin
                   ` (253 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Dmitry V. Levin, David S . Miller, Sasha Levin

From: "Dmitry V. Levin" <ldv@altlinux.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 745cb7f8a5de0805cade3de3991b7a95317c7c73 ]

Replace MAX_ADDR_LEN with its numeric value to fix the following
linux/packet_diag.h userspace compilation error:

/usr/include/linux/packet_diag.h:67:17: error: 'MAX_ADDR_LEN' undeclared here (not in a function)
  __u8 pdmc_addr[MAX_ADDR_LEN];

This is not the first case in the UAPI where the numeric value
of MAX_ADDR_LEN is used instead of symbolic one, uapi/linux/if_link.h
already does the same:

$ grep MAX_ADDR_LEN include/uapi/linux/if_link.h
	__u8 mac[32]; /* MAX_ADDR_LEN */

There are no UAPI headers besides these two that use MAX_ADDR_LEN.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Acked-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 include/uapi/linux/packet_diag.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/packet_diag.h b/include/uapi/linux/packet_diag.h
index d08c63f3dd6f..0c5d5dd61b6a 100644
--- a/include/uapi/linux/packet_diag.h
+++ b/include/uapi/linux/packet_diag.h
@@ -64,7 +64,7 @@ struct packet_diag_mclist {
 	__u32	pdmc_count;
 	__u16	pdmc_type;
 	__u16	pdmc_alen;
-	__u8	pdmc_addr[MAX_ADDR_LEN];
+	__u8	pdmc_addr[32]; /* MAX_ADDR_LEN */
 };
 
 struct packet_diag_ring {
-- 
2.11.0

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

* [added to the 4.1 stable tree] act_connmark: avoid crashing on malformed nlattrs with null parms
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (41 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] uapi: fix linux/packet_diag.h userspace compilation error Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] mpls: Send route delete notifications when router module is unloaded Sasha Levin
                   ` (252 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Etienne Noss, Victorien Molle, David S . Miller, Sasha Levin

From: Etienne Noss <etienne.noss@wifirst.fr>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 52491c7607c5527138095edf44c53169dc1ddb82 ]

tcf_connmark_init does not check in its configuration if TCA_CONNMARK_PARMS
is set, resulting in a null pointer dereference when trying to access it.

[501099.043007] BUG: unable to handle kernel NULL pointer dereference at 0000000000000004
[501099.043039] IP: [<ffffffffc10c60fb>] tcf_connmark_init+0x8b/0x180 [act_connmark]
...
[501099.044334] Call Trace:
[501099.044345]  [<ffffffffa47270e8>] ? tcf_action_init_1+0x198/0x1b0
[501099.044363]  [<ffffffffa47271b0>] ? tcf_action_init+0xb0/0x120
[501099.044380]  [<ffffffffa47250a4>] ? tcf_exts_validate+0xc4/0x110
[501099.044398]  [<ffffffffc0f5fa97>] ? u32_set_parms+0xa7/0x270 [cls_u32]
[501099.044417]  [<ffffffffc0f60bf0>] ? u32_change+0x680/0x87b [cls_u32]
[501099.044436]  [<ffffffffa4725d1d>] ? tc_ctl_tfilter+0x4dd/0x8a0
[501099.044454]  [<ffffffffa44a23a1>] ? security_capable+0x41/0x60
[501099.044471]  [<ffffffffa470ca01>] ? rtnetlink_rcv_msg+0xe1/0x220
[501099.044490]  [<ffffffffa470c920>] ? rtnl_newlink+0x870/0x870
[501099.044507]  [<ffffffffa472cc61>] ? netlink_rcv_skb+0xa1/0xc0
[501099.044524]  [<ffffffffa47073f4>] ? rtnetlink_rcv+0x24/0x30
[501099.044541]  [<ffffffffa472c634>] ? netlink_unicast+0x184/0x230
[501099.044558]  [<ffffffffa472c9d8>] ? netlink_sendmsg+0x2f8/0x3b0
[501099.044576]  [<ffffffffa46d8880>] ? sock_sendmsg+0x30/0x40
[501099.044592]  [<ffffffffa46d8e03>] ? SYSC_sendto+0xd3/0x150
[501099.044608]  [<ffffffffa425fda1>] ? __do_page_fault+0x2d1/0x510
[501099.044626]  [<ffffffffa47fbd7b>] ? system_call_fast_compare_end+0xc/0x9b

Fixes: 22a5dc0e5e3e ("net: sched: Introduce connmark action")
Signed-off-by: Étienne Noss <etienne.noss@wifirst.fr>
Signed-off-by: Victorien Molle <victorien.molle@wifirst.fr>
Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/sched/act_connmark.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/sched/act_connmark.c b/net/sched/act_connmark.c
index 295d14bd6c67..85e3207d047a 100644
--- a/net/sched/act_connmark.c
+++ b/net/sched/act_connmark.c
@@ -105,6 +105,9 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla,
 	if (ret < 0)
 		return ret;
 
+	if (!tb[TCA_CONNMARK_PARMS])
+		return -EINVAL;
+
 	parm = nla_data(tb[TCA_CONNMARK_PARMS]);
 
 	if (!tcf_hash_check(parm->index, a, bind)) {
-- 
2.11.0

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

* [added to the 4.1 stable tree] mpls: Send route delete notifications when router module is unloaded
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (42 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] act_connmark: avoid crashing on malformed nlattrs with null parms Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] ipv6: make ECMP route replacement less greedy Sasha Levin
                   ` (251 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David Ahern, David S . Miller, Sasha Levin

From: David Ahern <dsa@cumulusnetworks.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e37791ec1ad785b59022ae211f63a16189bacebf ]

When the mpls_router module is unloaded, mpls routes are deleted but
notifications are not sent to userspace leaving userspace caches
out of sync. Add the call to mpls_notify_route in mpls_net_exit as
routes are freed.

Fixes: 0189197f44160 ("mpls: Basic routing support")
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/mpls/af_mpls.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 1f93a5978f2a..398375098efb 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -1098,6 +1098,7 @@ static void mpls_net_exit(struct net *net)
 	for (index = 0; index < platform_labels; index++) {
 		struct mpls_route *rt = rtnl_dereference(platform_label[index]);
 		RCU_INIT_POINTER(platform_label[index], NULL);
+		mpls_notify_route(net, index, rt, NULL, NULL);
 		mpls_rt_free(rt);
 	}
 	rtnl_unlock();
-- 
2.11.0

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

* [added to the 4.1 stable tree] dccp/tcp: fix routing redirect race
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (44 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] ipv6: make ECMP route replacement less greedy Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] dccp: fix memory leak during tear-down of unsuccessful connection request Sasha Levin
                   ` (249 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jon Maxwell, David S . Miller, Sasha Levin

From: Jon Maxwell <jmaxwell37@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 45caeaa5ac0b4b11784ac6f932c0ad4c6b67cda0 ]

As Eric Dumazet pointed out this also needs to be fixed in IPv6.
v2: Contains the IPv6 tcp/Ipv6 dccp patches as well.

We have seen a few incidents lately where a dst_enty has been freed
with a dangling TCP socket reference (sk->sk_dst_cache) pointing to that
dst_entry. If the conditions/timings are right a crash then ensues when the
freed dst_entry is referenced later on. A Common crashing back trace is:

 #8 [] page_fault at ffffffff8163e648
    [exception RIP: __tcp_ack_snd_check+74]
.
.
 #9 [] tcp_rcv_established at ffffffff81580b64
#10 [] tcp_v4_do_rcv at ffffffff8158b54a
#11 [] tcp_v4_rcv at ffffffff8158cd02
#12 [] ip_local_deliver_finish at ffffffff815668f4
#13 [] ip_local_deliver at ffffffff81566bd9
#14 [] ip_rcv_finish at ffffffff8156656d
#15 [] ip_rcv at ffffffff81566f06
#16 [] __netif_receive_skb_core at ffffffff8152b3a2
#17 [] __netif_receive_skb at ffffffff8152b608
#18 [] netif_receive_skb at ffffffff8152b690
#19 [] vmxnet3_rq_rx_complete at ffffffffa015eeaf [vmxnet3]
#20 [] vmxnet3_poll_rx_only at ffffffffa015f32a [vmxnet3]
#21 [] net_rx_action at ffffffff8152bac2
#22 [] __do_softirq at ffffffff81084b4f
#23 [] call_softirq at ffffffff8164845c
#24 [] do_softirq at ffffffff81016fc5
#25 [] irq_exit at ffffffff81084ee5
#26 [] do_IRQ at ffffffff81648ff8

Of course it may happen with other NIC drivers as well.

It's found the freed dst_entry here:

 224 static bool tcp_in_quickack_mode(struct sock *sk)↩
 225 {↩
 226 ▹       const struct inet_connection_sock *icsk = inet_csk(sk);↩
 227 ▹       const struct dst_entry *dst = __sk_dst_get(sk);↩
 228 ↩
 229 ▹       return (dst && dst_metric(dst, RTAX_QUICKACK)) ||↩
 230 ▹       ▹       (icsk->icsk_ack.quick && !icsk->icsk_ack.pingpong);↩
 231 }↩

But there are other backtraces attributed to the same freed dst_entry in
netfilter code as well.

All the vmcores showed 2 significant clues:

- Remote hosts behind the default gateway had always been redirected to a
different gateway. A rtable/dst_entry will be added for that host. Making
more dst_entrys with lower reference counts. Making this more probable.

- All vmcores showed a postitive LockDroppedIcmps value, e.g:

LockDroppedIcmps                  267

A closer look at the tcp_v4_err() handler revealed that do_redirect() will run
regardless of whether user space has the socket locked. This can result in a
race condition where the same dst_entry cached in sk->sk_dst_entry can be
decremented twice for the same socket via:

do_redirect()->__sk_dst_check()-> dst_release().

Which leads to the dst_entry being prematurely freed with another socket
pointing to it via sk->sk_dst_cache and a subsequent crash.

To fix this skip do_redirect() if usespace has the socket locked. Instead let
the redirect take place later when user space does not have the socket
locked.

The dccp/IPv6 code is very similar in this respect, so fixing it there too.

As Eric Garver pointed out the following commit now invalidates routes. Which
can set the dst->obsolete flag so that ipv4_dst_check() returns null and
triggers the dst_release().

Fixes: ceb3320610d6 ("ipv4: Kill routes during PMTU/redirect updates.")
Cc: Eric Garver <egarver@redhat.com>
Cc: Hannes Sowa <hsowa@redhat.com>
Signed-off-by: Jon Maxwell <jmaxwell37@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/dccp/ipv4.c     | 3 ++-
 net/dccp/ipv6.c     | 8 +++++---
 net/ipv4/tcp_ipv4.c | 3 ++-
 net/ipv6/tcp_ipv6.c | 8 +++++---
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index fd7ac7895c38..bafb2223b879 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -289,7 +289,8 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
 
 	switch (type) {
 	case ICMP_REDIRECT:
-		dccp_do_redirect(skb, sk);
+		if (!sock_owned_by_user(sk))
+			dccp_do_redirect(skb, sk);
 		goto out;
 	case ICMP_SOURCE_QUENCH:
 		/* Just silently ignore these. */
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index a0490508d213..d61027e78e25 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -121,10 +121,12 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	np = inet6_sk(sk);
 
 	if (type == NDISC_REDIRECT) {
-		struct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie);
+		if (!sock_owned_by_user(sk)) {
+			struct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie);
 
-		if (dst)
-			dst->ops->redirect(dst, sk, skb);
+			if (dst)
+				dst->ops->redirect(dst, sk, skb);
+		}
 		goto out;
 	}
 
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 23ea6cf1a4e5..2923f7f7932a 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -420,7 +420,8 @@ void tcp_v4_err(struct sk_buff *icmp_skb, u32 info)
 
 	switch (type) {
 	case ICMP_REDIRECT:
-		do_redirect(icmp_skb, sk);
+		if (!sock_owned_by_user(sk))
+			do_redirect(icmp_skb, sk);
 		goto out;
 	case ICMP_SOURCE_QUENCH:
 		/* Just silently ignore these. */
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 0b43bcb6e576..2f0f1b415fbe 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -382,10 +382,12 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	np = inet6_sk(sk);
 
 	if (type == NDISC_REDIRECT) {
-		struct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie);
+		if (!sock_owned_by_user(sk)) {
+			struct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie);
 
-		if (dst)
-			dst->ops->redirect(dst, sk, skb);
+			if (dst)
+				dst->ops->redirect(dst, sk, skb);
+		}
 		goto out;
 	}
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] ipv6: make ECMP route replacement less greedy
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (43 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] mpls: Send route delete notifications when router module is unloaded Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] dccp/tcp: fix routing redirect race Sasha Levin
                   ` (250 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Sabrina Dubroca, David S . Miller, Sasha Levin

From: Sabrina Dubroca <sd@queasysnail.net>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 67e194007be08d071294456274dd53e0a04fdf90 ]

Commit 27596472473a ("ipv6: fix ECMP route replacement") introduced a
loop that removes all siblings of an ECMP route that is being
replaced. However, this loop doesn't stop when it has replaced
siblings, and keeps removing other routes with a higher metric.
We also end up triggering the WARN_ON after the loop, because after
this nsiblings < 0.

Instead, stop the loop when we have taken care of all routes with the
same metric as the route being replaced.

  Reproducer:
  ===========
    #!/bin/sh

    ip netns add ns1
    ip netns add ns2
    ip -net ns1 link set lo up

    for x in 0 1 2 ; do
        ip link add veth$x netns ns2 type veth peer name eth$x netns ns1
        ip -net ns1 link set eth$x up
        ip -net ns2 link set veth$x up
    done

    ip -net ns1 -6 r a 2000::/64 nexthop via fe80::0 dev eth0 \
            nexthop via fe80::1 dev eth1 nexthop via fe80::2 dev eth2
    ip -net ns1 -6 r a 2000::/64 via fe80::42 dev eth0 metric 256
    ip -net ns1 -6 r a 2000::/64 via fe80::43 dev eth0 metric 2048

    echo "before replace, 3 routes"
    ip -net ns1 -6 r | grep -v '^fe80\|^ff00'
    echo

    ip -net ns1 -6 r c 2000::/64 nexthop via fe80::4 dev eth0 \
            nexthop via fe80::5 dev eth1 nexthop via fe80::6 dev eth2

    echo "after replace, only 2 routes, metric 2048 is gone"
    ip -net ns1 -6 r | grep -v '^fe80\|^ff00'

Fixes: 27596472473a ("ipv6: fix ECMP route replacement")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv6/ip6_fib.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index e7a60f5de097..0c9a4cac95ee 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -868,6 +868,8 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
 			ins = &rt->dst.rt6_next;
 			iter = *ins;
 			while (iter) {
+				if (iter->rt6i_metric > rt->rt6i_metric)
+					break;
 				if (rt6_qualify_for_ecmp(iter)) {
 					*ins = iter->dst.rt6_next;
 					fib6_purge_rt(iter, fn, info->nl_net);
-- 
2.11.0

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

* [added to the 4.1 stable tree] net sched actions: decrement module reference count after table flush.
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (46 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] dccp: fix memory leak during tear-down of unsuccessful connection request Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] crypto: ghash-clmulni - Fix load failure Sasha Levin
                   ` (247 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Roman Mashak, Jamal Hadi Salim, David S . Miller, Sasha Levin

From: Roman Mashak <mrv@mojatatu.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit edb9d1bff4bbe19b8ae0e71b1f38732591a9eeb2 ]

When tc actions are loaded as a module and no actions have been installed,
flushing them would result in actions removed from the memory, but modules
reference count not being decremented, so that the modules would not be
unloaded.

Following is example with GACT action:

% sudo modprobe act_gact
% lsmod
Module                  Size  Used by
act_gact               16384  0
%
% sudo tc actions ls action gact
%
% sudo tc actions flush action gact
% lsmod
Module                  Size  Used by
act_gact               16384  1
% sudo tc actions flush action gact
% lsmod
Module                  Size  Used by
act_gact               16384  2
% sudo rmmod act_gact
rmmod: ERROR: Module act_gact is in use
....

After the fix:
% lsmod
Module                  Size  Used by
act_gact               16384  0
%
% sudo tc actions add action pass index 1
% sudo tc actions add action pass index 2
% sudo tc actions add action pass index 3
% lsmod
Module                  Size  Used by
act_gact               16384  3
%
% sudo tc actions flush action gact
% lsmod
Module                  Size  Used by
act_gact               16384  0
%
% sudo tc actions flush action gact
% lsmod
Module                  Size  Used by
act_gact               16384  0
% sudo rmmod act_gact
% lsmod
Module                  Size  Used by
%

Fixes: f97017cdefef ("net-sched: Fix actions flushing")
Signed-off-by: Roman Mashak <mrv@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/sched/act_api.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index f8d9c2a2c451..c9387f62f634 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -802,10 +802,8 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
 		goto out_module_put;
 
 	err = a.ops->walk(skb, &dcb, RTM_DELACTION, &a);
-	if (err < 0)
+	if (err <= 0)
 		goto out_module_put;
-	if (err == 0)
-		goto noflush_out;
 
 	nla_nest_end(skb, nest);
 
@@ -822,7 +820,6 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
 out_module_put:
 	module_put(a.ops->owner);
 err_out:
-noflush_out:
 	kfree_skb(skb);
 	return err;
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] dccp: fix memory leak during tear-down of unsuccessful connection request
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (45 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] dccp/tcp: fix routing redirect race Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net sched actions: decrement module reference count after table flush Sasha Levin
                   ` (248 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Hannes Frederic Sowa, David S . Miller, Sasha Levin

From: Hannes Frederic Sowa <hannes@stressinduktion.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 72ef9c4125c7b257e3a714d62d778ab46583d6a3 ]

This patch fixes a memory leak, which happens if the connection request
is not fulfilled between parsing the DCCP options and handling the SYN
(because e.g. the backlog is full), because we forgot to free the
list of ack vectors.

Reported-by: Jianwen Ji <jiji@redhat.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/dccp/ccids/ccid2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index f053198e730c..5e3a7302f774 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -749,6 +749,7 @@ static void ccid2_hc_tx_exit(struct sock *sk)
 	for (i = 0; i < hc->tx_seqbufc; i++)
 		kfree(hc->tx_seqbuf[i]);
 	hc->tx_seqbufc = 0;
+	dccp_ackvec_parsed_cleanup(&hc->tx_av_chunks);
 }
 
 static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
-- 
2.11.0

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

* [added to the 4.1 stable tree] crypto: cryptd - Assign statesize properly
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (48 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] crypto: ghash-clmulni - Fix load failure Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] crypto: mcryptd - Fix load failure Sasha Levin
                   ` (245 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Wang, Rui Y, Herbert Xu, Sasha Levin

From: "Wang, Rui Y" <rui.y.wang@intel.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 1a07834024dfca5c4bed5de8f8714306e0a11836 ]

cryptd_create_hash() fails by returning -EINVAL.  It is because after
8996eafdc ("crypto: ahash - ensure statesize is non-zero") all ahash
drivers must have a non-zero statesize.

This patch fixes the problem by properly assigning the statesize.

Signed-off-by: Rui Wang <rui.y.wang@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 crypto/cryptd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index 34e4dfafb94f..66c9e8262572 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -633,6 +633,7 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
 	inst->alg.halg.base.cra_flags = type;
 
 	inst->alg.halg.digestsize = salg->digestsize;
+	inst->alg.halg.statesize = salg->statesize;
 	inst->alg.halg.base.cra_ctxsize = sizeof(struct cryptd_hash_ctx);
 
 	inst->alg.halg.base.cra_init = cryptd_hash_init_tfm;
-- 
2.11.0

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

* [added to the 4.1 stable tree] crypto: ghash-clmulni - Fix load failure
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (47 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net sched actions: decrement module reference count after table flush Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] crypto: cryptd - Assign statesize properly Sasha Levin
                   ` (246 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Wang, Rui Y, Herbert Xu, Sasha Levin

From: "Wang, Rui Y" <rui.y.wang@intel.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 3a020a723c65eb8ffa7c237faca26521a024e582 ]

ghash_clmulni_intel fails to load on Linux 4.3+ with the following message:
"modprobe: ERROR: could not insert 'ghash_clmulni_intel': Invalid argument"

After 8996eafdc ("crypto: ahash - ensure statesize is non-zero") all ahash
drivers are required to implement import()/export(), and must have a non-
zero statesize.

This patch has been tested with the algif_hash interface. The calculated
digest values, after several rounds of import()s and export()s, match those
calculated by tcrypt.

Signed-off-by: Rui Wang <rui.y.wang@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/x86/crypto/ghash-clmulni-intel_glue.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/arch/x86/crypto/ghash-clmulni-intel_glue.c b/arch/x86/crypto/ghash-clmulni-intel_glue.c
index daf8d2b9a217..b7ef6e202bb7 100644
--- a/arch/x86/crypto/ghash-clmulni-intel_glue.c
+++ b/arch/x86/crypto/ghash-clmulni-intel_glue.c
@@ -219,6 +219,29 @@ static int ghash_async_final(struct ahash_request *req)
 	}
 }
 
+static int ghash_async_import(struct ahash_request *req, const void *in)
+{
+	struct ahash_request *cryptd_req = ahash_request_ctx(req);
+	struct shash_desc *desc = cryptd_shash_desc(cryptd_req);
+	struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
+
+	ghash_async_init(req);
+	memcpy(dctx, in, sizeof(*dctx));
+	return 0;
+
+}
+
+static int ghash_async_export(struct ahash_request *req, void *out)
+{
+	struct ahash_request *cryptd_req = ahash_request_ctx(req);
+	struct shash_desc *desc = cryptd_shash_desc(cryptd_req);
+	struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
+
+	memcpy(out, dctx, sizeof(*dctx));
+	return 0;
+
+}
+
 static int ghash_async_digest(struct ahash_request *req)
 {
 	struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
@@ -288,8 +311,11 @@ static struct ahash_alg ghash_async_alg = {
 	.final		= ghash_async_final,
 	.setkey		= ghash_async_setkey,
 	.digest		= ghash_async_digest,
+	.export		= ghash_async_export,
+	.import		= ghash_async_import,
 	.halg = {
 		.digestsize	= GHASH_DIGEST_SIZE,
+		.statesize = sizeof(struct ghash_desc_ctx),
 		.base = {
 			.cra_name		= "ghash",
 			.cra_driver_name	= "ghash-clmulni",
-- 
2.11.0

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

* [added to the 4.1 stable tree] ACPI / video: skip evaluating _DOD when it does not exist
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (50 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] crypto: mcryptd - Fix load failure Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] KVM: PPC: Book3S PR: Fix illegal opcode emulation Sasha Levin
                   ` (243 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Alex Hung, Rafael J . Wysocki, Sasha Levin

From: Alex Hung <alex.hung@canonical.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e34fbbac669de0b7fb7803929d0477f35f6e2833 ]

Some system supports hybrid graphics and its discrete VGA
does not have any connectors and therefore has no _DOD method.

Signed-off-by: Alex Hung <alex.hung@canonical.com>
Reviewed-by: Aaron Lu <aaron.lu@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/acpi/video.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index cc79d3fedfb2..493811b895bd 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -1276,6 +1276,9 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
 	union acpi_object *dod = NULL;
 	union acpi_object *obj;
 
+	if (!video->cap._DOD)
+		return AE_NOT_EXIST;
+
 	status = acpi_evaluate_object(video->device->handle, "_DOD", NULL, &buffer);
 	if (!ACPI_SUCCESS(status)) {
 		ACPI_EXCEPTION((AE_INFO, status, "Evaluating _DOD"));
-- 
2.11.0

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

* [added to the 4.1 stable tree] crypto: mcryptd - Fix load failure
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (49 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] crypto: cryptd - Assign statesize properly Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] ACPI / video: skip evaluating _DOD when it does not exist Sasha Levin
                   ` (244 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Wang, Rui Y, Herbert Xu, Sasha Levin

From: "Wang, Rui Y" <rui.y.wang@intel.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit ddef482420b1ba8ec45e6123a7e8d3f67b21e5e3 ]

mcryptd_create_hash() fails by returning -EINVAL, causing any
driver using mcryptd to fail to load. It is because it needs
to set its statesize properly.

Signed-off-by: Rui Wang <rui.y.wang@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 crypto/mcryptd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/crypto/mcryptd.c b/crypto/mcryptd.c
index fe5b495a434d..cfb68a889ef6 100644
--- a/crypto/mcryptd.c
+++ b/crypto/mcryptd.c
@@ -526,6 +526,7 @@ static int mcryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
 	inst->alg.halg.base.cra_flags = type;
 
 	inst->alg.halg.digestsize = salg->digestsize;
+	inst->alg.halg.statesize = salg->statesize;
 	inst->alg.halg.base.cra_ctxsize = sizeof(struct mcryptd_hash_ctx);
 
 	inst->alg.halg.base.cra_init = mcryptd_hash_init_tfm;
-- 
2.11.0

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

* [added to the 4.1 stable tree] KVM: PPC: Book3S PR: Fix illegal opcode emulation
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (51 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] ACPI / video: skip evaluating _DOD when it does not exist Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] Drivers: hv: balloon: don't crash when memory is added in non-sorted order Sasha Levin
                   ` (242 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Thomas Huth, Paul Mackerras, Sasha Levin

From: Thomas Huth <thuth@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 708e75a3ee750dce1072134e630d66c4e6eaf63c ]

If kvmppc_handle_exit_pr() calls kvmppc_emulate_instruction() to emulate
one instruction (in the BOOK3S_INTERRUPT_H_EMUL_ASSIST case), it calls
kvmppc_core_queue_program() afterwards if kvmppc_emulate_instruction()
returned EMULATE_FAIL, so the guest gets an program interrupt for the
illegal opcode.
However, the kvmppc_emulate_instruction() also tried to inject a
program exception for this already, so the program interrupt gets
injected twice and the return address in srr0 gets destroyed.
All other callers of kvmppc_emulate_instruction() are also injecting
a program interrupt, and since the callers have the right knowledge
about the srr1 flags that should be used, it is the function
kvmppc_emulate_instruction() that should _not_ inject program
interrupts, so remove the kvmppc_core_queue_program() here.

This fixes the issue discovered by Laurent Vivier with kvm-unit-tests
where the logs are filled with these messages when the test tries
to execute an illegal instruction:

     Couldn't emulate instruction 0x00000000 (op 0 xop 0)
     kvmppc_handle_exit_pr: emulation at 700 failed (00000000)

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
Tested-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/powerpc/kvm/emulate.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index 5cc2e7af3a7b..b379146de55b 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -302,7 +302,6 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
 			advance = 0;
 			printk(KERN_ERR "Couldn't emulate instruction 0x%08x "
 			       "(op %d xop %d)\n", inst, get_op(inst), get_xop(inst));
-			kvmppc_core_queue_program(vcpu, 0);
 		}
 	}
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] Drivers: hv: balloon: don't crash when memory is added in non-sorted order
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (52 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] KVM: PPC: Book3S PR: Fix illegal opcode emulation Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] s390/pci: fix use after free in dma_init Sasha Levin
                   ` (241 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Vitaly Kuznetsov, KY Srinivasan, Greg Kroah-Hartman, Sasha Levin

From: Vitaly Kuznetsov <vkuznets@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 77c0c9735bc0ba5898e637a3a20d6bcb50e3f67d ]

When we iterate through all HA regions in handle_pg_range() we have an
assumption that all these regions are sorted in the list and the
'start_pfn >= has->end_pfn' check is enough to find the proper region.
Unfortunately it's not the case with WS2016 where host can hot-add regions
in a different order. We end up modifying the wrong HA region and crashing
later on pages online. Modify the check to make sure we found the region
we were searching for while iterating. Fix the same check in pfn_covered()
as well.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/hv/hv_balloon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 9e7f93bcd3ea..15031b46c9c4 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -748,7 +748,7 @@ static int pfn_covered(unsigned long start_pfn, unsigned long pfn_cnt)
 		 * If the pfn range we are dealing with is not in the current
 		 * "hot add block", move on.
 		 */
-		if ((start_pfn >= has->end_pfn))
+		if (start_pfn < has->start_pfn || start_pfn >= has->end_pfn)
 			continue;
 
 		/*
@@ -811,7 +811,7 @@ static unsigned long handle_pg_range(unsigned long pg_start,
 		 * If the pfn range we are dealing with is not in the current
 		 * "hot add block", move on.
 		 */
-		if ((start_pfn >= has->end_pfn))
+		if (start_pfn < has->start_pfn || start_pfn >= has->end_pfn)
 			continue;
 
 		old_covered_state = has->covered_end_pfn;
-- 
2.11.0

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

* [added to the 4.1 stable tree] tpm_tis: Use devm_free_irq not free_irq
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (54 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] s390/pci: fix use after free in dma_init Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] give up on gcc ilog2() constant optimizations Sasha Levin
                   ` (239 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jason Gunthorpe, Jarkko Sakkinen, Sasha Levin

From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 727f28b8ca24a581c7bd868326b8cea1058c720a ]

The interrupt is always allocated with devm_request_irq so it
must always be freed with devm_free_irq.

Fixes: 448e9c55c12d ("tpm_tis: verify interrupt during init")
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Acked-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Acked-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/char/tpm/tpm_tis.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 696ef1d56b4f..5809567d3cf0 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -401,7 +401,7 @@ static void disable_interrupts(struct tpm_chip *chip)
 	iowrite32(intmask,
 		  chip->vendor.iobase +
 		  TPM_INT_ENABLE(chip->vendor.locality));
-	free_irq(chip->vendor.irq, chip);
+	devm_free_irq(chip->pdev, chip->vendor.irq, chip);
 	chip->vendor.irq = 0;
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] s390/pci: fix use after free in dma_init
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (53 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] Drivers: hv: balloon: don't crash when memory is added in non-sorted order Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] tpm_tis: Use devm_free_irq not free_irq Sasha Levin
                   ` (240 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Sebastian Ott, Martin Schwidefsky, Sasha Levin

From: Sebastian Ott <sebott@linux.vnet.ibm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit dba599091c191d209b1499511a524ad9657c0e5a ]

After a failure during registration of the dma_table (because of the
function being in error state) we free its memory but don't reset the
associated pointer to zero.

When we then receive a notification from firmware (about the function
being in error state) we'll try to walk and free the dma_table again.

Fix this by resetting the dma_table pointer. In addition to that make
sure that we free the iommu_bitmap when appropriate.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Reviewed-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/s390/pci/pci_dma.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c
index 6fd8d5836138..888cc878efaa 100644
--- a/arch/s390/pci/pci_dma.c
+++ b/arch/s390/pci/pci_dma.c
@@ -432,7 +432,7 @@ int zpci_dma_init_device(struct zpci_dev *zdev)
 	zdev->dma_table = dma_alloc_cpu_table();
 	if (!zdev->dma_table) {
 		rc = -ENOMEM;
-		goto out_clean;
+		goto out;
 	}
 
 	zdev->iommu_size = (unsigned long) high_memory - PAGE_OFFSET;
@@ -440,7 +440,7 @@ int zpci_dma_init_device(struct zpci_dev *zdev)
 	zdev->iommu_bitmap = vzalloc(zdev->iommu_pages / 8);
 	if (!zdev->iommu_bitmap) {
 		rc = -ENOMEM;
-		goto out_reg;
+		goto free_dma_table;
 	}
 
 	rc = zpci_register_ioat(zdev,
@@ -449,12 +449,16 @@ int zpci_dma_init_device(struct zpci_dev *zdev)
 				zdev->start_dma + zdev->iommu_size - 1,
 				(u64) zdev->dma_table);
 	if (rc)
-		goto out_reg;
-	return 0;
+		goto free_bitmap;
 
-out_reg:
+	return 0;
+free_bitmap:
+	vfree(zdev->iommu_bitmap);
+	zdev->iommu_bitmap = NULL;
+free_dma_table:
 	dma_free_cpu_table(zdev->dma_table);
-out_clean:
+	zdev->dma_table = NULL;
+out:
 	return rc;
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] give up on gcc ilog2() constant optimizations
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (55 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] tpm_tis: Use devm_free_irq not free_irq Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: properly release sk_frag.page Sasha Levin
                   ` (238 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Linus Torvalds, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 474c90156c8dcc2fa815e6716cc9394d7930cb9c ]

gcc-7 has an "optimization" pass that completely screws up, and
generates the code expansion for the (impossible) case of calling
ilog2() with a zero constant, even when the code gcc compiles does not
actually have a zero constant.

And we try to generate a compile-time error for anybody doing ilog2() on
a constant where that doesn't make sense (be it zero or negative).  So
now gcc7 will fail the build due to our sanity checking, because it
created that constant-zero case that didn't actually exist in the source
code.

There's a whole long discussion on the kernel mailing about how to work
around this gcc bug.  The gcc people themselevs have discussed their
"feature" in

   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72785

but it's all water under the bridge, because while it looked at one
point like it would be solved by the time gcc7 was released, that was
not to be.

So now we have to deal with this compiler braindamage.

And the only simple approach seems to be to just delete the code that
tries to warn about bad uses of ilog2().

So now "ilog2()" will just return 0 not just for the value 1, but for
any non-positive value too.

It's not like I can recall anybody having ever actually tried to use
this function on any invalid value, but maybe the sanity check just
meant that such code never made it out in public.

Reported-by: Laura Abbott <labbott@redhat.com>
Cc: John Stultz <john.stultz@linaro.org>,
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 include/linux/log2.h       | 13 ++-----------
 tools/include/linux/log2.h | 13 ++-----------
 2 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/include/linux/log2.h b/include/linux/log2.h
index ef3d4f67118c..c373295f359f 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -16,12 +16,6 @@
 #include <linux/bitops.h>
 
 /*
- * deal with unrepresentable constant logarithms
- */
-extern __attribute__((const, noreturn))
-int ____ilog2_NaN(void);
-
-/*
  * non-constant log of base 2 calculators
  * - the arch may override these in asm/bitops.h if they can be implemented
  *   more efficiently than using fls() and fls64()
@@ -85,7 +79,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
 #define ilog2(n)				\
 (						\
 	__builtin_constant_p(n) ? (		\
-		(n) < 1 ? ____ilog2_NaN() :	\
+		(n) < 2 ? 0 :			\
 		(n) & (1ULL << 63) ? 63 :	\
 		(n) & (1ULL << 62) ? 62 :	\
 		(n) & (1ULL << 61) ? 61 :	\
@@ -148,10 +142,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
 		(n) & (1ULL <<  4) ?  4 :	\
 		(n) & (1ULL <<  3) ?  3 :	\
 		(n) & (1ULL <<  2) ?  2 :	\
-		(n) & (1ULL <<  1) ?  1 :	\
-		(n) & (1ULL <<  0) ?  0 :	\
-		____ilog2_NaN()			\
-				   ) :		\
+		1 ) :				\
 	(sizeof(n) <= 4) ?			\
 	__ilog2_u32(n) :			\
 	__ilog2_u64(n)				\
diff --git a/tools/include/linux/log2.h b/tools/include/linux/log2.h
index 41446668ccce..d5677d39c1e4 100644
--- a/tools/include/linux/log2.h
+++ b/tools/include/linux/log2.h
@@ -13,12 +13,6 @@
 #define _TOOLS_LINUX_LOG2_H
 
 /*
- * deal with unrepresentable constant logarithms
- */
-extern __attribute__((const, noreturn))
-int ____ilog2_NaN(void);
-
-/*
  * non-constant log of base 2 calculators
  * - the arch may override these in asm/bitops.h if they can be implemented
  *   more efficiently than using fls() and fls64()
@@ -78,7 +72,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
 #define ilog2(n)				\
 (						\
 	__builtin_constant_p(n) ? (		\
-		(n) < 1 ? ____ilog2_NaN() :	\
+		(n) < 2 ? 0 :			\
 		(n) & (1ULL << 63) ? 63 :	\
 		(n) & (1ULL << 62) ? 62 :	\
 		(n) & (1ULL << 61) ? 61 :	\
@@ -141,10 +135,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
 		(n) & (1ULL <<  4) ?  4 :	\
 		(n) & (1ULL <<  3) ?  3 :	\
 		(n) & (1ULL <<  2) ?  2 :	\
-		(n) & (1ULL <<  1) ?  1 :	\
-		(n) & (1ULL <<  0) ?  0 :	\
-		____ilog2_NaN()			\
-				   ) :		\
+		1 ) :				\
 	(sizeof(n) <= 4) ?			\
 	__ilog2_u32(n) :			\
 	__ilog2_u64(n)				\
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: bcmgenet: Do not suspend PHY if Wake-on-LAN is enabled
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (57 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: properly release sk_frag.page Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: unix: properly re-increment inflight counter of GC discarded candidates Sasha Levin
                   ` (236 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Florian Fainelli, David S . Miller, Sasha Levin

From: Florian Fainelli <f.fainelli@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 5371bbf4b295eea334ed453efa286afa2c3ccff3 ]

Suspending the PHY would be putting it in a low power state where it
may no longer allow us to do Wake-on-LAN.

Fixes: cc013fb48898 ("net: bcmgenet: correctly suspend and resume PHY device")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index a9fcac044e9e..add05e743b6c 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -3234,7 +3234,8 @@ static int bcmgenet_suspend(struct device *d)
 
 	bcmgenet_netif_stop(dev);
 
-	phy_suspend(priv->phydev);
+	if (!device_may_wakeup(d))
+		phy_suspend(priv->phydev);
 
 	netif_device_detach(dev);
 
@@ -3331,7 +3332,8 @@ static int bcmgenet_resume(struct device *d)
 
 	netif_device_attach(dev);
 
-	phy_resume(priv->phydev);
+	if (!device_may_wakeup(d))
+		phy_resume(priv->phydev);
 
 	if (priv->eee.eee_enabled)
 		bcmgenet_eee_enable_set(dev, true);
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: properly release sk_frag.page
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (56 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] give up on gcc ilog2() constant optimizations Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: bcmgenet: Do not suspend PHY if Wake-on-LAN is enabled Sasha Levin
                   ` (237 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Dumazet, David S . Miller, Sasha Levin

From: Eric Dumazet <edumazet@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 22a0e18eac7a9e986fec76c60fa4a2926d1291e2 ]

I mistakenly added the code to release sk->sk_frag in
sk_common_release() instead of sk_destruct()

TCP sockets using sk->sk_allocation == GFP_ATOMIC do no call
sk_common_release() at close time, thus leaking one (order-3) page.

iSCSI is using such sockets.

Fixes: 5640f7685831 ("net: use a per task frag allocator")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/core/sock.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index e369262ea57e..76e0b874f378 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1435,6 +1435,11 @@ static void __sk_free(struct sock *sk)
 		pr_debug("%s: optmem leakage (%d bytes) detected\n",
 			 __func__, atomic_read(&sk->sk_omem_alloc));
 
+	if (sk->sk_frag.page) {
+		put_page(sk->sk_frag.page);
+		sk->sk_frag.page = NULL;
+	}
+
 	if (sk->sk_peer_cred)
 		put_cred(sk->sk_peer_cred);
 	put_pid(sk->sk_peer_pid);
@@ -2622,11 +2627,6 @@ void sk_common_release(struct sock *sk)
 
 	sk_refcnt_debug_release(sk);
 
-	if (sk->sk_frag.page) {
-		put_page(sk->sk_frag.page);
-		sk->sk_frag.page = NULL;
-	}
-
 	sock_put(sk);
 }
 EXPORT_SYMBOL(sk_common_release);
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: unix: properly re-increment inflight counter of GC discarded candidates
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (58 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: bcmgenet: Do not suspend PHY if Wake-on-LAN is enabled Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net/mlx5: Increase number of max QPs in default profile Sasha Levin
                   ` (235 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Andrey Ulanov, David S . Miller, Sasha Levin

From: Andrey Ulanov <andreyu@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 7df9c24625b9981779afb8fcdbe2bb4765e61147 ]

Dmitry has reported that a BUG_ON() condition in unix_notinflight()
may be triggered by a simple code that forwards unix socket in an
SCM_RIGHTS message.
That is caused by incorrect unix socket GC implementation in unix_gc().

The GC first collects list of candidates, then (a) decrements their
"children's" inflight counter, (b) checks which inflight counters are
now 0, and then (c) increments all inflight counters back.
(a) and (c) are done by calling scan_children() with inc_inflight or
dec_inflight as the second argument.

Commit 6209344f5a37 ("net: unix: fix inflight counting bug in garbage
collector") changed scan_children() such that it no longer considers
sockets that do not have UNIX_GC_CANDIDATE flag. It also added a block
of code that that unsets this flag _before_ invoking
scan_children(, dec_iflight, ). This may lead to incorrect inflight
counters for some sockets.

This change fixes this bug by changing order of operations:
UNIX_GC_CANDIDATE is now unset only after all inflight counters are
restored to the original state.

  kernel BUG at net/unix/garbage.c:149!
  RIP: 0010:[<ffffffff8717ebf4>]  [<ffffffff8717ebf4>]
  unix_notinflight+0x3b4/0x490 net/unix/garbage.c:149
  Call Trace:
   [<ffffffff8716cfbf>] unix_detach_fds.isra.19+0xff/0x170 net/unix/af_unix.c:1487
   [<ffffffff8716f6a9>] unix_destruct_scm+0xf9/0x210 net/unix/af_unix.c:1496
   [<ffffffff86a90a01>] skb_release_head_state+0x101/0x200 net/core/skbuff.c:655
   [<ffffffff86a9808a>] skb_release_all+0x1a/0x60 net/core/skbuff.c:668
   [<ffffffff86a980ea>] __kfree_skb+0x1a/0x30 net/core/skbuff.c:684
   [<ffffffff86a98284>] kfree_skb+0x184/0x570 net/core/skbuff.c:705
   [<ffffffff871789d5>] unix_release_sock+0x5b5/0xbd0 net/unix/af_unix.c:559
   [<ffffffff87179039>] unix_release+0x49/0x90 net/unix/af_unix.c:836
   [<ffffffff86a694b2>] sock_release+0x92/0x1f0 net/socket.c:570
   [<ffffffff86a6962b>] sock_close+0x1b/0x20 net/socket.c:1017
   [<ffffffff81a76b8e>] __fput+0x34e/0x910 fs/file_table.c:208
   [<ffffffff81a771da>] ____fput+0x1a/0x20 fs/file_table.c:244
   [<ffffffff81483ab0>] task_work_run+0x1a0/0x280 kernel/task_work.c:116
   [<     inline     >] exit_task_work include/linux/task_work.h:21
   [<ffffffff8141287a>] do_exit+0x183a/0x2640 kernel/exit.c:828
   [<ffffffff8141383e>] do_group_exit+0x14e/0x420 kernel/exit.c:931
   [<ffffffff814429d3>] get_signal+0x663/0x1880 kernel/signal.c:2307
   [<ffffffff81239b45>] do_signal+0xc5/0x2190 arch/x86/kernel/signal.c:807
   [<ffffffff8100666a>] exit_to_usermode_loop+0x1ea/0x2d0
  arch/x86/entry/common.c:156
   [<     inline     >] prepare_exit_to_usermode arch/x86/entry/common.c:190
   [<ffffffff81009693>] syscall_return_slowpath+0x4d3/0x570
  arch/x86/entry/common.c:259
   [<ffffffff881478e6>] entry_SYSCALL_64_fastpath+0xc4/0xc6

Link: https://lkml.org/lkml/2017/3/6/252
Signed-off-by: Andrey Ulanov <andreyu@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Fixes: 6209344 ("net: unix: fix inflight counting bug in garbage collector")
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/unix/garbage.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index 6a0d48525fcf..c36757e72844 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -146,6 +146,7 @@ void unix_notinflight(struct user_struct *user, struct file *fp)
 	if (s) {
 		struct unix_sock *u = unix_sk(s);
 
+		BUG_ON(!atomic_long_read(&u->inflight));
 		BUG_ON(list_empty(&u->link));
 
 		if (atomic_long_dec_and_test(&u->inflight))
@@ -341,6 +342,14 @@ void unix_gc(void)
 	}
 	list_del(&cursor);
 
+	/* Now gc_candidates contains only garbage.  Restore original
+	 * inflight counters for these as well, and remove the skbuffs
+	 * which are creating the cycle(s).
+	 */
+	skb_queue_head_init(&hitlist);
+	list_for_each_entry(u, &gc_candidates, link)
+		scan_children(&u->sk, inc_inflight, &hitlist);
+
 	/* not_cycle_list contains those sockets which do not make up a
 	 * cycle.  Restore these to the inflight list.
 	 */
@@ -350,14 +359,6 @@ void unix_gc(void)
 		list_move_tail(&u->link, &gc_inflight_list);
 	}
 
-	/* Now gc_candidates contains only garbage.  Restore original
-	 * inflight counters for these as well, and remove the skbuffs
-	 * which are creating the cycle(s).
-	 */
-	skb_queue_head_init(&hitlist);
-	list_for_each_entry(u, &gc_candidates, link)
-	scan_children(&u->sk, inc_inflight, &hitlist);
-
 	spin_unlock(&unix_gc_lock);
 
 	/* Here we are. Hitlist is filled. Die. */
-- 
2.11.0

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

* [added to the 4.1 stable tree] net/mlx5: Increase number of max QPs in default profile
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (59 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net: unix: properly re-increment inflight counter of GC discarded candidates Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] ipv4: provide stronger user input validation in nl_fib_input() Sasha Levin
                   ` (234 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Maor Gottlieb, Saeed Mahameed, David S . Miller, Sasha Levin

From: Maor Gottlieb <maorg@mellanox.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 5f40b4ed975c26016cf41953b7510fe90718e21c ]

With ConnectX-4 sharing SRQs from the same space as QPs, we hit a
limit preventing some applications to allocate needed QPs amount.
Double the size to 256K.

Fixes: e126ba97dba9e ('mlx5: Add driver for Mellanox Connect-IB adapters')
Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 28425e5ea91f..316fe86040d4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -87,7 +87,7 @@ static struct mlx5_profile profile[] = {
 	[2] = {
 		.mask		= MLX5_PROF_MASK_QP_SIZE |
 				  MLX5_PROF_MASK_MR_CACHE,
-		.log_max_qp	= 17,
+		.log_max_qp	= 18,
 		.mr_cache[0]	= {
 			.size	= 500,
 			.limit	= 250
-- 
2.11.0

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

* [added to the 4.1 stable tree] tcp: initialize icsk_ack.lrcvtime at session start time
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (62 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] iio: adc: ti_am335x_adc: fix fifo overrun recovery Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] iio: hid-sensor-trigger: Change get poll value function order to avoid sensor properties losing after resume from S3 Sasha Levin
                   ` (231 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Dumazet, David S . Miller, Sasha Levin

From: Eric Dumazet <edumazet@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 15bb7745e94a665caf42bfaabf0ce062845b533b ]

icsk_ack.lrcvtime has a 0 value at socket creation time.

tcpi_last_data_recv can have bogus value if no payload is ever received.

This patch initializes icsk_ack.lrcvtime for active sessions
in tcp_finish_connect(), and for passive sessions in
tcp_create_openreq_child()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv4/tcp_input.c     | 2 +-
 net/ipv4/tcp_minisocks.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 95f98d2444fa..adfb709c6ee6 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5388,6 +5388,7 @@ void tcp_finish_connect(struct sock *sk, struct sk_buff *skb)
 	struct inet_connection_sock *icsk = inet_csk(sk);
 
 	tcp_set_state(sk, TCP_ESTABLISHED);
+	icsk->icsk_ack.lrcvtime = tcp_time_stamp;
 
 	if (skb) {
 		icsk->icsk_af_ops->sk_rx_dst_set(sk, skb);
@@ -5600,7 +5601,6 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
 			 * to stand against the temptation 8)     --ANK
 			 */
 			inet_csk_schedule_ack(sk);
-			icsk->icsk_ack.lrcvtime = tcp_time_stamp;
 			tcp_enter_quickack_mode(sk);
 			inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
 						  TCP_DELACK_MAX, TCP_RTO_MAX);
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index fec2907b85e8..2c58a5d4cba8 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -462,6 +462,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
 		newtp->srtt_us = 0;
 		newtp->mdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT);
 		newicsk->icsk_rto = TCP_TIMEOUT_INIT;
+		newicsk->icsk_ack.lrcvtime = tcp_time_stamp;
 
 		newtp->packets_out = 0;
 		newtp->retrans_out = 0;
-- 
2.11.0

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

* [added to the 4.1 stable tree] ipv4: provide stronger user input validation in nl_fib_input()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (60 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] net/mlx5: Increase number of max QPs in default profile Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] iio: adc: ti_am335x_adc: fix fifo overrun recovery Sasha Levin
                   ` (233 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Dumazet, David S . Miller, Sasha Levin

From: Eric Dumazet <edumazet@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit c64c0b3cac4c5b8cb093727d2c19743ea3965c0b ]

Alexander reported a KMSAN splat caused by reads of uninitialized
field (tb_id_in) from user provided struct fib_result_nl

It turns out nl_fib_input() sanity tests on user input is a bit
wrong :

User can pretend nlh->nlmsg_len is big enough, but provide
at sendmsg() time a too small buffer.

Reported-by: Alexander Potapenko <glider@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv4/fib_frontend.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 765909ba781e..a8db70b7fe45 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -1033,7 +1033,8 @@ static void nl_fib_input(struct sk_buff *skb)
 
 	net = sock_net(skb->sk);
 	nlh = nlmsg_hdr(skb);
-	if (skb->len < NLMSG_HDRLEN || skb->len < nlh->nlmsg_len ||
+	if (skb->len < nlmsg_total_size(sizeof(*frn)) ||
+	    skb->len < nlh->nlmsg_len ||
 	    nlmsg_len(nlh) < sizeof(*frn))
 		return;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] iio: adc: ti_am335x_adc: fix fifo overrun recovery
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (61 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] ipv4: provide stronger user input validation in nl_fib_input() Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] tcp: initialize icsk_ack.lrcvtime at session start time Sasha Levin
                   ` (232 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Michael Engl, Jonathan Cameron, Sasha Levin

From: Michael Engl <michael.engl@wjw-solutions.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e83bb3e6f3efa21f4a9d883a25d0ecd9dfb431e1 ]

The tiadc_irq_h(int irq, void *private) function is handling FIFO
overruns by clearing flags, disabling and enabling the ADC to
recover.

If the ADC is running in continuous mode a FIFO overrun happens
regularly. If the disabling of the ADC happens concurrently with
a new conversion. It might happen that the enabling of the ADC
is ignored by the hardware. This stops the ADC permanently. No
more interrupts are triggered.

According to the AM335x Reference Manual (SPRUH73H October 2011 -
Revised April 2013 - Chapter 12.4 and 12.5) it is necessary to
check the ADC FSM bits in REG_ADCFSM before enabling the ADC
again. Because the disabling of the ADC is done right after the
current conversion has been finished.

To trigger this bug it is necessary to run the ADC in continuous
mode. The ADC values of all channels need to be read in an endless
loop. The bug appears within the first 6 hours (~5.4 million
handled FIFO overruns). The user space application will hang on
reading new values from the character device.

Fixes: ca9a563805f7a ("iio: ti_am335x_adc: Add continuous sampling
support")
Signed-off-by: Michael Engl <michael.engl@wjw-solutions.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/iio/adc/ti_am335x_adc.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index a0e7161f040c..58e1a54fc119 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -121,7 +121,9 @@ static irqreturn_t tiadc_irq_h(int irq, void *private)
 {
 	struct iio_dev *indio_dev = private;
 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
-	unsigned int status, config;
+	unsigned int status, config, adc_fsm;
+	unsigned short count = 0;
+
 	status = tiadc_readl(adc_dev, REG_IRQSTATUS);
 
 	/*
@@ -135,6 +137,15 @@ static irqreturn_t tiadc_irq_h(int irq, void *private)
 		tiadc_writel(adc_dev, REG_CTRL, config);
 		tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1OVRRUN
 				| IRQENB_FIFO1UNDRFLW | IRQENB_FIFO1THRES);
+
+		/* wait for idle state.
+		 * ADC needs to finish the current conversion
+		 * before disabling the module
+		 */
+		do {
+			adc_fsm = tiadc_readl(adc_dev, REG_ADCFSM);
+		} while (adc_fsm != 0x10 && count++ < 100);
+
 		tiadc_writel(adc_dev, REG_CTRL, (config | CNTRLREG_TSCSSENB));
 		return IRQ_HANDLED;
 	} else if (status & IRQENB_FIFO1THRES) {
-- 
2.11.0

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

* [added to the 4.1 stable tree] iio: hid-sensor-trigger: Change get poll value function order to avoid sensor properties losing after resume from S3
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (63 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] tcp: initialize icsk_ack.lrcvtime at session start time Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] libceph: don't set weight to IN when OSD is destroyed Sasha Levin
                   ` (230 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Song Hongyan, Jonathan Cameron, Sasha Levin

From: Song Hongyan <hongyan.song@intel.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 3bec247474469f769af41e8c80d3a100dd97dd76 ]

In function _hid_sensor_power_state(), when hid_sensor_read_poll_value()
is called, sensor's all properties will be updated by the value from
sensor hardware/firmware.
In some implementation, sensor hardware/firmware will do a power cycle
during S3. In this case, after resume, once hid_sensor_read_poll_value()
is called, sensor's all properties which are kept by driver during S3
will be changed to default value.
But instead, if a set feature function is called first, sensor
hardware/firmware will be recovered to the last status. So change the
sensor_hub_set_feature() calling order to behind of set feature function
to avoid sensor properties lose.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 3460dd0e3e99..a8db38db622e 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -49,8 +49,6 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
 			st->report_state.report_id,
 			st->report_state.index,
 			HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM);
-
-		poll_value = hid_sensor_read_poll_value(st);
 	} else {
 		int val;
 
@@ -90,7 +88,9 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
 	sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
 			       st->power_state.index,
 			       sizeof(state_val), &state_val);
-	if (state && poll_value)
+	if (state)
+		poll_value = hid_sensor_read_poll_value(st);
+	if (poll_value > 0)
 		msleep_interruptible(poll_value * 2);
 
 	return 0;
-- 
2.11.0

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

* [added to the 4.1 stable tree] libceph: don't set weight to IN when OSD is destroyed
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (64 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] iio: hid-sensor-trigger: Change get poll value function order to avoid sensor properties losing after resume from S3 Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 20:59 ` [added to the 4.1 stable tree] raid10: increment write counter after bio is split Sasha Levin
                   ` (229 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Ilya Dryomov, Sasha Levin

From: Ilya Dryomov <idryomov@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit b581a5854eee4b7851dedb0f8c2ceb54fb902c06 ]

Since ceph.git commit 4e28f9e63644 ("osd/OSDMap: clear osd_info,
osd_xinfo on osd deletion"), weight is set to IN when OSD is deleted.
This changes the result of applying an incremental for clients, not
just OSDs.  Because CRUSH computations are obviously affected,
pre-4e28f9e63644 servers disagree with post-4e28f9e63644 clients on
object placement, resulting in misdirected requests.

Mirrors ceph.git commit a6009d1039a55e2c77f431662b3d6cc5a8e8e63f.

Fixes: 930c53286977 ("libceph: apply new_state before new_up_client on incrementals")
Link: http://tracker.ceph.com/issues/19122
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Sage Weil <sage@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ceph/osdmap.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index ddc3573894b0..bc95e48d5cfb 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -1265,7 +1265,6 @@ static int decode_new_up_state_weight(void **p, void *end,
 		if ((map->osd_state[osd] & CEPH_OSD_EXISTS) &&
 		    (xorstate & CEPH_OSD_EXISTS)) {
 			pr_info("osd%d does not exist\n", osd);
-			map->osd_weight[osd] = CEPH_OSD_IN;
 			ret = set_primary_affinity(map, osd,
 						   CEPH_OSD_DEFAULT_PRIMARY_AFFINITY);
 			if (ret)
-- 
2.11.0

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

* [added to the 4.1 stable tree] raid10: increment write counter after bio is split
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (65 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] libceph: don't set weight to IN when OSD is destroyed Sasha Levin
@ 2018-01-18 20:59 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] igb: Workaround for igb i210 firmware issue Sasha Levin
                   ` (228 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 20:59 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Tomasz Majchrzak, Shaohua Li, Sasha Levin

From: Tomasz Majchrzak <tomasz.majchrzak@intel.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 9b622e2bbcf049c82e2550d35fb54ac205965f50 ]

md pending write counter must be incremented after bio is split,
otherwise it gets decremented too many times in end bio callback and
becomes negative.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/md/raid10.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 0ba6c358c6e0..4cbc3df79a2a 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1161,6 +1161,8 @@ static void __make_request(struct mddev *mddev, struct bio *bio)
 	int max_sectors;
 	int sectors;
 
+	md_write_start(mddev, bio);
+
 	/*
 	 * Register the new request and wait if the reconstruction
 	 * thread has put up a bar for new requests.
@@ -1559,8 +1561,6 @@ static void make_request(struct mddev *mddev, struct bio *bio)
 		return;
 	}
 
-	md_write_start(mddev, bio);
-
 	do {
 
 		/*
-- 
2.11.0

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

* [added to the 4.1 stable tree] xfs: don't allow di_size with high bit set
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (68 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] xfs: clear _XBF_PAGES from buffers when readahead page Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Separate VF BAR updates from standard BAR updates Sasha Levin
                   ` (225 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Darrick J. Wong, Dave Chinner, Sasha Levin

From: "Darrick J. Wong" <darrick.wong@oracle.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit ef388e2054feedaeb05399ed654bdb06f385d294 ]

The on-disk field di_size is used to set i_size, which is a signed
integer of loff_t.  If the high bit of di_size is set, we'll end up with
a negative i_size, which will cause all sorts of problems.  Since the
VFS won't let us create a file with such length, we should catch them
here in the verifier too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/xfs/libxfs/xfs_inode_buf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index a217176fde65..bc151999b68b 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -301,6 +301,14 @@ xfs_dinode_verify(
 	if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC))
 		return false;
 
+	/* don't allow invalid i_size */
+	if (be64_to_cpu(dip->di_size) & (1ULL << 63))
+		return false;
+
+	/* No zero-length symlinks. */
+	if (S_ISLNK(be16_to_cpu(dip->di_mode)) && dip->di_size == 0)
+		return false;
+
 	/* only version 3 or greater inodes are extensively verified here */
 	if (dip->di_version < 3)
 		return true;
-- 
2.11.0

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

* [added to the 4.1 stable tree] xfs: clear _XBF_PAGES from buffers when readahead page
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (67 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] igb: Workaround for igb i210 firmware issue Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] xfs: don't allow di_size with high bit set Sasha Levin
                   ` (226 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Darrick J. Wong, Sasha Levin

From: "Darrick J. Wong" <darrick.wong@oracle.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 2aa6ba7b5ad3189cc27f14540aa2f57f0ed8df4b ]

If we try to allocate memory pages to back an xfs_buf that we're trying
to read, it's possible that we'll be so short on memory that the page
allocation fails.  For a blocking read we'll just wait, but for
readahead we simply dump all the pages we've collected so far.

Unfortunately, after dumping the pages we neglect to clear the
_XBF_PAGES state, which means that the subsequent call to xfs_buf_free
thinks that b_pages still points to pages we own.  It then double-frees
the b_pages pages.

This results in screaming about negative page refcounts from the memory
manager, which xfs oughtn't be triggering.  To reproduce this case,
mount a filesystem where the size of the inodes far outweighs the
availalble memory (a ~500M inode filesystem on a VM with 300MB memory
did the trick here) and run bulkstat in parallel with other memory
eating processes to put a huge load on the system.  The "check summary"
phase of xfs_scrub also works for this purpose.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/xfs/xfs_buf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index fb0eb697a621..bdb68e919b46 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -374,6 +374,7 @@ xfs_buf_allocate_memory(
 out_free_pages:
 	for (i = 0; i < bp->b_page_count; i++)
 		__free_page(bp->b_pages[i]);
+	bp->b_flags &= ~_XBF_PAGES;
 	return error;
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] igb: Workaround for igb i210 firmware issue
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (66 preceding siblings ...)
  2018-01-18 20:59 ` [added to the 4.1 stable tree] raid10: increment write counter after bio is split Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] xfs: clear _XBF_PAGES from buffers when readahead page Sasha Levin
                   ` (227 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Sumit Semwal, Chris J Arges, Jeff Kirsher, Sasha Levin

From: Sumit Semwal <sumit.semwal@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 4e684f59d760a2c7c716bb60190783546e2d08a1 ]

Sometimes firmware may not properly initialize I347AT4_PAGE_SELECT causing
the probe of an igb i210 NIC to fail. This patch adds an addition zeroing
of this register during igb_get_phy_id to workaround this issue.

Thanks for Jochen Henneberg for the idea and original patch.

Signed-off-by: Chris J Arges <christopherarges@gmail.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/intel/igb/e1000_phy.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c
index c1bb64d8366f..bffbcc085689 100644
--- a/drivers/net/ethernet/intel/igb/e1000_phy.c
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.c
@@ -83,6 +83,10 @@ s32 igb_get_phy_id(struct e1000_hw *hw)
 	s32 ret_val = 0;
 	u16 phy_id;
 
+	/* ensure PHY page selection to fix misconfigured i210 */
+	if (hw->mac.type == e1000_i210)
+		phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, 0);
+
 	ret_val = phy->ops.read_reg(hw, PHY_ID1, &phy_id);
 	if (ret_val)
 		goto out;
-- 
2.11.0

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

* [added to the 4.1 stable tree] PCI: Separate VF BAR updates from standard BAR updates
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (69 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] xfs: don't allow di_size with high bit set Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] igb: add i211 to i210 PHY workaround Sasha Levin
                   ` (224 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Sumit Semwal, Bjorn Helgaas, Sasha Levin

From: Sumit Semwal <sumit.semwal@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 6ffa2489c51da77564a0881a73765ea2169f955d ]

Previously pci_update_resource() used the same code path for updating
standard BARs and VF BARs in SR-IOV capabilities.

Split the VF BAR update into a new pci_iov_update_resource() internal
interface, which makes it simpler to compute the BAR address (we can get
rid of pci_resource_bar() and pci_iov_resource_bar()).

This patch:

  - Renames pci_update_resource() to pci_std_update_resource(),
  - Adds pci_iov_update_resource(),
  - Makes pci_update_resource() a wrapper that calls the appropriate one,

No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/pci/iov.c       | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci.h       |  1 +
 drivers/pci/setup-res.c | 13 +++++++++++--
 3 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index ee0ebff103a4..2a8f5e9af69c 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -569,6 +569,56 @@ int pci_iov_resource_bar(struct pci_dev *dev, int resno)
 		4 * (resno - PCI_IOV_RESOURCES);
 }
 
+/**
+ * pci_iov_update_resource - update a VF BAR
+ * @dev: the PCI device
+ * @resno: the resource number
+ *
+ * Update a VF BAR in the SR-IOV capability of a PF.
+ */
+void pci_iov_update_resource(struct pci_dev *dev, int resno)
+{
+	struct pci_sriov *iov = dev->is_physfn ? dev->sriov : NULL;
+	struct resource *res = dev->resource + resno;
+	int vf_bar = resno - PCI_IOV_RESOURCES;
+	struct pci_bus_region region;
+	u32 new;
+	int reg;
+
+	/*
+	 * The generic pci_restore_bars() path calls this for all devices,
+	 * including VFs and non-SR-IOV devices.  If this is not a PF, we
+	 * have nothing to do.
+	 */
+	if (!iov)
+		return;
+
+	/*
+	 * Ignore unimplemented BARs, unused resource slots for 64-bit
+	 * BARs, and non-movable resources, e.g., those described via
+	 * Enhanced Allocation.
+	 */
+	if (!res->flags)
+		return;
+
+	if (res->flags & IORESOURCE_UNSET)
+		return;
+
+	if (res->flags & IORESOURCE_PCI_FIXED)
+		return;
+
+	pcibios_resource_to_bus(dev->bus, &region, res);
+	new = region.start;
+	new |= res->flags & ~PCI_BASE_ADDRESS_MEM_MASK;
+
+	reg = iov->pos + PCI_SRIOV_BAR + 4 * vf_bar;
+	pci_write_config_dword(dev, reg, new);
+	if (res->flags & IORESOURCE_MEM_64) {
+		new = region.start >> 16 >> 16;
+		pci_write_config_dword(dev, reg + 4, new);
+	}
+}
+
 resource_size_t __weak pcibios_iov_resource_alignment(struct pci_dev *dev,
 						      int resno)
 {
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 0c039200ed79..0f7972545091 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -264,6 +264,7 @@ static inline void pci_restore_ats_state(struct pci_dev *dev)
 int pci_iov_init(struct pci_dev *dev);
 void pci_iov_release(struct pci_dev *dev);
 int pci_iov_resource_bar(struct pci_dev *dev, int resno);
+void pci_iov_update_resource(struct pci_dev *dev, int resno);
 resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno);
 void pci_restore_iov_state(struct pci_dev *dev);
 int pci_iov_bus_range(struct pci_bus *bus);
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 232f9254c11a..6bdd4957d3ef 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -25,8 +25,7 @@
 #include <linux/slab.h>
 #include "pci.h"
 
-
-void pci_update_resource(struct pci_dev *dev, int resno)
+static void pci_std_update_resource(struct pci_dev *dev, int resno)
 {
 	struct pci_bus_region region;
 	bool disable;
@@ -105,6 +104,16 @@ void pci_update_resource(struct pci_dev *dev, int resno)
 		pci_write_config_word(dev, PCI_COMMAND, cmd);
 }
 
+void pci_update_resource(struct pci_dev *dev, int resno)
+{
+	if (resno <= PCI_ROM_RESOURCE)
+		pci_std_update_resource(dev, resno);
+#ifdef CONFIG_PCI_IOV
+	else if (resno >= PCI_IOV_RESOURCES && resno <= PCI_IOV_RESOURCE_END)
+		pci_iov_update_resource(dev, resno);
+#endif
+}
+
 int pci_claim_resource(struct pci_dev *dev, int resource)
 {
 	struct resource *res = &dev->resource[resource];
-- 
2.11.0

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

* [added to the 4.1 stable tree] igb: add i211 to i210 PHY workaround
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (70 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Separate VF BAR updates from standard BAR updates Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Add comments about ROM BAR updating Sasha Levin
                   ` (223 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Sumit Semwal, Todd Fujinaka, Jeff Kirsher, Sasha Levin

From: Sumit Semwal <sumit.semwal@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 5bc8c230e2a993b49244f9457499f17283da9ec7 ]

i210 and i211 share the same PHY but have different PCI IDs. Don't
forget i211 for any i210 workarounds.

Signed-off-by: Todd Fujinaka <todd.fujinaka@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/intel/igb/e1000_phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c
index bffbcc085689..62e36649ea09 100644
--- a/drivers/net/ethernet/intel/igb/e1000_phy.c
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.c
@@ -84,7 +84,7 @@ s32 igb_get_phy_id(struct e1000_hw *hw)
 	u16 phy_id;
 
 	/* ensure PHY page selection to fix misconfigured i210 */
-	if (hw->mac.type == e1000_i210)
+	if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211))
 		phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, 0);
 
 	ret_val = phy->ops.read_reg(hw, PHY_ID1, &phy_id);
-- 
2.11.0

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

* [added to the 4.1 stable tree] PCI: Remove pci_resource_bar() and pci_iov_resource_bar()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (72 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Add comments about ROM BAR updating Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Decouple IORESOURCE_ROM_ENABLE and PCI_ROM_ADDRESS_ENABLE Sasha Levin
                   ` (221 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Sumit Semwal, Bjorn Helgaas, Sasha Levin

From: Sumit Semwal <sumit.semwal@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 286c2378aaccc7343ebf17ec6cd86567659caf70 ]

pci_std_update_resource() only deals with standard BARs, so we don't have
to worry about the complications of VF BARs in an SR-IOV capability.

Compute the BAR address inline and remove pci_resource_bar().  That makes
pci_iov_resource_bar() unused, so remove that as well.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/pci/iov.c       | 18 ------------------
 drivers/pci/pci.c       | 30 ------------------------------
 drivers/pci/pci.h       |  6 ------
 drivers/pci/setup-res.c | 13 +++++++------
 4 files changed, 7 insertions(+), 60 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 2a8f5e9af69c..06959425cdea 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -552,24 +552,6 @@ void pci_iov_release(struct pci_dev *dev)
 }
 
 /**
- * pci_iov_resource_bar - get position of the SR-IOV BAR
- * @dev: the PCI device
- * @resno: the resource number
- *
- * Returns position of the BAR encapsulated in the SR-IOV capability.
- */
-int pci_iov_resource_bar(struct pci_dev *dev, int resno)
-{
-	if (resno < PCI_IOV_RESOURCES || resno > PCI_IOV_RESOURCE_END)
-		return 0;
-
-	BUG_ON(!dev->is_physfn);
-
-	return dev->sriov->pos + PCI_SRIOV_BAR +
-		4 * (resno - PCI_IOV_RESOURCES);
-}
-
-/**
  * pci_iov_update_resource - update a VF BAR
  * @dev: the PCI device
  * @resno: the resource number
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b5b80a5560ed..409f895b5a3d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4270,36 +4270,6 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags)
 }
 EXPORT_SYMBOL(pci_select_bars);
 
-/**
- * pci_resource_bar - get position of the BAR associated with a resource
- * @dev: the PCI device
- * @resno: the resource number
- * @type: the BAR type to be filled in
- *
- * Returns BAR position in config space, or 0 if the BAR is invalid.
- */
-int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
-{
-	int reg;
-
-	if (resno < PCI_ROM_RESOURCE) {
-		*type = pci_bar_unknown;
-		return PCI_BASE_ADDRESS_0 + 4 * resno;
-	} else if (resno == PCI_ROM_RESOURCE) {
-		*type = pci_bar_mem32;
-		return dev->rom_base_reg;
-	} else if (resno < PCI_BRIDGE_RESOURCES) {
-		/* device specific resource */
-		*type = pci_bar_unknown;
-		reg = pci_iov_resource_bar(dev, resno);
-		if (reg)
-			return reg;
-	}
-
-	dev_err(&dev->dev, "BAR %d: invalid resource\n", resno);
-	return 0;
-}
-
 /* Some architectures require additional programming to enable VGA */
 static arch_set_vga_state_t arch_set_vga_state;
 
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 0f7972545091..9dac40998336 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -208,7 +208,6 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *pl,
 int pci_setup_device(struct pci_dev *dev);
 int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
 		    struct resource *res, unsigned int reg);
-int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type);
 void pci_configure_ari(struct pci_dev *dev);
 void __pci_bus_size_bridges(struct pci_bus *bus,
 			struct list_head *realloc_head);
@@ -263,7 +262,6 @@ static inline void pci_restore_ats_state(struct pci_dev *dev)
 #ifdef CONFIG_PCI_IOV
 int pci_iov_init(struct pci_dev *dev);
 void pci_iov_release(struct pci_dev *dev);
-int pci_iov_resource_bar(struct pci_dev *dev, int resno);
 void pci_iov_update_resource(struct pci_dev *dev, int resno);
 resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno);
 void pci_restore_iov_state(struct pci_dev *dev);
@@ -278,10 +276,6 @@ static inline void pci_iov_release(struct pci_dev *dev)
 
 {
 }
-static inline int pci_iov_resource_bar(struct pci_dev *dev, int resno)
-{
-	return 0;
-}
 static inline void pci_restore_iov_state(struct pci_dev *dev)
 {
 }
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 6bdd4957d3ef..3ec798ead2c9 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -32,7 +32,6 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno)
 	u16 cmd;
 	u32 new, check, mask;
 	int reg;
-	enum pci_bar_type type;
 	struct resource *res = dev->resource + resno;
 
 	/*
@@ -61,14 +60,16 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno)
 	else
 		mask = (u32)PCI_BASE_ADDRESS_MEM_MASK;
 
-	reg = pci_resource_bar(dev, resno, &type);
-	if (!reg)
-		return;
-	if (type != pci_bar_unknown) {
+	if (resno < PCI_ROM_RESOURCE) {
+		reg = PCI_BASE_ADDRESS_0 + 4 * resno;
+	} else if (resno == PCI_ROM_RESOURCE) {
 		if (!(res->flags & IORESOURCE_ROM_ENABLE))
 			return;
+
+		reg = dev->rom_base_reg;
 		new |= PCI_ROM_ADDRESS_ENABLE;
-	}
+	} else
+		return;
 
 	/*
 	 * We can't update a 64-bit BAR atomically, so when possible,
-- 
2.11.0

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

* [added to the 4.1 stable tree] PCI: Add comments about ROM BAR updating
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (71 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] igb: add i211 to i210 PHY workaround Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Remove pci_resource_bar() and pci_iov_resource_bar() Sasha Levin
                   ` (222 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Sumit Semwal, Bjorn Helgaas, Sasha Levin

From: Sumit Semwal <sumit.semwal@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 0b457dde3cf8b7c76a60f8e960f21bbd4abdc416 ]

pci_update_resource() updates a hardware BAR so its address matches the
kernel's struct resource UNLESS it's a disabled ROM BAR.  We only update
those when we enable the ROM.

It's not obvious from the code why ROM BARs should be handled specially.
Apparently there are Matrox devices with defective ROM BARs that read as
zero when disabled.  That means that if pci_enable_rom() reads the disabled
BAR, sets PCI_ROM_ADDRESS_ENABLE (without re-inserting the address), and
writes it back, it would enable the ROM at address zero.

Add comments and references to explain why we can't make the code look more
rational.

The code changes are from 755528c860b0 ("Ignore disabled ROM resources at
setup") and 8085ce084c0f ("[PATCH] Fix PCI ROM mapping").

Link: https://lkml.org/lkml/2005/8/30/138
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/pci/rom.c       | 5 +++++
 drivers/pci/setup-res.c | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index eb0ad530dc43..3eea7fc5e1a2 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -31,6 +31,11 @@ int pci_enable_rom(struct pci_dev *pdev)
 	if (!res->flags)
 		return -1;
 
+	/*
+	 * Ideally pci_update_resource() would update the ROM BAR address,
+	 * and we would only set the enable bit here.  But apparently some
+	 * devices have buggy ROM BARs that read as zero when disabled.
+	 */
 	pcibios_resource_to_bus(pdev->bus, &region, res);
 	pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr);
 	rom_addr &= ~PCI_ROM_ADDRESS_MASK;
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 3ec798ead2c9..b1b88bfaddc0 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -63,6 +63,12 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno)
 	if (resno < PCI_ROM_RESOURCE) {
 		reg = PCI_BASE_ADDRESS_0 + 4 * resno;
 	} else if (resno == PCI_ROM_RESOURCE) {
+
+		/*
+		 * Apparently some Matrox devices have ROM BARs that read
+		 * as zero when disabled, so don't update ROM BARs unless
+		 * they're enabled.  See https://lkml.org/lkml/2005/8/30/138.
+		 */
 		if (!(res->flags & IORESOURCE_ROM_ENABLE))
 			return;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] PCI: Decouple IORESOURCE_ROM_ENABLE and PCI_ROM_ADDRESS_ENABLE
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (73 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Remove pci_resource_bar() and pci_iov_resource_bar() Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Don't update VF BARs while VF memory space is enabled Sasha Levin
                   ` (220 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Sumit Semwal, Bjorn Helgaas, Sasha Levin

From: Sumit Semwal <sumit.semwal@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 7a6d312b50e63f598f5b5914c4fd21878ac2b595 ]

Remove the assumption that IORESOURCE_ROM_ENABLE == PCI_ROM_ADDRESS_ENABLE.
PCI_ROM_ADDRESS_ENABLE is the ROM enable bit defined by the PCI spec, so if
we're reading or writing a BAR register value, that's what we should use.
IORESOURCE_ROM_ENABLE is a corresponding bit in struct resource flags.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/pci/probe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 5754d7b48c1f..c7dc06636bf6 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -223,7 +223,8 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
 			mask64 = (u32)PCI_BASE_ADDRESS_MEM_MASK;
 		}
 	} else {
-		res->flags |= (l & IORESOURCE_ROM_ENABLE);
+		if (l & PCI_ROM_ADDRESS_ENABLE)
+			res->flags |= IORESOURCE_ROM_ENABLE;
 		l64 = l & PCI_ROM_ADDRESS_MASK;
 		sz64 = sz & PCI_ROM_ADDRESS_MASK;
 		mask64 = (u32)PCI_ROM_ADDRESS_MASK;
-- 
2.11.0

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

* [added to the 4.1 stable tree] PCI: Don't update VF BARs while VF memory space is enabled
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (74 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Decouple IORESOURCE_ROM_ENABLE and PCI_ROM_ADDRESS_ENABLE Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Update BARs using property bits appropriate for type Sasha Levin
                   ` (219 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Sumit Semwal, Bjorn Helgaas, Sasha Levin

From: Sumit Semwal <sumit.semwal@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 546ba9f8f22f71b0202b6ba8967be5cc6dae4e21 ]

If we update a VF BAR while it's enabled, there are two potential problems:

  1) Any driver that's using the VF has a cached BAR value that is stale
     after the update, and

  2) We can't update 64-bit BARs atomically, so the intermediate state
     (new lower dword with old upper dword) may conflict with another
     device, and an access by a driver unrelated to the VF may cause a bus
     error.

Warn about attempts to update VF BARs while they are enabled.  This is a
programming error, so use dev_WARN() to get a backtrace.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/pci/iov.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 06959425cdea..846d4f604ebd 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -564,6 +564,7 @@ void pci_iov_update_resource(struct pci_dev *dev, int resno)
 	struct resource *res = dev->resource + resno;
 	int vf_bar = resno - PCI_IOV_RESOURCES;
 	struct pci_bus_region region;
+	u16 cmd;
 	u32 new;
 	int reg;
 
@@ -575,6 +576,13 @@ void pci_iov_update_resource(struct pci_dev *dev, int resno)
 	if (!iov)
 		return;
 
+	pci_read_config_word(dev, iov->pos + PCI_SRIOV_CTRL, &cmd);
+	if ((cmd & PCI_SRIOV_CTRL_VFE) && (cmd & PCI_SRIOV_CTRL_MSE)) {
+		dev_WARN(&dev->dev, "can't update enabled VF BAR%d %pR\n",
+			 vf_bar, res);
+		return;
+	}
+
 	/*
 	 * Ignore unimplemented BARs, unused resource slots for 64-bit
 	 * BARs, and non-movable resources, e.g., those described via
-- 
2.11.0

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

* [added to the 4.1 stable tree] PCI: Update BARs using property bits appropriate for type
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (75 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Don't update VF BARs while VF memory space is enabled Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] block: allow WRITE_SAME commands with the SG_IO ioctl Sasha Levin
                   ` (218 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Sumit Semwal, Bjorn Helgaas, Sasha Levin

From: Sumit Semwal <sumit.semwal@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 45d004f4afefdd8d79916ee6d97a9ecd94bb1ffe ]

The BAR property bits (0-3 for memory BARs, 0-1 for I/O BARs) are supposed
to be read-only, but we do save them in res->flags and include them when
updating the BAR.

Mask the I/O property bits with ~PCI_BASE_ADDRESS_IO_MASK (0x3) instead of
PCI_REGION_FLAG_MASK (0xf) to make it obvious that we can't corrupt bits
2-3 of I/O addresses.

Use PCI_ROM_ADDRESS_MASK for ROM BARs.  This means we'll only check the top
21 bits (instead of the 28 bits we used to check) of a ROM BAR to see if
the update was successful.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/pci/setup-res.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index b1b88bfaddc0..00f32ff6f74e 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -53,12 +53,17 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno)
 		return;
 
 	pcibios_resource_to_bus(dev->bus, &region, res);
+	new = region.start;
 
-	new = region.start | (res->flags & PCI_REGION_FLAG_MASK);
-	if (res->flags & IORESOURCE_IO)
+	if (res->flags & IORESOURCE_IO) {
 		mask = (u32)PCI_BASE_ADDRESS_IO_MASK;
-	else
+		new |= res->flags & ~PCI_BASE_ADDRESS_IO_MASK;
+	} else if (resno == PCI_ROM_RESOURCE) {
+		mask = (u32)PCI_ROM_ADDRESS_MASK;
+	} else {
 		mask = (u32)PCI_BASE_ADDRESS_MEM_MASK;
+		new |= res->flags & ~PCI_BASE_ADDRESS_MEM_MASK;
+	}
 
 	if (resno < PCI_ROM_RESOURCE) {
 		reg = PCI_BASE_ADDRESS_0 + 4 * resno;
-- 
2.11.0

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

* [added to the 4.1 stable tree] PCI: Do any VF BAR updates before enabling the BARs
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (77 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] block: allow WRITE_SAME commands with the SG_IO ioctl Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] serial: 8250_pci: Detach low-level driver during PCI error recovery Sasha Levin
                   ` (216 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Sumit Semwal, Gavin Shan, Bjorn Helgaas, Sasha Levin

From: Sumit Semwal <sumit.semwal@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f40ec3c748c6912f6266c56a7f7992de61b255ed ]

Previously we enabled VFs and enable their memory space before calling
pcibios_sriov_enable().  But pcibios_sriov_enable() may update the VF BARs:
for example, on PPC PowerNV we may change them to manage the association of
VFs to PEs.

Because 64-bit BARs cannot be updated atomically, it's unsafe to update
them while they're enabled.  The half-updated state may conflict with other
devices in the system.

Call pcibios_sriov_enable() before enabling the VFs so any BAR updates
happen while the VF BARs are disabled.

[bhelgaas: changelog]
Tested-by: Carol Soto <clsoto@us.ibm.com>
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/pci/iov.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 846d4f604ebd..089a1f41e44e 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -302,13 +302,6 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
 			return rc;
 	}
 
-	pci_iov_set_numvfs(dev, nr_virtfn);
-	iov->ctrl |= PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE;
-	pci_cfg_access_lock(dev);
-	pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
-	msleep(100);
-	pci_cfg_access_unlock(dev);
-
 	iov->initial_VFs = initial;
 	if (nr_virtfn < initial)
 		initial = nr_virtfn;
@@ -319,6 +312,13 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
 		return retval;
 	}
 
+	pci_iov_set_numvfs(dev, nr_virtfn);
+	iov->ctrl |= PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE;
+	pci_cfg_access_lock(dev);
+	pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
+	msleep(100);
+	pci_cfg_access_unlock(dev);
+
 	for (i = 0; i < initial; i++) {
 		rc = virtfn_add(dev, i, 0);
 		if (rc)
-- 
2.11.0

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

* [added to the 4.1 stable tree] block: allow WRITE_SAME commands with the SG_IO ioctl
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (76 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Update BARs using property bits appropriate for type Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Do any VF BAR updates before enabling the BARs Sasha Levin
                   ` (217 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Sumit Semwal, Mauricio Faria de Oliveira, Brahadambal Srinivasan,
	Jens Axboe, Sasha Levin

From: Sumit Semwal <sumit.semwal@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 25cdb64510644f3e854d502d69c73f21c6df88a9 ]

The WRITE_SAME commands are not present in the blk_default_cmd_filter
write_ok list, and thus are failed with -EPERM when the SG_IO ioctl()
is executed without CAP_SYS_RAWIO capability (e.g., unprivileged users).
[ sg_io() -> blk_fill_sghdr_rq() > blk_verify_command() -> -EPERM ]

The problem can be reproduced with the sg_write_same command

  # sg_write_same --num 1 --xferlen 512 /dev/sda
  #

  # capsh --drop=cap_sys_rawio -- -c \
    'sg_write_same --num 1 --xferlen 512 /dev/sda'
    Write same: pass through os error: Operation not permitted
  #

For comparison, the WRITE_VERIFY command does not observe this problem,
since it is in that list:

  # capsh --drop=cap_sys_rawio -- -c \
    'sg_write_verify --num 1 --ilen 512 --lba 0 /dev/sda'
  #

So, this patch adds the WRITE_SAME commands to the list, in order
for the SG_IO ioctl to finish successfully:

  # capsh --drop=cap_sys_rawio -- -c \
    'sg_write_same --num 1 --xferlen 512 /dev/sda'
  #

That case happens to be exercised by QEMU KVM guests with 'scsi-block' devices
(qemu "-device scsi-block" [1], libvirt "<disk type='block' device='lun'>" [2]),
which employs the SG_IO ioctl() and runs as an unprivileged user (libvirt-qemu).

In that scenario, when a filesystem (e.g., ext4) performs its zero-out calls,
which are translated to write-same calls in the guest kernel, and then into
SG_IO ioctls to the host kernel, SCSI I/O errors may be observed in the guest:

  [...] sd 0:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
  [...] sd 0:0:0:0: [sda] tag#0 Sense Key : Aborted Command [current]
  [...] sd 0:0:0:0: [sda] tag#0 Add. Sense: I/O process terminated
  [...] sd 0:0:0:0: [sda] tag#0 CDB: Write Same(10) 41 00 01 04 e0 78 00 00 08 00
  [...] blk_update_request: I/O error, dev sda, sector 17096824

Links:
[1] http://git.qemu.org/?p=qemu.git;a=commit;h=336a6915bc7089fb20fea4ba99972ad9a97c5f52
[2] https://libvirt.org/formatdomain.html#elementsDisks (see 'disk' -> 'device')

Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Signed-off-by: Brahadambal Srinivasan <latha@linux.vnet.ibm.com>
Reported-by: Manjunatha H R <manjuhr1@in.ibm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 block/scsi_ioctl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 55b6f15dac90..3356fd91bc61 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -182,6 +182,9 @@ static void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter)
 	__set_bit(WRITE_16, filter->write_ok);
 	__set_bit(WRITE_LONG, filter->write_ok);
 	__set_bit(WRITE_LONG_2, filter->write_ok);
+	__set_bit(WRITE_SAME, filter->write_ok);
+	__set_bit(WRITE_SAME_16, filter->write_ok);
+	__set_bit(WRITE_SAME_32, filter->write_ok);
 	__set_bit(ERASE, filter->write_ok);
 	__set_bit(GPCMD_MODE_SELECT_10, filter->write_ok);
 	__set_bit(MODE_SELECT, filter->write_ok);
-- 
2.11.0

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

* [added to the 4.1 stable tree] serial: 8250_pci: Detach low-level driver during PCI error recovery
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (78 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Do any VF BAR updates before enabling the BARs Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] [media] uvcvideo: uvc_scan_fallback() for webcams with broken chain Sasha Levin
                   ` (215 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Sumit Semwal, Gabriel Krisman Bertazi, Greg Kroah-Hartman, Sasha Levin

From: Sumit Semwal <sumit.semwal@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f209fa03fc9d131b3108c2e4936181eabab87416 ]

During a PCI error recovery, like the ones provoked by EEH in the ppc64
platform, all IO to the device must be blocked while the recovery is
completed.  Current 8250_pci implementation only suspends the port
instead of detaching it, which doesn't prevent incoming accesses like
TIOCMGET and TIOCMSET calls from reaching the device.  Those end up
racing with the EEH recovery, crashing it.  Similar races were also
observed when opening the device and when shutting it down during
recovery.

This patch implements a more robust IO blockage for the 8250_pci
recovery by unregistering the port at the beginning of the procedure and
re-adding it afterwards.  Since the port is detached from the uart
layer, we can be sure that no request will make through to the device
during recovery.  This is similar to the solution used by the JSM serial
driver.

I thank Peter Hurley <peter@hurleysoftware.com> for valuable input on
this one over one year ago.

Signed-off-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/tty/serial/8250/8250_pci.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 83a145f61f1f..bfd5e2afaeaf 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -58,6 +58,7 @@ struct serial_private {
 	unsigned int		nr;
 	void __iomem		*remapped_bar[PCI_NUM_BAR_RESOURCES];
 	struct pci_serial_quirk	*quirk;
+	const struct pciserial_board *board;
 	int			line[0];
 };
 
@@ -4155,6 +4156,7 @@ pciserial_init_ports(struct pci_dev *dev, const struct pciserial_board *board)
 		}
 	}
 	priv->nr = i;
+	priv->board = board;
 	return priv;
 
 err_deinit:
@@ -4165,7 +4167,7 @@ pciserial_init_ports(struct pci_dev *dev, const struct pciserial_board *board)
 }
 EXPORT_SYMBOL_GPL(pciserial_init_ports);
 
-void pciserial_remove_ports(struct serial_private *priv)
+void pciserial_detach_ports(struct serial_private *priv)
 {
 	struct pci_serial_quirk *quirk;
 	int i;
@@ -4185,7 +4187,11 @@ void pciserial_remove_ports(struct serial_private *priv)
 	quirk = find_quirk(priv->dev);
 	if (quirk->exit)
 		quirk->exit(priv->dev);
+}
 
+void pciserial_remove_ports(struct serial_private *priv)
+{
+	pciserial_detach_ports(priv);
 	kfree(priv);
 }
 EXPORT_SYMBOL_GPL(pciserial_remove_ports);
@@ -5936,7 +5942,7 @@ static pci_ers_result_t serial8250_io_error_detected(struct pci_dev *dev,
 		return PCI_ERS_RESULT_DISCONNECT;
 
 	if (priv)
-		pciserial_suspend_ports(priv);
+		pciserial_detach_ports(priv);
 
 	pci_disable_device(dev);
 
@@ -5961,9 +5967,18 @@ static pci_ers_result_t serial8250_io_slot_reset(struct pci_dev *dev)
 static void serial8250_io_resume(struct pci_dev *dev)
 {
 	struct serial_private *priv = pci_get_drvdata(dev);
+	const struct pciserial_board *board;
 
-	if (priv)
-		pciserial_resume_ports(priv);
+	if (!priv)
+		return;
+
+	board = priv->board;
+	kfree(priv);
+	priv = pciserial_init_ports(dev, board);
+
+	if (!IS_ERR(priv)) {
+		pci_set_drvdata(dev, priv);
+	}
 }
 
 static const struct pci_error_handlers serial8250_err_handler = {
-- 
2.11.0

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

* [added to the 4.1 stable tree] [media] uvcvideo: uvc_scan_fallback() for webcams with broken chain
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (79 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] serial: 8250_pci: Detach low-level driver during PCI error recovery Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] crypto: algif_hash - avoid zero-sized array Sasha Levin
                   ` (214 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Sumit Semwal, Henrik Ingo, Laurent Pinchart,
	Mauro Carvalho Chehab, Sasha Levin

From: Sumit Semwal <sumit.semwal@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e950267ab802c8558f1100eafd4087fd039ad634 ]

Some devices have invalid baSourceID references, causing uvc_scan_chain()
to fail, but if we just take the entities we can find and put them
together in the most sensible chain we can think of, turns out they do
work anyway. Note: This heuristic assumes there is a single chain.

At the time of writing, devices known to have such a broken chain are
  - Acer Integrated Camera (5986:055a)
  - Realtek rtl157a7 (0bda:57a7)

Signed-off-by: Henrik Ingo <henrik.ingo@avoinelama.fi>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/media/usb/uvc/uvc_driver.c | 118 +++++++++++++++++++++++++++++++++++--
 1 file changed, 112 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 5970dd6a1c1c..a41a4f6a51b2 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1574,6 +1574,114 @@ static const char *uvc_print_chain(struct uvc_video_chain *chain)
 	return buffer;
 }
 
+static struct uvc_video_chain *uvc_alloc_chain(struct uvc_device *dev)
+{
+	struct uvc_video_chain *chain;
+
+	chain = kzalloc(sizeof(*chain), GFP_KERNEL);
+	if (chain == NULL)
+		return NULL;
+
+	INIT_LIST_HEAD(&chain->entities);
+	mutex_init(&chain->ctrl_mutex);
+	chain->dev = dev;
+	v4l2_prio_init(&chain->prio);
+
+	return chain;
+}
+
+/*
+ * Fallback heuristic for devices that don't connect units and terminals in a
+ * valid chain.
+ *
+ * Some devices have invalid baSourceID references, causing uvc_scan_chain()
+ * to fail, but if we just take the entities we can find and put them together
+ * in the most sensible chain we can think of, turns out they do work anyway.
+ * Note: This heuristic assumes there is a single chain.
+ *
+ * At the time of writing, devices known to have such a broken chain are
+ *  - Acer Integrated Camera (5986:055a)
+ *  - Realtek rtl157a7 (0bda:57a7)
+ */
+static int uvc_scan_fallback(struct uvc_device *dev)
+{
+	struct uvc_video_chain *chain;
+	struct uvc_entity *iterm = NULL;
+	struct uvc_entity *oterm = NULL;
+	struct uvc_entity *entity;
+	struct uvc_entity *prev;
+
+	/*
+	 * Start by locating the input and output terminals. We only support
+	 * devices with exactly one of each for now.
+	 */
+	list_for_each_entry(entity, &dev->entities, list) {
+		if (UVC_ENTITY_IS_ITERM(entity)) {
+			if (iterm)
+				return -EINVAL;
+			iterm = entity;
+		}
+
+		if (UVC_ENTITY_IS_OTERM(entity)) {
+			if (oterm)
+				return -EINVAL;
+			oterm = entity;
+		}
+	}
+
+	if (iterm == NULL || oterm == NULL)
+		return -EINVAL;
+
+	/* Allocate the chain and fill it. */
+	chain = uvc_alloc_chain(dev);
+	if (chain == NULL)
+		return -ENOMEM;
+
+	if (uvc_scan_chain_entity(chain, oterm) < 0)
+		goto error;
+
+	prev = oterm;
+
+	/*
+	 * Add all Processing and Extension Units with two pads. The order
+	 * doesn't matter much, use reverse list traversal to connect units in
+	 * UVC descriptor order as we build the chain from output to input. This
+	 * leads to units appearing in the order meant by the manufacturer for
+	 * the cameras known to require this heuristic.
+	 */
+	list_for_each_entry_reverse(entity, &dev->entities, list) {
+		if (entity->type != UVC_VC_PROCESSING_UNIT &&
+		    entity->type != UVC_VC_EXTENSION_UNIT)
+			continue;
+
+		if (entity->num_pads != 2)
+			continue;
+
+		if (uvc_scan_chain_entity(chain, entity) < 0)
+			goto error;
+
+		prev->baSourceID[0] = entity->id;
+		prev = entity;
+	}
+
+	if (uvc_scan_chain_entity(chain, iterm) < 0)
+		goto error;
+
+	prev->baSourceID[0] = iterm->id;
+
+	list_add_tail(&chain->list, &dev->chains);
+
+	uvc_trace(UVC_TRACE_PROBE,
+		  "Found a video chain by fallback heuristic (%s).\n",
+		  uvc_print_chain(chain));
+
+	return 0;
+
+error:
+	kfree(chain);
+	return -EINVAL;
+}
+
 /*
  * Scan the device for video chains and register video devices.
  *
@@ -1596,15 +1704,10 @@ static int uvc_scan_device(struct uvc_device *dev)
 		if (term->chain.next || term->chain.prev)
 			continue;
 
-		chain = kzalloc(sizeof(*chain), GFP_KERNEL);
+		chain = uvc_alloc_chain(dev);
 		if (chain == NULL)
 			return -ENOMEM;
 
-		INIT_LIST_HEAD(&chain->entities);
-		mutex_init(&chain->ctrl_mutex);
-		chain->dev = dev;
-		v4l2_prio_init(&chain->prio);
-
 		term->flags |= UVC_ENTITY_FLAG_DEFAULT;
 
 		if (uvc_scan_chain(chain, term) < 0) {
@@ -1618,6 +1721,9 @@ static int uvc_scan_device(struct uvc_device *dev)
 		list_add_tail(&chain->list, &dev->chains);
 	}
 
+	if (list_empty(&dev->chains))
+		uvc_scan_fallback(dev);
+
 	if (list_empty(&dev->chains)) {
 		uvc_printk(KERN_INFO, "No valid video chain found.\n");
 		return -1;
-- 
2.11.0

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

* [added to the 4.1 stable tree] crypto: algif_hash - avoid zero-sized array
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (80 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] [media] uvcvideo: uvc_scan_fallback() for webcams with broken chain Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] fbcon: Fix vc attr at deinit Sasha Levin
                   ` (213 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jiri Slaby, Herbert Xu, Sasha Levin

From: Jiri Slaby <jslaby@suse.cz>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 6207119444595d287b1e9e83a2066c17209698f3 ]

With this reproducer:
  struct sockaddr_alg alg = {
          .salg_family = 0x26,
          .salg_type = "hash",
          .salg_feat = 0xf,
          .salg_mask = 0x5,
          .salg_name = "digest_null",
  };
  int sock, sock2;

  sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
  bind(sock, (struct sockaddr *)&alg, sizeof(alg));
  sock2 = accept(sock, NULL, NULL);
  setsockopt(sock, SOL_ALG, ALG_SET_KEY, "\x9b\xca", 2);
  accept(sock2, NULL, NULL);

==== 8< ======== 8< ======== 8< ======== 8< ====

one can immediatelly see an UBSAN warning:
UBSAN: Undefined behaviour in crypto/algif_hash.c:187:7
variable length array bound value 0 <= 0
CPU: 0 PID: 15949 Comm: syz-executor Tainted: G            E      4.4.30-0-default #1
...
Call Trace:
...
 [<ffffffff81d598fd>] ? __ubsan_handle_vla_bound_not_positive+0x13d/0x188
 [<ffffffff81d597c0>] ? __ubsan_handle_out_of_bounds+0x1bc/0x1bc
 [<ffffffffa0e2204d>] ? hash_accept+0x5bd/0x7d0 [algif_hash]
 [<ffffffffa0e2293f>] ? hash_accept_nokey+0x3f/0x51 [algif_hash]
 [<ffffffffa0e206b0>] ? hash_accept_parent_nokey+0x4a0/0x4a0 [algif_hash]
 [<ffffffff8235c42b>] ? SyS_accept+0x2b/0x40

It is a correct warning, as hash state is propagated to accept as zero,
but creating a zero-length variable array is not allowed in C.

Fix this as proposed by Herbert -- do "?: 1" on that site. No sizeof or
similar happens in the code there, so we just allocate one byte even
though we do not use the array.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net> (maintainer:CRYPTO API)
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 crypto/algif_hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
index d7a3435280d8..db83dabe5fc9 100644
--- a/crypto/algif_hash.c
+++ b/crypto/algif_hash.c
@@ -184,7 +184,7 @@ static int hash_accept(struct socket *sock, struct socket *newsock, int flags)
 	struct alg_sock *ask = alg_sk(sk);
 	struct hash_ctx *ctx = ask->private;
 	struct ahash_request *req = &ctx->req;
-	char state[crypto_ahash_statesize(crypto_ahash_reqtfm(req))];
+	char state[crypto_ahash_statesize(crypto_ahash_reqtfm(req)) ? : 1];
 	struct sock *sk2;
 	struct alg_sock *ask2;
 	struct hash_ctx *ctx2;
-- 
2.11.0

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

* [added to the 4.1 stable tree] fbcon: Fix vc attr at deinit
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (81 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] crypto: algif_hash - avoid zero-sized array Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] xfrm_user: validate XFRM_MSG_NEWAE XFRMA_REPLAY_ESN_VAL replay_window Sasha Levin
                   ` (212 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Takashi Iwai, Bartlomiej Zolnierkiewicz, Sasha Levin

From: Takashi Iwai <tiwai@suse.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 8aac7f34369726d1a158788ae8aff3002d5eb528 ]

fbcon can deal with vc_hi_font_mask (the upper 256 chars) and adjust
the vc attrs dynamically when vc_hi_font_mask is changed at
fbcon_init().  When the vc_hi_font_mask is set, it remaps the attrs in
the existing console buffer with one bit shift up (for 9 bits), while
it remaps with one bit shift down (for 8 bits) when the value is
cleared.  It works fine as long as the font gets updated after fbcon
was initialized.

However, we hit a bizarre problem when the console is switched to
another fb driver (typically from vesafb or efifb to drmfb).  At
switching to the new fb driver, we temporarily rebind the console to
the dummy console, then rebind to the new driver.  During the
switching, we leave the modified attrs as is.  Thus, the new fbcon
takes over the old buffer as if it were to contain 8 bits chars
(although the attrs are still shifted for 9 bits), and effectively
this results in the yellow color texts instead of the original white
color, as found in the bugzilla entry below.

An easy fix for this is to re-adjust the attrs before leaving the
fbcon at con_deinit callback.  Since the code to adjust the attrs is
already present in the current fbcon code, in this patch, we simply
factor out the relevant code, and call it from fbcon_deinit().

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1000619
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/video/console/fbcon.c | 67 ++++++++++++++++++++++++++-----------------
 1 file changed, 40 insertions(+), 27 deletions(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index b97210671a81..106348c6d993 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -1165,6 +1165,8 @@ static void fbcon_free_font(struct display *p, bool freefont)
 	p->userfont = 0;
 }
 
+static void set_vc_hi_font(struct vc_data *vc, bool set);
+
 static void fbcon_deinit(struct vc_data *vc)
 {
 	struct display *p = &fb_display[vc->vc_num];
@@ -1200,6 +1202,9 @@ static void fbcon_deinit(struct vc_data *vc)
 	if (free_font)
 		vc->vc_font.data = NULL;
 
+	if (vc->vc_hi_font_mask)
+		set_vc_hi_font(vc, false);
+
 	if (!con_is_bound(&fb_con))
 		fbcon_exit();
 
@@ -2434,32 +2439,10 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font)
 	return 0;
 }
 
-static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
-			     const u8 * data, int userfont)
+/* set/clear vc_hi_font_mask and update vc attrs accordingly */
+static void set_vc_hi_font(struct vc_data *vc, bool set)
 {
-	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
-	struct fbcon_ops *ops = info->fbcon_par;
-	struct display *p = &fb_display[vc->vc_num];
-	int resize;
-	int cnt;
-	char *old_data = NULL;
-
-	if (CON_IS_VISIBLE(vc) && softback_lines)
-		fbcon_set_origin(vc);
-
-	resize = (w != vc->vc_font.width) || (h != vc->vc_font.height);
-	if (p->userfont)
-		old_data = vc->vc_font.data;
-	if (userfont)
-		cnt = FNTCHARCNT(data);
-	else
-		cnt = 256;
-	vc->vc_font.data = (void *)(p->fontdata = data);
-	if ((p->userfont = userfont))
-		REFCOUNT(data)++;
-	vc->vc_font.width = w;
-	vc->vc_font.height = h;
-	if (vc->vc_hi_font_mask && cnt == 256) {
+	if (!set) {
 		vc->vc_hi_font_mask = 0;
 		if (vc->vc_can_do_color) {
 			vc->vc_complement_mask >>= 1;
@@ -2482,7 +2465,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
 			    ((c & 0xfe00) >> 1) | (c & 0xff);
 			vc->vc_attr >>= 1;
 		}
-	} else if (!vc->vc_hi_font_mask && cnt == 512) {
+	} else {
 		vc->vc_hi_font_mask = 0x100;
 		if (vc->vc_can_do_color) {
 			vc->vc_complement_mask <<= 1;
@@ -2514,8 +2497,38 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
 			} else
 				vc->vc_video_erase_char = c & ~0x100;
 		}
-
 	}
+}
+
+static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
+			     const u8 * data, int userfont)
+{
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
+	struct fbcon_ops *ops = info->fbcon_par;
+	struct display *p = &fb_display[vc->vc_num];
+	int resize;
+	int cnt;
+	char *old_data = NULL;
+
+	if (CON_IS_VISIBLE(vc) && softback_lines)
+		fbcon_set_origin(vc);
+
+	resize = (w != vc->vc_font.width) || (h != vc->vc_font.height);
+	if (p->userfont)
+		old_data = vc->vc_font.data;
+	if (userfont)
+		cnt = FNTCHARCNT(data);
+	else
+		cnt = 256;
+	vc->vc_font.data = (void *)(p->fontdata = data);
+	if ((p->userfont = userfont))
+		REFCOUNT(data)++;
+	vc->vc_font.width = w;
+	vc->vc_font.height = h;
+	if (vc->vc_hi_font_mask && cnt == 256)
+		set_vc_hi_font(vc, false);
+	else if (!vc->vc_hi_font_mask && cnt == 512)
+		set_vc_hi_font(vc, true);
 
 	if (resize) {
 		int cols, rows;
-- 
2.11.0

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

* [added to the 4.1 stable tree] xfrm: policy: init locks early
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (83 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] xfrm_user: validate XFRM_MSG_NEWAE XFRMA_REPLAY_ESN_VAL replay_window Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder Sasha Levin
                   ` (210 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Florian Westphal, Steffen Klassert, Sasha Levin

From: Florian Westphal <fw@strlen.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit c282222a45cb9503cbfbebfdb60491f06ae84b49 ]

Dmitry reports following splat:
 INFO: trying to register non-static key.
 the code is fine but needs lockdep annotation.
 turning off the locking correctness validator.
 CPU: 0 PID: 13059 Comm: syz-executor1 Not tainted 4.10.0-rc7-next-20170207 #1
[..]
 spin_lock_bh include/linux/spinlock.h:304 [inline]
 xfrm_policy_flush+0x32/0x470 net/xfrm/xfrm_policy.c:963
 xfrm_policy_fini+0xbf/0x560 net/xfrm/xfrm_policy.c:3041
 xfrm_net_init+0x79f/0x9e0 net/xfrm/xfrm_policy.c:3091
 ops_init+0x10a/0x530 net/core/net_namespace.c:115
 setup_net+0x2ed/0x690 net/core/net_namespace.c:291
 copy_net_ns+0x26c/0x530 net/core/net_namespace.c:396
 create_new_namespaces+0x409/0x860 kernel/nsproxy.c:106
 unshare_nsproxy_namespaces+0xae/0x1e0 kernel/nsproxy.c:205
 SYSC_unshare kernel/fork.c:2281 [inline]

Problem is that when we get error during xfrm_net_init we will call
xfrm_policy_fini which will acquire xfrm_policy_lock before it was
initialized.  Just move it around so locks get set up first.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Fixes: 283bc9f35bbbcb0e9 ("xfrm: Namespacify xfrm state/policy locks")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/xfrm/xfrm_policy.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 04a025218d13..85cddb37feac 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -2963,6 +2963,11 @@ static int __net_init xfrm_net_init(struct net *net)
 {
 	int rv;
 
+	/* Initialize the per-net locks here */
+	spin_lock_init(&net->xfrm.xfrm_state_lock);
+	rwlock_init(&net->xfrm.xfrm_policy_lock);
+	mutex_init(&net->xfrm.xfrm_cfg_mutex);
+
 	rv = xfrm_statistics_init(net);
 	if (rv < 0)
 		goto out_statistics;
@@ -2979,11 +2984,6 @@ static int __net_init xfrm_net_init(struct net *net)
 	if (rv < 0)
 		goto out;
 
-	/* Initialize the per-net locks here */
-	spin_lock_init(&net->xfrm.xfrm_state_lock);
-	rwlock_init(&net->xfrm.xfrm_policy_lock);
-	mutex_init(&net->xfrm.xfrm_cfg_mutex);
-
 	return 0;
 
 out:
-- 
2.11.0

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

* [added to the 4.1 stable tree] xfrm_user: validate XFRM_MSG_NEWAE XFRMA_REPLAY_ESN_VAL replay_window
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (82 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] fbcon: Fix vc attr at deinit Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] xfrm: policy: init locks early Sasha Levin
                   ` (211 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Andy Whitcroft, Linus Torvalds, Sasha Levin

From: Andy Whitcroft <apw@canonical.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 677e806da4d916052585301785d847c3b3e6186a ]

When a new xfrm state is created during an XFRM_MSG_NEWSA call we
validate the user supplied replay_esn to ensure that the size is valid
and to ensure that the replay_window size is within the allocated
buffer.  However later it is possible to update this replay_esn via a
XFRM_MSG_NEWAE call.  There we again validate the size of the supplied
buffer matches the existing state and if so inject the contents.  We do
not at this point check that the replay_window is within the allocated
memory.  This leads to out-of-bounds reads and writes triggered by
netlink packets.  This leads to memory corruption and the potential for
priviledge escalation.

We already attempt to validate the incoming replay information in
xfrm_new_ae() via xfrm_replay_verify_len().  This confirms that the user
is not trying to change the size of the replay state buffer which
includes the replay_esn.  It however does not check the replay_window
remains within that buffer.  Add validation of the contained
replay_window.

CVE-2017-7184
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/xfrm/xfrm_user.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 18d9cf2eb648..177cb17cf09c 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -389,6 +389,9 @@ static inline int xfrm_replay_verify_len(struct xfrm_replay_state_esn *replay_es
 	if (nla_len(rp) < ulen || xfrm_replay_state_esn_len(replay_esn) != ulen)
 		return -EINVAL;
 
+	if (up->replay_window > up->bmp_len * sizeof(__u32) * 8)
+		return -EINVAL;
+
 	return 0;
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (84 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] xfrm: policy: init locks early Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] c6x/ptrace: Remove useless PTRACE_SETREGSET implementation Sasha Levin
                   ` (209 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Andy Whitcroft, Linus Torvalds, Sasha Levin

From: Andy Whitcroft <apw@canonical.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f843ee6dd019bcece3e74e76ad9df0155655d0df ]

Kees Cook has pointed out that xfrm_replay_state_esn_len() is subject to
wrapping issues.  To ensure we are correctly ensuring that the two ESN
structures are the same size compare both the overall size as reported
by xfrm_replay_state_esn_len() and the internal length are the same.

CVE-2017-7184
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/xfrm/xfrm_user.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 177cb17cf09c..30593cadd428 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -386,7 +386,11 @@ static inline int xfrm_replay_verify_len(struct xfrm_replay_state_esn *replay_es
 	up = nla_data(rp);
 	ulen = xfrm_replay_state_esn_len(up);
 
-	if (nla_len(rp) < ulen || xfrm_replay_state_esn_len(replay_esn) != ulen)
+	/* Check the overall length and the internal bitmap length to avoid
+	 * potential overflow. */
+	if (nla_len(rp) < ulen ||
+	    xfrm_replay_state_esn_len(replay_esn) != ulen ||
+	    replay_esn->bmp_len != up->bmp_len)
 		return -EINVAL;
 
 	if (up->replay_window > up->bmp_len * sizeof(__u32) * 8)
-- 
2.11.0

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

* [added to the 4.1 stable tree] mips/ptrace: Preserve previous registers for short regset write
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (86 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] c6x/ptrace: Remove useless PTRACE_SETREGSET implementation Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] sparc/ptrace: " Sasha Levin
                   ` (207 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Dave Martin, Linus Torvalds, Sasha Levin

From: Dave Martin <Dave.Martin@arm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit d614fd58a2834cfe4efa472c33c8f3ce2338b09b ]

Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET
to fill all the registers, the thread's old registers are preserved.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/mips/kernel/ptrace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index 81a13fd56d13..2bea5db01b0b 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -484,7 +484,8 @@ static int fpr_set(struct task_struct *target,
 					  &target->thread.fpu,
 					  0, sizeof(elf_fpregset_t));
 
-	for (i = 0; i < NUM_FPU_REGS; i++) {
+	BUILD_BUG_ON(sizeof(fpr_val) != sizeof(elf_fpreg_t));
+	for (i = 0; i < NUM_FPU_REGS && count >= sizeof(elf_fpreg_t); i++) {
 		err = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
 					 &fpr_val, i * sizeof(elf_fpreg_t),
 					 (i + 1) * sizeof(elf_fpreg_t));
-- 
2.11.0

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

* [added to the 4.1 stable tree] c6x/ptrace: Remove useless PTRACE_SETREGSET implementation
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (85 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] mips/ptrace: Preserve previous registers for short regset write Sasha Levin
                   ` (208 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Dave Martin, Linus Torvalds, Sasha Levin

From: Dave Martin <Dave.Martin@arm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit fb411b837b587a32046dc4f369acb93a10b1def8 ]

gpr_set won't work correctly and can never have been tested, and the
correct behaviour is not clear due to the endianness-dependent task
layout.

So, just remove it.  The core code will now return -EOPNOTSUPPORT when
trying to set NT_PRSTATUS on this architecture until/unless a correct
implementation is supplied.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/c6x/kernel/ptrace.c | 41 -----------------------------------------
 1 file changed, 41 deletions(-)

diff --git a/arch/c6x/kernel/ptrace.c b/arch/c6x/kernel/ptrace.c
index 3c494e84444d..a511ac16a8e3 100644
--- a/arch/c6x/kernel/ptrace.c
+++ b/arch/c6x/kernel/ptrace.c
@@ -69,46 +69,6 @@ static int gpr_get(struct task_struct *target,
 				   0, sizeof(*regs));
 }
 
-static int gpr_set(struct task_struct *target,
-		   const struct user_regset *regset,
-		   unsigned int pos, unsigned int count,
-		   const void *kbuf, const void __user *ubuf)
-{
-	int ret;
-	struct pt_regs *regs = task_pt_regs(target);
-
-	/* Don't copyin TSR or CSR */
-	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
-				 &regs,
-				 0, PT_TSR * sizeof(long));
-	if (ret)
-		return ret;
-
-	ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
-					PT_TSR * sizeof(long),
-					(PT_TSR + 1) * sizeof(long));
-	if (ret)
-		return ret;
-
-	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
-				 &regs,
-				 (PT_TSR + 1) * sizeof(long),
-				 PT_CSR * sizeof(long));
-	if (ret)
-		return ret;
-
-	ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
-					PT_CSR * sizeof(long),
-					(PT_CSR + 1) * sizeof(long));
-	if (ret)
-		return ret;
-
-	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
-				 &regs,
-				 (PT_CSR + 1) * sizeof(long), -1);
-	return ret;
-}
-
 enum c6x_regset {
 	REGSET_GPR,
 };
@@ -120,7 +80,6 @@ static const struct user_regset c6x_regsets[] = {
 		.size = sizeof(u32),
 		.align = sizeof(u32),
 		.get = gpr_get,
-		.set = gpr_set
 	},
 };
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] sparc/ptrace: Preserve previous registers for short regset write
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (87 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] mips/ptrace: Preserve previous registers for short regset write Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] metag/ptrace: Reject partial NT_METAG_RPIPE writes Sasha Levin
                   ` (206 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Dave Martin, Linus Torvalds, Sasha Levin

From: Dave Martin <Dave.Martin@arm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit d3805c546b275c8cc7d40f759d029ae92c7175f2 ]

Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET
to fill all the registers, the thread's old registers are preserved.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/sparc/kernel/ptrace_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
index 9ddc4928a089..c1566170964f 100644
--- a/arch/sparc/kernel/ptrace_64.c
+++ b/arch/sparc/kernel/ptrace_64.c
@@ -311,7 +311,7 @@ static int genregs64_set(struct task_struct *target,
 	}
 
 	if (!ret) {
-		unsigned long y;
+		unsigned long y = regs->y;
 
 		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
 					 &y,
-- 
2.11.0

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

* [added to the 4.1 stable tree] metag/ptrace: Reject partial NT_METAG_RPIPE writes
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (88 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] sparc/ptrace: " Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS Sasha Levin
                   ` (205 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Dave Martin, Linus Torvalds, Sasha Levin

From: Dave Martin <Dave.Martin@arm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 7195ee3120d878259e8d94a5d9f808116f34d5ea ]

It's not clear what behaviour is sensible when doing partial write of
NT_METAG_RPIPE, so just don't bother.

This patch assumes that userspace will never rely on a partial SETREGSET
in this case, since it's not clear what should happen anyway.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Acked-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/metag/kernel/ptrace.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/metag/kernel/ptrace.c b/arch/metag/kernel/ptrace.c
index 2e4dfc15abd3..5e2dc7defd2c 100644
--- a/arch/metag/kernel/ptrace.c
+++ b/arch/metag/kernel/ptrace.c
@@ -253,6 +253,8 @@ int metag_rp_state_copyin(struct pt_regs *regs,
 	unsigned long long *ptr;
 	int ret, i;
 
+	if (count < 4*13)
+		return -EINVAL;
 	/* Read the entire pipeline before making any changes */
 	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
 				 &rp, 0, 4*13);
-- 
2.11.0

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

* [added to the 4.1 stable tree] metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (89 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] metag/ptrace: Reject partial NT_METAG_RPIPE writes Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] metag/ptrace: Preserve previous registers for short regset write Sasha Levin
                   ` (204 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Dave Martin, Linus Torvalds, Sasha Levin

From: Dave Martin <Dave.Martin@arm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 5fe81fe98123ce41265c65e95d34418d30d005d1 ]

Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET
to fill TXSTATUS, a well-defined default value is used, based on the
task's current value.

Suggested-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/metag/kernel/ptrace.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/arch/metag/kernel/ptrace.c b/arch/metag/kernel/ptrace.c
index ae659ba61948..2e4dfc15abd3 100644
--- a/arch/metag/kernel/ptrace.c
+++ b/arch/metag/kernel/ptrace.c
@@ -24,6 +24,16 @@
  * user_regset definitions.
  */
 
+static unsigned long user_txstatus(const struct pt_regs *regs)
+{
+	unsigned long data = (unsigned long)regs->ctx.Flags;
+
+	if (regs->ctx.SaveMask & TBICTX_CBUF_BIT)
+		data |= USER_GP_REGS_STATUS_CATCH_BIT;
+
+	return data;
+}
+
 int metag_gp_regs_copyout(const struct pt_regs *regs,
 			  unsigned int pos, unsigned int count,
 			  void *kbuf, void __user *ubuf)
@@ -62,9 +72,7 @@ int metag_gp_regs_copyout(const struct pt_regs *regs,
 	if (ret)
 		goto out;
 	/* TXSTATUS */
-	data = (unsigned long)regs->ctx.Flags;
-	if (regs->ctx.SaveMask & TBICTX_CBUF_BIT)
-		data |= USER_GP_REGS_STATUS_CATCH_BIT;
+	data = user_txstatus(regs);
 	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
 				  &data, 4*25, 4*26);
 	if (ret)
@@ -119,6 +127,7 @@ int metag_gp_regs_copyin(struct pt_regs *regs,
 	if (ret)
 		goto out;
 	/* TXSTATUS */
+	data = user_txstatus(regs);
 	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
 				 &data, 4*25, 4*26);
 	if (ret)
-- 
2.11.0

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

* [added to the 4.1 stable tree] metag/ptrace: Preserve previous registers for short regset write
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (90 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] libceph: force GFP_NOIO for socket allocations Sasha Levin
                   ` (203 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Dave Martin, Linus Torvalds, Sasha Levin

From: Dave Martin <Dave.Martin@arm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit a78ce80d2c9178351b34d78fec805140c29c193e ]

Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET
to fill all the registers, the thread's old registers are preserved.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Acked-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/metag/kernel/ptrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/metag/kernel/ptrace.c b/arch/metag/kernel/ptrace.c
index 7563628822bd..ae659ba61948 100644
--- a/arch/metag/kernel/ptrace.c
+++ b/arch/metag/kernel/ptrace.c
@@ -303,7 +303,7 @@ static int metag_tls_set(struct task_struct *target,
 			const void *kbuf, const void __user *ubuf)
 {
 	int ret;
-	void __user *tls;
+	void __user *tls = target->thread.tls_ptr;
 
 	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &tls, 0, -1);
 	if (ret)
-- 
2.11.0

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

* [added to the 4.1 stable tree] libceph: force GFP_NOIO for socket allocations
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (91 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] metag/ptrace: Preserve previous registers for short regset write Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] MIPS: Lantiq: Fix cascaded IRQ setup Sasha Levin
                   ` (202 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Ilya Dryomov, Sasha Levin

From: Ilya Dryomov <idryomov@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 633ee407b9d15a75ac9740ba9d3338815e1fcb95 ]

sock_alloc_inode() allocates socket+inode and socket_wq with
GFP_KERNEL, which is not allowed on the writeback path:

    Workqueue: ceph-msgr con_work [libceph]
    ffff8810871cb018 0000000000000046 0000000000000000 ffff881085d40000
    0000000000012b00 ffff881025cad428 ffff8810871cbfd8 0000000000012b00
    ffff880102fc1000 ffff881085d40000 ffff8810871cb038 ffff8810871cb148
    Call Trace:
    [<ffffffff816dd629>] schedule+0x29/0x70
    [<ffffffff816e066d>] schedule_timeout+0x1bd/0x200
    [<ffffffff81093ffc>] ? ttwu_do_wakeup+0x2c/0x120
    [<ffffffff81094266>] ? ttwu_do_activate.constprop.135+0x66/0x70
    [<ffffffff816deb5f>] wait_for_completion+0xbf/0x180
    [<ffffffff81097cd0>] ? try_to_wake_up+0x390/0x390
    [<ffffffff81086335>] flush_work+0x165/0x250
    [<ffffffff81082940>] ? worker_detach_from_pool+0xd0/0xd0
    [<ffffffffa03b65b1>] xlog_cil_force_lsn+0x81/0x200 [xfs]
    [<ffffffff816d6b42>] ? __slab_free+0xee/0x234
    [<ffffffffa03b4b1d>] _xfs_log_force_lsn+0x4d/0x2c0 [xfs]
    [<ffffffff811adc1e>] ? lookup_page_cgroup_used+0xe/0x30
    [<ffffffffa039a723>] ? xfs_reclaim_inode+0xa3/0x330 [xfs]
    [<ffffffffa03b4dcf>] xfs_log_force_lsn+0x3f/0xf0 [xfs]
    [<ffffffffa039a723>] ? xfs_reclaim_inode+0xa3/0x330 [xfs]
    [<ffffffffa03a62c6>] xfs_iunpin_wait+0xc6/0x1a0 [xfs]
    [<ffffffff810aa250>] ? wake_atomic_t_function+0x40/0x40
    [<ffffffffa039a723>] xfs_reclaim_inode+0xa3/0x330 [xfs]
    [<ffffffffa039ac07>] xfs_reclaim_inodes_ag+0x257/0x3d0 [xfs]
    [<ffffffffa039bb13>] xfs_reclaim_inodes_nr+0x33/0x40 [xfs]
    [<ffffffffa03ab745>] xfs_fs_free_cached_objects+0x15/0x20 [xfs]
    [<ffffffff811c0c18>] super_cache_scan+0x178/0x180
    [<ffffffff8115912e>] shrink_slab_node+0x14e/0x340
    [<ffffffff811afc3b>] ? mem_cgroup_iter+0x16b/0x450
    [<ffffffff8115af70>] shrink_slab+0x100/0x140
    [<ffffffff8115e425>] do_try_to_free_pages+0x335/0x490
    [<ffffffff8115e7f9>] try_to_free_pages+0xb9/0x1f0
    [<ffffffff816d56e4>] ? __alloc_pages_direct_compact+0x69/0x1be
    [<ffffffff81150cba>] __alloc_pages_nodemask+0x69a/0xb40
    [<ffffffff8119743e>] alloc_pages_current+0x9e/0x110
    [<ffffffff811a0ac5>] new_slab+0x2c5/0x390
    [<ffffffff816d71c4>] __slab_alloc+0x33b/0x459
    [<ffffffff815b906d>] ? sock_alloc_inode+0x2d/0xd0
    [<ffffffff8164bda1>] ? inet_sendmsg+0x71/0xc0
    [<ffffffff815b906d>] ? sock_alloc_inode+0x2d/0xd0
    [<ffffffff811a21f2>] kmem_cache_alloc+0x1a2/0x1b0
    [<ffffffff815b906d>] sock_alloc_inode+0x2d/0xd0
    [<ffffffff811d8566>] alloc_inode+0x26/0xa0
    [<ffffffff811da04a>] new_inode_pseudo+0x1a/0x70
    [<ffffffff815b933e>] sock_alloc+0x1e/0x80
    [<ffffffff815ba855>] __sock_create+0x95/0x220
    [<ffffffff815baa04>] sock_create_kern+0x24/0x30
    [<ffffffffa04794d9>] con_work+0xef9/0x2050 [libceph]
    [<ffffffffa04aa9ec>] ? rbd_img_request_submit+0x4c/0x60 [rbd]
    [<ffffffff81084c19>] process_one_work+0x159/0x4f0
    [<ffffffff8108561b>] worker_thread+0x11b/0x530
    [<ffffffff81085500>] ? create_worker+0x1d0/0x1d0
    [<ffffffff8108b6f9>] kthread+0xc9/0xe0
    [<ffffffff8108b630>] ? flush_kthread_worker+0x90/0x90
    [<ffffffff816e1b98>] ret_from_fork+0x58/0x90
    [<ffffffff8108b630>] ? flush_kthread_worker+0x90/0x90

Use memalloc_noio_{save,restore}() to temporarily force GFP_NOIO here.

Cc: stable@vger.kernel.org # 3.10+, needs backporting
Link: http://tracker.ceph.com/issues/19309
Reported-by: Sergey Jerusalimov <wintchester@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ceph/messenger.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 940ba74b297c..d30864a8ed57 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -6,6 +6,7 @@
 #include <linux/inet.h>
 #include <linux/kthread.h>
 #include <linux/net.h>
+#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/socket.h>
 #include <linux/string.h>
@@ -477,11 +478,16 @@ static int ceph_tcp_connect(struct ceph_connection *con)
 {
 	struct sockaddr_storage *paddr = &con->peer_addr.in_addr;
 	struct socket *sock;
+	unsigned int noio_flag;
 	int ret;
 
 	BUG_ON(con->sock);
+
+	/* sock_create_kern() allocates with GFP_KERNEL */
+	noio_flag = memalloc_noio_save();
 	ret = sock_create_kern(con->peer_addr.in_addr.ss_family, SOCK_STREAM,
 			       IPPROTO_TCP, &sock);
+	memalloc_noio_restore(noio_flag);
 	if (ret)
 		return ret;
 	sock->sk->sk_allocation = GFP_NOFS;
-- 
2.11.0

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

* [added to the 4.1 stable tree] MIPS: Lantiq: Fix cascaded IRQ setup
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (92 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] libceph: force GFP_NOIO for socket allocations Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] KVM: x86: clear bus pointer when destroyed Sasha Levin
                   ` (201 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Felix Fietkau, James Hogan, Sasha Levin

From: Felix Fietkau <nbd@nbd.name>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 6c356eda225e3ee134ed4176b9ae3a76f793f4dd ]

With the IRQ stack changes integrated, the XRX200 devices started
emitting a constant stream of kernel messages like this:

[  565.415310] Spurious IRQ: CAUSE=0x1100c300

This is caused by IP0 getting handled by plat_irq_dispatch() rather than
its vectored interrupt handler, which is fixed by commit de856416e714
("MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch").

Fix plat_irq_dispatch() to handle non-vectored IPI interrupts correctly
by setting up IP2-6 as proper chained IRQ handlers and calling do_IRQ
for all MIPS CPU interrupts.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Acked-by: John Crispin <john@phrozen.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/15077/
[james.hogan@imgtec.com: tweaked commit message]
Signed-off-by: James Hogan <james.hogan@imgtec.com>

Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/mips/lantiq/irq.c | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/arch/mips/lantiq/irq.c b/arch/mips/lantiq/irq.c
index d01ade63492f..7e2279ac6c0d 100644
--- a/arch/mips/lantiq/irq.c
+++ b/arch/mips/lantiq/irq.c
@@ -269,6 +269,11 @@ static void ltq_hw5_irqdispatch(void)
 DEFINE_HWx_IRQDISPATCH(5)
 #endif
 
+static void ltq_hw_irq_handler(struct irq_desc *desc)
+{
+	ltq_hw_irqdispatch(irq_desc_get_irq(desc) - 2);
+}
+
 #ifdef CONFIG_MIPS_MT_SMP
 void __init arch_init_ipiirq(int irq, struct irqaction *action)
 {
@@ -313,23 +318,19 @@ static struct irqaction irq_call = {
 asmlinkage void plat_irq_dispatch(void)
 {
 	unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM;
-	unsigned int i;
-
-	if ((MIPS_CPU_TIMER_IRQ == 7) && (pending & CAUSEF_IP7)) {
-		do_IRQ(MIPS_CPU_TIMER_IRQ);
-		goto out;
-	} else {
-		for (i = 0; i < MAX_IM; i++) {
-			if (pending & (CAUSEF_IP2 << i)) {
-				ltq_hw_irqdispatch(i);
-				goto out;
-			}
-		}
+	int irq;
+
+	if (!pending) {
+		spurious_interrupt();
+		return;
 	}
-	pr_alert("Spurious IRQ: CAUSE=0x%08x\n", read_c0_status());
 
-out:
-	return;
+	pending >>= CAUSEB_IP;
+	while (pending) {
+		irq = fls(pending) - 1;
+		do_IRQ(MIPS_CPU_IRQ_BASE + irq);
+		pending &= ~BIT(irq);
+	}
 }
 
 static int icu_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)
@@ -354,11 +355,6 @@ static const struct irq_domain_ops irq_domain_ops = {
 	.map = icu_map,
 };
 
-static struct irqaction cascade = {
-	.handler = no_action,
-	.name = "cascade",
-};
-
 int __init icu_of_init(struct device_node *node, struct device_node *parent)
 {
 	struct device_node *eiu_node;
@@ -390,7 +386,7 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent)
 	mips_cpu_irq_init();
 
 	for (i = 0; i < MAX_IM; i++)
-		setup_irq(i + 2, &cascade);
+		irq_set_chained_handler(i + 2, ltq_hw_irq_handler);
 
 	if (cpu_has_vint) {
 		pr_info("Setting up vectored interrupts\n");
-- 
2.11.0

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

* [added to the 4.1 stable tree] KVM: x86: clear bus pointer when destroyed
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (93 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] MIPS: Lantiq: Fix cascaded IRQ setup Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] rtc: s35390a: fix reading out alarm Sasha Levin
                   ` (200 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Peter Xu, Radim Krčmář, Sasha Levin

From: Peter Xu <peterx@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit df630b8c1e851b5e265dc2ca9c87222e342c093b ]

When releasing the bus, let's clear the bus pointers to mark it out. If
any further device unregister happens on this bus, we know that we're
done if we found the bus being released already.

Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 virt/kvm/kvm_main.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index f9746f29f870..f0b703cf1aaf 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -600,8 +600,10 @@ static void kvm_destroy_vm(struct kvm *kvm)
 	list_del(&kvm->vm_list);
 	spin_unlock(&kvm_lock);
 	kvm_free_irq_routing(kvm);
-	for (i = 0; i < KVM_NR_BUSES; i++)
+	for (i = 0; i < KVM_NR_BUSES; i++) {
 		kvm_io_bus_destroy(kvm->buses[i]);
+		kvm->buses[i] = NULL;
+	}
 	kvm_coalesced_mmio_free(kvm);
 #if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER)
 	mmu_notifier_unregister(&kvm->mmu_notifier, kvm->mm);
@@ -3143,6 +3145,14 @@ int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
 	struct kvm_io_bus *new_bus, *bus;
 
 	bus = kvm->buses[bus_idx];
+
+	/*
+	 * It's possible the bus being released before hand. If so,
+	 * we're done here.
+	 */
+	if (!bus)
+		return 0;
+
 	r = -ENOENT;
 	for (i = 0; i < bus->dev_count; i++)
 		if (bus->range[i].dev == dev) {
-- 
2.11.0

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

* [added to the 4.1 stable tree] rtc: s35390a: fix reading out alarm
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (94 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] KVM: x86: clear bus pointer when destroyed Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] rtc: s35390a: implement reset routine as suggested by the reference Sasha Levin
                   ` (199 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Uwe Kleine-König, Alexandre Belloni, Sasha Levin

From: Uwe Kleine-König <uwe@kleine-koenig.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f87e904ddd8f0ef120e46045b0addeb1cc88354e ]

There are several issues fixed in this patch:

 - When alarm isn't enabled, set .enabled to zero instead of returning
   -EINVAL.
 - Ignore how IRQ1 is configured when determining if IRQ2 is on.
 - The three alarm registers have an enable flag which must be
   evaluated.
 - The chip always triggers when the seconds register gets 0.

Note that the rtc framework however doesn't handle the result correctly
because it doesn't check wday being initialized and so interprets an
alarm being set for 10:00 AM in three days as 10:00 AM tomorrow (or
today if that's not over yet).

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/rtc/rtc-s35390a.c | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
index f40afdd0e5f5..6507a01cf9ad 100644
--- a/drivers/rtc/rtc-s35390a.c
+++ b/drivers/rtc/rtc-s35390a.c
@@ -242,6 +242,8 @@ static int s35390a_set_alarm(struct i2c_client *client, struct rtc_wkalrm *alm)
 
 	if (alm->time.tm_wday != -1)
 		buf[S35390A_ALRM_BYTE_WDAY] = bin2bcd(alm->time.tm_wday) | 0x80;
+	else
+		buf[S35390A_ALRM_BYTE_WDAY] = 0;
 
 	buf[S35390A_ALRM_BYTE_HOURS] = s35390a_hr2reg(s35390a,
 			alm->time.tm_hour) | 0x80;
@@ -269,23 +271,43 @@ static int s35390a_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alm)
 	if (err < 0)
 		return err;
 
-	if (bitrev8(sts) != S35390A_INT2_MODE_ALARM)
-		return -EINVAL;
+	if ((bitrev8(sts) & S35390A_INT2_MODE_MASK) != S35390A_INT2_MODE_ALARM) {
+		/*
+		 * When the alarm isn't enabled, the register to configure
+		 * the alarm time isn't accessible.
+		 */
+		alm->enabled = 0;
+		return 0;
+	} else {
+		alm->enabled = 1;
+	}
 
 	err = s35390a_get_reg(s35390a, S35390A_CMD_INT2_REG1, buf, sizeof(buf));
 	if (err < 0)
 		return err;
 
 	/* This chip returns the bits of each byte in reverse order */
-	for (i = 0; i < 3; ++i) {
+	for (i = 0; i < 3; ++i)
 		buf[i] = bitrev8(buf[i]);
-		buf[i] &= ~0x80;
-	}
 
-	alm->time.tm_wday = bcd2bin(buf[S35390A_ALRM_BYTE_WDAY]);
-	alm->time.tm_hour = s35390a_reg2hr(s35390a,
-						buf[S35390A_ALRM_BYTE_HOURS]);
-	alm->time.tm_min = bcd2bin(buf[S35390A_ALRM_BYTE_MINS]);
+	/*
+	 * B0 of the three matching registers is an enable flag. Iff it is set
+	 * the configured value is used for matching.
+	 */
+	if (buf[S35390A_ALRM_BYTE_WDAY] & 0x80)
+		alm->time.tm_wday =
+			bcd2bin(buf[S35390A_ALRM_BYTE_WDAY] & ~0x80);
+
+	if (buf[S35390A_ALRM_BYTE_HOURS] & 0x80)
+		alm->time.tm_hour =
+			s35390a_reg2hr(s35390a,
+				       buf[S35390A_ALRM_BYTE_HOURS] & ~0x80);
+
+	if (buf[S35390A_ALRM_BYTE_MINS] & 0x80)
+		alm->time.tm_min = bcd2bin(buf[S35390A_ALRM_BYTE_MINS] & ~0x80);
+
+	/* alarm triggers always at s=0 */
+	alm->time.tm_sec = 0;
 
 	dev_dbg(&client->dev, "%s: alm is mins=%d, hours=%d, wday=%d\n",
 			__func__, alm->time.tm_min, alm->time.tm_hour,
-- 
2.11.0

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

* [added to the 4.1 stable tree] rtc: s35390a: implement reset routine as suggested by the reference
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (95 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] rtc: s35390a: fix reading out alarm Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] rtc: s35390a: improve irq handling Sasha Levin
                   ` (198 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Uwe Kleine-König, Alexandre Belloni, Sasha Levin

From: Uwe Kleine-König <uwe@kleine-koenig.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 8e6583f1b5d1f5f129b873f1428b7e414263d847 ]

There were two deviations from the reference manual: you have to wait
half a second when POC is active and you might have to repeat
initialization when POC or BLD are still set after the sequence.

Note however that as POC and BLD are cleared by read the driver might
not be able to detect that a reset is necessary. I don't have a good
idea how to fix this.

Additionally report the value read from STATUS1 to the caller. This
prepares the next patch.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/rtc/rtc-s35390a.c | 65 +++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 55 insertions(+), 10 deletions(-)

diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
index 6507a01cf9ad..6c90c9f48cab 100644
--- a/drivers/rtc/rtc-s35390a.c
+++ b/drivers/rtc/rtc-s35390a.c
@@ -15,6 +15,7 @@
 #include <linux/bitrev.h>
 #include <linux/bcd.h>
 #include <linux/slab.h>
+#include <linux/delay.h>
 
 #define S35390A_CMD_STATUS1	0
 #define S35390A_CMD_STATUS2	1
@@ -94,19 +95,63 @@ static int s35390a_get_reg(struct s35390a *s35390a, int reg, char *buf, int len)
 	return 0;
 }
 
-static int s35390a_reset(struct s35390a *s35390a)
+/*
+ * Returns <0 on error, 0 if rtc is setup fine and 1 if the chip was reset.
+ * To keep the information if an irq is pending, pass the value read from
+ * STATUS1 to the caller.
+ */
+static int s35390a_reset(struct s35390a *s35390a, char *status1)
 {
-	char buf[1];
+	char buf;
+	int ret;
+	unsigned initcount = 0;
 
-	if (s35390a_get_reg(s35390a, S35390A_CMD_STATUS1, buf, sizeof(buf)) < 0)
-		return -EIO;
+	ret = s35390a_get_reg(s35390a, S35390A_CMD_STATUS1, status1, 1);
+	if (ret < 0)
+		return ret;
 
-	if (!(buf[0] & (S35390A_FLAG_POC | S35390A_FLAG_BLD)))
+	if (*status1 & S35390A_FLAG_POC)
+		/*
+		 * Do not communicate for 0.5 seconds since the power-on
+		 * detection circuit is in operation.
+		 */
+		msleep(500);
+	else if (!(*status1 & S35390A_FLAG_BLD))
+		/*
+		 * If both POC and BLD are unset everything is fine.
+		 */
 		return 0;
 
-	buf[0] |= (S35390A_FLAG_RESET | S35390A_FLAG_24H);
-	buf[0] &= 0xf0;
-	return s35390a_set_reg(s35390a, S35390A_CMD_STATUS1, buf, sizeof(buf));
+	/*
+	 * At least one of POC and BLD are set, so reinitialise chip. Keeping
+	 * this information in the hardware to know later that the time isn't
+	 * valid is unfortunately not possible because POC and BLD are cleared
+	 * on read. So the reset is best done now.
+	 *
+	 * The 24H bit is kept over reset, so set it already here.
+	 */
+initialize:
+	*status1 = S35390A_FLAG_24H;
+	buf = S35390A_FLAG_RESET | S35390A_FLAG_24H;
+	ret = s35390a_set_reg(s35390a, S35390A_CMD_STATUS1, &buf, 1);
+
+	if (ret < 0)
+		return ret;
+
+	ret = s35390a_get_reg(s35390a, S35390A_CMD_STATUS1, &buf, 1);
+	if (ret < 0)
+		return ret;
+
+	if (buf & (S35390A_FLAG_POC | S35390A_FLAG_BLD)) {
+		/* Try up to five times to reset the chip */
+		if (initcount < 5) {
+			++initcount;
+			goto initialize;
+		} else
+			return -EIO;
+	}
+
+	return 1;
 }
 
 static int s35390a_disable_test_mode(struct s35390a *s35390a)
@@ -353,7 +398,7 @@ static int s35390a_probe(struct i2c_client *client,
 	unsigned int i;
 	struct s35390a *s35390a;
 	struct rtc_time tm;
-	char buf[1];
+	char buf[1], status1;
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
 		err = -ENODEV;
@@ -382,7 +427,7 @@ static int s35390a_probe(struct i2c_client *client,
 		}
 	}
 
-	err = s35390a_reset(s35390a);
+	err = s35390a_reset(s35390a, &status1);
 	if (err < 0) {
 		dev_err(&client->dev, "error resetting chip\n");
 		goto exit_dummy;
-- 
2.11.0

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

* [added to the 4.1 stable tree] rtc: s35390a: improve irq handling
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (96 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] rtc: s35390a: implement reset routine as suggested by the reference Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] KVM: kvm_io_bus_unregister_dev() should never fail Sasha Levin
                   ` (197 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Uwe Kleine-König, Alexandre Belloni, Sasha Levin

From: Uwe Kleine-König <uwe@kleine-koenig.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 3bd32722c827d00eafe8e6d5b83e9f3148ea7c7e ]

On some QNAP NAS devices the rtc can wake the machine. Several people
noticed that once the machine was woken this way it fails to shut down.
That's because the driver fails to acknowledge the interrupt and so it
keeps active and restarts the machine immediatly after shutdown. See
https://bugs.debian.org/794266 for a bug report.

Doing this correctly requires to interpret the INT2 flag of the first read
of the STATUS1 register because this bit is cleared by read.

Note this is not maximally robust though because a pending irq isn't
detected when the STATUS1 register was already read (and so INT2 is not
set) but the irq was not disabled. But that is a hardware imposed problem
that cannot easily be fixed by software.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/rtc/rtc-s35390a.c | 48 ++++++++++++++++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
index 6c90c9f48cab..d5b572266a72 100644
--- a/drivers/rtc/rtc-s35390a.c
+++ b/drivers/rtc/rtc-s35390a.c
@@ -35,10 +35,14 @@
 #define S35390A_ALRM_BYTE_HOURS	1
 #define S35390A_ALRM_BYTE_MINS	2
 
+/* flags for STATUS1 */
 #define S35390A_FLAG_POC	0x01
 #define S35390A_FLAG_BLD	0x02
+#define S35390A_FLAG_INT2	0x04
 #define S35390A_FLAG_24H	0x40
 #define S35390A_FLAG_RESET	0x80
+
+/* flag for STATUS2 */
 #define S35390A_FLAG_TEST	0x01
 
 #define S35390A_INT2_MODE_MASK		0xF0
@@ -394,11 +398,11 @@ static struct i2c_driver s35390a_driver;
 static int s35390a_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
-	int err;
+	int err, err_reset;
 	unsigned int i;
 	struct s35390a *s35390a;
 	struct rtc_time tm;
-	char buf[1], status1;
+	char buf, status1;
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
 		err = -ENODEV;
@@ -427,29 +431,35 @@ static int s35390a_probe(struct i2c_client *client,
 		}
 	}
 
-	err = s35390a_reset(s35390a, &status1);
-	if (err < 0) {
+	err_reset = s35390a_reset(s35390a, &status1);
+	if (err_reset < 0) {
+		err = err_reset;
 		dev_err(&client->dev, "error resetting chip\n");
 		goto exit_dummy;
 	}
 
-	err = s35390a_disable_test_mode(s35390a);
-	if (err < 0) {
-		dev_err(&client->dev, "error disabling test mode\n");
-		goto exit_dummy;
-	}
-
-	err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS1, buf, sizeof(buf));
-	if (err < 0) {
-		dev_err(&client->dev, "error checking 12/24 hour mode\n");
-		goto exit_dummy;
-	}
-	if (buf[0] & S35390A_FLAG_24H)
+	if (status1 & S35390A_FLAG_24H)
 		s35390a->twentyfourhour = 1;
 	else
 		s35390a->twentyfourhour = 0;
 
-	if (s35390a_get_datetime(client, &tm) < 0)
+	if (status1 & S35390A_FLAG_INT2) {
+		/* disable alarm (and maybe test mode) */
+		buf = 0;
+		err = s35390a_set_reg(s35390a, S35390A_CMD_STATUS2, &buf, 1);
+		if (err < 0) {
+			dev_err(&client->dev, "error disabling alarm");
+			goto exit_dummy;
+		}
+	} else {
+		err = s35390a_disable_test_mode(s35390a);
+		if (err < 0) {
+			dev_err(&client->dev, "error disabling test mode\n");
+			goto exit_dummy;
+		}
+	}
+
+	if (err_reset > 0 || s35390a_get_datetime(client, &tm) < 0)
 		dev_warn(&client->dev, "clock needs to be set\n");
 
 	device_set_wakeup_capable(&client->dev, 1);
@@ -462,6 +472,10 @@ static int s35390a_probe(struct i2c_client *client,
 		err = PTR_ERR(s35390a->rtc);
 		goto exit_dummy;
 	}
+
+	if (status1 & S35390A_FLAG_INT2)
+		rtc_update_irq(s35390a->rtc, 1, RTC_AF);
+
 	return 0;
 
 exit_dummy:
-- 
2.11.0

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

* [added to the 4.1 stable tree] padata: avoid race in reordering
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (98 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] KVM: kvm_io_bus_unregister_dev() should never fail Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] KEYS: fix dereferencing NULL payload with nonzero length Sasha Levin
                   ` (195 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jason A. Donenfeld, Herbert Xu, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit de5540d088fe97ad583cc7d396586437b32149a5 ]

Under extremely heavy uses of padata, crashes occur, and with list
debugging turned on, this happens instead:

[87487.298728] WARNING: CPU: 1 PID: 882 at lib/list_debug.c:33
__list_add+0xae/0x130
[87487.301868] list_add corruption. prev->next should be next
(ffffb17abfc043d0), but was ffff8dba70872c80. (prev=ffff8dba70872b00).
[87487.339011]  [<ffffffff9a53d075>] dump_stack+0x68/0xa3
[87487.342198]  [<ffffffff99e119a1>] ? console_unlock+0x281/0x6d0
[87487.345364]  [<ffffffff99d6b91f>] __warn+0xff/0x140
[87487.348513]  [<ffffffff99d6b9aa>] warn_slowpath_fmt+0x4a/0x50
[87487.351659]  [<ffffffff9a58b5de>] __list_add+0xae/0x130
[87487.354772]  [<ffffffff9add5094>] ? _raw_spin_lock+0x64/0x70
[87487.357915]  [<ffffffff99eefd66>] padata_reorder+0x1e6/0x420
[87487.361084]  [<ffffffff99ef0055>] padata_do_serial+0xa5/0x120

padata_reorder calls list_add_tail with the list to which its adding
locked, which seems correct:

spin_lock(&squeue->serial.lock);
list_add_tail(&padata->list, &squeue->serial.list);
spin_unlock(&squeue->serial.lock);

This therefore leaves only place where such inconsistency could occur:
if padata->list is added at the same time on two different threads.
This pdata pointer comes from the function call to
padata_get_next(pd), which has in it the following block:

next_queue = per_cpu_ptr(pd->pqueue, cpu);
padata = NULL;
reorder = &next_queue->reorder;
if (!list_empty(&reorder->list)) {
       padata = list_entry(reorder->list.next,
                           struct padata_priv, list);
       spin_lock(&reorder->lock);
       list_del_init(&padata->list);
       atomic_dec(&pd->reorder_objects);
       spin_unlock(&reorder->lock);

       pd->processed++;

       goto out;
}
out:
return padata;

I strongly suspect that the problem here is that two threads can race
on reorder list. Even though the deletion is locked, call to
list_entry is not locked, which means it's feasible that two threads
pick up the same padata object and subsequently call list_add_tail on
them at the same time. The fix is thus be hoist that lock outside of
that block.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 kernel/padata.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/padata.c b/kernel/padata.c
index ed6f4f93cc92..ecc7b3f452c7 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -189,19 +189,20 @@ static struct padata_priv *padata_get_next(struct parallel_data *pd)
 
 	reorder = &next_queue->reorder;
 
+	spin_lock(&reorder->lock);
 	if (!list_empty(&reorder->list)) {
 		padata = list_entry(reorder->list.next,
 				    struct padata_priv, list);
 
-		spin_lock(&reorder->lock);
 		list_del_init(&padata->list);
 		atomic_dec(&pd->reorder_objects);
-		spin_unlock(&reorder->lock);
 
 		pd->processed++;
 
+		spin_unlock(&reorder->lock);
 		goto out;
 	}
+	spin_unlock(&reorder->lock);
 
 	if (__this_cpu_read(pd->pqueue->cpu_index) == next_queue->cpu_index) {
 		padata = ERR_PTR(-ENODATA);
-- 
2.11.0

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

* [added to the 4.1 stable tree] KVM: kvm_io_bus_unregister_dev() should never fail
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (97 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] rtc: s35390a: improve irq handling Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] padata: avoid race in reordering Sasha Levin
                   ` (196 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David Hildenbrand, Paolo Bonzini, Sasha Levin

From: David Hildenbrand <david@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 90db10434b163e46da413d34db8d0e77404cc645 ]

No caller currently checks the return value of
kvm_io_bus_unregister_dev(). This is evil, as all callers silently go on
freeing their device. A stale reference will remain in the io_bus,
getting at least used again, when the iobus gets teared down on
kvm_destroy_vm() - leading to use after free errors.

There is nothing the callers could do, except retrying over and over
again.

So let's simply remove the bus altogether, print an error and make
sure no one can access this broken bus again (returning -ENOMEM on any
attempt to access it).

Fixes: e93f8a0f821e ("KVM: convert io_bus to SRCU")
Cc: stable@vger.kernel.org # 3.4+
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 include/linux/kvm_host.h |  4 ++--
 virt/kvm/eventfd.c       |  3 ++-
 virt/kvm/kvm_main.c      | 40 +++++++++++++++++++++++-----------------
 3 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 29a57a5b7cee..ef4945c3f713 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -173,8 +173,8 @@ int kvm_io_bus_read(struct kvm_vcpu *vcpu, enum kvm_bus bus_idx, gpa_t addr,
 		    int len, void *val);
 int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
 			    int len, struct kvm_io_device *dev);
-int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
-			      struct kvm_io_device *dev);
+void kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
+			       struct kvm_io_device *dev);
 
 #ifdef CONFIG_KVM_ASYNC_PF
 struct kvm_async_pf {
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 79db45336e3a..962bf7371cee 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -862,7 +862,8 @@ kvm_deassign_ioeventfd_idx(struct kvm *kvm, enum kvm_bus bus_idx,
 			continue;
 
 		kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev);
-		kvm->buses[bus_idx]->ioeventfd_count--;
+		if (kvm->buses[bus_idx])
+			kvm->buses[bus_idx]->ioeventfd_count--;
 		ioeventfd_release(p);
 		ret = 0;
 		break;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index f0b703cf1aaf..457719410ab4 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -601,7 +601,8 @@ static void kvm_destroy_vm(struct kvm *kvm)
 	spin_unlock(&kvm_lock);
 	kvm_free_irq_routing(kvm);
 	for (i = 0; i < KVM_NR_BUSES; i++) {
-		kvm_io_bus_destroy(kvm->buses[i]);
+		if (kvm->buses[i])
+			kvm_io_bus_destroy(kvm->buses[i]);
 		kvm->buses[i] = NULL;
 	}
 	kvm_coalesced_mmio_free(kvm);
@@ -3040,6 +3041,8 @@ int kvm_io_bus_write(struct kvm_vcpu *vcpu, enum kvm_bus bus_idx, gpa_t addr,
 	};
 
 	bus = srcu_dereference(vcpu->kvm->buses[bus_idx], &vcpu->kvm->srcu);
+	if (!bus)
+		return -ENOMEM;
 	r = __kvm_io_bus_write(vcpu, bus, &range, val);
 	return r < 0 ? r : 0;
 }
@@ -3057,6 +3060,8 @@ int kvm_io_bus_write_cookie(struct kvm_vcpu *vcpu, enum kvm_bus bus_idx,
 	};
 
 	bus = srcu_dereference(vcpu->kvm->buses[bus_idx], &vcpu->kvm->srcu);
+	if (!bus)
+		return -ENOMEM;
 
 	/* First try the device referenced by cookie. */
 	if ((cookie >= 0) && (cookie < bus->dev_count) &&
@@ -3107,6 +3112,8 @@ int kvm_io_bus_read(struct kvm_vcpu *vcpu, enum kvm_bus bus_idx, gpa_t addr,
 	};
 
 	bus = srcu_dereference(vcpu->kvm->buses[bus_idx], &vcpu->kvm->srcu);
+	if (!bus)
+		return -ENOMEM;
 	r = __kvm_io_bus_read(vcpu, bus, &range, val);
 	return r < 0 ? r : 0;
 }
@@ -3119,6 +3126,9 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
 	struct kvm_io_bus *new_bus, *bus;
 
 	bus = kvm->buses[bus_idx];
+	if (!bus)
+		return -ENOMEM;
+
 	/* exclude ioeventfd which is limited by maximum fd */
 	if (bus->dev_count - bus->ioeventfd_count > NR_IOBUS_DEVS - 1)
 		return -ENOSPC;
@@ -3138,45 +3148,41 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
 }
 
 /* Caller must hold slots_lock. */
-int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
-			      struct kvm_io_device *dev)
+void kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
+			       struct kvm_io_device *dev)
 {
-	int i, r;
+	int i;
 	struct kvm_io_bus *new_bus, *bus;
 
 	bus = kvm->buses[bus_idx];
-
-	/*
-	 * It's possible the bus being released before hand. If so,
-	 * we're done here.
-	 */
 	if (!bus)
-		return 0;
+		return;
 
-	r = -ENOENT;
 	for (i = 0; i < bus->dev_count; i++)
 		if (bus->range[i].dev == dev) {
-			r = 0;
 			break;
 		}
 
-	if (r)
-		return r;
+	if (i == bus->dev_count)
+		return;
 
 	new_bus = kzalloc(sizeof(*bus) + ((bus->dev_count - 1) *
 			  sizeof(struct kvm_io_range)), GFP_KERNEL);
-	if (!new_bus)
-		return -ENOMEM;
+	if (!new_bus)  {
+		pr_err("kvm: failed to shrink bus, removing it completely\n");
+		goto broken;
+	}
 
 	memcpy(new_bus, bus, sizeof(*bus) + i * sizeof(struct kvm_io_range));
 	new_bus->dev_count--;
 	memcpy(new_bus->range + i, bus->range + i + 1,
 	       (new_bus->dev_count - i) * sizeof(struct kvm_io_range));
 
+broken:
 	rcu_assign_pointer(kvm->buses[bus_idx], new_bus);
 	synchronize_srcu_expedited(&kvm->srcu);
 	kfree(bus);
-	return r;
+	return;
 }
 
 static struct notifier_block kvm_cpu_notifier = {
-- 
2.11.0

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

* [added to the 4.1 stable tree] KEYS: fix dereferencing NULL payload with nonzero length
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (99 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] padata: avoid race in reordering Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] 8250_pci: Fix potential use-after-free in error path Sasha Levin
                   ` (194 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Eric Biggers, David Howells, James Morris, Sasha Levin

From: Eric Biggers <ebiggers@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 5649645d725c73df4302428ee4e02c869248b4c5 ]

sys_add_key() and the KEYCTL_UPDATE operation of sys_keyctl() allowed a
NULL payload with nonzero length to be passed to the key type's
->preparse(), ->instantiate(), and/or ->update() methods.  Various key
types including asymmetric, cifs.idmap, cifs.spnego, and pkcs7_test did
not handle this case, allowing an unprivileged user to trivially cause a
NULL pointer dereference (kernel oops) if one of these key types was
present.  Fix it by doing the copy_from_user() when 'plen' is nonzero
rather than when '_payload' is non-NULL, causing the syscall to fail
with EFAULT as expected when an invalid buffer is specified.

Cc: stable@vger.kernel.org # 2.6.10+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 security/keys/keyctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index a2d29cca16c6..c804189d0d03 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -99,7 +99,7 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type,
 	payload = NULL;
 
 	vm = false;
-	if (_payload) {
+	if (plen) {
 		ret = -ENOMEM;
 		payload = kmalloc(plen, GFP_KERNEL | __GFP_NOWARN);
 		if (!payload) {
@@ -333,7 +333,7 @@ long keyctl_update_key(key_serial_t id,
 
 	/* pull the payload in if one was supplied */
 	payload = NULL;
-	if (_payload) {
+	if (plen) {
 		ret = -ENOMEM;
 		payload = kmalloc(plen, GFP_KERNEL);
 		if (!payload)
-- 
2.11.0

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

* [added to the 4.1 stable tree] 8250_pci: Fix potential use-after-free in error path
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (100 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] KEYS: fix dereferencing NULL payload with nonzero length Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] arm64: hw_breakpoint: fix watchpoint matching for tagged pointers Sasha Levin
                   ` (193 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Gabriel Krisman Bertazi, Guilherme G . Piccoli,
	Greg Kroah-Hartman, Sasha Levin

From: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit c130b666a9a711f985a0a44b58699ebe14bb7245 ]

Commit f209fa03fc9d ("serial: 8250_pci: Detach low-level driver during
PCI error recovery") introduces a potential use-after-free in case the
pciserial_init_ports call in serial8250_io_resume fails, which may
happen if a memory allocation fails or if the .init quirk failed for
whatever reason).  If this happen, further pci_get_drvdata will return a
pointer to freed memory.

This patch reworks the PCI recovery resume hook to restore the old priv
structure in this case, which should be ok, since the ports were already
detached. Such error during recovery causes us to give up on the
recovery.

Fixes: f209fa03fc9d ("serial: 8250_pci: Detach low-level driver during
  PCI error recovery")
Reported-by: Michal Suchanek <msuchanek@suse.com>
Signed-off-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/tty/serial/8250/8250_pci.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index bfd5e2afaeaf..933961968ec9 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -5967,17 +5967,15 @@ static pci_ers_result_t serial8250_io_slot_reset(struct pci_dev *dev)
 static void serial8250_io_resume(struct pci_dev *dev)
 {
 	struct serial_private *priv = pci_get_drvdata(dev);
-	const struct pciserial_board *board;
+	struct serial_private *new;
 
 	if (!priv)
 		return;
 
-	board = priv->board;
-	kfree(priv);
-	priv = pciserial_init_ports(dev, board);
-
-	if (!IS_ERR(priv)) {
-		pci_set_drvdata(dev, priv);
+	new = pciserial_init_ports(dev, priv->board);
+	if (!IS_ERR(new)) {
+		pci_set_drvdata(dev, new);
+		kfree(priv);
 	}
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] arm64: hw_breakpoint: fix watchpoint matching for tagged pointers
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (101 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] 8250_pci: Fix potential use-after-free in error path Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] net: phy: fix marvell phy status reading Sasha Levin
                   ` (192 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Kristina Martsenko, Catalin Marinas, Sasha Levin

From: Kristina Martsenko <kristina.martsenko@arm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 7dcd9dd8cebe9fa626af7e2358d03a37041a70fb ]

When we take a watchpoint exception, the address that triggered the
watchpoint is found in FAR_EL1. We compare it to the address of each
configured watchpoint to see which one was hit.

The configured watchpoint addresses are untagged, while the address in
FAR_EL1 will have an address tag if the data access was done using a
tagged address. The tag needs to be removed to compare the address to
the watchpoints.

Currently we don't remove it, and as a result can report the wrong
watchpoint as being hit (specifically, always either the highest TTBR0
watchpoint or lowest TTBR1 watchpoint). This patch removes the tag.

Fixes: d50240a5f6ce ("arm64: mm: permit use of tagged pointers at EL0")
Cc: <stable@vger.kernel.org> # 3.12.x-
Acked-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/arm64/include/asm/uaccess.h  | 8 ++++++++
 arch/arm64/kernel/hw_breakpoint.c | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index 4849baa914d8..8f65f969f51c 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -21,6 +21,7 @@
 /*
  * User space memory access functions
  */
+#include <linux/bitops.h>
 #include <linux/string.h>
 #include <linux/thread_info.h>
 
@@ -100,6 +101,13 @@ static inline void set_fs(mm_segment_t fs)
 	flag;								\
 })
 
+/*
+ * When dealing with data aborts, watchpoints, or instruction traps we may end
+ * up with a tagged userland pointer. Clear the tag to get a sane pointer to
+ * pass on to access_ok(), for instance.
+ */
+#define untagged_addr(addr)		sign_extend64(addr, 55)
+
 #define access_ok(type, addr, size)	__range_ok(addr, size)
 #define user_addr_max			get_fs
 
diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
index e7d934d3afe0..30f92321c00f 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -35,6 +35,7 @@
 #include <asm/traps.h>
 #include <asm/cputype.h>
 #include <asm/system_misc.h>
+#include <asm/uaccess.h>
 
 /* Breakpoint currently in use for each BRP. */
 static DEFINE_PER_CPU(struct perf_event *, bp_on_reg[ARM_MAX_BRP]);
@@ -688,7 +689,7 @@ static int watchpoint_handler(unsigned long addr, unsigned int esr,
 
 		/* Check if the watchpoint value matches. */
 		val = read_wb_reg(AARCH64_DBG_REG_WVR, i);
-		if (val != (addr & ~alignment_mask))
+		if (val != (untagged_addr(addr) & ~alignment_mask))
 			goto unlock;
 
 		/* Possible match, check the byte address select to confirm. */
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: phy: fix marvell phy status reading
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (102 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] arm64: hw_breakpoint: fix watchpoint matching for tagged pointers Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ipv6: avoid unregistering inet6_dev for loopback Sasha Levin
                   ` (191 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Russell King, David S . Miller, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 898805e0cdf7fd860ec21bf661d3a0285a3defbd ]

The Marvell driver incorrectly provides phydev->lp_advertising as the
logical and of the link partner's advert and our advert.  This is
incorrect - this field is supposed to store the link parter's unmodified
advertisment.

This allows ethtool to report the correct link partner auto-negotiation
status.

Fixes: be937f1f89ca ("Marvell PHY m88e1111 driver fix")
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/phy/marvell.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 1b1698f98818..9c582da5a08e 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -763,8 +763,6 @@ static int marvell_read_status(struct phy_device *phydev)
 		if (adv < 0)
 			return adv;
 
-		lpa &= adv;
-
 		if (status & MII_M1011_PHY_STATUS_FULLDUPLEX)
 			phydev->duplex = DUPLEX_FULL;
 		else
-- 
2.11.0

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

* [added to the 4.1 stable tree] ipv6: avoid unregistering inet6_dev for loopback
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (103 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] net: phy: fix marvell phy status reading Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] tcp: reset sk_rx_dst in tcp_disconnect() Sasha Levin
                   ` (190 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: WANG Cong, David S . Miller, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 60abc0be96e00ca71bac083215ac91ad2e575096 ]

The per netns loopback_dev->ip6_ptr is unregistered and set to
NULL when its mtu is set to smaller than IPV6_MIN_MTU, this
leads to that we could set rt->rt6i_idev NULL after a
rt6_uncached_list_flush_dev() and then crash after another
call.

In this case we should just bring its inet6_dev down, rather
than unregistering it, at least prior to commit 176c39af29bc
("netns: fix addrconf_ifdown kernel panic") we always
override the case for loopback.

Thanks a lot to Andrey for finding a reliable reproducer.

Fixes: 176c39af29bc ("netns: fix addrconf_ifdown kernel panic")
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Daniel Lezcano <dlezcano@fr.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: David Ahern <dsahern@gmail.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv6/addrconf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index df4edab0ba3a..8441f9939d49 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3068,6 +3068,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
 {
 	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
 	struct inet6_dev *idev = __in6_dev_get(dev);
+	struct net *net = dev_net(dev);
 	int run_pending = 0;
 	int err;
 
@@ -3170,7 +3171,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
 			 * IPV6_MIN_MTU stop IPv6 on this interface.
 			 */
 			if (dev->mtu < IPV6_MIN_MTU)
-				addrconf_ifdown(dev, 1);
+				addrconf_ifdown(dev, dev != net->loopback_dev);
 		}
 		break;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] tcp: reset sk_rx_dst in tcp_disconnect()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (104 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ipv6: avoid unregistering inet6_dev for loopback Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] bcache: do not subtract sectors_to_gc for bypassed IO Sasha Levin
                   ` (189 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: WANG Cong, David S . Miller, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit d747a7a51b00984127a88113cdbbc26f91e9d815 ]

We have to reset the sk->sk_rx_dst when we disconnect a TCP
connection, because otherwise when we re-connect it this
dst reference is simply overridden in tcp_finish_connect().

This fixes a dst leak which leads to a loopback dev refcnt
leak. It is a long-standing bug, Kevin reported a very similar
(if not same) bug before. Thanks to Andrei for providing such
a reliable reproducer which greatly narrows down the problem.

Fixes: 41063e9dd119 ("ipv4: Early TCP socket demux.")
Reported-by: Andrei Vagin <avagin@gmail.com>
Reported-by: Kevin Xu <kaiwen.xu@hulu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv4/tcp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 1ba4d0964042..a1de8300cfce 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2227,6 +2227,8 @@ int tcp_disconnect(struct sock *sk, int flags)
 	tcp_init_send_head(sk);
 	memset(&tp->rx_opt, 0, sizeof(tp->rx_opt));
 	__sk_dst_reset(sk);
+	dst_release(sk->sk_rx_dst);
+	sk->sk_rx_dst = NULL;
 
 	WARN_ON(inet->inet_num && !icsk->icsk_bind_hash);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] bcache: do not subtract sectors_to_gc for bypassed IO
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (105 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] tcp: reset sk_rx_dst in tcp_disconnect() Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] bcache: only permit to recovery read error when cache device is clean Sasha Levin
                   ` (188 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Tang Junhui, Jens Axboe, Sasha Levin

From: Tang Junhui <tang.junhui@zte.com.cn>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 69daf03adef5f7bc13e0ac86b4b8007df1767aab ]

Since bypassed IOs use no bucket, so do not subtract sectors_to_gc to
trigger gc thread.

Signed-off-by: tang.junhui <tang.junhui@zte.com.cn>
Acked-by: Coly Li <colyli@suse.de>
Reviewed-by: Eric Wheeler <bcache@linux.ewheeler.net>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: stable@vger.kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/md/bcache/request.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index a9864ef73ec6..5be152b5bb59 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -193,12 +193,12 @@ static void bch_data_insert_start(struct closure *cl)
 	struct data_insert_op *op = container_of(cl, struct data_insert_op, cl);
 	struct bio *bio = op->bio, *n;
 
-	if (atomic_sub_return(bio_sectors(bio), &op->c->sectors_to_gc) < 0)
-		wake_up_gc(op->c);
-
 	if (op->bypass)
 		return bch_data_invalidate(cl);
 
+	if (atomic_sub_return(bio_sectors(bio), &op->c->sectors_to_gc) < 0)
+		wake_up_gc(op->c);
+
 	/*
 	 * Journal writes are marked REQ_FLUSH; if the original write was a
 	 * flush, it'll wait on the journal write.
-- 
2.11.0

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

* [added to the 4.1 stable tree] bcache: only permit to recovery read error when cache device is clean
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (106 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] bcache: do not subtract sectors_to_gc for bypassed IO Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] bcache: recover data from backing when data " Sasha Levin
                   ` (187 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Coly Li, Michael Lyle, Jens Axboe, Sasha Levin

From: Coly Li <colyli@suse.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit d59b23795933678c9638fd20c942d2b4f3cd6185 ]

When bcache does read I/Os, for example in writeback or writethrough mode,
if a read request on cache device is failed, bcache will try to recovery
the request by reading from cached device. If the data on cached device is
not synced with cache device, then requester will get a stale data.

For critical storage system like database, providing stale data from
recovery may result an application level data corruption, which is
unacceptible.

With this patch, for a failed read request in writeback or writethrough
mode, recovery a recoverable read request only happens when cache device
is clean. That is to say, all data on cached device is up to update.

For other cache modes in bcache, read request will never hit
cached_dev_read_error(), they don't need this patch.

Please note, because cache mode can be switched arbitrarily in run time, a
writethrough mode might be switched from a writeback mode. Therefore
checking dc->has_data in writethrough mode still makes sense.

Changelog:
V4: Fix parens error pointed by Michael Lyle.
v3: By response from Kent Oversteet, he thinks recovering stale data is a
    bug to fix, and option to permit it is unnecessary. So this version
    the sysfs file is removed.
v2: rename sysfs entry from allow_stale_data_on_failure  to
    allow_stale_data_on_failure, and fix the confusing commit log.
v1: initial patch posted.

[small change to patch comment spelling by mlyle]

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Michael Lyle <mlyle@lyle.org>
Reported-by: Arne Wolf <awolf@lenovo.com>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Cc: Kent Overstreet <kent.overstreet@gmail.com>
Cc: Nix <nix@esperi.org.uk>
Cc: Kai Krakow <hurikhan77@gmail.com>
Cc: Eric Wheeler <bcache@lists.ewheeler.net>
Cc: Junhui Tang <tang.junhui@zte.com.cn>
Cc: stable@vger.kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/md/bcache/request.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index 5be152b5bb59..5c30410c4487 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -698,8 +698,16 @@ static void cached_dev_read_error(struct closure *cl)
 {
 	struct search *s = container_of(cl, struct search, cl);
 	struct bio *bio = &s->bio.bio;
+	struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);
 
-	if (s->recoverable) {
+	/*
+	 * If cache device is dirty (dc->has_dirty is non-zero), then
+	 * recovery a failed read request from cached device may get a
+	 * stale data back. So read failure recovery is only permitted
+	 * when cache device is clean.
+	 */
+	if (s->recoverable &&
+	    (dc && !atomic_read(&dc->has_dirty))) {
 		/* Retry from the backing device: */
 		trace_bcache_read_retry(s->orig_bio);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] bcache: recover data from backing when data is clean
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (107 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] bcache: only permit to recovery read error when cache device is clean Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: quirks: Add no-lpm quirk for KY-688 USB 3.1 Type-C Hub Sasha Levin
                   ` (186 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Rui Hua, Michael Lyle, Jens Axboe, Sasha Levin

From: Rui Hua <huarui.dev@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e393aa2446150536929140739f09c6ecbcbea7f0 ]

When we send a read request and hit the clean data in cache device, there
is a situation called cache read race in bcache(see the commit in the tail
of cache_look_up(), the following explaination just copy from there):
The bucket we're reading from might be reused while our bio is in flight,
and we could then end up reading the wrong data. We guard against this
by checking (in bch_cache_read_endio()) if the pointer is stale again;
if so, we treat it as an error (s->iop.error = -EINTR) and reread from
the backing device (but we don't pass that error up anywhere)

It should be noted that cache read race happened under normal
circumstances, not the circumstance when SSD failed, it was counted
and shown in  /sys/fs/bcache/XXX/internal/cache_read_races.

Without this patch, when we use writeback mode, we will never reread from
the backing device when cache read race happened, until the whole cache
device is clean, because the condition
(s->recoverable && (dc && !atomic_read(&dc->has_dirty))) is false in
cached_dev_read_error(). In this situation, the s->iop.error(= -EINTR)
will be passed up, at last, user will receive -EINTR when it's bio end,
this is not suitable, and wield to up-application.

In this patch, we use s->read_dirty_data to judge whether the read
request hit dirty data in cache device, it is safe to reread data from
the backing device when the read request hit clean data. This can not
only handle cache read race, but also recover data when failed read
request from cache device.

[edited by mlyle to fix up whitespace, commit log title, comment
spelling]

Fixes: d59b23795933 ("bcache: only permit to recovery read error when cache device is clean")
Cc: <stable@vger.kernel.org> # 4.14
Signed-off-by: Hua Rui <huarui.dev@gmail.com>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Reviewed-by: Coly Li <colyli@suse.de>
Signed-off-by: Michael Lyle <mlyle@lyle.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/md/bcache/request.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index 5c30410c4487..3a86f23ee72e 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -698,16 +698,15 @@ static void cached_dev_read_error(struct closure *cl)
 {
 	struct search *s = container_of(cl, struct search, cl);
 	struct bio *bio = &s->bio.bio;
-	struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);
 
 	/*
-	 * If cache device is dirty (dc->has_dirty is non-zero), then
-	 * recovery a failed read request from cached device may get a
-	 * stale data back. So read failure recovery is only permitted
-	 * when cache device is clean.
+	 * If read request hit dirty data (s->read_dirty_data is true),
+	 * then recovery a failed read request from cached device may
+	 * get a stale data back. So read failure recovery is only
+	 * permitted when read request hit clean data in cache device,
+	 * or when cache read race happened.
 	 */
-	if (s->recoverable &&
-	    (dc && !atomic_read(&dc->has_dirty))) {
+	if (s->recoverable && !s->read_dirty_data) {
 		/* Retry from the backing device: */
 		trace_bcache_read_retry(s->orig_bio);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] uas: Always apply US_FL_NO_ATA_1X quirk to Seagate devices
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (109 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: quirks: Add no-lpm quirk for KY-688 USB 3.1 Type-C Hub Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] serial: 8250_pci: Add Amazon PCI serial device ID Sasha Levin
                   ` (184 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Hans de Goede, Greg Kroah-Hartman, Sasha Levin

From: Hans de Goede <hdegoede@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 7fee72d5e8f1e7b8d8212e28291b1a0243ecf2f1 ]

We've been adding this as a quirk on a per device basis hoping that
newer disk enclosures would do better, but that has not happened,
so simply apply this quirk to all Seagate devices.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/storage/uas-detect.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/storage/uas-detect.h b/drivers/usb/storage/uas-detect.h
index a155cd02bce2..ecc83c405a8b 100644
--- a/drivers/usb/storage/uas-detect.h
+++ b/drivers/usb/storage/uas-detect.h
@@ -111,6 +111,10 @@ static int uas_use_uas_driver(struct usb_interface *intf,
 		}
 	}
 
+	/* All Seagate disk enclosures have broken ATA pass-through support */
+	if (le16_to_cpu(udev->descriptor.idVendor) == 0x0bc2)
+		flags |= US_FL_NO_ATA_1X;
+
 	usb_stor_adjust_quirks(udev, &flags);
 
 	if (flags & US_FL_IGNORE_UAS) {
-- 
2.11.0

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

* [added to the 4.1 stable tree] usb: quirks: Add no-lpm quirk for KY-688 USB 3.1 Type-C Hub
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (108 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] bcache: recover data from backing when data " Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] uas: Always apply US_FL_NO_ATA_1X quirk to Seagate devices Sasha Levin
                   ` (185 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Kai-Heng Feng, Greg Kroah-Hartman, Sasha Levin

From: Kai-Heng Feng <kai.heng.feng@canonical.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e43a12f1793ae1fe006e26fe9327a8840a92233c ]

KY-688 USB 3.1 Type-C Hub internally uses a Genesys Logic hub to connect
to Realtek r8153.

Similar to commit ("7496cfe5431f2 usb: quirks: Add no-lpm quirk for Moshi
USB to Ethernet Adapter"), no-lpm can make r8153 ethernet work.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/core/quirks.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 37c418e581fb..50010282c010 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -151,6 +151,9 @@ static const struct usb_device_id usb_quirk_list[] = {
 	/* appletouch */
 	{ USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
 
+	/* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */
+	{ USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM },
+
 	/* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */
 	{ USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] serial: 8250_pci: Add Amazon PCI serial device ID
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (110 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] uas: Always apply US_FL_NO_ATA_1X quirk to Seagate devices Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] s390/pci: do not require AIS facility Sasha Levin
                   ` (183 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Matt Wilson, Greg Kroah-Hartman, Sasha Levin

From: Matt Wilson <msw@amazon.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 3bfd1300abfe3adb18e84a89d97a0e82a22124bb ]

This device will be used in future Amazon EC2 instances as the primary
serial port (i.e., data sent to this port will be available via the
GetConsoleOuput [1] EC2 API).

[1] http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_GetConsoleOutput.html

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Matt Wilson <msw@amazon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/tty/serial/8250/8250_pci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 933961968ec9..0a1e9f4d9882 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -5914,6 +5914,9 @@ static struct pci_device_id serial_pci_tbl[] = {
 	{ PCI_DEVICE(0x1601, 0x0800), .driver_data = pbn_b0_4_1250000 },
 	{ PCI_DEVICE(0x1601, 0xa801), .driver_data = pbn_b0_4_1250000 },
 
+	/* Amazon PCI serial device */
+	{ PCI_DEVICE(0x1d0f, 0x8250), .driver_data = pbn_b0_1_115200 },
+
 	/*
 	 * These entries match devices with class COMMUNICATION_SERIAL,
 	 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL
-- 
2.11.0

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

* [added to the 4.1 stable tree] ima: fix hash algorithm initialization
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (112 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] s390/pci: do not require AIS facility Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] spi: sh-msiof: Fix DMA transfer size check Sasha Levin
                   ` (181 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Boshi Wang, Mimi Zohar, Sasha Levin

From: Boshi Wang <wangboshi@huawei.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit ebe7c0a7be92bbd34c6ff5b55810546a0ee05bee ]

The hash_setup function always sets the hash_setup_done flag, even
when the hash algorithm is invalid.  This prevents the default hash
algorithm defined as CONFIG_IMA_DEFAULT_HASH from being used.

This patch sets hash_setup_done flag only for valid hash algorithms.

Fixes: e7a2ad7eb6f4 "ima: enable support for larger default filedata hash
	algorithms"
Signed-off-by: Boshi Wang <wangboshi@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>

Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 security/integrity/ima/ima_main.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index eeee00dce729..cf837338a85e 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -52,6 +52,8 @@ static int __init hash_setup(char *str)
 			ima_hash_algo = HASH_ALGO_SHA1;
 		else if (strncmp(str, "md5", 3) == 0)
 			ima_hash_algo = HASH_ALGO_MD5;
+		else
+			return 1;
 		goto out;
 	}
 
@@ -61,6 +63,8 @@ static int __init hash_setup(char *str)
 			break;
 		}
 	}
+	if (i == HASH_ALGO__LAST)
+		return 1;
 out:
 	hash_setup_done = 1;
 	return 1;
-- 
2.11.0

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

* [added to the 4.1 stable tree] s390/pci: do not require AIS facility
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (111 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] serial: 8250_pci: Add Amazon PCI serial device ID Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ima: fix hash algorithm initialization Sasha Levin
                   ` (182 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Christian Borntraeger, Heiko Carstens, Sasha Levin

From: Christian Borntraeger <borntraeger@de.ibm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 48070c73058be6de9c0d754d441ed7092dfc8f12 ]

As of today QEMU does not provide the AIS facility to its guest.  This
prevents Linux guests from using PCI devices as the ais facility is
checked during init. As this is just a performance optimization, we can
move the ais check into the code where we need it (calling the SIC
instruction). This is used at initialization and on interrupt. Both
places do not require any serialization, so we can simply skip the
instruction.

Since we will now get all interrupts, we can also avoid the 2nd scan.
As we can have multiple interrupts in parallel we might trigger spurious
irqs more often for the non-AIS case but the core code can handle that.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
Acked-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/s390/include/asm/pci_insn.h | 2 +-
 arch/s390/pci/pci.c              | 5 +++--
 arch/s390/pci/pci_insn.c         | 6 +++++-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/s390/include/asm/pci_insn.h b/arch/s390/include/asm/pci_insn.h
index 649eb62c52b3..9e02cb7955c1 100644
--- a/arch/s390/include/asm/pci_insn.h
+++ b/arch/s390/include/asm/pci_insn.h
@@ -81,6 +81,6 @@ int zpci_refresh_trans(u64 fn, u64 addr, u64 range);
 int zpci_load(u64 *data, u64 req, u64 offset);
 int zpci_store(u64 data, u64 req, u64 offset);
 int zpci_store_block(const u64 *data, u64 req, u64 offset);
-void zpci_set_irq_ctrl(u16 ctl, char *unused, u8 isc);
+int zpci_set_irq_ctrl(u16 ctl, char *unused, u8 isc);
 
 #endif
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 50a79a5fc116..666baac18ff0 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -364,7 +364,8 @@ static void zpci_irq_handler(struct airq_struct *airq)
 				/* End of second scan with interrupts on. */
 				break;
 			/* First scan complete, reenable interrupts. */
-			zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC);
+			if (zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC))
+				break;
 			si = 0;
 			continue;
 		}
@@ -922,7 +923,7 @@ static int __init pci_base_init(void)
 	if (!s390_pci_probe)
 		return 0;
 
-	if (!test_facility(69) || !test_facility(71) || !test_facility(72))
+	if (!test_facility(69) || !test_facility(71))
 		return 0;
 
 	rc = zpci_debug_init();
diff --git a/arch/s390/pci/pci_insn.c b/arch/s390/pci/pci_insn.c
index 85267c058af8..abccf44c1e65 100644
--- a/arch/s390/pci/pci_insn.c
+++ b/arch/s390/pci/pci_insn.c
@@ -7,6 +7,7 @@
 #include <linux/export.h>
 #include <linux/errno.h>
 #include <linux/delay.h>
+#include <asm/facility.h>
 #include <asm/pci_insn.h>
 #include <asm/processor.h>
 
@@ -78,11 +79,14 @@ int zpci_refresh_trans(u64 fn, u64 addr, u64 range)
 }
 
 /* Set Interruption Controls */
-void zpci_set_irq_ctrl(u16 ctl, char *unused, u8 isc)
+int zpci_set_irq_ctrl(u16 ctl, char *unused, u8 isc)
 {
+	if (!test_facility(72))
+		return -EIO;
 	asm volatile (
 		"	.insn	rsy,0xeb00000000d1,%[ctl],%[isc],%[u]\n"
 		: : [ctl] "d" (ctl), [isc] "d" (isc << 27), [u] "Q" (*unused));
+	return 0;
 }
 
 /* PCI Load */
-- 
2.11.0

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

* [added to the 4.1 stable tree] serial: 8250_fintek: Fix rs485 disablement on invalid ioctl()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (114 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] spi: sh-msiof: Fix DMA transfer size check Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] EDAC, sb_edac: Fix missing break in switch Sasha Levin
                   ` (179 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Lukas Wunner, Greg Kroah-Hartman, Sasha Levin

From: Lukas Wunner <lukas@wunner.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 3236a965486ba0c6043cf2c7b51943d8b382ae29 ]

This driver's ->rs485_config callback checks if SER_RS485_RTS_ON_SEND
and SER_RS485_RTS_AFTER_SEND have the same value.  If they do, it means
the user has passed in invalid data with the TIOCSRS485 ioctl()
since RTS must have a different polarity when sending and when not
sending.  In this case, rs485 mode is not enabled (the RS485_URA bit
is not set in the RS485 Enable Register) and this is supposed to be
signaled back to the user by clearing the SER_RS485_ENABLED bit in
struct serial_rs485 ... except a missing tilde character is preventing
that from happening.

Fixes: 28e3fb6c4dce ("serial: Add support for Fintek F81216A LPC to 4 UART")
Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Cc: "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/tty/serial/8250/8250_fintek.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c
index 5815e81b5fc6..a8a6fe6fc924 100644
--- a/drivers/tty/serial/8250/8250_fintek.c
+++ b/drivers/tty/serial/8250/8250_fintek.c
@@ -118,7 +118,7 @@ static int fintek_8250_rs485_config(struct uart_port *port,
 
 	if ((!!(rs485->flags & SER_RS485_RTS_ON_SEND)) ==
 			(!!(rs485->flags & SER_RS485_RTS_AFTER_SEND)))
-		rs485->flags &= SER_RS485_ENABLED;
+		rs485->flags &= ~SER_RS485_ENABLED;
 	else
 		config |= RS485_URA;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] spi: sh-msiof: Fix DMA transfer size check
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (113 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ima: fix hash algorithm initialization Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] serial: 8250_fintek: Fix rs485 disablement on invalid ioctl() Sasha Levin
                   ` (180 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Hiromitsu Yamasaki, Simon Horman, Mark Brown, Sasha Levin

From: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 36735783fdb599c94b9c86824583df367c65900b ]

DMA supports 32-bit words only,
even if BITLEN1 of SITMDR2 register is 16bit.

Fixes: b0d0ce8b6b91 ("spi: sh-msiof: Add DMA support")
Signed-off-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/spi/spi-sh-msiof.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 7872f3c78b51..dc0ffd3dd96a 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -860,7 +860,7 @@ static int sh_msiof_transfer_one(struct spi_master *master,
 				break;
 			copy32 = copy_bswap32;
 		} else if (bits <= 16) {
-			if (l & 1)
+			if (l & 3)
 				break;
 			copy32 = copy_wswap32;
 		} else {
-- 
2.11.0

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

* [added to the 4.1 stable tree] EDAC, sb_edac: Fix missing break in switch
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (115 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] serial: 8250_fintek: Fix rs485 disablement on invalid ioctl() Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] sysrq : fix Show Regs call trace on ARM Sasha Levin
                   ` (178 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Gustavo A. R. Silva, Borislav Petkov, Sasha Levin

From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit a8e9b186f153a44690ad0363a56716e7077ad28c ]

Add missing break statement in order to prevent the code from falling
through.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Cc: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/20171016174029.GA19757@embeddedor.com
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/edac/sb_edac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index cb46c468b01e..25e51151b957 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -1700,6 +1700,7 @@ static int ibridge_mci_bind_devs(struct mem_ctl_info *mci,
 			break;
 		case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_TA:
 			pvt->pci_ta = pdev;
+			break;
 		case PCI_DEVICE_ID_INTEL_IBRIDGE_IMC_HA0_RAS:
 			pvt->pci_ras = pdev;
 			break;
-- 
2.11.0

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

* [added to the 4.1 stable tree] perf test attr: Fix ignored test case result
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (117 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] sysrq : fix Show Regs call trace on ARM Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] net: systemport: Utilize skb_put_padto() Sasha Levin
                   ` (176 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Thomas Richter, Arnaldo Carvalho de Melo, Sasha Levin

From: Thomas Richter <tmricht@linux.vnet.ibm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 22905582f6dd4bbd0c370fe5732c607452010c04 ]

Command perf test -v 16 (Setup struct perf_event_attr test) always
reports success even if the test case fails.  It works correctly if you
also specify -F (for don't fork).

   root@s35lp76 perf]# ./perf test -v 16
   15: Setup struct perf_event_attr               :
   --- start ---
   running './tests/attr/test-record-no-delay'
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.002 MB /tmp/tmp4E1h7R/perf.data
     (1 samples) ]
   expected task=0, got 1
   expected precise_ip=0, got 3
   expected wakeup_events=1, got 0
   FAILED './tests/attr/test-record-no-delay' - match failure
   test child finished with 0
   ---- end ----
   Setup struct perf_event_attr: Ok

The reason for the wrong error reporting is the return value of the
system() library call. It is called in run_dir() file tests/attr.c and
returns the exit status, in above case 0xff00.

This value is given as parameter to the exit() function which can only
handle values 0-0xff.

The child process terminates with exit value of 0 and the parent does
not detect any error.

This patch corrects the error reporting and prints the correct test
result.

Signed-off-by: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
LPU-Reference: 20170913081209.39570-2-tmricht@linux.vnet.ibm.com
Link: http://lkml.kernel.org/n/tip-rdube6rfcjsr1nzue72c7lqn@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 tools/perf/tests/attr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index 2dfc9ad0e6f2..8e92b56c610a 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -150,7 +150,7 @@ static int run_dir(const char *d, const char *perf)
 	snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
 		 d, d, perf, vcnt, v);
 
-	return system(cmd);
+	return system(cmd) ? TEST_FAIL : TEST_OK;
 }
 
 int test__attr(void)
-- 
2.11.0

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

* [added to the 4.1 stable tree] sysrq : fix Show Regs call trace on ARM
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (116 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] EDAC, sb_edac: Fix missing break in switch Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] perf test attr: Fix ignored test case result Sasha Levin
                   ` (177 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jibin Xu, Greg Kroah-Hartman, Sasha Levin

From: Jibin Xu <jibin.xu@windriver.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit b00bebbc301c8e1f74f230dc82282e56b7e7a6db ]

When kernel configuration SMP,PREEMPT and DEBUG_PREEMPT are enabled,
echo 1 >/proc/sys/kernel/sysrq
echo p >/proc/sysrq-trigger
kernel will print call trace as below:

sysrq: SysRq : Show Regs
BUG: using __this_cpu_read() in preemptible [00000000] code: sh/435
caller is __this_cpu_preempt_check+0x18/0x20
Call trace:
[<ffffff8008088e80>] dump_backtrace+0x0/0x1d0
[<ffffff8008089074>] show_stack+0x24/0x30
[<ffffff8008447970>] dump_stack+0x90/0xb0
[<ffffff8008463950>] check_preemption_disabled+0x100/0x108
[<ffffff8008463998>] __this_cpu_preempt_check+0x18/0x20
[<ffffff80084c9194>] sysrq_handle_showregs+0x1c/0x40
[<ffffff80084c9c7c>] __handle_sysrq+0x12c/0x1a0
[<ffffff80084ca140>] write_sysrq_trigger+0x60/0x70
[<ffffff8008251e00>] proc_reg_write+0x90/0xd0
[<ffffff80081f1788>] __vfs_write+0x48/0x90
[<ffffff80081f241c>] vfs_write+0xa4/0x190
[<ffffff80081f3354>] SyS_write+0x54/0xb0
[<ffffff80080833f0>] el0_svc_naked+0x24/0x28

This can be seen on a common board like an r-pi3.
This happens because when echo p >/proc/sysrq-trigger,
get_irq_regs() is called outside of IRQ context,
if preemption is enabled in this situation,kernel will
print the call trace. Since many prior discussions on
the mailing lists have made it clear that get_irq_regs
either just returns NULL or stale data when used outside
of IRQ context,we simply avoid calling it outside of
IRQ context.

Signed-off-by: Jibin Xu <jibin.xu@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/tty/sysrq.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 2f7cfa5c7b8b..529cc86283e7 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -237,8 +237,10 @@ static void sysrq_handle_showallcpus(int key)
 	 * architecture has no support for it:
 	 */
 	if (!trigger_all_cpu_backtrace()) {
-		struct pt_regs *regs = get_irq_regs();
+		struct pt_regs *regs = NULL;
 
+		if (in_irq())
+			regs = get_irq_regs();
 		if (regs) {
 			pr_info("CPU%d:\n", smp_processor_id());
 			show_regs(regs);
@@ -257,7 +259,10 @@ static struct sysrq_key_op sysrq_showallcpus_op = {
 
 static void sysrq_handle_showregs(int key)
 {
-	struct pt_regs *regs = get_irq_regs();
+	struct pt_regs *regs = NULL;
+
+	if (in_irq())
+		regs = get_irq_regs();
 	if (regs)
 		show_regs(regs);
 	perf_event_print_debug();
-- 
2.11.0

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

* [added to the 4.1 stable tree] kprobes/x86: Disable preemption in ftrace-based jprobes
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (119 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] net: systemport: Utilize skb_put_padto() Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] net: systemport: Pad packet before inserting TSB Sasha Levin
                   ` (174 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Masami Hiramatsu, Ingo Molnar, Sasha Levin

From: Masami Hiramatsu <mhiramat@kernel.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 5bb4fc2d8641219732eb2bb654206775a4219aca ]

Disable preemption in ftrace-based jprobe handlers as
described in Documentation/kprobes.txt:

  "Probe handlers are run with preemption disabled."

This will fix jprobes behavior when CONFIG_PREEMPT=y.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E . McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/150581530024.32348.9863783558598926771.stgit@devbox
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/x86/kernel/kprobes/ftrace.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/kprobes/ftrace.c b/arch/x86/kernel/kprobes/ftrace.c
index 5f8f0b3cc674..2c0b0b645a74 100644
--- a/arch/x86/kernel/kprobes/ftrace.c
+++ b/arch/x86/kernel/kprobes/ftrace.c
@@ -26,7 +26,7 @@
 #include "common.h"
 
 static nokprobe_inline
-int __skip_singlestep(struct kprobe *p, struct pt_regs *regs,
+void __skip_singlestep(struct kprobe *p, struct pt_regs *regs,
 		      struct kprobe_ctlblk *kcb, unsigned long orig_ip)
 {
 	/*
@@ -41,20 +41,21 @@ int __skip_singlestep(struct kprobe *p, struct pt_regs *regs,
 	__this_cpu_write(current_kprobe, NULL);
 	if (orig_ip)
 		regs->ip = orig_ip;
-	return 1;
 }
 
 int skip_singlestep(struct kprobe *p, struct pt_regs *regs,
 		    struct kprobe_ctlblk *kcb)
 {
-	if (kprobe_ftrace(p))
-		return __skip_singlestep(p, regs, kcb, 0);
-	else
-		return 0;
+	if (kprobe_ftrace(p)) {
+		__skip_singlestep(p, regs, kcb, 0);
+		preempt_enable_no_resched();
+		return 1;
+	}
+	return 0;
 }
 NOKPROBE_SYMBOL(skip_singlestep);
 
-/* Ftrace callback handler for kprobes */
+/* Ftrace callback handler for kprobes -- called under preepmt disabed */
 void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
 			   struct ftrace_ops *ops, struct pt_regs *regs)
 {
@@ -77,13 +78,17 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
 		/* Kprobe handler expects regs->ip = ip + 1 as breakpoint hit */
 		regs->ip = ip + sizeof(kprobe_opcode_t);
 
+		/* To emulate trap based kprobes, preempt_disable here */
+		preempt_disable();
 		__this_cpu_write(current_kprobe, p);
 		kcb->kprobe_status = KPROBE_HIT_ACTIVE;
-		if (!p->pre_handler || !p->pre_handler(p, regs))
+		if (!p->pre_handler || !p->pre_handler(p, regs)) {
 			__skip_singlestep(p, regs, kcb, orig_ip);
+			preempt_enable_no_resched();
+		}
 		/*
 		 * If pre_handler returns !0, it sets regs->ip and
-		 * resets current kprobe.
+		 * resets current kprobe, and keep preempt count +1.
 		 */
 	}
 end:
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: systemport: Utilize skb_put_padto()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (118 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] perf test attr: Fix ignored test case result Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] kprobes/x86: Disable preemption in ftrace-based jprobes Sasha Levin
                   ` (175 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Florian Fainelli, David S . Miller, Sasha Levin

From: Florian Fainelli <f.fainelli@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit bb7da333d0a9f3bddc08f84187b7579a3f68fd24 ]

Since we need to pad our packets, utilize skb_put_padto() which
increases skb->len by how much we need to pad, allowing us to eliminate
the test on skb->len right below.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 783543ad1fcf..320d8d0f0e0b 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -971,13 +971,12 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
 	 * (including FCS and tag) because the length verification is done after
 	 * the Broadcom tag is stripped off the ingress packet.
 	 */
-	if (skb_padto(skb, ETH_ZLEN + ENET_BRCM_TAG_LEN)) {
+	if (skb_put_padto(skb, ETH_ZLEN + ENET_BRCM_TAG_LEN)) {
 		ret = NETDEV_TX_OK;
 		goto out;
 	}
 
-	skb_len = skb->len < ETH_ZLEN + ENET_BRCM_TAG_LEN ?
-			ETH_ZLEN + ENET_BRCM_TAG_LEN : skb->len;
+	skb_len = skb->len;
 
 	mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE);
 	if (dma_mapping_error(kdev, mapping)) {
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: systemport: Pad packet before inserting TSB
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (120 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] kprobes/x86: Disable preemption in ftrace-based jprobes Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ARM: OMAP1: DMA: Correct the number of logical channels Sasha Levin
                   ` (173 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Florian Fainelli, David S . Miller, Sasha Levin

From: Florian Fainelli <f.fainelli@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 38e5a85562a6cd911fc26d951d576551a688574c ]

Inserting the TSB means adding an extra 8 bytes in front the of packet
that is going to be used as metadata information by the TDMA engine, but
stripped off, so it does not really help with the packet padding.

For some odd packet sizes that fall below the 60 bytes payload (e.g: ARP)
we can end-up padding them after the TSB insertion, thus making them 64
bytes, but with the TDMA stripping off the first 8 bytes, they could
still be smaller than 64 bytes which is required to ingress the switch.

Fix this by swapping the padding and TSB insertion, guaranteeing that
the packets have the right sizes.

Fixes: 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 320d8d0f0e0b..621a970bddf6 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -955,15 +955,6 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
 		goto out;
 	}
 
-	/* Insert TSB and checksum infos */
-	if (priv->tsb_en) {
-		skb = bcm_sysport_insert_tsb(skb, dev);
-		if (!skb) {
-			ret = NETDEV_TX_OK;
-			goto out;
-		}
-	}
-
 	/* The Ethernet switch we are interfaced with needs packets to be at
 	 * least 64 bytes (including FCS) otherwise they will be discarded when
 	 * they enter the switch port logic. When Broadcom tags are enabled, we
@@ -976,6 +967,15 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
 		goto out;
 	}
 
+	/* Insert TSB and checksum infos */
+	if (priv->tsb_en) {
+		skb = bcm_sysport_insert_tsb(skb, dev);
+		if (!skb) {
+			ret = NETDEV_TX_OK;
+			goto out;
+		}
+	}
+
 	skb_len = skb->len;
 
 	mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE);
-- 
2.11.0

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

* [added to the 4.1 stable tree] ARM: OMAP1: DMA: Correct the number of logical channels
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (121 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] net: systemport: Pad packet before inserting TSB Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] net/appletalk: Fix kernel memory disclosure Sasha Levin
                   ` (172 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Peter Ujfalusi, Tony Lindgren, Sasha Levin

From: Peter Ujfalusi <peter.ujfalusi@ti.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 657279778af54f35e54b07b6687918f254a2992c ]

OMAP1510, OMAP5910 and OMAP310 have only 9 logical channels.
OMAP1610, OMAP5912, OMAP1710, OMAP730, and OMAP850 have 16 logical channels
available.

The wired 17 for the lch_count must have been used to cover the 16 + 1
dedicated LCD channel, in reality we can only use 9 or 16 channels.

The d->chan_count is not used by the omap-dma stack, so we can skip the
setup. chan_count was configured to the number of logical channels and not
the actual number of physical channels anyways.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/arm/mach-omap1/dma.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap1/dma.c b/arch/arm/mach-omap1/dma.c
index 4be601b638d7..8129e5f9c94d 100644
--- a/arch/arm/mach-omap1/dma.c
+++ b/arch/arm/mach-omap1/dma.c
@@ -31,7 +31,6 @@
 #include <mach/irqs.h>
 
 #define OMAP1_DMA_BASE			(0xfffed800)
-#define OMAP1_LOGICAL_DMA_CH_COUNT	17
 
 static u32 enable_1510_mode;
 
@@ -311,8 +310,6 @@ static int __init omap1_system_dma_init(void)
 		goto exit_iounmap;
 	}
 
-	d->lch_count		= OMAP1_LOGICAL_DMA_CH_COUNT;
-
 	/* Valid attributes for omap1 plus processors */
 	if (cpu_is_omap15xx())
 		d->dev_caps = ENABLE_1510_MODE;
@@ -329,13 +326,14 @@ static int __init omap1_system_dma_init(void)
 	d->dev_caps		|= CLEAR_CSR_ON_READ;
 	d->dev_caps		|= IS_WORD_16;
 
-	if (cpu_is_omap15xx())
-		d->chan_count = 9;
-	else if (cpu_is_omap16xx() || cpu_is_omap7xx()) {
-		if (!(d->dev_caps & ENABLE_1510_MODE))
-			d->chan_count = 16;
+	/* available logical channels */
+	if (cpu_is_omap15xx()) {
+		d->lch_count = 9;
+	} else {
+		if (d->dev_caps & ENABLE_1510_MODE)
+			d->lch_count = 9;
 		else
-			d->chan_count = 9;
+			d->lch_count = 16;
 	}
 
 	p = dma_plat_info;
-- 
2.11.0

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

* [added to the 4.1 stable tree] net/appletalk: Fix kernel memory disclosure
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (122 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ARM: OMAP1: DMA: Correct the number of logical channels Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] vti6: fix device register to report IFLA_INFO_KIND Sasha Levin
                   ` (171 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Vlad Tsyrklevich, David S . Miller, Sasha Levin

From: Vlad Tsyrklevich <vlad@tsyrklevich.net>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit ce7e40c432ba84da104438f6799d460a4cad41bc ]

ipddp_route structs contain alignment padding so kernel heap memory
is leaked when they are copied to user space in
ipddp_ioctl(SIOCFINDIPDDPRT). Change kmalloc() to kzalloc() to clear
that memory.

Signed-off-by: Vlad Tsyrklevich <vlad@tsyrklevich.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/appletalk/ipddp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index e90c6a7333d7..2e4649655181 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -191,7 +191,7 @@ static netdev_tx_t ipddp_xmit(struct sk_buff *skb, struct net_device *dev)
  */
 static int ipddp_create(struct ipddp_route *new_rt)
 {
-        struct ipddp_route *rt = kmalloc(sizeof(*rt), GFP_KERNEL);
+        struct ipddp_route *rt = kzalloc(sizeof(*rt), GFP_KERNEL);
 
         if (rt == NULL)
                 return -ENOMEM;
-- 
2.11.0

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

* [added to the 4.1 stable tree] vti6: fix device register to report IFLA_INFO_KIND
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (123 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] net/appletalk: Fix kernel memory disclosure Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] nfs: Don't take a reference on fl->fl_file for LOCK operation Sasha Levin
                   ` (170 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David Forster, David S . Miller, Sasha Levin

From: David Forster <dforster@brocade.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 93e246f783e6bd1bc64fdfbfe68b18161f69b28e ]

vti6 interface is registered before the rtnl_link_ops block
is attached. As a result the resulting RTM_NEWLINK is missing
IFLA_INFO_KIND. Re-order attachment of rtnl_link_ops block to fix.

Signed-off-by: Dave Forster <dforster@brocade.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv6/ip6_vti.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index 2ded71f4c299..afa1741efdb0 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -189,12 +189,12 @@ static int vti6_tnl_create2(struct net_device *dev)
 	struct vti6_net *ip6n = net_generic(net, vti6_net_id);
 	int err;
 
+	dev->rtnl_link_ops = &vti6_link_ops;
 	err = register_netdevice(dev);
 	if (err < 0)
 		goto out;
 
 	strcpy(t->parms.name, dev->name);
-	dev->rtnl_link_ops = &vti6_link_ops;
 
 	dev_hold(dev);
 	vti6_tnl_link(ip6n, t);
-- 
2.11.0

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

* [added to the 4.1 stable tree] nfs: Don't take a reference on fl->fl_file for LOCK operation
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (124 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] vti6: fix device register to report IFLA_INFO_KIND Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] NFSv4: Fix client recovery when server reboots multiple times Sasha Levin
                   ` (169 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Benjamin Coddington, Trond Myklebust, Sasha Levin

From: Benjamin Coddington <bcodding@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 4b09ec4b14a168bf2c687e1f598140c3c11e9222 ]

I have reports of a crash that look like __fput() was called twice for
a NFSv4.0 file.  It seems possible that the state manager could try to
reclaim a lock and take a reference on the fl->fl_file at the same time the
file is being released if, during the close(), a signal interrupts the wait
for outstanding IO while removing locks which then skips the removal
of that lock.

Since 83bfff23e9ed ("nfs4: have do_vfs_lock take an inode pointer") has
removed the need to traverse fl->fl_file->f_inode in nfs4_lock_done(),
taking that reference is no longer necessary.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/nfs/nfs4proc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 1ce18913762a..0fb0dc739fb2 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -38,7 +38,6 @@
 #include <linux/mm.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
-#include <linux/file.h>
 #include <linux/string.h>
 #include <linux/ratelimit.h>
 #include <linux/printk.h>
@@ -5605,7 +5604,6 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl,
 	p->server = server;
 	atomic_inc(&lsp->ls_count);
 	p->ctx = get_nfs_open_context(ctx);
-	get_file(fl->fl_file);
 	memcpy(&p->fl, fl, sizeof(p->fl));
 	return p;
 out_free_seqid:
@@ -5718,7 +5716,6 @@ static void nfs4_lock_release(void *calldata)
 		nfs_free_seqid(data->arg.lock_seqid);
 	nfs4_put_lock_state(data->lsp);
 	put_nfs_open_context(data->ctx);
-	fput(data->fl.fl_file);
 	kfree(data);
 	dprintk("%s: done!\n", __func__);
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] NFSv4: Fix client recovery when server reboots multiple times
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (125 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] nfs: Don't take a reference on fl->fl_file for LOCK operation Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] net: sctp: fix array overrun read on sctp_timer_tbl Sasha Levin
                   ` (168 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Trond Myklebust, Sasha Levin

From: Trond Myklebust <trond.myklebust@primarydata.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit c6180a6237174f481dc856ed6e890d8196b6f0fb ]

If the server reboots multiple times, the client should rely on the
server to tell it that it cannot reclaim state as per section 9.6.3.4
in RFC7530 and section 8.4.2.1 in RFC5661.
Currently, the client is being to conservative, and is assuming that
if the server reboots while state recovery is in progress, then it must
ignore state that was not recovered before the reboot.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/nfs/nfs4state.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 2a9ab265aa32..f8d2902ec118 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1678,7 +1678,6 @@ static int nfs4_recovery_handle_error(struct nfs_client *clp, int error)
 			break;
 		case -NFS4ERR_STALE_CLIENTID:
 			set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
-			nfs4_state_clear_reclaim_reboot(clp);
 			nfs4_state_start_reclaim_reboot(clp);
 			break;
 		case -NFS4ERR_EXPIRED:
-- 
2.11.0

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

* [added to the 4.1 stable tree] tipc: fix cleanup at module unload
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (127 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] net: sctp: fix array overrun read on sctp_timer_tbl Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] tcp: correct memory barrier usage in tcp_check_space() Sasha Levin
                   ` (166 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Parthasarathy Bhuvaragan, David S . Miller, Sasha Levin

From: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 35e22e49a5d6a741ebe7f2dd280b2052c3003ef7 ]

In tipc_server_stop(), we iterate over the connections with limiting
factor as server's idr_in_use. We ignore the fact that this variable
is decremented in tipc_close_conn(), leading to premature exit.

In this commit, we iterate until the we have no connections left.

Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Tested-by: John Thompson <thompa.atl@gmail.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/tipc/server.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/tipc/server.c b/net/tipc/server.c
index d0d619813684..7c52cb5781ab 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -614,14 +614,12 @@ int tipc_server_start(struct tipc_server *s)
 void tipc_server_stop(struct tipc_server *s)
 {
 	struct tipc_conn *con;
-	int total = 0;
 	int id;
 
 	spin_lock_bh(&s->idr_lock);
-	for (id = 0; total < s->idr_in_use; id++) {
+	for (id = 0; s->idr_in_use; id++) {
 		con = idr_find(&s->conn_idr, id);
 		if (con) {
-			total++;
 			spin_unlock_bh(&s->idr_lock);
 			tipc_close_conn(con);
 			spin_lock_bh(&s->idr_lock);
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: sctp: fix array overrun read on sctp_timer_tbl
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (126 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] NFSv4: Fix client recovery when server reboots multiple times Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] tipc: fix cleanup at module unload Sasha Levin
                   ` (167 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Colin Ian King, David S . Miller, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 0e73fc9a56f22f2eec4d2b2910c649f7af67b74d ]

The comparison on the timeout can lead to an array overrun
read on sctp_timer_tbl because of an off-by-one error. Fix
this by using < instead of <= and also compare to the array
size rather than SCTP_EVENT_TIMEOUT_MAX.

Fixes CoverityScan CID#1397639 ("Out-of-bounds read")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/sctp/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sctp/debug.c b/net/sctp/debug.c
index 95d7b15dad21..e371a0d90068 100644
--- a/net/sctp/debug.c
+++ b/net/sctp/debug.c
@@ -166,7 +166,7 @@ static const char *const sctp_timer_tbl[] = {
 /* Lookup timer debug name. */
 const char *sctp_tname(const sctp_subtype_t id)
 {
-	if (id.timeout <= SCTP_EVENT_TIMEOUT_MAX)
+	if (id.timeout < ARRAY_SIZE(sctp_timer_tbl))
 		return sctp_timer_tbl[id.timeout];
 	return "unknown_timer";
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] tcp: correct memory barrier usage in tcp_check_space()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (128 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] tipc: fix cleanup at module unload Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] dmaengine: pl330: fix double lock Sasha Levin
                   ` (165 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jason Baron, David S . Miller, Sasha Levin

From: Jason Baron <jbaron@akamai.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 56d806222ace4c3aeae516cd7a855340fb2839d8 ]

sock_reset_flag() maps to __clear_bit() not the atomic version clear_bit().
Thus, we need smp_mb(), smp_mb__after_atomic() is not sufficient.

Fixes: 3c7151275c0c ("tcp: add memory barriers to write space paths")
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Jason Baron <jbaron@akamai.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Reported-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv4/tcp_input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index adfb709c6ee6..4763c431f7d8 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4895,7 +4895,7 @@ static void tcp_check_space(struct sock *sk)
 	if (sock_flag(sk, SOCK_QUEUE_SHRUNK)) {
 		sock_reset_flag(sk, SOCK_QUEUE_SHRUNK);
 		/* pairs with tcp_poll() */
-		smp_mb__after_atomic();
+		smp_mb();
 		if (sk->sk_socket &&
 		    test_bit(SOCK_NOSPACE, &sk->sk_socket->flags))
 			tcp_new_space(sk);
-- 
2.11.0

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

* [added to the 4.1 stable tree] dmaengine: pl330: fix double lock
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (129 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] tcp: correct memory barrier usage in tcp_check_space() Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] net: fec: fix multicast filtering hardware setup Sasha Levin
                   ` (164 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Iago Abal, Vinod Koul, Sasha Levin

From: Iago Abal <mail@iagoabal.eu>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 91539eb1fda2d530d3b268eef542c5414e54bf1a ]

The static bug finder EBA (http://www.iagoabal.eu/eba/) reported the
following double-lock bug:

    Double lock:
    1. spin_lock_irqsave(pch->lock, flags) at pl330_free_chan_resources:2236;
    2. call to function `pl330_release_channel' immediately after;
    3. call to function `dma_pl330_rqcb' in line 1753;
    4. spin_lock_irqsave(pch->lock, flags) at dma_pl330_rqcb:1505.

I have fixed it as suggested by Marek Szyprowski.

First, I have replaced `pch->lock' with `pl330->lock' in functions
`pl330_alloc_chan_resources' and `pl330_free_chan_resources'. This avoids
the double-lock by acquiring a different lock than `dma_pl330_rqcb'.

NOTE that, as a result, `pl330_free_chan_resources' executes
`list_splice_tail_init' on `pch->work_list' under lock `pl330->lock',
whereas in the rest of the code `pch->work_list' is protected by
`pch->lock'. I don't know if this may cause race conditions. Similarly
`pch->cyclic' is written by `pl330_alloc_chan_resources' under
`pl330->lock' but read by `pl330_tx_submit' under `pch->lock'.

Second, I have removed locking from `pl330_request_channel' and
`pl330_release_channel' functions. Function `pl330_request_channel' is
only called from `pl330_alloc_chan_resources', so the lock is already
held. Function `pl330_release_channel' is called from
`pl330_free_chan_resources', which already holds the lock, and from
`pl330_del'. Function `pl330_del' is called in an error path of
`pl330_probe' and at the end of `pl330_remove', but I assume that there
cannot be concurrent accesses to the protected data at those points.

Signed-off-by: Iago Abal <mail@iagoabal.eu>
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/dma/pl330.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 3dabc52b9615..cb731749205a 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -1651,7 +1651,6 @@ static bool _chan_ns(const struct pl330_dmac *pl330, int i)
 static struct pl330_thread *pl330_request_channel(struct pl330_dmac *pl330)
 {
 	struct pl330_thread *thrd = NULL;
-	unsigned long flags;
 	int chans, i;
 
 	if (pl330->state == DYING)
@@ -1659,8 +1658,6 @@ static struct pl330_thread *pl330_request_channel(struct pl330_dmac *pl330)
 
 	chans = pl330->pcfg.num_chan;
 
-	spin_lock_irqsave(&pl330->lock, flags);
-
 	for (i = 0; i < chans; i++) {
 		thrd = &pl330->channels[i];
 		if ((thrd->free) && (!_manager_ns(thrd) ||
@@ -1678,8 +1675,6 @@ static struct pl330_thread *pl330_request_channel(struct pl330_dmac *pl330)
 		thrd = NULL;
 	}
 
-	spin_unlock_irqrestore(&pl330->lock, flags);
-
 	return thrd;
 }
 
@@ -1697,7 +1692,6 @@ static inline void _free_event(struct pl330_thread *thrd, int ev)
 static void pl330_release_channel(struct pl330_thread *thrd)
 {
 	struct pl330_dmac *pl330;
-	unsigned long flags;
 
 	if (!thrd || thrd->free)
 		return;
@@ -1709,10 +1703,8 @@ static void pl330_release_channel(struct pl330_thread *thrd)
 
 	pl330 = thrd->dmac;
 
-	spin_lock_irqsave(&pl330->lock, flags);
 	_free_event(thrd, thrd->ev);
 	thrd->free = true;
-	spin_unlock_irqrestore(&pl330->lock, flags);
 }
 
 /* Initialize the structure for PL330 configuration, that can be used
@@ -2077,20 +2069,20 @@ static int pl330_alloc_chan_resources(struct dma_chan *chan)
 	struct pl330_dmac *pl330 = pch->dmac;
 	unsigned long flags;
 
-	spin_lock_irqsave(&pch->lock, flags);
+	spin_lock_irqsave(&pl330->lock, flags);
 
 	dma_cookie_init(chan);
 	pch->cyclic = false;
 
 	pch->thread = pl330_request_channel(pl330);
 	if (!pch->thread) {
-		spin_unlock_irqrestore(&pch->lock, flags);
+		spin_unlock_irqrestore(&pl330->lock, flags);
 		return -ENOMEM;
 	}
 
 	tasklet_init(&pch->task, pl330_tasklet, (unsigned long) pch);
 
-	spin_unlock_irqrestore(&pch->lock, flags);
+	spin_unlock_irqrestore(&pl330->lock, flags);
 
 	return 1;
 }
@@ -2188,12 +2180,13 @@ static int pl330_pause(struct dma_chan *chan)
 static void pl330_free_chan_resources(struct dma_chan *chan)
 {
 	struct dma_pl330_chan *pch = to_pchan(chan);
+	struct pl330_dmac *pl330 = pch->dmac;
 	unsigned long flags;
 
 	tasklet_kill(&pch->task);
 
 	pm_runtime_get_sync(pch->dmac->ddma.dev);
-	spin_lock_irqsave(&pch->lock, flags);
+	spin_lock_irqsave(&pl330->lock, flags);
 
 	pl330_release_channel(pch->thread);
 	pch->thread = NULL;
@@ -2201,7 +2194,7 @@ static void pl330_free_chan_resources(struct dma_chan *chan)
 	if (pch->cyclic)
 		list_splice_tail_init(&pch->work_list, &pch->dmac->desc_pool);
 
-	spin_unlock_irqrestore(&pch->lock, flags);
+	spin_unlock_irqrestore(&pl330->lock, flags);
 	pm_runtime_mark_last_busy(pch->dmac->ddma.dev);
 	pm_runtime_put_autosuspend(pch->dmac->ddma.dev);
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: fec: fix multicast filtering hardware setup
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (130 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] dmaengine: pl330: fix double lock Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] mm: avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers Sasha Levin
                   ` (163 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Rui Sousa, Fugang Duan, David S . Miller, Sasha Levin

From: Rui Sousa <rui.sousa@nxp.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 01f8902bcf3ff124d0aeb88a774180ebcec20ace ]

Fix hardware setup of multicast address hash:
- Never clear the hardware hash (to avoid packet loss)
- Construct the hash register values in software and then write once
to hardware

Signed-off-by: Rui Sousa <rui.sousa@nxp.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 67aec18dd76c..fe5a7d207b1d 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2850,6 +2850,7 @@ static void set_multicast_list(struct net_device *ndev)
 	struct netdev_hw_addr *ha;
 	unsigned int i, bit, data, crc, tmp;
 	unsigned char hash;
+	unsigned int hash_high = 0, hash_low = 0;
 
 	if (ndev->flags & IFF_PROMISC) {
 		tmp = readl(fep->hwp + FEC_R_CNTRL);
@@ -2872,11 +2873,7 @@ static void set_multicast_list(struct net_device *ndev)
 		return;
 	}
 
-	/* Clear filter and add the addresses in hash register
-	 */
-	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-
+	/* Add the addresses in hash register */
 	netdev_for_each_mc_addr(ha, ndev) {
 		/* calculate crc32 value of mac address */
 		crc = 0xffffffff;
@@ -2894,16 +2891,14 @@ static void set_multicast_list(struct net_device *ndev)
 		 */
 		hash = (crc >> (32 - HASH_BITS)) & 0x3f;
 
-		if (hash > 31) {
-			tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-			tmp |= 1 << (hash - 32);
-			writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-		} else {
-			tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-			tmp |= 1 << hash;
-			writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-		}
+		if (hash > 31)
+			hash_high |= 1 << (hash - 32);
+		else
+			hash_low |= 1 << hash;
 	}
+
+	writel(hash_high, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+	writel(hash_low, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
 }
 
 /* Set a MAC change in hardware. */
-- 
2.11.0

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

* [added to the 4.1 stable tree] mm: avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (131 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] net: fec: fix multicast filtering hardware setup Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: hub: Cycle HUB power when initialization fails Sasha Levin
                   ` (162 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Jan Kara, Andrew Morton, Linus Torvalds, Sasha Levin

From: Jan Kara <jack@suse.cz>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 0911d0041c22922228ca52a977d7b0b0159fee4b ]

Some ->page_mkwrite handlers may return VM_FAULT_RETRY as its return
code (GFS2 or Lustre can definitely do this).  However VM_FAULT_RETRY
from ->page_mkwrite is completely unhandled by the mm code and results
in locking and writeably mapping the page which definitely is not what
the caller wanted.

Fix Lustre and block_page_mkwrite_ret() used by other filesystems
(notably GFS2) to return VM_FAULT_NOPAGE instead which results in
bailing out from the fault code, the CPU then retries the access, and we
fault again effectively doing what the handler wanted.

Link: http://lkml.kernel.org/r/20170203150729.15863-1-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/staging/lustre/lustre/llite/llite_mmap.c | 4 +---
 include/linux/buffer_head.h                      | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c
index a90214bb84dd..7511b4dfdfe5 100644
--- a/drivers/staging/lustre/lustre/llite/llite_mmap.c
+++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c
@@ -404,15 +404,13 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 		result = VM_FAULT_LOCKED;
 		break;
 	case -ENODATA:
+	case -EAGAIN:
 	case -EFAULT:
 		result = VM_FAULT_NOPAGE;
 		break;
 	case -ENOMEM:
 		result = VM_FAULT_OOM;
 		break;
-	case -EAGAIN:
-		result = VM_FAULT_RETRY;
-		break;
 	default:
 		result = VM_FAULT_SIGBUS;
 		break;
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index e6797ded700e..696b6c44c564 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -236,12 +236,10 @@ static inline int block_page_mkwrite_return(int err)
 {
 	if (err == 0)
 		return VM_FAULT_LOCKED;
-	if (err == -EFAULT)
+	if (err == -EFAULT || err == -EAGAIN)
 		return VM_FAULT_NOPAGE;
 	if (err == -ENOMEM)
 		return VM_FAULT_OOM;
-	if (err == -EAGAIN)
-		return VM_FAULT_RETRY;
 	/* -ENOSPC, -EDQUOT, -EIO ... */
 	return VM_FAULT_SIGBUS;
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] usb: xhci: fix panic in xhci_free_virt_devices_depth_first
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (133 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: hub: Cycle HUB power when initialization fails Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] USB: devio: Prevent integer overflow in proc_do_submiturb() Sasha Levin
                   ` (160 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Yu Chen, Fan Ning, Li Rui, yangdi, Mathias Nyman,
	Greg Kroah-Hartman, Sasha Levin

From: Yu Chen <chenyu56@huawei.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 80e457699a8dbdd70f2d26911e46f538645c55fc ]

Check vdev->real_port 0 to avoid panic
[    9.261347] [<ffffff800884a390>] xhci_free_virt_devices_depth_first+0x58/0x108
[    9.261352] [<ffffff800884a814>] xhci_mem_cleanup+0x1bc/0x570
[    9.261355] [<ffffff8008842de8>] xhci_stop+0x140/0x1c8
[    9.261365] [<ffffff80087ed304>] usb_remove_hcd+0xfc/0x1d0
[    9.261369] [<ffffff80088551c4>] xhci_plat_remove+0x6c/0xa8
[    9.261377] [<ffffff80086e928c>] platform_drv_remove+0x2c/0x70
[    9.261384] [<ffffff80086e6ea0>] __device_release_driver+0x80/0x108
[    9.261387] [<ffffff80086e7a1c>] device_release_driver+0x2c/0x40
[    9.261392] [<ffffff80086e5f28>] bus_remove_device+0xe0/0x120
[    9.261396] [<ffffff80086e2e34>] device_del+0x114/0x210
[    9.261399] [<ffffff80086e9e00>] platform_device_del+0x30/0xa0
[    9.261403] [<ffffff8008810bdc>] dwc3_otg_work+0x204/0x488
[    9.261407] [<ffffff80088133fc>] event_work+0x304/0x5b8
[    9.261414] [<ffffff80080e31b0>] process_one_work+0x148/0x490
[    9.261417] [<ffffff80080e3548>] worker_thread+0x50/0x4a0
[    9.261421] [<ffffff80080e9ea0>] kthread+0xe8/0x100
[    9.261427] [<ffffff8008083680>] ret_from_fork+0x10/0x50

The problem can occur if xhci_plat_remove() is called shortly after
xhci_plat_probe(). While xhci_free_virt_devices_depth_first been
called before the device has been setup and get real_port initialized.
The problem occurred on Hikey960 and was reproduced by Guenter Roeck
on Kevin with chromeos-4.4.

Fixes: ee8665e28e8d ("xhci: free xhci virtual devices with leaf nodes first")
Cc: Guenter Roeck <groeck@google.com>
Cc: <stable@vger.kernel.org> # v4.10+
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Fan Ning <fanning4@hisilicon.com>
Signed-off-by: Li Rui <lirui39@hisilicon.com>
Signed-off-by: yangdi <yangdi10@hisilicon.com>
Signed-off-by: Yu Chen <chenyu56@huawei.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/host/xhci-mem.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 68e37424a26d..49b1aa48ee15 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -981,6 +981,12 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
 	if (!vdev)
 		return;
 
+	if (vdev->real_port == 0 ||
+			vdev->real_port > HCS_MAX_PORTS(xhci->hcs_params1)) {
+		xhci_dbg(xhci, "Bad vdev->real_port.\n");
+		goto out;
+	}
+
 	tt_list_head = &(xhci->rh_bw[vdev->real_port - 1].tts);
 	list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) {
 		/* is this a hub device that added a tt_info to the tts list */
@@ -994,6 +1000,7 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
 			}
 		}
 	}
+out:
 	/* we are now at a leaf device */
 	xhci_free_virt_device(xhci, slot_id);
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] usb: hub: Cycle HUB power when initialization fails
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (132 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] mm: avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: xhci: fix panic in xhci_free_virt_devices_depth_first Sasha Levin
                   ` (161 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Mike Looijmans, Greg Kroah-Hartman, Sasha Levin

From: Mike Looijmans <mike.looijmans@topic.nl>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 973593a960ddac0f14f0d8877d2d0abe0afda795 ]

Sometimes the USB device gets confused about the state of the initialization and
the connection fails. In particular, the device thinks that it's already set up
and running while the host thinks the device still needs to be configured. To
work around this issue, power-cycle the hub's output to issue a sort of "reset"
to the device. This makes the device restart its state machine and then the
initialization succeeds.

This fixes problems where the kernel reports a list of errors like this:

usb 1-1.3: device not accepting address 19, error -71

The end result is a non-functioning device. After this patch, the sequence
becomes like this:

usb 1-1.3: new high-speed USB device number 18 using ci_hdrc
usb 1-1.3: device not accepting address 18, error -71
usb 1-1.3: new high-speed USB device number 19 using ci_hdrc
usb 1-1.3: device not accepting address 19, error -71
usb 1-1-port3: attempt power cycle
usb 1-1.3: new high-speed USB device number 21 using ci_hdrc
usb-storage 1-1.3:1.2: USB Mass Storage device detected

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/core/hub.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 8600144a7aab..1ba74441d7bf 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4815,6 +4815,15 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
 		usb_put_dev(udev);
 		if ((status == -ENOTCONN) || (status == -ENOTSUPP))
 			break;
+
+		/* When halfway through our retry count, power-cycle the port */
+		if (i == (SET_CONFIG_TRIES / 2) - 1) {
+			dev_info(&port_dev->dev, "attempt power cycle\n");
+			usb_hub_set_port_power(hdev, hub, port1, false);
+			msleep(2 * hub_power_on_good_delay(hub));
+			usb_hub_set_port_power(hdev, hub, port1, true);
+			msleep(hub_power_on_good_delay(hub));
+		}
 	}
 	if (hub->hdev->parent ||
 			!hcd->driver->port_handed_over ||
-- 
2.11.0

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

* [added to the 4.1 stable tree] USB: devio: Prevent integer overflow in proc_do_submiturb()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (134 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: xhci: fix panic in xhci_free_virt_devices_depth_first Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] USB: Increase usbfs transfer limit Sasha Levin
                   ` (159 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Dan Carpenter, Greg Kroah-Hartman, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 57999d1107c1e60c2ca7088f2ac0f819e2f554b3 ]

There used to be an integer overflow check in proc_do_submiturb() but
we removed it.  It turns out that it's still required.  The
uurb->buffer_length variable is a signed integer and it's controlled by
the user.  It can lead to an integer overflow when we do:

	num_sgs = DIV_ROUND_UP(uurb->buffer_length, USB_SG_SIZE);

If we strip away the macro then that line looks like this:

	num_sgs = (uurb->buffer_length + USB_SG_SIZE - 1) / USB_SG_SIZE;
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It's the first addition which can overflow.

Fixes: 1129d270cbfb ("USB: Increase usbfs transfer limit")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/core/devio.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index de9fa65bb03b..25e0cfe0d407 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -118,6 +118,9 @@ module_param(usbfs_memory_mb, uint, 0644);
 MODULE_PARM_DESC(usbfs_memory_mb,
 		"maximum MB allowed for usbfs buffers (0 = no limit)");
 
+/* Hard limit, necessary to avoid arithmetic overflow */
+#define USBFS_XFER_MAX         (UINT_MAX / 2 - 1000000)
+
 static atomic64_t usbfs_memory_usage;	/* Total memory currently allocated */
 
 /* Check whether it's okay to allocate more memory for a transfer */
@@ -1295,6 +1298,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
 				USBDEVFS_URB_ZERO_PACKET |
 				USBDEVFS_URB_NO_INTERRUPT))
 		return -EINVAL;
+	if ((unsigned int)uurb->buffer_length >= USBFS_XFER_MAX)
+		return -EINVAL;
 	if (uurb->buffer_length > 0 && !uurb->buffer)
 		return -EINVAL;
 	if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL &&
-- 
2.11.0

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

* [added to the 4.1 stable tree] USB: Increase usbfs transfer limit
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (135 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] USB: devio: Prevent integer overflow in proc_do_submiturb() Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] USB: usbfs: Filter flags passed in from user space Sasha Levin
                   ` (158 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Mateusz Berezecki, Greg Kroah-Hartman, Sasha Levin

From: Mateusz Berezecki <mateuszb@fastmail.fm>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 1129d270cbfbb7e2b1ec3dede4a13930bdd10e41 ]

Promote a variable keeping track of USB transfer memory usage to a
wider data type and allow for higher bandwidth transfers from a large
number of USB devices connected to a single host.

Signed-off-by: Mateusz Berezecki <mateuszb@fastmail.fm>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/core/devio.c | 43 ++++++++++++++++---------------------------
 1 file changed, 16 insertions(+), 27 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 94a15883f8cc..de9fa65bb03b 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -113,42 +113,35 @@ enum snoop_when {
 #define USB_DEVICE_DEV		MKDEV(USB_DEVICE_MAJOR, 0)
 
 /* Limit on the total amount of memory we can allocate for transfers */
-static unsigned usbfs_memory_mb = 16;
+static u32 usbfs_memory_mb = 16;
 module_param(usbfs_memory_mb, uint, 0644);
 MODULE_PARM_DESC(usbfs_memory_mb,
 		"maximum MB allowed for usbfs buffers (0 = no limit)");
 
-/* Hard limit, necessary to avoid arithmetic overflow */
-#define USBFS_XFER_MAX		(UINT_MAX / 2 - 1000000)
-
-static atomic_t usbfs_memory_usage;	/* Total memory currently allocated */
+static atomic64_t usbfs_memory_usage;	/* Total memory currently allocated */
 
 /* Check whether it's okay to allocate more memory for a transfer */
-static int usbfs_increase_memory_usage(unsigned amount)
+static int usbfs_increase_memory_usage(u64 amount)
 {
-	unsigned lim;
+	u64 lim;
 
-	/*
-	 * Convert usbfs_memory_mb to bytes, avoiding overflows.
-	 * 0 means use the hard limit (effectively unlimited).
-	 */
 	lim = ACCESS_ONCE(usbfs_memory_mb);
-	if (lim == 0 || lim > (USBFS_XFER_MAX >> 20))
-		lim = USBFS_XFER_MAX;
-	else
-		lim <<= 20;
+	lim <<= 20;
 
-	atomic_add(amount, &usbfs_memory_usage);
-	if (atomic_read(&usbfs_memory_usage) <= lim)
-		return 0;
-	atomic_sub(amount, &usbfs_memory_usage);
-	return -ENOMEM;
+	atomic64_add(amount, &usbfs_memory_usage);
+
+	if (lim > 0 && atomic64_read(&usbfs_memory_usage) > lim) {
+		atomic64_sub(amount, &usbfs_memory_usage);
+		return -ENOMEM;
+	}
+
+	return 0;
 }
 
 /* Memory for a transfer is being deallocated */
-static void usbfs_decrease_memory_usage(unsigned amount)
+static void usbfs_decrease_memory_usage(u64 amount)
 {
-	atomic_sub(amount, &usbfs_memory_usage);
+	atomic64_sub(amount, &usbfs_memory_usage);
 }
 
 static int connected(struct usb_dev_state *ps)
@@ -1077,7 +1070,7 @@ static int proc_bulk(struct usb_dev_state *ps, void __user *arg)
 	if (!usb_maxpacket(dev, pipe, !(bulk.ep & USB_DIR_IN)))
 		return -EINVAL;
 	len1 = bulk.len;
-	if (len1 >= USBFS_XFER_MAX)
+	if (len1 >= (INT_MAX - sizeof(struct urb)))
 		return -EINVAL;
 	ret = usbfs_increase_memory_usage(len1 + sizeof(struct urb));
 	if (ret)
@@ -1420,10 +1413,6 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
 		return -EINVAL;
 	}
 
-	if (uurb->buffer_length >= USBFS_XFER_MAX) {
-		ret = -EINVAL;
-		goto error;
-	}
 	if (uurb->buffer_length > 0 &&
 			!access_ok(is_in ? VERIFY_WRITE : VERIFY_READ,
 				uurb->buffer, uurb->buffer_length)) {
-- 
2.11.0

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

* [added to the 4.1 stable tree] usb: host: fix incorrect updating of offset
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (137 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] USB: usbfs: Filter flags passed in from user space Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: kvaser_usb: free buf in error paths Sasha Levin
                   ` (156 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Colin Ian King, Greg Kroah-Hartman, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 1d5a31582ef046d3b233f0da1a68ae26519b2f0a ]

The variable temp is incorrectly being updated, instead it should
be offset otherwise the loop just reads the same capability value
and loops forever.  Thanks to Alan Stern for pointing out the
correct fix to my original fix.  Fix also cleans up clang warning:

drivers/usb/host/ehci-dbg.c:840:4: warning: Value stored to 'temp'
is never read

Fixes: d49d43174400 ("USB: misc ehci updates")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/host/ehci-dbg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 524cbf26d992..e37395ef5d49 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -850,7 +850,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
 			default:		/* unknown */
 				break;
 			}
-			temp = (cap >> 8) & 0xff;
+			offset = (cap >> 8) & 0xff;
 		}
 	}
 #endif
-- 
2.11.0

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

* [added to the 4.1 stable tree] USB: usbfs: Filter flags passed in from user space
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (136 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] USB: Increase usbfs transfer limit Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: host: fix incorrect updating of offset Sasha Levin
                   ` (157 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Oliver Neukum, Greg Kroah-Hartman, Sasha Levin

From: Oliver Neukum <oneukum@suse.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 446f666da9f019ce2ffd03800995487e79a91462 ]

USBDEVFS_URB_ISO_ASAP must be accepted only for ISO endpoints.
Improve sanity checking.

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Cc: stable <stable@vger.kernel.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/core/devio.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 25e0cfe0d407..3c31309f06d3 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1290,14 +1290,18 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
 	int number_of_packets = 0;
 	unsigned int stream_id = 0;
 	void *buf;
-
-	if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP |
-				USBDEVFS_URB_SHORT_NOT_OK |
+	unsigned long mask =	USBDEVFS_URB_SHORT_NOT_OK |
 				USBDEVFS_URB_BULK_CONTINUATION |
 				USBDEVFS_URB_NO_FSBR |
 				USBDEVFS_URB_ZERO_PACKET |
-				USBDEVFS_URB_NO_INTERRUPT))
-		return -EINVAL;
+				USBDEVFS_URB_NO_INTERRUPT;
+	/* USBDEVFS_URB_ISO_ASAP is a special case */
+	if (uurb->type == USBDEVFS_URB_TYPE_ISO)
+		mask |= USBDEVFS_URB_ISO_ASAP;
+
+	if (uurb->flags & ~mask)
+			return -EINVAL;
+
 	if ((unsigned int)uurb->buffer_length >= USBFS_XFER_MAX)
 		return -EINVAL;
 	if (uurb->buffer_length > 0 && !uurb->buffer)
-- 
2.11.0

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

* [added to the 4.1 stable tree] can: ti_hecc: Fix napi poll return value for repoll
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (139 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: kvaser_usb: free buf in error paths Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: kvaser_usb: Fix comparison bug in kvaser_usb_read_bulk_callback() Sasha Levin
                   ` (154 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Oliver Stäbler, Marc Kleine-Budde, Sasha Levin

From: Oliver Stäbler <oliver.staebler@bytesatwork.ch>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f6c23b174c3c96616514827407769cbcfc8005cf ]

After commit d75b1ade567f ("net: less interrupt masking in NAPI") napi
repoll is done only when work_done == budget.
So we need to return budget if there are still packets to receive.

Signed-off-by: Oliver Stäbler <oliver.staebler@bytesatwork.ch>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/can/ti_hecc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 7bb3cf38f346..2965453853f3 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -652,6 +652,9 @@ static int ti_hecc_rx_poll(struct napi_struct *napi, int quota)
 		mbx_mask = hecc_read(priv, HECC_CANMIM);
 		mbx_mask |= HECC_TX_MBOX_MASK;
 		hecc_write(priv, HECC_CANMIM, mbx_mask);
+	} else {
+		/* repoll is done only if whole budget is used */
+		num_pkts = quota;
 	}
 
 	return num_pkts;
-- 
2.11.0

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

* [added to the 4.1 stable tree] can: kvaser_usb: free buf in error paths
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (138 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: host: fix incorrect updating of offset Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: ti_hecc: Fix napi poll return value for repoll Sasha Levin
                   ` (155 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jimmy Assarsson, Marc Kleine-Budde, Sasha Levin

From: Jimmy Assarsson <jimmyassarsson@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 435019b48033138581a6171093b181fc6b4d3d30 ]

The allocated buffer was not freed if usb_submit_urb() failed.

Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/can/usb/kvaser_usb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index dc77225227c7..7e35f1f6dd7e 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -809,6 +809,7 @@ static int kvaser_usb_simple_msg_async(struct kvaser_usb_net_priv *priv,
 	if (err) {
 		netdev_err(netdev, "Error transmitting URB\n");
 		usb_unanchor_urb(urb);
+		kfree(buf);
 		usb_free_urb(urb);
 		return err;
 	}
@@ -1768,6 +1769,7 @@ static netdev_tx_t kvaser_usb_start_xmit(struct sk_buff *skb,
 		spin_unlock_irqrestore(&priv->tx_contexts_lock, flags);
 
 		usb_unanchor_urb(urb);
+		kfree(buf);
 
 		stats->tx_dropped++;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] can: kvaser_usb: Fix comparison bug in kvaser_usb_read_bulk_callback()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (140 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: ti_hecc: Fix napi poll return value for repoll Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: kvaser_usb: cancel urb on -EPIPE and -EPROTO Sasha Levin
                   ` (153 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jimmy Assarsson, Marc Kleine-Budde, Sasha Levin

From: Jimmy Assarsson <jimmyassarsson@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e84f44eb5523401faeb9cc1c97895b68e3cfb78d ]

The conditon in the while-loop becomes true when actual_length is less than
2 (MSG_HEADER_LEN). In best case we end up with a former, already
dispatched msg, that got msg->len greater than actual_length. This will
result in a "Format error" error printout.

Problem seen when unplugging a Kvaser USB device connected to a vbox guest.

warning: comparison between signed and unsigned integer expressions
[-Wsign-compare]

Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/can/usb/kvaser_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index 7e35f1f6dd7e..faced1e1b3fa 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -1331,7 +1331,7 @@ static void kvaser_usb_read_bulk_callback(struct urb *urb)
 		goto resubmit_urb;
 	}
 
-	while (pos <= urb->actual_length - MSG_HEADER_LEN) {
+	while (pos <= (int)(urb->actual_length - MSG_HEADER_LEN)) {
 		msg = urb->transfer_buffer + pos;
 
 		/* The Kvaser firmware can only read and write messages that
-- 
2.11.0

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

* [added to the 4.1 stable tree] can: kvaser_usb: ratelimit errors if incomplete messages are received
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (142 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: kvaser_usb: cancel urb on -EPIPE and -EPROTO Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: ems_usb: cancel urb on -EPIPE and -EPROTO Sasha Levin
                   ` (151 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jimmy Assarsson, Marc Kleine-Budde, Sasha Levin

From: Jimmy Assarsson <jimmyassarsson@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 8bd13bd522ff7dfa0eb371921aeb417155f7a3be ]

Avoid flooding the kernel log with "Formate error", if incomplete message
are received.

Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/can/usb/kvaser_usb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index faced1e1b3fa..b1df2628457d 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -603,8 +603,8 @@ static int kvaser_usb_wait_msg(const struct kvaser_usb *dev, u8 id,
 			}
 
 			if (pos + tmp->len > actual_len) {
-				dev_err(dev->udev->dev.parent,
-					"Format error\n");
+				dev_err_ratelimited(dev->udev->dev.parent,
+						    "Format error\n");
 				break;
 			}
 
@@ -1350,7 +1350,8 @@ static void kvaser_usb_read_bulk_callback(struct urb *urb)
 		}
 
 		if (pos + msg->len > urb->actual_length) {
-			dev_err(dev->udev->dev.parent, "Format error\n");
+			dev_err_ratelimited(dev->udev->dev.parent,
+					    "Format error\n");
 			break;
 		}
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] can: kvaser_usb: cancel urb on -EPIPE and -EPROTO
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (141 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: kvaser_usb: Fix comparison bug in kvaser_usb_read_bulk_callback() Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: kvaser_usb: ratelimit errors if incomplete messages are received Sasha Levin
                   ` (152 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Martin Kelly, Marc Kleine-Budde, Sasha Levin

From: Martin Kelly <mkelly@xevo.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 6aa8d5945502baf4687d80de59b7ac865e9e666b ]

In mcba_usb, we have observed that when you unplug the device, the driver will
endlessly resubmit failing URBs, which can cause CPU stalls. This issue
is fixed in mcba_usb by catching the codes seen on device disconnect
(-EPIPE and -EPROTO).

This driver also resubmits in the case of -EPIPE and -EPROTO, so fix it
in the same way.

Signed-off-by: Martin Kelly <mkelly@xevo.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/can/usb/kvaser_usb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index b1df2628457d..699fdaf19895 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -1323,6 +1323,8 @@ static void kvaser_usb_read_bulk_callback(struct urb *urb)
 	case 0:
 		break;
 	case -ENOENT:
+	case -EPIPE:
+	case -EPROTO:
 	case -ESHUTDOWN:
 		return;
 	default:
-- 
2.11.0

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

* [added to the 4.1 stable tree] can: esd_usb2: cancel urb on -EPIPE and -EPROTO
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (144 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: ems_usb: cancel urb on -EPIPE and -EPROTO Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: usb_8dev: " Sasha Levin
                   ` (149 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Martin Kelly, Marc Kleine-Budde, Sasha Levin

From: Martin Kelly <mkelly@xevo.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 7a31ced3de06e9878e4f9c3abe8f87d9344d8144 ]

In mcba_usb, we have observed that when you unplug the device, the driver will
endlessly resubmit failing URBs, which can cause CPU stalls. This issue
is fixed in mcba_usb by catching the codes seen on device disconnect
(-EPIPE and -EPROTO).

This driver also resubmits in the case of -EPIPE and -EPROTO, so fix it
in the same way.

Signed-off-by: Martin Kelly <mkelly@xevo.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/can/usb/esd_usb2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c
index 730a2bac124d..f413c0b7be23 100644
--- a/drivers/net/can/usb/esd_usb2.c
+++ b/drivers/net/can/usb/esd_usb2.c
@@ -396,6 +396,8 @@ static void esd_usb2_read_bulk_callback(struct urb *urb)
 		break;
 
 	case -ENOENT:
+	case -EPIPE:
+	case -EPROTO:
 	case -ESHUTDOWN:
 		return;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] can: ems_usb: cancel urb on -EPIPE and -EPROTO
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (143 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: kvaser_usb: ratelimit errors if incomplete messages are received Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: esd_usb2: " Sasha Levin
                   ` (150 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Martin Kelly, Marc Kleine-Budde, Sasha Levin

From: Martin Kelly <mkelly@xevo.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit bd352e1adfe0d02d3ea7c8e3fb19183dc317e679 ]

In mcba_usb, we have observed that when you unplug the device, the driver will
endlessly resubmit failing URBs, which can cause CPU stalls. This issue
is fixed in mcba_usb by catching the codes seen on device disconnect
(-EPIPE and -EPROTO).

This driver also resubmits in the case of -EPIPE and -EPROTO, so fix it
in the same way.

Signed-off-by: Martin Kelly <mkelly@xevo.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/can/usb/ems_usb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index 339b0c5ce60c..a5b92d8ff345 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -290,6 +290,8 @@ static void ems_usb_read_interrupt_callback(struct urb *urb)
 
 	case -ECONNRESET: /* unlink */
 	case -ENOENT:
+	case -EPIPE:
+	case -EPROTO:
 	case -ESHUTDOWN:
 		return;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] can: usb_8dev: cancel urb on -EPIPE and -EPROTO
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (145 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: esd_usb2: " Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] virtio: release virtio index when fail to device_register Sasha Levin
                   ` (148 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Martin Kelly, Marc Kleine-Budde, Sasha Levin

From: Martin Kelly <mkelly@xevo.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 12147edc434c9e4c7c2f5fee2e5519b2e5ac34ce ]

In mcba_usb, we have observed that when you unplug the device, the driver will
endlessly resubmit failing URBs, which can cause CPU stalls. This issue
is fixed in mcba_usb by catching the codes seen on device disconnect
(-EPIPE and -EPROTO).

This driver also resubmits in the case of -EPIPE and -EPROTO, so fix it
in the same way.

Signed-off-by: Martin Kelly <mkelly@xevo.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/can/usb/usb_8dev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/usb/usb_8dev.c b/drivers/net/can/usb/usb_8dev.c
index d60a9fcc9896..4f4a5be07634 100644
--- a/drivers/net/can/usb/usb_8dev.c
+++ b/drivers/net/can/usb/usb_8dev.c
@@ -528,6 +528,8 @@ static void usb_8dev_read_bulk_callback(struct urb *urb)
 		break;
 
 	case -ENOENT:
+	case -EPIPE:
+	case -EPROTO:
 	case -ESHUTDOWN:
 		return;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] virtio: release virtio index when fail to device_register
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (146 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] can: usb_8dev: " Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] isa: Prevent NULL dereference in isa_bus driver callbacks Sasha Levin
                   ` (147 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: weiping zhang, weiping zhang, Michael S . Tsirkin, Sasha Levin

From: weiping zhang <zwp10758@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e60ea67bb60459b95a50a156296041a13e0e380e ]

index can be reused by other virtio device.

Cc: stable@vger.kernel.org
Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/virtio/virtio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index b1877d73fa56..42a51c872754 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -323,6 +323,8 @@ int register_virtio_device(struct virtio_device *dev)
 	/* device_register() causes the bus infrastructure to look for a
 	 * matching driver. */
 	err = device_register(&dev->dev);
+	if (err)
+		ida_simple_remove(&virtio_index_ida, dev->index);
 out:
 	if (err)
 		add_status(dev, VIRTIO_CONFIG_S_FAILED);
-- 
2.11.0

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

* [added to the 4.1 stable tree] hv: kvp: Avoid reading past allocated blocks from KVP file
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (148 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] isa: Prevent NULL dereference in isa_bus driver callbacks Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ASN.1: check for error from ASN1_OP_END__ACT actions Sasha Levin
                   ` (145 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Paul Meyer, Long Li, KY Srinivasan, Greg Kroah-Hartman, Sasha Levin

From: Paul Meyer <Paul.Meyer@microsoft.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 297d6b6e56c2977fc504c61bbeeaa21296923f89 ]

While reading in more than one block (50) of KVP records, the allocation
goes per block, but the reads used the total number of allocated records
(without resetting the pointer/stream). This causes the records buffer to
overrun when the refresh reads more than one block over the previous
capacity (e.g. reading more than 100 KVP records whereas the in-memory
database was empty before).

Fix this by reading the correct number of KVP records from file each time.

Signed-off-by: Paul Meyer <Paul.Meyer@microsoft.com>
Signed-off-by: Long Li <longli@microsoft.com>
Cc: stable@vger.kernel.org
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 tools/hv/hv_kvp_daemon.c | 70 ++++++++++--------------------------------------
 1 file changed, 14 insertions(+), 56 deletions(-)

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 408bb076a234..db4a1eb5af7d 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -195,11 +195,14 @@ static void kvp_update_mem_state(int pool)
 	for (;;) {
 		readp = &record[records_read];
 		records_read += fread(readp, sizeof(struct kvp_record),
-					ENTRIES_PER_BLOCK * num_blocks,
-					filep);
+				ENTRIES_PER_BLOCK * num_blocks - records_read,
+				filep);
 
 		if (ferror(filep)) {
-			syslog(LOG_ERR, "Failed to read file, pool: %d", pool);
+			syslog(LOG_ERR,
+				"Failed to read file, pool: %d; error: %d %s",
+				 pool, errno, strerror(errno));
+			kvp_release_lock(pool);
 			exit(EXIT_FAILURE);
 		}
 
@@ -212,6 +215,7 @@ static void kvp_update_mem_state(int pool)
 
 			if (record == NULL) {
 				syslog(LOG_ERR, "malloc failed");
+				kvp_release_lock(pool);
 				exit(EXIT_FAILURE);
 			}
 			continue;
@@ -226,15 +230,11 @@ static void kvp_update_mem_state(int pool)
 	fclose(filep);
 	kvp_release_lock(pool);
 }
+
 static int kvp_file_init(void)
 {
 	int  fd;
-	FILE *filep;
-	size_t records_read;
 	char *fname;
-	struct kvp_record *record;
-	struct kvp_record *readp;
-	int num_blocks;
 	int i;
 	int alloc_unit = sizeof(struct kvp_record) * ENTRIES_PER_BLOCK;
 
@@ -248,61 +248,19 @@ static int kvp_file_init(void)
 
 	for (i = 0; i < KVP_POOL_COUNT; i++) {
 		fname = kvp_file_info[i].fname;
-		records_read = 0;
-		num_blocks = 1;
 		sprintf(fname, "%s/.kvp_pool_%d", KVP_CONFIG_LOC, i);
 		fd = open(fname, O_RDWR | O_CREAT | O_CLOEXEC, 0644 /* rw-r--r-- */);
 
 		if (fd == -1)
 			return 1;
 
-
-		filep = fopen(fname, "re");
-		if (!filep) {
-			close(fd);
-			return 1;
-		}
-
-		record = malloc(alloc_unit * num_blocks);
-		if (record == NULL) {
-			fclose(filep);
-			close(fd);
-			return 1;
-		}
-		for (;;) {
-			readp = &record[records_read];
-			records_read += fread(readp, sizeof(struct kvp_record),
-					ENTRIES_PER_BLOCK,
-					filep);
-
-			if (ferror(filep)) {
-				syslog(LOG_ERR, "Failed to read file, pool: %d",
-				       i);
-				exit(EXIT_FAILURE);
-			}
-
-			if (!feof(filep)) {
-				/*
-				 * We have more data to read.
-				 */
-				num_blocks++;
-				record = realloc(record, alloc_unit *
-						num_blocks);
-				if (record == NULL) {
-					fclose(filep);
-					close(fd);
-					return 1;
-				}
-				continue;
-			}
-			break;
-		}
 		kvp_file_info[i].fd = fd;
-		kvp_file_info[i].num_blocks = num_blocks;
-		kvp_file_info[i].records = record;
-		kvp_file_info[i].num_records = records_read;
-		fclose(filep);
-
+		kvp_file_info[i].num_blocks = 1;
+		kvp_file_info[i].records = malloc(alloc_unit);
+		if (kvp_file_info[i].records == NULL)
+			return 1;
+		kvp_file_info[i].num_records = 0;
+		kvp_update_mem_state(i);
 	}
 
 	return 0;
-- 
2.11.0

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

* [added to the 4.1 stable tree] isa: Prevent NULL dereference in isa_bus driver callbacks
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (147 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] virtio: release virtio index when fail to device_register Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] hv: kvp: Avoid reading past allocated blocks from KVP file Sasha Levin
                   ` (146 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: William Breathitt Gray, Greg Kroah-Hartman, Sasha Levin

From: William Breathitt Gray <vilhelm.gray@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 5a244727f428a06634f22bb890e78024ab0c89f3 ]

The isa_driver structure for an isa_bus device is stored in the device
platform_data member of the respective device structure. This
platform_data member may be reset to NULL if isa_driver match callback
for the device fails, indicating a device unsupported by the ISA driver.

This patch fixes a possible NULL pointer dereference if one of the
isa_driver callbacks to attempted for an unsupported device. This error
should not occur in practice since ISA devices are typically manually
configured and loaded by the users, but we may as well prevent this
error from popping up for the 0day testers.

Fixes: a5117ba7da37 ("[PATCH] Driver model: add ISA bus")
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: stable <stable@vger.kernel.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/base/isa.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/base/isa.c b/drivers/base/isa.c
index 91dba65d7264..901d8185309e 100644
--- a/drivers/base/isa.c
+++ b/drivers/base/isa.c
@@ -39,7 +39,7 @@ static int isa_bus_probe(struct device *dev)
 {
 	struct isa_driver *isa_driver = dev->platform_data;
 
-	if (isa_driver->probe)
+	if (isa_driver && isa_driver->probe)
 		return isa_driver->probe(dev, to_isa_dev(dev)->id);
 
 	return 0;
@@ -49,7 +49,7 @@ static int isa_bus_remove(struct device *dev)
 {
 	struct isa_driver *isa_driver = dev->platform_data;
 
-	if (isa_driver->remove)
+	if (isa_driver && isa_driver->remove)
 		return isa_driver->remove(dev, to_isa_dev(dev)->id);
 
 	return 0;
@@ -59,7 +59,7 @@ static void isa_bus_shutdown(struct device *dev)
 {
 	struct isa_driver *isa_driver = dev->platform_data;
 
-	if (isa_driver->shutdown)
+	if (isa_driver && isa_driver->shutdown)
 		isa_driver->shutdown(dev, to_isa_dev(dev)->id);
 }
 
@@ -67,7 +67,7 @@ static int isa_bus_suspend(struct device *dev, pm_message_t state)
 {
 	struct isa_driver *isa_driver = dev->platform_data;
 
-	if (isa_driver->suspend)
+	if (isa_driver && isa_driver->suspend)
 		return isa_driver->suspend(dev, to_isa_dev(dev)->id, state);
 
 	return 0;
@@ -77,7 +77,7 @@ static int isa_bus_resume(struct device *dev)
 {
 	struct isa_driver *isa_driver = dev->platform_data;
 
-	if (isa_driver->resume)
+	if (isa_driver && isa_driver->resume)
 		return isa_driver->resume(dev, to_isa_dev(dev)->id);
 
 	return 0;
-- 
2.11.0

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

* [added to the 4.1 stable tree] ASN.1: check for error from ASN1_OP_END__ACT actions
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (149 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] hv: kvp: Avoid reading past allocated blocks from KVP file Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] scsi: libsas: align sata_device's rps_resp on a cacheline Sasha Levin
                   ` (144 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Biggers, David Howells, Sasha Levin

From: Eric Biggers <ebiggers@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 81a7be2cd69b412ab6aeacfe5ebf1bb6e5bce955 ]

asn1_ber_decoder() was ignoring errors from actions associated with the
opcodes ASN1_OP_END_SEQ_ACT, ASN1_OP_END_SET_ACT,
ASN1_OP_END_SEQ_OF_ACT, and ASN1_OP_END_SET_OF_ACT.  In practice, this
meant the pkcs7_note_signed_info() action (since that was the only user
of those opcodes).  Fix it by checking for the error, just like the
decoder does for actions associated with the other opcodes.

This bug allowed users to leak slab memory by repeatedly trying to add a
specially crafted "pkcs7_test" key (requires CONFIG_PKCS7_TEST_KEY).

In theory, this bug could also be used to bypass module signature
verification, by providing a PKCS#7 message that is misparsed such that
a signature's ->authattrs do not contain its ->msgdigest.  But it
doesn't seem practical in normal cases, due to restrictions on the
format of the ->authattrs.

Fixes: 42d5ec27f873 ("X.509: Add an ASN.1 decoder")
Cc: <stable@vger.kernel.org> # v3.7+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 lib/asn1_decoder.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/asn1_decoder.c b/lib/asn1_decoder.c
index 3bb040e347ec..bbdfbcb912f3 100644
--- a/lib/asn1_decoder.c
+++ b/lib/asn1_decoder.c
@@ -421,6 +421,8 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder,
 			else
 				act = machine[pc + 1];
 			ret = actions[act](context, hdr, 0, data + tdp, len);
+			if (ret < 0)
+				return ret;
 		}
 		pc += asn1_op_lengths[op];
 		goto next_op;
-- 
2.11.0

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

* [added to the 4.1 stable tree] scsi: libsas: align sata_device's rps_resp on a cacheline
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (150 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ASN.1: check for error from ASN1_OP_END__ACT actions Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] X.509: reject invalid BIT STRING for subjectPublicKey Sasha Levin
                   ` (143 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Huacai Chen, Christoph Hellwig, Martin K . Petersen, Sasha Levin

From: Huacai Chen <chenhc@lemote.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit c2e8fbf908afd81ad502b567a6639598f92c9b9d ]

The rps_resp buffer in ata_device is a DMA target, but it isn't
explicitly cacheline aligned. Due to this, adjacent fields can be
overwritten with stale data from memory on non-coherent architectures.
As a result, the kernel is sometimes unable to communicate with an SATA
device behind a SAS expander.

Fix this by ensuring that the rps_resp buffer is cacheline aligned.

This issue is similar to that fixed by Commit 84bda12af31f93 ("libata:
align ap->sector_buf") and Commit 4ee34ea3a12396f35b26 ("libata: Align
ata_device's id on a cacheline").

Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 include/scsi/libsas.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index dae99d7d2bc0..706a7017885c 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -165,11 +165,11 @@ struct expander_device {
 
 struct sata_device {
 	unsigned int class;
-	struct smp_resp        rps_resp; /* report_phy_sata_resp */
 	u8     port_no;        /* port number, if this is a PM (Port) */
 
 	struct ata_port *ap;
 	struct ata_host ata_host;
+	struct smp_resp rps_resp ____cacheline_aligned; /* report_phy_sata_resp */
 	u8     fis[ATA_RESP_FIS_SIZE];
 };
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] x86/PCI: Make broadcom_postcore_init() check acpi_disabled
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (152 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] X.509: reject invalid BIT STRING for subjectPublicKey Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ALSA: seq: Remove spurious WARN_ON() at timer check Sasha Levin
                   ` (141 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Rafael J. Wysocki, Thomas Gleixner, Ingo Molnar, Sasha Levin

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit ddec3bdee05b06f1dda20ded003c3e10e4184cab ]

acpi_os_get_root_pointer() may return a valid address even if acpi_disabled
is set, but the host bridge information from the ACPI tables is not going
to be used in that case and the Broadcom host bridge initialization should
not be skipped then, So make broadcom_postcore_init() check acpi_disabled
too to avoid this issue.

Fixes: 6361d72b04d1 (x86/PCI: read Broadcom CNB20LE host bridge info before PCI scan)
Reported-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linux PCI <linux-pci@vger.kernel.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/3186627.pxZj1QbYNg@aspire.rjw.lan
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/x86/pci/broadcom_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/pci/broadcom_bus.c b/arch/x86/pci/broadcom_bus.c
index bb461cfd01ab..526536c81ddc 100644
--- a/arch/x86/pci/broadcom_bus.c
+++ b/arch/x86/pci/broadcom_bus.c
@@ -97,7 +97,7 @@ static int __init broadcom_postcore_init(void)
 	 * We should get host bridge information from ACPI unless the BIOS
 	 * doesn't support it.
 	 */
-	if (acpi_os_get_root_pointer())
+	if (!acpi_disabled && acpi_os_get_root_pointer())
 		return 0;
 #endif
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] X.509: reject invalid BIT STRING for subjectPublicKey
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (151 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] scsi: libsas: align sata_device's rps_resp on a cacheline Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] x86/PCI: Make broadcom_postcore_init() check acpi_disabled Sasha Levin
                   ` (142 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Biggers, David Howells, Sasha Levin

From: Eric Biggers <ebiggers@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 0f30cbea005bd3077bd98cd29277d7fc2699c1da ]

Adding a specially crafted X.509 certificate whose subjectPublicKey
ASN.1 value is zero-length caused x509_extract_key_data() to set the
public key size to SIZE_MAX, as it subtracted the nonexistent BIT STRING
metadata byte.  Then, x509_cert_parse() called kmemdup() with that bogus
size, triggering the WARN_ON_ONCE() in kmalloc_slab().

This appears to be harmless, but it still must be fixed since WARNs are
never supposed to be user-triggerable.

Fix it by updating x509_cert_parse() to validate that the value has a
BIT STRING metadata byte, and that the byte is 0 which indicates that
the number of bits in the bitstring is a multiple of 8.

It would be nice to handle the metadata byte in asn1_ber_decoder()
instead.  But that would be tricky because in the general case a BIT
STRING could be implicitly tagged, and/or could legitimately have a
length that is not a whole number of bytes.

Here was the WARN (cleaned up slightly):

    WARNING: CPU: 1 PID: 202 at mm/slab_common.c:971 kmalloc_slab+0x5d/0x70 mm/slab_common.c:971
    Modules linked in:
    CPU: 1 PID: 202 Comm: keyctl Tainted: G    B            4.14.0-09238-g1d3b78bbc6e9 #26
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-20171110_100015-anatol 04/01/2014
    task: ffff880033014180 task.stack: ffff8800305c8000
    Call Trace:
     __do_kmalloc mm/slab.c:3706 [inline]
     __kmalloc_track_caller+0x22/0x2e0 mm/slab.c:3726
     kmemdup+0x17/0x40 mm/util.c:118
     kmemdup include/linux/string.h:414 [inline]
     x509_cert_parse+0x2cb/0x620 crypto/asymmetric_keys/x509_cert_parser.c:106
     x509_key_preparse+0x61/0x750 crypto/asymmetric_keys/x509_public_key.c:174
     asymmetric_key_preparse+0xa4/0x150 crypto/asymmetric_keys/asymmetric_type.c:388
     key_create_or_update+0x4d4/0x10a0 security/keys/key.c:850
     SYSC_add_key security/keys/keyctl.c:122 [inline]
     SyS_add_key+0xe8/0x290 security/keys/keyctl.c:62
     entry_SYSCALL_64_fastpath+0x1f/0x96

Fixes: 42d5ec27f873 ("X.509: Add an ASN.1 decoder")
Cc: <stable@vger.kernel.org> # v3.7+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 crypto/asymmetric_keys/x509_cert_parser.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index 1995d6d962f5..2eac68e51433 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -399,6 +399,8 @@ int x509_extract_key_data(void *context, size_t hdrlen,
 	ctx->cert->pub->pkey_algo = PKEY_ALGO_RSA;
 
 	/* Discard the BIT STRING metadata */
+	if (vlen < 1 || *(const u8 *)value != 0)
+		return -EBADMSG;
 	ctx->key = value + 1;
 	ctx->key_size = vlen - 1;
 	return 0;
-- 
2.11.0

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

* [added to the 4.1 stable tree] ALSA: seq: Remove spurious WARN_ON() at timer check
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (153 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] x86/PCI: Make broadcom_postcore_init() check acpi_disabled Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ALSA: pcm: prevent UAF in snd_pcm_info Sasha Levin
                   ` (140 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Takashi Iwai, Sasha Levin

From: Takashi Iwai <tiwai@suse.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 43a3542870328601be02fcc9d27b09db467336ef ]

The use of snd_BUG_ON() in ALSA sequencer timer may lead to a spurious
WARN_ON() when a slave timer is deployed as its backend and a
corresponding master timer stops meanwhile.  The symptom was triggered
by syzkaller spontaneously.

Since the NULL timer is valid there, rip off snd_BUG_ON().

Reported-by: syzbot <syzkaller@googlegroups.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 sound/core/seq/seq_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c
index a2468f1101d1..0e6210000fa9 100644
--- a/sound/core/seq/seq_timer.c
+++ b/sound/core/seq/seq_timer.c
@@ -355,7 +355,7 @@ static int initialize_timer(struct snd_seq_timer *tmr)
 	unsigned long freq;
 
 	t = tmr->timeri->timer;
-	if (snd_BUG_ON(!t))
+	if (!t)
 		return -EINVAL;
 
 	freq = tmr->preferred_resolution;
-- 
2.11.0

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

* [added to the 4.1 stable tree] ALSA: pcm: prevent UAF in snd_pcm_info
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (154 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ALSA: seq: Remove spurious WARN_ON() at timer check Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ALSA: usb-audio: Fix out-of-bound error Sasha Levin
                   ` (139 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Robb Glasser, Nick Desaulniers, Takashi Iwai, Sasha Levin

From: Robb Glasser <rglasser@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 362bca57f5d78220f8b5907b875961af9436e229 ]

When the device descriptor is closed, the `substream->runtime` pointer
is freed. But another thread may be in the ioctl handler, case
SNDRV_CTL_IOCTL_PCM_INFO. This case calls snd_pcm_info_user() which
calls snd_pcm_info() which accesses the now freed `substream->runtime`.

Note: this fixes CVE-2017-0861

Signed-off-by: Robb Glasser <rglasser@google.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 sound/core/pcm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index f6e7fdd354de..7c60cb289719 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -149,7 +149,9 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
 				err = -ENXIO;
 				goto _error;
 			}
+			mutex_lock(&pcm->open_mutex);
 			err = snd_pcm_info_user(substream, info);
+			mutex_unlock(&pcm->open_mutex);
 		_error:
 			mutex_unlock(&register_mutex);
 			return err;
-- 
2.11.0

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

* [added to the 4.1 stable tree] ALSA: usb-audio: Add check return value for usb_string()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (156 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ALSA: usb-audio: Fix out-of-bound error Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] iommu/vt-d: Fix scatterlist offset handling Sasha Levin
                   ` (137 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jaejoong Kim, Takashi Iwai, Sasha Levin

From: Jaejoong Kim <climbbb.kim@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 89b89d121ffcf8d9546633b98ded9d18b8f75891 ]

snd_usb_copy_string_desc() returns zero if usb_string() fails.
In case of failure, we need to check the snd_usb_copy_string_desc()'s
return value and add an exception case

Signed-off-by: Jaejoong Kim <climbbb.kim@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 sound/usb/mixer.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 332cfeee4cb1..2ee449fbe55f 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -2100,13 +2100,14 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid,
 	if (len)
 		;
 	else if (nameid)
-		snd_usb_copy_string_desc(state, nameid, kctl->id.name,
+		len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
 					 sizeof(kctl->id.name));
-	else {
+	else
 		len = get_term_name(state, &state->oterm,
 				    kctl->id.name, sizeof(kctl->id.name), 0);
-		if (!len)
-			strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));
+
+	if (!len) {
+		strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));
 
 		if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR)
 			append_ctl_name(kctl, " Clock Source");
-- 
2.11.0

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

* [added to the 4.1 stable tree] ALSA: usb-audio: Fix out-of-bound error
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (155 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ALSA: pcm: prevent UAF in snd_pcm_info Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ALSA: usb-audio: Add check return value for usb_string() Sasha Levin
                   ` (138 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jaejoong Kim, Takashi Iwai, Sasha Levin

From: Jaejoong Kim <climbbb.kim@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 251552a2b0d454badc8f486e6d79100970c744b0 ]

The snd_usb_copy_string_desc() retrieves the usb string corresponding to
the index number through the usb_string(). The problem is that the
usb_string() returns the length of the string (>= 0) when successful, but
it can also return a negative value about the error case or status of
usb_control_msg().

If iClockSource is '0' as shown below, usb_string() will returns -EINVAL.
This will result in '0' being inserted into buf[-22], and the following
KASAN out-of-bound error message will be output.

AudioControl Interface Descriptor:
  bLength                 8
  bDescriptorType        36
  bDescriptorSubtype     10 (CLOCK_SOURCE)
  bClockID                1
  bmAttributes         0x07 Internal programmable Clock (synced to SOF)
  bmControls           0x07
  Clock Frequency Control (read/write)
  Clock Validity Control (read-only)
  bAssocTerminal          0
  iClockSource            0

To fix it, check usb_string()'return value and bail out.

==================================================================
BUG: KASAN: stack-out-of-bounds in parse_audio_unit+0x1327/0x1960 [snd_usb_audio]
Write of size 1 at addr ffff88007e66735a by task systemd-udevd/18376

CPU: 0 PID: 18376 Comm: systemd-udevd Not tainted 4.13.0+ #3
Hardware name: LG Electronics                   15N540-RFLGL/White Tip Mountain, BIOS 15N5
Call Trace:
dump_stack+0x63/0x8d
print_address_description+0x70/0x290
? parse_audio_unit+0x1327/0x1960 [snd_usb_audio]
kasan_report+0x265/0x350
__asan_store1+0x4a/0x50
parse_audio_unit+0x1327/0x1960 [snd_usb_audio]
? save_stack+0xb5/0xd0
? save_stack_trace+0x1b/0x20
? save_stack+0x46/0xd0
? kasan_kmalloc+0xad/0xe0
? kmem_cache_alloc_trace+0xff/0x230
? snd_usb_create_mixer+0xb0/0x4b0 [snd_usb_audio]
? usb_audio_probe+0x4de/0xf40 [snd_usb_audio]
? usb_probe_interface+0x1f5/0x440
? driver_probe_device+0x3ed/0x660
? build_feature_ctl+0xb10/0xb10 [snd_usb_audio]
? save_stack_trace+0x1b/0x20
? init_object+0x69/0xa0
? snd_usb_find_csint_desc+0xa8/0xf0 [snd_usb_audio]
snd_usb_mixer_controls+0x1dc/0x370 [snd_usb_audio]
? build_audio_procunit+0x890/0x890 [snd_usb_audio]
? snd_usb_create_mixer+0xb0/0x4b0 [snd_usb_audio]
? kmem_cache_alloc_trace+0xff/0x230
? usb_ifnum_to_if+0xbd/0xf0
snd_usb_create_mixer+0x25b/0x4b0 [snd_usb_audio]
? snd_usb_create_stream+0x255/0x2c0 [snd_usb_audio]
usb_audio_probe+0x4de/0xf40 [snd_usb_audio]
? snd_usb_autosuspend.part.7+0x30/0x30 [snd_usb_audio]
? __pm_runtime_idle+0x90/0x90
? kernfs_activate+0xa6/0xc0
? usb_match_one_id_intf+0xdc/0x130
? __pm_runtime_set_status+0x2d4/0x450
usb_probe_interface+0x1f5/0x440

Cc: <stable@vger.kernel.org>
Signed-off-by: Jaejoong Kim <climbbb.kim@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 sound/usb/mixer.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 3ebfaa527825..332cfeee4cb1 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -203,6 +203,10 @@ static int snd_usb_copy_string_desc(struct mixer_build *state,
 				    int index, char *buf, int maxlen)
 {
 	int len = usb_string(state->chip->dev, index, buf, maxlen - 1);
+
+	if (len < 0)
+		return 0;
+
 	buf[len] = 0;
 	return len;
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] kdb: Fix handling of kallsyms_symbol_next() return value
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (158 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] iommu/vt-d: Fix scatterlist offset handling Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] drm: extra printk() wrapper macros Sasha Levin
                   ` (135 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Daniel Thompson, Jason Wessel, Sasha Levin

From: Daniel Thompson <daniel.thompson@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit c07d35338081d107e57cf37572d8cc931a8e32e2 ]

kallsyms_symbol_next() returns a boolean (true on success). Currently
kdb_read() tests the return value with an inequality that
unconditionally evaluates to true.

This is fixed in the obvious way and, since the conditional branch is
supposed to be unreachable, we also add a WARN_ON().

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 kernel/debug/kdb/kdb_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index fc1ef736253c..77777d918676 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -349,7 +349,7 @@ static char *kdb_read(char *buffer, size_t bufsize)
 			}
 			kdb_printf("\n");
 			for (i = 0; i < count; i++) {
-				if (kallsyms_symbol_next(p_tmp, i) < 0)
+				if (WARN_ON(!kallsyms_symbol_next(p_tmp, i)))
 					break;
 				kdb_printf("%s ", p_tmp);
 				*(p_tmp + len) = '\0';
-- 
2.11.0

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

* [added to the 4.1 stable tree] iommu/vt-d: Fix scatterlist offset handling
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (157 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ALSA: usb-audio: Add check return value for usb_string() Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] kdb: Fix handling of kallsyms_symbol_next() return value Sasha Levin
                   ` (136 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Robin Murphy, Alex Williamson, Sasha Levin

From: Robin Murphy <robin.murphy@arm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 29a90b70893817e2f2bb3cea40a29f5308e21b21 ]

The intel-iommu DMA ops fail to correctly handle scatterlists where
sg->offset is greater than PAGE_SIZE - the IOVA allocation is computed
appropriately based on the page-aligned portion of the offset, but the
mapping is set up relative to sg->page, which means it fails to actually
cover the whole buffer (and in the worst case doesn't cover it at all):

    (sg->dma_address + sg->dma_len) ----+
    sg->dma_address ---------+          |
    iov_pfn------+           |          |
                 |           |          |
                 v           v          v
iova:   a        b        c        d        e        f
        |--------|--------|--------|--------|--------|
                          <...calculated....>
                 [_____mapped______]
pfn:    0        1        2        3        4        5
        |--------|--------|--------|--------|--------|
                 ^           ^          ^
                 |           |          |
    sg->page ----+           |          |
    sg->offset --------------+          |
    (sg->offset + sg->length) ----------+

As a result, the caller ends up overrunning the mapping into whatever
lies beyond, which usually goes badly:

[  429.645492] DMAR: DRHD: handling fault status reg 2
[  429.650847] DMAR: [DMA Write] Request device [02:00.4] fault addr f2682000 ...

Whilst this is a fairly rare occurrence, it can happen from the result
of intermediate scatterlist processing such as scatterwalk_ffwd() in the
crypto layer. Whilst that particular site could be fixed up, it still
seems worthwhile to bring intel-iommu in line with other DMA API
implementations in handling this robustly.

To that end, fix the intel_map_sg() path to line up the mapping
correctly (in units of MM pages rather than VT-d pages to match the
aligned_nrpages() calculation) regardless of the offset, and use
sg_phys() consistently for clarity.

Reported-by: Harsh Jain <Harsh@chelsio.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Reviewed by: Ashok Raj <ashok.raj@intel.com>
Tested by: Jacob Pan <jacob.jun.pan@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/iommu/intel-iommu.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 275f59071f56..9d05a711a2f4 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2018,10 +2018,12 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
 		uint64_t tmp;
 
 		if (!sg_res) {
+			unsigned int pgoff = sg->offset & ~PAGE_MASK;
+
 			sg_res = aligned_nrpages(sg->offset, sg->length);
-			sg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + sg->offset;
+			sg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + pgoff;
 			sg->dma_length = sg->length;
-			pteval = page_to_phys(sg_page(sg)) | prot;
+			pteval = (sg_phys(sg) - pgoff) | prot;
 			phys_pfn = pteval >> VTD_PAGE_SHIFT;
 		}
 
@@ -3324,7 +3326,7 @@ static int intel_nontranslate_map_sg(struct device *hddev,
 
 	for_each_sg(sglist, sg, nelems, i) {
 		BUG_ON(!sg_page(sg));
-		sg->dma_address = page_to_phys(sg_page(sg)) + sg->offset;
+		sg->dma_address = sg_phys(sg);
 		sg->dma_length = sg->length;
 	}
 	return nelems;
-- 
2.11.0

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

* [added to the 4.1 stable tree] drm: extra printk() wrapper macros
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (159 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] kdb: Fix handling of kallsyms_symbol_next() return value Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] media: dvb: i2c transfers over usb cannot be done from stack Sasha Levin
                   ` (134 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Dave Gordon, Tvrtko Ursulin, Sasha Levin

From: Dave Gordon <david.s.gordon@intel.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 30b0da8d556e65ff935a56cd82c05ba0516d3e4a ]

We had only DRM_INFO() and DRM_ERROR(), whereas the underlying printk()
provides several other useful intermediate levels such as NOTICE and
WARNING. So this patch fills out the set by providing both regular and
once-only macros for each of the levels INFO, NOTICE, and WARNING, using
a common underlying macro that does all the token-pasting.

DRM_ERROR is unchanged, as it's not just a printk wrapper.

v2:
    Fix whitespace, missing ## (Eric Engestrom)

Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Cc: dri-devel@lists.freedesktop.org
Acked-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 include/drm/drmP.h | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 62c40777c009..8aba0f72aae4 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -153,6 +153,26 @@ void drm_err(const char *format, ...);
 /** \name Macros to make printk easier */
 /*@{*/
 
+#define _DRM_PRINTK(once, level, fmt, ...)				\
+	do {								\
+		printk##once(KERN_##level "[" DRM_NAME "] " fmt,	\
+			     ##__VA_ARGS__);				\
+	} while (0)
+
+#define DRM_INFO(fmt, ...)						\
+	_DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
+#define DRM_NOTE(fmt, ...)						\
+	_DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
+#define DRM_WARN(fmt, ...)						\
+	_DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
+
+#define DRM_INFO_ONCE(fmt, ...)						\
+	_DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
+#define DRM_NOTE_ONCE(fmt, ...)						\
+	_DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
+#define DRM_WARN_ONCE(fmt, ...)						\
+	_DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
+
 /**
  * Error output.
  *
@@ -178,12 +198,6 @@ void drm_err(const char *format, ...);
 		drm_err(fmt, ##__VA_ARGS__);				\
 })
 
-#define DRM_INFO(fmt, ...)				\
-	printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
-
-#define DRM_INFO_ONCE(fmt, ...)				\
-	printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
-
 /**
  * Debug output.
  *
-- 
2.11.0

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

* [added to the 4.1 stable tree] arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (161 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] media: dvb: i2c transfers over usb cannot be done from stack Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] KVM: VMX: remove I/O port 0x80 bypass on Intel hosts Sasha Levin
                   ` (132 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Kristina Martsenko, Marc Zyngier, Christoffer Dall, Sasha Levin

From: Kristina Martsenko <kristina.martsenko@arm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 26aa7b3b1c0fb3f1a6176a0c1847204ef4355693 ]

VTTBR_BADDR_MASK is used to sanity check the size and alignment of the
VTTBR address. It seems to currently be off by one, thereby only
allowing up to 47-bit addresses (instead of 48-bit) and also
insufficiently checking the alignment. This patch fixes it.

As an example, with 4k pages, before this patch we have:

  PHYS_MASK_SHIFT = 48
  VTTBR_X = 37 - 24 = 13
  VTTBR_BADDR_SHIFT = 13 - 1 = 12
  VTTBR_BADDR_MASK = ((1 << 35) - 1) << 12 = 0x00007ffffffff000

Which is wrong, because the mask doesn't allow bit 47 of the VTTBR
address to be set, and only requires the address to be 12-bit (4k)
aligned, while it actually needs to be 13-bit (8k) aligned because we
concatenate two 4k tables.

With this patch, the mask becomes 0x0000ffffffffe000, which is what we
want.

Fixes: 0369f6a34b9f ("arm64: KVM: EL2 register definitions")
Cc: <stable@vger.kernel.org> # 3.11.x
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/arm64/include/asm/kvm_arm.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h
index ac6fafb95fe7..4b695bfbb7fd 100644
--- a/arch/arm64/include/asm/kvm_arm.h
+++ b/arch/arm64/include/asm/kvm_arm.h
@@ -162,8 +162,7 @@
 #define VTTBR_X		(37 - VTCR_EL2_T0SZ_40B)
 #endif
 
-#define VTTBR_BADDR_SHIFT (VTTBR_X - 1)
-#define VTTBR_BADDR_MASK  (((UL(1) << (PHYS_MASK_SHIFT - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT)
+#define VTTBR_BADDR_MASK  (((UL(1) << (PHYS_MASK_SHIFT - VTTBR_X)) - 1) << VTTBR_X)
 #define VTTBR_VMID_SHIFT  (UL(48))
 #define VTTBR_VMID_MASK	  (UL(0xFF) << VTTBR_VMID_SHIFT)
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] media: dvb: i2c transfers over usb cannot be done from stack
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (160 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] drm: extra printk() wrapper macros Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one Sasha Levin
                   ` (133 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Laurent Caumont, Sean Young, Mauro Carvalho Chehab, Sasha Levin

From: Laurent Caumont <lcaumont2@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit b4756707152700c96acdfe149cb1ca4cec306c7a ]

Since commit 29d2fef8be11 ("usb: catch attempts to submit urbs
with a vmalloc'd transfer buffer"), the AverMedia AverTV DVB-T
USB 2.0 (a800) fails to probe.

Cc: stable@vger.kernel.org
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/media/usb/dvb-usb/dibusb-common.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/dibusb-common.c b/drivers/media/usb/dvb-usb/dibusb-common.c
index ef3a8f75f82e..7b15aea2723d 100644
--- a/drivers/media/usb/dvb-usb/dibusb-common.c
+++ b/drivers/media/usb/dvb-usb/dibusb-common.c
@@ -179,8 +179,20 @@ EXPORT_SYMBOL(dibusb_i2c_algo);
 
 int dibusb_read_eeprom_byte(struct dvb_usb_device *d, u8 offs, u8 *val)
 {
-	u8 wbuf[1] = { offs };
-	return dibusb_i2c_msg(d, 0x50, wbuf, 1, val, 1);
+	u8 *buf;
+	int rc;
+
+	buf = kmalloc(2, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
+	buf[0] = offs;
+
+	rc = dibusb_i2c_msg(d, 0x50, &buf[0], 1, &buf[1], 1);
+	*val = buf[1];
+	kfree(buf);
+
+	return rc;
 }
 EXPORT_SYMBOL(dibusb_read_eeprom_byte);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] arm64: fpsimd: Prevent registers leaking from dead tasks
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (163 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] KVM: VMX: remove I/O port 0x80 bypass on Intel hosts Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] scsi: storvsc: Workaround for virtual DVD SCSI version Sasha Levin
                   ` (130 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Dave Martin, Will Deacon, Sasha Levin

From: Dave Martin <Dave.Martin@arm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 071b6d4a5d343046f253a5a8835d477d93992002 ]

Currently, loading of a task's fpsimd state into the CPU registers
is skipped if that task's state is already present in the registers
of that CPU.

However, the code relies on the struct fpsimd_state * (and by
extension struct task_struct *) to unambiguously identify a task.

There is a particular case in which this doesn't work reliably:
when a task exits, its task_struct may be recycled to describe a
new task.

Consider the following scenario:

 1) Task P loads its fpsimd state onto cpu C.
        per_cpu(fpsimd_last_state, C) := P;
        P->thread.fpsimd_state.cpu := C;

 2) Task X is scheduled onto C and loads its fpsimd state on C.
        per_cpu(fpsimd_last_state, C) := X;
        X->thread.fpsimd_state.cpu := C;

 3) X exits, causing X's task_struct to be freed.

 4) P forks a new child T, which obtains X's recycled task_struct.
	T == X.
	T->thread.fpsimd_state.cpu == C (inherited from P).

 5) T is scheduled on C.
	T's fpsimd state is not loaded, because
	per_cpu(fpsimd_last_state, C) == T (== X) &&
	T->thread.fpsimd_state.cpu == C.

        (This is the check performed by fpsimd_thread_switch().)

So, T gets X's registers because the last registers loaded onto C
were those of X, in (2).

This patch fixes the problem by ensuring that the sched-in check
fails in (5): fpsimd_flush_task_state(T) is called when T is
forked, so that T->thread.fpsimd_state.cpu == C cannot be true.
This relies on the fact that T is not schedulable until after
copy_thread() completes.

Once T's fpsimd state has been loaded on some CPU C there may still
be other cpus D for which per_cpu(fpsimd_last_state, D) ==
&X->thread.fpsimd_state.  But D is necessarily != C in this case,
and the check in (5) must fail.

An alternative fix would be to do refcounting on task_struct.  This
would result in each CPU holding a reference to the last task whose
fpsimd state was loaded there.  It's not clear whether this is
preferable, and it involves higher overhead than the fix proposed
in this patch.  It would also move all the task_struct freeing
work into the context switch critical section, or otherwise some
deferred cleanup mechanism would need to be introduced, neither of
which seems obviously justified.

Cc: <stable@vger.kernel.org>
Fixes: 005f78cd8849 ("arm64: defer reloading a task's FPSIMD state to userland resume")
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
[will: word-smithed the comment so it makes more sense]
Signed-off-by: Will Deacon <will.deacon@arm.com>

Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/arm64/kernel/process.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index c6b1f3b96f45..a838d628cff7 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -258,6 +258,15 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start,
 
 	memset(&p->thread.cpu_context, 0, sizeof(struct cpu_context));
 
+	/*
+	 * In case p was allocated the same task_struct pointer as some
+	 * other recently-exited task, make sure p is disassociated from
+	 * any cpu that may have run that now-exited task recently.
+	 * Otherwise we could erroneously skip reloading the FPSIMD
+	 * registers for p.
+	 */
+	fpsimd_flush_task_state(p);
+
 	if (likely(!(p->flags & PF_KTHREAD))) {
 		*childregs = *current_pt_regs();
 		childregs->regs[0] = 0;
-- 
2.11.0

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

* [added to the 4.1 stable tree] KVM: VMX: remove I/O port 0x80 bypass on Intel hosts
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (162 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] arm64: fpsimd: Prevent registers leaking from dead tasks Sasha Levin
                   ` (131 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Andrew Honig, Jim Mattson, Radim Krčmář, Sasha Levin

From: Andrew Honig <ahonig@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit d59d51f088014f25c2562de59b9abff4f42a7468 ]

This fixes CVE-2017-1000407.

KVM allows guests to directly access I/O port 0x80 on Intel hosts.  If
the guest floods this port with writes it generates exceptions and
instability in the host kernel, leading to a crash.  With this change
guest writes to port 0x80 on Intel will behave the same as they
currently behave on AMD systems.

Prevent the flooding by removing the code that sets port 0x80 as a
passthrough port.  This is essentially the same as upstream patch
99f85a28a78e96d28907fe036e1671a218fee597, except that patch was
for AMD chipsets and this patch is for Intel.

Signed-off-by: Andrew Honig <ahonig@google.com>
Signed-off-by: Jim Mattson <jmattson@google.com>
Fixes: fdef3ad1b386 ("KVM: VMX: Enable io bitmaps to avoid IO port 0x80 VMEXITs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/x86/kvm/vmx.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 50e0c4c6f69a..ffee8b35eeb3 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6075,12 +6075,7 @@ static __init int hardware_setup(void)
 	memset(vmx_vmread_bitmap, 0xff, PAGE_SIZE);
 	memset(vmx_vmwrite_bitmap, 0xff, PAGE_SIZE);
 
-	/*
-	 * Allow direct access to the PC debug port (it is often used for I/O
-	 * delays, but the vmexits simply slow things down).
-	 */
 	memset(vmx_io_bitmap_a, 0xff, PAGE_SIZE);
-	clear_bit(0x80, vmx_io_bitmap_a);
 
 	memset(vmx_io_bitmap_b, 0xff, PAGE_SIZE);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] scsi: storvsc: Workaround for virtual DVD SCSI version
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (164 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] arm64: fpsimd: Prevent registers leaking from dead tasks Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] vti6: Don't report path MTU below IPV6_MIN_MTU Sasha Levin
                   ` (129 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Stephen Hemminger, Stephen Hemminger, Martin K . Petersen, Sasha Levin

From: Stephen Hemminger <stephen@networkplumber.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f1c635b439a5c01776fe3a25b1e2dc546ea82e6f ]

Hyper-V host emulation of SCSI for virtual DVD device reports SCSI
version 0 (UNKNOWN) but is still capable of supporting REPORTLUN.

Without this patch, a GEN2 Linux guest on Hyper-V will not boot 4.11
successfully with virtual DVD ROM device. What happens is that the SCSI
scan process falls back to doing sequential probing by INQUIRY.  But the
storvsc driver has a previous workaround that masks/blocks all errors
reports from INQUIRY (or MODE_SENSE) commands.  This workaround causes
the scan to then populate a full set of bogus LUN's on the target and
then sends kernel spinning off into a death spiral doing block reads on
the non-existent LUNs.

By setting the correct blacklist flags, the target with the DVD device
is scanned with REPORTLUN and that works correctly.

Patch needs to go in current 4.11, it is safe but not necessary in older
kernels.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/scsi/storvsc_drv.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 51a0cc047b5f..e4b103d5d289 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -325,8 +325,6 @@ MODULE_PARM_DESC(vcpus_per_sub_channel, "Ratio of VCPUs to subchannels");
  */
 static int storvsc_timeout = 180;
 
-static int msft_blist_flags = BLIST_TRY_VPD_PAGES;
-
 
 static void storvsc_on_channel_callback(void *context);
 
@@ -1416,6 +1414,22 @@ static int storvsc_do_io(struct hv_device *device,
 	return ret;
 }
 
+static int storvsc_device_alloc(struct scsi_device *sdevice)
+{
+	/*
+	 * Set blist flag to permit the reading of the VPD pages even when
+	 * the target may claim SPC-2 compliance. MSFT targets currently
+	 * claim SPC-2 compliance while they implement post SPC-2 features.
+	 * With this flag we can correctly handle WRITE_SAME_16 issues.
+	 *
+	 * Hypervisor reports SCSI_UNKNOWN type for DVD ROM device but
+	 * still supports REPORT LUN.
+	 */
+	sdevice->sdev_bflags = BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES;
+
+	return 0;
+}
+
 static int storvsc_device_configure(struct scsi_device *sdevice)
 {
 
@@ -1428,14 +1442,6 @@ static int storvsc_device_configure(struct scsi_device *sdevice)
 	sdevice->no_write_same = 1;
 
 	/*
-	 * Add blist flags to permit the reading of the VPD pages even when
-	 * the target may claim SPC-2 compliance. MSFT targets currently
-	 * claim SPC-2 compliance while they implement post SPC-2 features.
-	 * With this patch we can correctly handle WRITE_SAME_16 issues.
-	 */
-	sdevice->sdev_bflags |= msft_blist_flags;
-
-	/*
 	 * If the host is WIN8 or WIN8 R2, claim conformance to SPC-3
 	 * if the device is a MSFT virtual device.
 	 */
@@ -1722,6 +1728,7 @@ static struct scsi_host_template scsi_driver = {
 	.eh_host_reset_handler =	storvsc_host_reset_handler,
 	.proc_name =		"storvsc_host",
 	.eh_timed_out =		storvsc_eh_timed_out,
+	.slave_alloc =		storvsc_device_alloc,
 	.slave_configure =	storvsc_device_configure,
 	.cmd_per_lun =		255,
 	.this_id =		-1,
-- 
2.11.0

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

* [added to the 4.1 stable tree] vti6: Don't report path MTU below IPV6_MIN_MTU.
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (165 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] scsi: storvsc: Workaround for virtual DVD SCSI version Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ARM: OMAP2+: gpmc-onenand: propagate error on initialization failure Sasha Levin
                   ` (128 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Steffen Klassert, Sasha Levin

From: Steffen Klassert <steffen.klassert@secunet.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e3dc847a5f85b43ee2bfc8eae407a7e383483228 ]

In vti6_xmit(), the check for IPV6_MIN_MTU before we
send a ICMPV6_PKT_TOOBIG message is missing. So we might
report a PMTU below 1280. Fix this by adding the required
check.

Fixes: ccd740cbc6e ("vti6: Add pmtu handling to vti6_xmit.")
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv6/ip6_vti.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index afa1741efdb0..c460e653b6a5 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -474,11 +474,15 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
 	if (!skb->ignore_df && skb->len > mtu) {
 		skb_dst(skb)->ops->update_pmtu(dst, NULL, skb, mtu);
 
-		if (skb->protocol == htons(ETH_P_IPV6))
+		if (skb->protocol == htons(ETH_P_IPV6)) {
+			if (mtu < IPV6_MIN_MTU)
+				mtu = IPV6_MIN_MTU;
+
 			icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
-		else
+		} else {
 			icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
 				  htonl(mtu));
+		}
 
 		return -EMSGSIZE;
 	}
-- 
2.11.0

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

* [added to the 4.1 stable tree] ARM: OMAP2+: gpmc-onenand: propagate error on initialization failure
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (166 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] vti6: Don't report path MTU below IPV6_MIN_MTU Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] module: set __jump_table alignment to 8 Sasha Levin
                   ` (127 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Ladislav Michl, Tony Lindgren, Sasha Levin

From: Ladislav Michl <ladis@linux-mips.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 7807e086a2d1f69cc1a57958cac04fea79fc2112 ]

gpmc_probe_onenand_child returns success even on gpmc_onenand_init
failure. Fix that.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Acked-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/arm/mach-omap2/gpmc-onenand.c | 10 ++++++----
 drivers/memory/omap-gpmc.c         |  4 +---
 include/linux/omap-gpmc.h          |  5 +++--
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc-onenand.c b/arch/arm/mach-omap2/gpmc-onenand.c
index f899e77ff5e6..a9e7733f3c70 100644
--- a/arch/arm/mach-omap2/gpmc-onenand.c
+++ b/arch/arm/mach-omap2/gpmc-onenand.c
@@ -363,7 +363,7 @@ static int gpmc_onenand_setup(void __iomem *onenand_base, int *freq_ptr)
 	return ret;
 }
 
-void gpmc_onenand_init(struct omap_onenand_platform_data *_onenand_data)
+int gpmc_onenand_init(struct omap_onenand_platform_data *_onenand_data)
 {
 	int err;
 	struct device *dev = &gpmc_onenand_device.dev;
@@ -389,15 +389,17 @@ void gpmc_onenand_init(struct omap_onenand_platform_data *_onenand_data)
 	if (err < 0) {
 		dev_err(dev, "Cannot request GPMC CS %d, error %d\n",
 			gpmc_onenand_data->cs, err);
-		return;
+		return err;
 	}
 
 	gpmc_onenand_resource.end = gpmc_onenand_resource.start +
 							ONENAND_IO_SIZE - 1;
 
-	if (platform_device_register(&gpmc_onenand_device) < 0) {
+	err = platform_device_register(&gpmc_onenand_device);
+	if (err) {
 		dev_err(dev, "Unable to register OneNAND device\n");
 		gpmc_cs_free(gpmc_onenand_data->cs);
-		return;
 	}
+
+	return err;
 }
diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index 2c51acce4b34..fedb19d1516b 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -1892,9 +1892,7 @@ static int gpmc_probe_onenand_child(struct platform_device *pdev,
 	if (!of_property_read_u32(child, "dma-channel", &val))
 		gpmc_onenand_data->dma_channel = val;
 
-	gpmc_onenand_init(gpmc_onenand_data);
-
-	return 0;
+	return gpmc_onenand_init(gpmc_onenand_data);
 }
 #else
 static int gpmc_probe_onenand_child(struct platform_device *pdev,
diff --git a/include/linux/omap-gpmc.h b/include/linux/omap-gpmc.h
index 7dee00143afd..c201e31e9d7e 100644
--- a/include/linux/omap-gpmc.h
+++ b/include/linux/omap-gpmc.h
@@ -191,10 +191,11 @@ static inline int gpmc_nand_init(struct omap_nand_platform_data *d,
 #endif
 
 #if IS_ENABLED(CONFIG_MTD_ONENAND_OMAP2)
-extern void gpmc_onenand_init(struct omap_onenand_platform_data *d);
+extern int gpmc_onenand_init(struct omap_onenand_platform_data *d);
 #else
 #define board_onenand_data	NULL
-static inline void gpmc_onenand_init(struct omap_onenand_platform_data *d)
+static inline int gpmc_onenand_init(struct omap_onenand_platform_data *d)
 {
+	return 0;
 }
 #endif
-- 
2.11.0

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

* [added to the 4.1 stable tree] module: set __jump_table alignment to 8
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (167 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] ARM: OMAP2+: gpmc-onenand: propagate error on initialization failure Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] selftest/powerpc: Fix false failures for skipped tests Sasha Levin
                   ` (126 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David Daney, Steven Rostedt, Sasha Levin

From: David Daney <david.daney@cavium.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit ab42632156becd35d3884ee5c14da2bedbf3149a ]

For powerpc the __jump_table section in modules is not aligned, this
causes a WARN_ON() splat when loading a module containing a __jump_table.

Strict alignment became necessary with commit 3821fd35b58d
("jump_label: Reduce the size of struct static_key"), currently in
linux-next, which uses the two least significant bits of pointers to
__jump_table elements.

Fix by forcing __jump_table to 8, which is the same alignment used for
this section in the kernel proper.

Link: http://lkml.kernel.org/r/20170301220453.4756-1-david.daney@cavium.com

Reviewed-by: Jason Baron <jbaron@akamai.com>
Acked-by: Jessica Yu <jeyu@redhat.com>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Tested-by: Sachin Sant <sachinp@linux.vnet.ibm.com>
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 scripts/module-common.lds | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/module-common.lds b/scripts/module-common.lds
index 73a2c7da0e55..53234e85192a 100644
--- a/scripts/module-common.lds
+++ b/scripts/module-common.lds
@@ -19,4 +19,6 @@ SECTIONS {
 
 	. = ALIGN(8);
 	.init_array		0 : { *(SORT(.init_array.*)) *(.init_array) }
+
+	__jump_table		0 : ALIGN(8) { KEEP(*(__jump_table)) }
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] selftest/powerpc: Fix false failures for skipped tests
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (168 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] module: set __jump_table alignment to 8 Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] libata: drop WARN from protocol error in ata_sff_qc_issue() Sasha Levin
                   ` (125 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Sachin Sant, Michael Ellerman, Sasha Levin

From: Sachin Sant <sachinp@linux.vnet.ibm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit a6d8a21596df041f36f4c2ccc260c459e3e851f1 ]

Tests under alignment subdirectory are skipped when executed on previous
generation hardware, but harness still marks them as failed.

  test: test_copy_unaligned
  tags: git_version:unknown
  [SKIP] Test skipped on line 26
  skip: test_copy_unaligned
  selftests: copy_unaligned [FAIL]

The MAGIC_SKIP_RETURN_VALUE value assigned to rc variable is retained till
the program exit which causes the test to be marked as failed.

This patch resets the value before returning to the main() routine.
With this patch the test o/p is as follows:

  test: test_copy_unaligned
  tags: git_version:unknown
  [SKIP] Test skipped on line 26
  skip: test_copy_unaligned
  selftests: copy_unaligned [PASS]

Signed-off-by: Sachin Sant <sachinp@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 tools/testing/selftests/powerpc/harness.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/powerpc/harness.c b/tools/testing/selftests/powerpc/harness.c
index f7997affd143..f45cee80c58b 100644
--- a/tools/testing/selftests/powerpc/harness.c
+++ b/tools/testing/selftests/powerpc/harness.c
@@ -109,9 +109,11 @@ int test_harness(int (test_function)(void), char *name)
 
 	rc = run_test(test_function, name);
 
-	if (rc == MAGIC_SKIP_RETURN_VALUE)
+	if (rc == MAGIC_SKIP_RETURN_VALUE) {
 		test_skip(name);
-	else
+		/* so that skipped test is not marked as failed */
+		rc = 0;
+	} else
 		test_finish(name, rc);
 
 	return rc;
-- 
2.11.0

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

* [added to the 4.1 stable tree] libata: drop WARN from protocol error in ata_sff_qc_issue()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (169 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] selftest/powerpc: Fix false failures for skipped tests Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: gadget: configs: plug memory leak Sasha Levin
                   ` (124 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Tejun Heo, Sasha Levin

From: Tejun Heo <tj@kernel.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 0580b762a4d6b70817476b90042813f8573283fa ]

ata_sff_qc_issue() expects upper layers to never issue commands on a
command protocol that it doesn't implement.  While the assumption
holds fine with the usual IO path, nothing filters based on the
command protocol in the passthrough path (which was added later),
allowing the warning to be tripped with a passthrough command with the
right (well, wrong) protocol.

Failing with AC_ERR_SYSTEM is the right thing to do anyway.  Remove
the unnecessary WARN.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Link: http://lkml.kernel.org/r/CACT4Y+bXkvevNZU8uP6X0QVqsj6wNoUA_1exfTSOzc+SmUtMOA@mail.gmail.com
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/ata/libata-sff.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 7dbba387d12a..18de4c457068 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1480,7 +1480,6 @@ unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc)
 		break;
 
 	default:
-		WARN_ON_ONCE(1);
 		return AC_ERR_SYSTEM;
 	}
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] USB: gadgetfs: Fix a potential memory leak in 'dev_config()'
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (171 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: gadget: configs: plug memory leak Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] scsi: lpfc: Fix crash during Hardware error recovery on SLI3 adapters Sasha Levin
                   ` (122 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Christophe JAILLET, Felipe Balbi, Sasha Levin

From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit b6e7aeeaf235901c42ec35de4633c7c69501d303 ]

'kbuf' is allocated just a few lines above using 'memdup_user()'.
If the 'if (dev->buf)' test fails, this memory is never released.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/gadget/legacy/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index 63d71400dcaf..ada2a4f5a774 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1834,8 +1834,10 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
 
 	spin_lock_irq (&dev->lock);
 	value = -EINVAL;
-	if (dev->buf)
+	if (dev->buf) {
+		kfree(kbuf);
 		goto fail;
+	}
 	dev->buf = kbuf;
 
 	/* full or low speed config */
-- 
2.11.0

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

* [added to the 4.1 stable tree] usb: gadget: configs: plug memory leak
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (170 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] libata: drop WARN from protocol error in ata_sff_qc_issue() Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] USB: gadgetfs: Fix a potential memory leak in 'dev_config()' Sasha Levin
                   ` (123 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: John Keeping, Felipe Balbi, Sasha Levin

From: John Keeping <john@metanate.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 38355b2a44776c25b0f2ad466e8c51bb805b3032 ]

When binding a gadget to a device, "name" is stored in gi->udc_name, but
this does not happen when unregistering and the string is leaked.

Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/gadget/configfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 0495c94a23d7..23330697aff2 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -266,6 +266,7 @@ static ssize_t gadget_dev_desc_UDC_store(struct gadget_info *gi,
 		ret = unregister_gadget(gi);
 		if (ret)
 			goto err;
+		kfree(name);
 	} else {
 		if (gi->udc_name) {
 			ret = -EBUSY;
-- 
2.11.0

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

* [added to the 4.1 stable tree] scsi: lpfc: Fix crash during Hardware error recovery on SLI3 adapters
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (172 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] USB: gadgetfs: Fix a potential memory leak in 'dev_config()' Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] workqueue: trigger WARN if queue_delayed_work() is called with NULL @wq Sasha Levin
                   ` (121 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: James Smart, Dick Kennedy, James Smart, Martin K . Petersen, Sasha Levin

From: James Smart <jsmart2021@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 5d181531bc6169e19a02a27d202cf0e982db9d0e ]

if REG_VPI fails, the driver was incorrectly issuing INIT_VFI
(a SLI4 command) on a SLI3 adapter.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/scsi/lpfc/lpfc_els.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 4da8963315c7..30f2fe9ba766 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -7286,11 +7286,17 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 			spin_lock_irq(shost->host_lock);
 			vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
 			spin_unlock_irq(shost->host_lock);
-			if (vport->port_type == LPFC_PHYSICAL_PORT
-				&& !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG))
-				lpfc_issue_init_vfi(vport);
-			else
+			if (mb->mbxStatus == MBX_NOT_FINISHED)
+				break;
+			if ((vport->port_type == LPFC_PHYSICAL_PORT) &&
+			    !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG)) {
+				if (phba->sli_rev == LPFC_SLI_REV4)
+					lpfc_issue_init_vfi(vport);
+				else
+					lpfc_initial_flogi(vport);
+			} else {
 				lpfc_initial_fdisc(vport);
+			}
 			break;
 		}
 	} else {
-- 
2.11.0

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

* [added to the 4.1 stable tree] workqueue: trigger WARN if queue_delayed_work() is called with NULL @wq
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (173 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] scsi: lpfc: Fix crash during Hardware error recovery on SLI3 adapters Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] KVM: nVMX: reset nested_run_pending if the vCPU is going to be reset Sasha Levin
                   ` (120 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Tejun Heo, Sasha Levin

From: Tejun Heo <tj@kernel.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 637fdbae60d6cb9f6e963c1079d7e0445c86ff7d ]

If queue_delayed_work() gets called with NULL @wq, the kernel will
oops asynchronuosly on timer expiration which isn't too helpful in
tracking down the offender.  This actually happened with smc.

__queue_delayed_work() already does several input sanity checks
synchronously.  Add NULL @wq check.

Reported-by: Dave Jones <davej@codemonkey.org.uk>
Link: http://lkml.kernel.org/r/20170227171439.jshx3qplflyrgcv7@codemonkey.org.uk
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 kernel/workqueue.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 791f6ebc84a3..376db986db9b 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1484,6 +1484,7 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,
 	struct timer_list *timer = &dwork->timer;
 	struct work_struct *work = &dwork->work;
 
+	WARN_ON_ONCE(!wq);
 	WARN_ON_ONCE(timer->function != delayed_work_timer_fn ||
 		     timer->data != (unsigned long)dwork);
 	WARN_ON_ONCE(timer_pending(timer));
-- 
2.11.0

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

* [added to the 4.1 stable tree] KVM: nVMX: reset nested_run_pending if the vCPU is going to be reset
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (174 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] workqueue: trigger WARN if queue_delayed_work() is called with NULL @wq Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] irqchip/crossbar: Fix incorrect type of register size Sasha Levin
                   ` (119 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Wanpeng Li, Radim Krčmář, Sasha Levin

From: Wanpeng Li <wanpeng.li@hotmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 2f707d97982286b307ef2a9b034e19aabc1abb56 ]

Reported by syzkaller:

    WARNING: CPU: 1 PID: 27742 at arch/x86/kvm/vmx.c:11029
    nested_vmx_vmexit+0x5c35/0x74d0 arch/x86/kvm/vmx.c:11029
    CPU: 1 PID: 27742 Comm: a.out Not tainted 4.10.0+ #229
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
    Call Trace:
     __dump_stack lib/dump_stack.c:15 [inline]
     dump_stack+0x2ee/0x3ef lib/dump_stack.c:51
     panic+0x1fb/0x412 kernel/panic.c:179
     __warn+0x1c4/0x1e0 kernel/panic.c:540
     warn_slowpath_null+0x2c/0x40 kernel/panic.c:583
     nested_vmx_vmexit+0x5c35/0x74d0 arch/x86/kvm/vmx.c:11029
     vmx_leave_nested arch/x86/kvm/vmx.c:11136 [inline]
     vmx_set_msr+0x1565/0x1910 arch/x86/kvm/vmx.c:3324
     kvm_set_msr+0xd4/0x170 arch/x86/kvm/x86.c:1099
     do_set_msr+0x11e/0x190 arch/x86/kvm/x86.c:1128
     __msr_io arch/x86/kvm/x86.c:2577 [inline]
     msr_io+0x24b/0x450 arch/x86/kvm/x86.c:2614
     kvm_arch_vcpu_ioctl+0x35b/0x46a0 arch/x86/kvm/x86.c:3497
     kvm_vcpu_ioctl+0x232/0x1120 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2721
     vfs_ioctl fs/ioctl.c:43 [inline]
     do_vfs_ioctl+0x1bf/0x1790 fs/ioctl.c:683
     SYSC_ioctl fs/ioctl.c:698 [inline]
     SyS_ioctl+0x8f/0xc0 fs/ioctl.c:689
     entry_SYSCALL_64_fastpath+0x1f/0xc2

The syzkaller folks reported a nested_run_pending warning during userspace
clear VMX capability which is exposed to L1 before.

The warning gets thrown while doing

(*(uint32_t*)0x20aecfe8 = (uint32_t)0x1);
(*(uint32_t*)0x20aecfec = (uint32_t)0x0);
(*(uint32_t*)0x20aecff0 = (uint32_t)0x3a);
(*(uint32_t*)0x20aecff4 = (uint32_t)0x0);
(*(uint64_t*)0x20aecff8 = (uint64_t)0x0);
r[29] = syscall(__NR_ioctl, r[4], 0x4008ae89ul,
		0x20aecfe8ul, 0, 0, 0, 0, 0, 0);

i.e. KVM_SET_MSR ioctl with

struct kvm_msrs {
	.nmsrs = 1,
		.pad = 0,
		.entries = {
			{.index = MSR_IA32_FEATURE_CONTROL,
			 .reserved = 0,
			 .data = 0}
		}
}

The VMLANCH/VMRESUME emulation should be stopped since the CPU is going to
reset here. This patch resets the nested_run_pending since the CPU is going
to be reset hence there should be nothing pending.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Suggested-by: Radim Krčmář <rkrcmar@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/x86/kvm/vmx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ffee8b35eeb3..84f2825f19b5 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -10135,8 +10135,10 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason,
  */
 static void vmx_leave_nested(struct kvm_vcpu *vcpu)
 {
-	if (is_guest_mode(vcpu))
+	if (is_guest_mode(vcpu)) {
+		to_vmx(vcpu)->nested.nested_run_pending = 0;
 		nested_vmx_vmexit(vcpu, -1, 0, 0);
+	}
 	free_nested(to_vmx(vcpu));
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] irqchip/crossbar: Fix incorrect type of register size
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (175 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] KVM: nVMX: reset nested_run_pending if the vCPU is going to be reset Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:00 ` [added to the 4.1 stable tree] arm: KVM: Survive unknown traps from guests Sasha Levin
                   ` (118 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Franck Demathieu, Marc Zyngier, Sasha Levin

From: Franck Demathieu <fdemathieu@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 4b9de5da7e120c7f02395da729f0ec77ce7a6044 ]

The 'size' variable is unsigned according to the dt-bindings.
As this variable is used as integer in other places, create a new variable
that allows to fix the following sparse issue (-Wtypesign):

  drivers/irqchip/irq-crossbar.c:279:52: warning: incorrect type in argument 3 (different signedness)
  drivers/irqchip/irq-crossbar.c:279:52:    expected unsigned int [usertype] *out_value
  drivers/irqchip/irq-crossbar.c:279:52:    got int *<noident>

Signed-off-by: Franck Demathieu <fdemathieu@gmail.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/irqchip/irq-crossbar.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-crossbar.c b/drivers/irqchip/irq-crossbar.c
index 2f7dffaae93a..5ba30449ee53 100644
--- a/drivers/irqchip/irq-crossbar.c
+++ b/drivers/irqchip/irq-crossbar.c
@@ -194,7 +194,7 @@ static const struct irq_domain_ops crossbar_domain_ops = {
 static int __init crossbar_of_init(struct device_node *node)
 {
 	int i, size, reserved = 0;
-	u32 max = 0, entry;
+	u32 max = 0, entry, reg_size;
 	const __be32 *irqsr;
 	int ret = -ENOMEM;
 
@@ -271,9 +271,9 @@ static int __init crossbar_of_init(struct device_node *node)
 	if (!cb->register_offsets)
 		goto err_irq_map;
 
-	of_property_read_u32(node, "ti,reg-size", &size);
+	of_property_read_u32(node, "ti,reg-size", &reg_size);
 
-	switch (size) {
+	switch (reg_size) {
 	case 1:
 		cb->write = crossbar_writeb;
 		break;
@@ -299,7 +299,7 @@ static int __init crossbar_of_init(struct device_node *node)
 			continue;
 
 		cb->register_offsets[i] = reserved;
-		reserved += size;
+		reserved += reg_size;
 	}
 
 	of_property_read_u32(node, "ti,irqs-safe-map", &cb->safe_map);
-- 
2.11.0

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

* [added to the 4.1 stable tree] arm: KVM: Survive unknown traps from guests
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (176 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] irqchip/crossbar: Fix incorrect type of register size Sasha Levin
@ 2018-01-18 21:00 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] spi_ks8995: fix "BUG: key accdaa28 not in .data!" Sasha Levin
                   ` (117 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:00 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Mark Rutland, Marc Zyngier, Sasha Levin

From: Mark Rutland <mark.rutland@arm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f050fe7a9164945dd1c28be05bf00e8cfb082ccf ]

Currently we BUG() if we see a HSR.EC value we don't recognise. As
configurable disables/enables are added to the architecture (controlled
by RES1/RES0 bits respectively), with associated synchronous exceptions,
it may be possible for a guest to trigger exceptions with classes that
we don't recognise.

While we can't service these exceptions in a manner useful to the guest,
we can avoid bringing down the host. Per ARM DDI 0406C.c, all currently
unallocated HSR EC encodings are reserved, and per ARM DDI
0487A.k_iss10775, page G6-4395, EC values within the range 0x00 - 0x2c
are reserved for future use with synchronous exceptions, and EC values
within the range 0x2d - 0x3f may be used for either synchronous or
asynchronous exceptions.

The patch makes KVM handle any unknown EC by injecting an UNDEFINED
exception into the guest, with a corresponding (ratelimited) warning in
the host dmesg. We could later improve on this with with a new (opt-in)
exit to the host userspace.

Cc: Dave Martin <dave.martin@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/arm/include/asm/kvm_arm.h |  1 +
 arch/arm/kvm/handle_exit.c     | 19 ++++++++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/arch/arm/include/asm/kvm_arm.h b/arch/arm/include/asm/kvm_arm.h
index d995821f1698..aacd6668d1a0 100644
--- a/arch/arm/include/asm/kvm_arm.h
+++ b/arch/arm/include/asm/kvm_arm.h
@@ -209,6 +209,7 @@
 #define HSR_EC_IABT_HYP	(0x21)
 #define HSR_EC_DABT	(0x24)
 #define HSR_EC_DABT_HYP	(0x25)
+#define HSR_EC_MAX	(0x3f)
 
 #define HSR_WFI_IS_WFE		(1U << 0)
 
diff --git a/arch/arm/kvm/handle_exit.c b/arch/arm/kvm/handle_exit.c
index 95f12b2ccdcb..f36b5b1acd1f 100644
--- a/arch/arm/kvm/handle_exit.c
+++ b/arch/arm/kvm/handle_exit.c
@@ -100,7 +100,19 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run)
 	return 1;
 }
 
+static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu, struct kvm_run *run)
+{
+	u32 hsr = kvm_vcpu_get_hsr(vcpu);
+
+	kvm_pr_unimpl("Unknown exception class: hsr: %#08x\n",
+		      hsr);
+
+	kvm_inject_undefined(vcpu);
+	return 1;
+}
+
 static exit_handle_fn arm_exit_handlers[] = {
+	[0 ... HSR_EC_MAX]	= kvm_handle_unknown_ec,
 	[HSR_EC_WFI]		= kvm_handle_wfx,
 	[HSR_EC_CP15_32]	= kvm_handle_cp15_32,
 	[HSR_EC_CP15_64]	= kvm_handle_cp15_64,
@@ -122,13 +134,6 @@ static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu)
 {
 	u8 hsr_ec = kvm_vcpu_trap_get_class(vcpu);
 
-	if (hsr_ec >= ARRAY_SIZE(arm_exit_handlers) ||
-	    !arm_exit_handlers[hsr_ec]) {
-		kvm_err("Unknown exception class: hsr: %#08x\n",
-			(unsigned int)kvm_vcpu_get_hsr(vcpu));
-		BUG();
-	}
-
 	return arm_exit_handlers[hsr_ec];
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] bnx2x: prevent crash when accessing PTP with interface down
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (178 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] spi_ks8995: fix "BUG: key accdaa28 not in .data!" Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] bnx2x: fix possible overrun of VFPF multicast addresses array Sasha Levin
                   ` (115 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Michal Schmidt, David S . Miller, Sasha Levin

From: Michal Schmidt <mschmidt@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 466e8bf10ac104d96e1ea813e8126e11cb72ea20 ]

It is possible to crash the kernel by accessing a PTP device while its
associated bnx2x interface is down. Before the interface is brought up,
the timecounter is not initialized, so accessing it results in NULL
dereference.

Fix it by checking if the interface is up.

Use -ENETDOWN as the error code when the interface is down.
 -EFAULT in bnx2x_ptp_adjfreq() did not seem right.

Tested using phc_ctl get/set/adj/freq commands.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 8a97d28f3d65..a1d149515531 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -13227,7 +13227,7 @@ static int bnx2x_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
 	if (!netif_running(bp->dev)) {
 		DP(BNX2X_MSG_PTP,
 		   "PTP adjfreq called while the interface is down\n");
-		return -EFAULT;
+		return -ENETDOWN;
 	}
 
 	if (ppb < 0) {
@@ -13286,6 +13286,12 @@ static int bnx2x_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 {
 	struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
 
+	if (!netif_running(bp->dev)) {
+		DP(BNX2X_MSG_PTP,
+		   "PTP adjtime called while the interface is down\n");
+		return -ENETDOWN;
+	}
+
 	DP(BNX2X_MSG_PTP, "PTP adjtime called, delta = %llx\n", delta);
 
 	timecounter_adjtime(&bp->timecounter, delta);
@@ -13298,6 +13304,12 @@ static int bnx2x_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 	struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
 	u64 ns;
 
+	if (!netif_running(bp->dev)) {
+		DP(BNX2X_MSG_PTP,
+		   "PTP gettime called while the interface is down\n");
+		return -ENETDOWN;
+	}
+
 	ns = timecounter_read(&bp->timecounter);
 
 	DP(BNX2X_MSG_PTP, "PTP gettime called, ns = %llu\n", ns);
@@ -13313,6 +13325,12 @@ static int bnx2x_ptp_settime(struct ptp_clock_info *ptp,
 	struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
 	u64 ns;
 
+	if (!netif_running(bp->dev)) {
+		DP(BNX2X_MSG_PTP,
+		   "PTP settime called while the interface is down\n");
+		return -ENETDOWN;
+	}
+
 	ns = timespec64_to_ns(ts);
 
 	DP(BNX2X_MSG_PTP, "PTP settime called, ns = %llu\n", ns);
-- 
2.11.0

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

* [added to the 4.1 stable tree] spi_ks8995: fix "BUG: key accdaa28 not in .data!"
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (177 preceding siblings ...)
  2018-01-18 21:00 ` [added to the 4.1 stable tree] arm: KVM: Survive unknown traps from guests Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] bnx2x: prevent crash when accessing PTP with interface down Sasha Levin
                   ` (116 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Blomme, Maarten, David S . Miller, Sasha Levin

From: "Blomme, Maarten" <Maarten.Blomme@flir.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 4342696df764ec65dcdfbd0c10d90ea52505f8ba ]

Signed-off-by: Maarten Blomme <Maarten.Blomme@flir.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/phy/spi_ks8995.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/phy/spi_ks8995.c b/drivers/net/phy/spi_ks8995.c
index 46530159256b..196f04015e8a 100644
--- a/drivers/net/phy/spi_ks8995.c
+++ b/drivers/net/phy/spi_ks8995.c
@@ -332,6 +332,7 @@ static int ks8995_probe(struct spi_device *spi)
 	if (err)
 		return err;
 
+	sysfs_attr_init(&ks->regs_attr.attr);
 	err = sysfs_create_bin_file(&spi->dev.kobj, &ks->regs_attr);
 	if (err) {
 		dev_err(&spi->dev, "unable to create sysfs file, err=%d\n",
-- 
2.11.0

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

* [added to the 4.1 stable tree] bnx2x: fix possible overrun of VFPF multicast addresses array
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (179 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] bnx2x: prevent crash when accessing PTP with interface down Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] ipv6: reorder icmpv6_init() and ip6_mr_init() Sasha Levin
                   ` (114 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Michal Schmidt, David S . Miller, Sasha Levin

From: Michal Schmidt <mschmidt@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 22118d861cec5da6ed525aaf12a3de9bfeffc58f ]

It is too late to check for the limit of the number of VF multicast
addresses after they have already been copied to the req->multicast[]
array, possibly overflowing it.

Do the check before copying.

Also fix the error path to not skip unlocking vf2pf_mutex.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
index 06b8c0d8fd3b..996d2dc21bde 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
@@ -852,7 +852,7 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev)
 	struct bnx2x *bp = netdev_priv(dev);
 	struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;
 	struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
-	int rc, i = 0;
+	int rc = 0, i = 0;
 	struct netdev_hw_addr *ha;
 
 	if (bp->state != BNX2X_STATE_OPEN) {
@@ -867,6 +867,15 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev)
 	/* Get Rx mode requested */
 	DP(NETIF_MSG_IFUP, "dev->flags = %x\n", dev->flags);
 
+	/* We support PFVF_MAX_MULTICAST_PER_VF mcast addresses tops */
+	if (netdev_mc_count(dev) > PFVF_MAX_MULTICAST_PER_VF) {
+		DP(NETIF_MSG_IFUP,
+		   "VF supports not more than %d multicast MAC addresses\n",
+		   PFVF_MAX_MULTICAST_PER_VF);
+		rc = -EINVAL;
+		goto out;
+	}
+
 	netdev_for_each_mc_addr(ha, dev) {
 		DP(NETIF_MSG_IFUP, "Adding mcast MAC: %pM\n",
 		   bnx2x_mc_addr(ha));
@@ -874,16 +883,6 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev)
 		i++;
 	}
 
-	/* We support four PFVF_MAX_MULTICAST_PER_VF mcast
-	  * addresses tops
-	  */
-	if (i >= PFVF_MAX_MULTICAST_PER_VF) {
-		DP(NETIF_MSG_IFUP,
-		   "VF supports not more than %d multicast MAC addresses\n",
-		   PFVF_MAX_MULTICAST_PER_VF);
-		return -EINVAL;
-	}
-
 	req->n_multicast = i;
 	req->flags |= VFPF_SET_Q_FILTERS_MULTICAST_CHANGED;
 	req->vf_qid = 0;
@@ -908,7 +907,7 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev)
 out:
 	bnx2x_vfpf_finalize(bp, &req->first_tlv);
 
-	return 0;
+	return rc;
 }
 
 int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp)
-- 
2.11.0

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

* [added to the 4.1 stable tree] crypto: s5p-sss - Fix completing crypto request in IRQ handler
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (181 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] ipv6: reorder icmpv6_init() and ip6_mr_init() Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] axonram: Fix gendisk handling Sasha Levin
                   ` (112 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Krzysztof Kozlowski, Herbert Xu, Sasha Levin

From: Krzysztof Kozlowski <krzk@kernel.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 07de4bc88ce6a4d898cad9aa4c99c1df7e87702d ]

In a regular interrupt handler driver was finishing the crypt/decrypt
request by calling complete on crypto request.  This is disallowed since
converting to skcipher in commit b286d8b1a690 ("crypto: skcipher - Add
skcipher walk interface") and causes a warning:
	WARNING: CPU: 0 PID: 0 at crypto/skcipher.c:430 skcipher_walk_first+0x13c/0x14c

The interrupt is marked shared but in fact there are no other users
sharing it.  Thus the simplest solution seems to be to just use a
threaded interrupt handler, after converting it to oneshot.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/crypto/s5p-sss.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index 36d936fb259e..4f0c4a3cc5c5 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -682,8 +682,9 @@ static int s5p_aes_probe(struct platform_device *pdev)
 		dev_warn(dev, "feed control interrupt is not available.\n");
 		goto err_irq;
 	}
-	err = devm_request_irq(dev, pdata->irq_fc, s5p_aes_interrupt,
-			       IRQF_SHARED, pdev->name, pdev);
+	err = devm_request_threaded_irq(dev, pdata->irq_fc, NULL,
+					s5p_aes_interrupt, IRQF_ONESHOT,
+					pdev->name, pdev);
 	if (err < 0) {
 		dev_warn(dev, "feed control interrupt is not available.\n");
 		goto err_irq;
-- 
2.11.0

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

* [added to the 4.1 stable tree] ipv6: reorder icmpv6_init() and ip6_mr_init()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (180 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] bnx2x: fix possible overrun of VFPF multicast addresses array Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] crypto: s5p-sss - Fix completing crypto request in IRQ handler Sasha Levin
                   ` (113 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: WANG Cong, David S . Miller, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 15e668070a64bb97f102ad9cf3bccbca0545cda8 ]

Andrey reported the following kernel crash:

kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
CPU: 0 PID: 14446 Comm: syz-executor6 Not tainted 4.10.0+ #82
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
task: ffff88001f311700 task.stack: ffff88001f6e8000
RIP: 0010:ip6mr_sk_done+0x15a/0x3d0 net/ipv6/ip6mr.c:1618
RSP: 0018:ffff88001f6ef418 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 1ffff10003edde8c RCX: ffffc900043ee000
RDX: 0000000000000004 RSI: ffffffff83e3b3f8 RDI: 0000000000000020
RBP: ffff88001f6ef508 R08: fffffbfff0dcc5d8 R09: 0000000000000000
R10: ffffffff86e62ec0 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: ffff88001f6ef4e0 R15: ffff8800380a0040
FS:  00007f7a52cec700(0000) GS:ffff88003ec00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000000061c500 CR3: 000000001f1ae000 CR4: 00000000000006f0
DR0: 0000000020000000 DR1: 0000000020000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600
Call Trace:
 rawv6_close+0x4c/0x80 net/ipv6/raw.c:1217
 inet_release+0xed/0x1c0 net/ipv4/af_inet.c:425
 inet6_release+0x50/0x70 net/ipv6/af_inet6.c:432
 sock_release+0x8d/0x1e0 net/socket.c:597
 __sock_create+0x39d/0x880 net/socket.c:1226
 sock_create_kern+0x3f/0x50 net/socket.c:1243
 inet_ctl_sock_create+0xbb/0x280 net/ipv4/af_inet.c:1526
 icmpv6_sk_init+0x163/0x500 net/ipv6/icmp.c:954
 ops_init+0x10a/0x550 net/core/net_namespace.c:115
 setup_net+0x261/0x660 net/core/net_namespace.c:291
 copy_net_ns+0x27e/0x540 net/core/net_namespace.c:396
9pnet_virtio: no channels available for device ./file1
 create_new_namespaces+0x437/0x9b0 kernel/nsproxy.c:106
 unshare_nsproxy_namespaces+0xae/0x1e0 kernel/nsproxy.c:205
 SYSC_unshare kernel/fork.c:2281 [inline]
 SyS_unshare+0x64e/0x1000 kernel/fork.c:2231
 entry_SYSCALL_64_fastpath+0x1f/0xc2

This is because net->ipv6.mr6_tables is not initialized at that point,
ip6mr_rules_init() is not called yet, therefore on the error path when
we iterator the list, we trigger this oops. Fix this by reordering
ip6mr_rules_init() before icmpv6_sk_init().

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv6/af_inet6.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index bad62fa5e70f..44bae47fa1b9 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -889,12 +889,12 @@ static int __init inet6_init(void)
 	err = register_pernet_subsys(&inet6_net_ops);
 	if (err)
 		goto register_pernet_fail;
-	err = icmpv6_init();
-	if (err)
-		goto icmp_fail;
 	err = ip6_mr_init();
 	if (err)
 		goto ipmr_fail;
+	err = icmpv6_init();
+	if (err)
+		goto icmp_fail;
 	err = ndisc_init();
 	if (err)
 		goto ndisc_fail;
@@ -1012,10 +1012,10 @@ static int __init inet6_init(void)
 	ndisc_cleanup();
 ndisc_fail:
 	ip6_mr_cleanup();
-ipmr_fail:
-	icmpv6_cleanup();
 icmp_fail:
 	unregister_pernet_subsys(&inet6_net_ops);
+ipmr_fail:
+	icmpv6_cleanup();
 register_pernet_fail:
 	sock_unregister(PF_INET6);
 	rtnl_unregister_all(PF_INET6);
-- 
2.11.0

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

* [added to the 4.1 stable tree] axonram: Fix gendisk handling
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (182 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] crypto: s5p-sss - Fix completing crypto request in IRQ handler Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] i2c: riic: fix restart condition Sasha Levin
                   ` (111 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jan Kara, Jens Axboe, Sasha Levin

From: Jan Kara <jack@suse.cz>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 672a2c87c83649fb0167202342ce85af9a3b4f1c ]

It is invalid to call del_gendisk() when disk->queue is NULL. Fix error
handling in axon_ram_probe() to avoid doing that.

Also del_gendisk() does not drop a reference to gendisk allocated by
alloc_disk(). That has to be done by put_disk(). Add that call where
needed.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/powerpc/sysdev/axonram.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c
index ee90db17b097..1629dd5aaacb 100644
--- a/arch/powerpc/sysdev/axonram.c
+++ b/arch/powerpc/sysdev/axonram.c
@@ -274,7 +274,9 @@ static int axon_ram_probe(struct platform_device *device)
 			if (bank->disk->major > 0)
 				unregister_blkdev(bank->disk->major,
 						bank->disk->disk_name);
-			del_gendisk(bank->disk);
+			if (bank->disk->flags & GENHD_FL_UP)
+				del_gendisk(bank->disk);
+			put_disk(bank->disk);
 		}
 		device->dev.platform_data = NULL;
 		if (bank->io_addr != 0)
@@ -299,6 +301,7 @@ axon_ram_remove(struct platform_device *device)
 	device_remove_file(&device->dev, &dev_attr_ecc);
 	free_irq(bank->irq_id, device);
 	del_gendisk(bank->disk);
+	put_disk(bank->disk);
 	iounmap((void __iomem *) bank->io_addr);
 	kfree(bank);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] i2c: riic: fix restart condition
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (183 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] axonram: Fix gendisk handling Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] EDAC, i5000, i5400: Fix use of MTR_DRAM_WIDTH macro Sasha Levin
                   ` (110 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Chris Brandt, Wolfram Sang, Sasha Levin

From: Chris Brandt <chris.brandt@renesas.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 2501c1bb054290679baad0ff7f4f07c714251f4c ]

While modifying the driver to use the STOP interrupt, the completion of the
intermediate transfers need to wake the driver back up in order to initiate
the next transfer (restart condition). Otherwise you get never ending
interrupts and only the first transfer sent.

Fixes: 71ccea095ea1 ("i2c: riic: correctly finish transfers")
Reported-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Tested-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/i2c/busses/i2c-riic.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
index d8803c3bbfdc..16833365475f 100644
--- a/drivers/i2c/busses/i2c-riic.c
+++ b/drivers/i2c/busses/i2c-riic.c
@@ -218,8 +218,12 @@ static irqreturn_t riic_tend_isr(int irq, void *data)
 	}
 
 	if (riic->is_last || riic->err) {
-		riic_clear_set_bit(riic, 0, ICIER_SPIE, RIIC_ICIER);
+		riic_clear_set_bit(riic, ICIER_TEIE, ICIER_SPIE, RIIC_ICIER);
 		writeb(ICCR2_SP, riic->base + RIIC_ICCR2);
+	} else {
+		/* Transfer is complete, but do not send STOP */
+		riic_clear_set_bit(riic, ICIER_TEIE, 0, RIIC_ICIER);
+		complete(&riic->msg_done);
 	}
 
 	return IRQ_HANDLED;
-- 
2.11.0

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

* [added to the 4.1 stable tree] EDAC, i5000, i5400: Fix definition of NRECMEMB register
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (185 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] EDAC, i5000, i5400: Fix use of MTR_DRAM_WIDTH macro Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] route: also update fnhe_genid when updating a route cache Sasha Levin
                   ` (108 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Jérémy Lefaure, Borislav Petkov, Sasha Levin

From: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit a8c8261425649da58bdf08221570e5335ad33a31 ]

In the i5000 and i5400 drivers, the NRECMEMB register is defined as a
16-bit value, which results in wrong shifts in the code, as reported by
sparse.

In the datasheets ([1], section 3.9.22.20 and [2], section 3.9.22.21),
this register is a 32-bit register. A u32 value for the register fixes
the wrong shifts warnings and matches the datasheet.

Also fix the mask to access to the CAS bits [27:16] in the i5000 driver.

[1]: https://www.intel.com/content/dam/doc/datasheet/5000p-5000v-5000z-chipset-memory-controller-hub-datasheet.pdf
[2]: https://www.intel.se/content/dam/doc/datasheet/5400-chipset-memory-controller-hub-datasheet.pdf

Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/20170629005729.8478-1-jeremy.lefaure@lse.epita.fr
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/edac/i5000_edac.c | 6 +++---
 drivers/edac/i5400_edac.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/edac/i5000_edac.c b/drivers/edac/i5000_edac.c
index 2a09be5f4f86..16e0eb523439 100644
--- a/drivers/edac/i5000_edac.c
+++ b/drivers/edac/i5000_edac.c
@@ -227,7 +227,7 @@
 #define			NREC_RDWR(x)		(((x)>>11) & 1)
 #define			NREC_RANK(x)		(((x)>>8) & 0x7)
 #define		NRECMEMB		0xC0
-#define			NREC_CAS(x)		(((x)>>16) & 0xFFFFFF)
+#define			NREC_CAS(x)		(((x)>>16) & 0xFFF)
 #define			NREC_RAS(x)		((x) & 0x7FFF)
 #define		NRECFGLOG		0xC4
 #define		NREEECFBDA		0xC8
@@ -371,7 +371,7 @@ struct i5000_error_info {
 	/* These registers are input ONLY if there was a
 	 * Non-Recoverable Error */
 	u16 nrecmema;		/* Non-Recoverable Mem log A */
-	u16 nrecmemb;		/* Non-Recoverable Mem log B */
+	u32 nrecmemb;		/* Non-Recoverable Mem log B */
 
 };
 
@@ -407,7 +407,7 @@ static void i5000_get_error_info(struct mem_ctl_info *mci,
 				NERR_FAT_FBD, &info->nerr_fat_fbd);
 		pci_read_config_word(pvt->branchmap_werrors,
 				NRECMEMA, &info->nrecmema);
-		pci_read_config_word(pvt->branchmap_werrors,
+		pci_read_config_dword(pvt->branchmap_werrors,
 				NRECMEMB, &info->nrecmemb);
 
 		/* Clear the error bits, by writing them back */
diff --git a/drivers/edac/i5400_edac.c b/drivers/edac/i5400_edac.c
index 029dfe07b734..2ea2f32e608b 100644
--- a/drivers/edac/i5400_edac.c
+++ b/drivers/edac/i5400_edac.c
@@ -368,7 +368,7 @@ struct i5400_error_info {
 
 	/* These registers are input ONLY if there was a Non-Rec Error */
 	u16 nrecmema;		/* Non-Recoverable Mem log A */
-	u16 nrecmemb;		/* Non-Recoverable Mem log B */
+	u32 nrecmemb;		/* Non-Recoverable Mem log B */
 
 };
 
@@ -458,7 +458,7 @@ static void i5400_get_error_info(struct mem_ctl_info *mci,
 				NERR_FAT_FBD, &info->nerr_fat_fbd);
 		pci_read_config_word(pvt->branchmap_werrors,
 				NRECMEMA, &info->nrecmema);
-		pci_read_config_word(pvt->branchmap_werrors,
+		pci_read_config_dword(pvt->branchmap_werrors,
 				NRECMEMB, &info->nrecmemb);
 
 		/* Clear the error bits, by writing them back */
-- 
2.11.0

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

* [added to the 4.1 stable tree] EDAC, i5000, i5400: Fix use of MTR_DRAM_WIDTH macro
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (184 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] i2c: riic: fix restart condition Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] EDAC, i5000, i5400: Fix definition of NRECMEMB register Sasha Levin
                   ` (109 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Jérémy Lefaure, Borislav Petkov, Sasha Levin

From: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e61555c29c28a4a3b6ba6207f4a0883ee236004d ]

The MTR_DRAM_WIDTH macro returns the data width. It is sometimes used
as if it returned a boolean true if the width if 8. Fix the tests where
MTR_DRAM_WIDTH is misused.

Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/20170309011809.8340-1-jeremy.lefaure@lse.epita.fr
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/edac/i5000_edac.c | 2 +-
 drivers/edac/i5400_edac.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/edac/i5000_edac.c b/drivers/edac/i5000_edac.c
index 72e07e3cf718..2a09be5f4f86 100644
--- a/drivers/edac/i5000_edac.c
+++ b/drivers/edac/i5000_edac.c
@@ -1293,7 +1293,7 @@ static int i5000_init_csrows(struct mem_ctl_info *mci)
 			dimm->mtype = MEM_FB_DDR2;
 
 			/* ask what device type on this row */
-			if (MTR_DRAM_WIDTH(mtr))
+			if (MTR_DRAM_WIDTH(mtr) == 8)
 				dimm->dtype = DEV_X8;
 			else
 				dimm->dtype = DEV_X4;
diff --git a/drivers/edac/i5400_edac.c b/drivers/edac/i5400_edac.c
index 6ef6ad1ba16e..029dfe07b734 100644
--- a/drivers/edac/i5400_edac.c
+++ b/drivers/edac/i5400_edac.c
@@ -1207,13 +1207,14 @@ static int i5400_init_dimms(struct mem_ctl_info *mci)
 
 			dimm->nr_pages = size_mb << 8;
 			dimm->grain = 8;
-			dimm->dtype = MTR_DRAM_WIDTH(mtr) ? DEV_X8 : DEV_X4;
+			dimm->dtype = MTR_DRAM_WIDTH(mtr) == 8 ?
+				      DEV_X8 : DEV_X4;
 			dimm->mtype = MEM_FB_DDR2;
 			/*
 			 * The eccc mechanism is SDDC (aka SECC), with
 			 * is similar to Chipkill.
 			 */
-			dimm->edac_mode = MTR_DRAM_WIDTH(mtr) ?
+			dimm->edac_mode = MTR_DRAM_WIDTH(mtr) == 8 ?
 					  EDAC_S8ECD8ED : EDAC_S4ECD4ED;
 			ndimms++;
 		}
-- 
2.11.0

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

* [added to the 4.1 stable tree] mac80211_hwsim: Fix memory leak in hwsim_new_radio_nl()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (187 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] route: also update fnhe_genid when updating a route cache Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] route: update fnhe_expires for redirect when the fnhe exists Sasha Levin
                   ` (106 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Ben Hutchings, Johannes Berg, Sasha Levin

From: Ben Hutchings <ben.hutchings@codethink.co.uk>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 67bd52386125ce1159c0581cbcd2740addf33cd4 ]

hwsim_new_radio_nl() now copies the name attribute in order to add a
null-terminator.  mac80211_hwsim_new_radio() (indirectly) copies it
again into the net_device structure, so the first copy is not used or
freed later.  Free the first copy before returning.

Fixes: ff4dd73dd2b4 ("mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length")
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/wireless/mac80211_hwsim.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 03097016fd43..aafb97ce080d 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2884,6 +2884,7 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
 {
 	struct hwsim_new_radio_params param = { 0 };
 	const char *hwname = NULL;
+	int ret;
 
 	param.reg_strict = info->attrs[HWSIM_ATTR_REG_STRICT_REG];
 	param.p2p_device = info->attrs[HWSIM_ATTR_SUPPORT_P2P_DEVICE];
@@ -2923,7 +2924,9 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
 		param.regd = hwsim_world_regdom_custom[idx];
 	}
 
-	return mac80211_hwsim_new_radio(info, &param);
+	ret = mac80211_hwsim_new_radio(info, &param);
+	kfree(hwname);
+	return ret;
 }
 
 static int hwsim_del_radio_nl(struct sk_buff *msg, struct genl_info *info)
-- 
2.11.0

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

* [added to the 4.1 stable tree] route: also update fnhe_genid when updating a route cache
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (186 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] EDAC, i5000, i5400: Fix definition of NRECMEMB register Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] mac80211_hwsim: Fix memory leak in hwsim_new_radio_nl() Sasha Levin
                   ` (107 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Xin Long, David S . Miller, Sasha Levin

From: Xin Long <lucien.xin@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit cebe84c6190d741045a322f5343f717139993c08 ]

Now when ip route flush cache and it turn out all fnhe_genid != genid.
If a redirect/pmtu icmp packet comes and the old fnhe is found and all
it's members but fnhe_genid will be updated.

Then next time when it looks up route and tries to rebind this fnhe to
the new dst, the fnhe will be flushed due to fnhe_genid != genid. It
causes this redirect/pmtu icmp packet acutally not to be applied.

This patch is to also reset fnhe_genid when updating a route cache.

Fixes: 5aad1de5ea2c ("ipv4: use separate genid for next hop exceptions")
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv4/route.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 8f29e29f18a1..42c7fed200b2 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -622,9 +622,12 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw,
 	struct fnhe_hash_bucket *hash;
 	struct fib_nh_exception *fnhe;
 	struct rtable *rt;
+	u32 genid, hval;
 	unsigned int i;
 	int depth;
-	u32 hval = fnhe_hashfun(daddr);
+
+	genid = fnhe_genid(dev_net(nh->nh_dev));
+	hval = fnhe_hashfun(daddr);
 
 	spin_lock_bh(&fnhe_lock);
 
@@ -647,6 +650,8 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw,
 	}
 
 	if (fnhe) {
+		if (fnhe->fnhe_genid != genid)
+			fnhe->fnhe_genid = genid;
 		if (gw)
 			fnhe->fnhe_gw = gw;
 		if (pmtu) {
@@ -671,7 +676,7 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw,
 			fnhe->fnhe_next = hash->chain;
 			rcu_assign_pointer(hash->chain, fnhe);
 		}
-		fnhe->fnhe_genid = fnhe_genid(dev_net(nh->nh_dev));
+		fnhe->fnhe_genid = genid;
 		fnhe->fnhe_daddr = daddr;
 		fnhe->fnhe_gw = gw;
 		fnhe->fnhe_pmtu = pmtu;
-- 
2.11.0

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

* [added to the 4.1 stable tree] lib/genalloc.c: make the avail variable an atomic_long_t
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (189 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] route: update fnhe_expires for redirect when the fnhe exists Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] NFS: Fix a typo in nfs_rename() Sasha Levin
                   ` (104 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Stephen Bates, Andrew Morton, Linus Torvalds, Sasha Levin

From: Stephen Bates <sbates@raithlin.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 36a3d1dd4e16bcd0d2ddfb4a2ec7092f0ae0d931 ]

If the amount of resources allocated to a gen_pool exceeds 2^32 then the
avail atomic overflows and this causes problems when clients try and
borrow resources from the pool.  This is only expected to be an issue on
64 bit systems.

Add the <linux/atomic.h> header to pull in atomic_long* operations.  So
that 32 bit systems continue to use atomic32_t but 64 bit systems can
use atomic64_t.

Link: http://lkml.kernel.org/r/1509033843-25667-1-git-send-email-sbates@raithlin.com
Signed-off-by: Stephen Bates <sbates@raithlin.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Reviewed-by: Daniel Mentz <danielmentz@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 include/linux/genalloc.h |  3 ++-
 lib/genalloc.c           | 10 +++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h
index 1ccaab44abcc..ec78cd93c0c1 100644
--- a/include/linux/genalloc.h
+++ b/include/linux/genalloc.h
@@ -31,6 +31,7 @@
 #define __GENALLOC_H__
 
 #include <linux/spinlock_types.h>
+#include <linux/atomic.h>
 
 struct device;
 struct device_node;
@@ -66,7 +67,7 @@ struct gen_pool {
  */
 struct gen_pool_chunk {
 	struct list_head next_chunk;	/* next chunk in pool */
-	atomic_t avail;
+	atomic_long_t avail;
 	phys_addr_t phys_addr;		/* physical starting address of memory chunk */
 	unsigned long start_addr;	/* start address of memory chunk */
 	unsigned long end_addr;		/* end address of memory chunk (inclusive) */
diff --git a/lib/genalloc.c b/lib/genalloc.c
index d214866eeea2..59dafa4ff412 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -193,7 +193,7 @@ int gen_pool_add_virt(struct gen_pool *pool, unsigned long virt, phys_addr_t phy
 	chunk->phys_addr = phys;
 	chunk->start_addr = virt;
 	chunk->end_addr = virt + size - 1;
-	atomic_set(&chunk->avail, size);
+	atomic_long_set(&chunk->avail, size);
 
 	spin_lock(&pool->lock);
 	list_add_rcu(&chunk->next_chunk, &pool->chunks);
@@ -284,7 +284,7 @@ unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size)
 	nbits = (size + (1UL << order) - 1) >> order;
 	rcu_read_lock();
 	list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) {
-		if (size > atomic_read(&chunk->avail))
+		if (size > atomic_long_read(&chunk->avail))
 			continue;
 
 		end_bit = chunk_size(chunk) >> order;
@@ -303,7 +303,7 @@ unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size)
 
 		addr = chunk->start_addr + ((unsigned long)start_bit << order);
 		size = nbits << order;
-		atomic_sub(size, &chunk->avail);
+		atomic_long_sub(size, &chunk->avail);
 		break;
 	}
 	rcu_read_unlock();
@@ -369,7 +369,7 @@ void gen_pool_free(struct gen_pool *pool, unsigned long addr, size_t size)
 			remain = bitmap_clear_ll(chunk->bits, start_bit, nbits);
 			BUG_ON(remain);
 			size = nbits << order;
-			atomic_add(size, &chunk->avail);
+			atomic_long_add(size, &chunk->avail);
 			rcu_read_unlock();
 			return;
 		}
@@ -443,7 +443,7 @@ size_t gen_pool_avail(struct gen_pool *pool)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk)
-		avail += atomic_read(&chunk->avail);
+		avail += atomic_long_read(&chunk->avail);
 	rcu_read_unlock();
 	return avail;
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] route: update fnhe_expires for redirect when the fnhe exists
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (188 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] mac80211_hwsim: Fix memory leak in hwsim_new_radio_nl() Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] lib/genalloc.c: make the avail variable an atomic_long_t Sasha Levin
                   ` (105 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Xin Long, David S . Miller, Sasha Levin

From: Xin Long <lucien.xin@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e39d5246111399dbc6e11cd39fd8580191b86c47 ]

Now when creating fnhe for redirect, it sets fnhe_expires for this
new route cache. But when updating the exist one, it doesn't do it.
It will cause this fnhe never to be expired.

Paolo already noticed it before, in Jianlin's test case, it became
even worse:

When ip route flush cache, the old fnhe is not to be removed, but
only clean it's members. When redirect comes again, this fnhe will
be found and updated, but never be expired due to fnhe_expires not
being set.

So fix it by simply updating fnhe_expires even it's for redirect.

Fixes: aee06da6726d ("ipv4: use seqlock for nh_exceptions")
Reported-by: Jianlin Shi <jishi@redhat.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv4/route.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 42c7fed200b2..6a9a495aff23 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -654,10 +654,9 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw,
 			fnhe->fnhe_genid = genid;
 		if (gw)
 			fnhe->fnhe_gw = gw;
-		if (pmtu) {
+		if (pmtu)
 			fnhe->fnhe_pmtu = pmtu;
-			fnhe->fnhe_expires = max(1UL, expires);
-		}
+		fnhe->fnhe_expires = max(1UL, expires);
 		/* Update all cached dsts too */
 		rt = rcu_dereference(fnhe->fnhe_rth_input);
 		if (rt)
-- 
2.11.0

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

* [added to the 4.1 stable tree] NFS: Fix a typo in nfs_rename()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (190 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] lib/genalloc.c: make the avail variable an atomic_long_t Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] dynamic-debug-howto: fix optional/omitted ending line number to be LARGE instead of 0 Sasha Levin
                   ` (103 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Trond Myklebust, Anna Schumaker, Sasha Levin

From: Trond Myklebust <trond.myklebust@primarydata.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit d803224c84be067754db7fa58a93f36f61566493 ]

On successful rename, the "old_dentry" is retained and is attached to
the "new_dir", so we need to call nfs_set_verifier() accordingly.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/nfs/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 1484ae1907c6..d2cb63259560 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2076,7 +2076,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		if (new_inode != NULL)
 			nfs_drop_nlink(new_inode);
 		d_move(old_dentry, new_dentry);
-		nfs_set_verifier(new_dentry,
+		nfs_set_verifier(old_dentry,
 					nfs_save_change_attribute(new_dir));
 	} else if (error == -ENOENT)
 		nfs_dentry_handle_enoent(old_dentry);
-- 
2.11.0

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

* [added to the 4.1 stable tree] dynamic-debug-howto: fix optional/omitted ending line number to be LARGE instead of 0
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (191 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] NFS: Fix a typo in nfs_rename() Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] sunrpc: Fix rpc_task_begin trace point Sasha Levin
                   ` (102 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Randy Dunlap, Andrew Morton, Linus Torvalds, Sasha Levin

From: Randy Dunlap <rdunlap@infradead.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 1f3c790bd5989fcfec9e53ad8fa09f5b740c958f ]

line-range is supposed to treat "1-" as "1-endoffile", so
handle the special case by setting last_lineno to UINT_MAX.

Fixes this error:

  dynamic_debug:ddebug_parse_query: last-line:0 < 1st-line:1
  dynamic_debug:ddebug_exec_query: query parse failed

Link: http://lkml.kernel.org/r/10a6a101-e2be-209f-1f41-54637824788e@infradead.org
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 lib/dynamic_debug.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index d8f3d3150603..2b382c165571 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -353,6 +353,10 @@ static int ddebug_parse_query(char *words[], int nwords,
 				if (parse_lineno(last, &query->last_lineno) < 0)
 					return -EINVAL;
 
+				/* special case for last lineno not specified */
+				if (query->last_lineno == 0)
+					query->last_lineno = UINT_MAX;
+
 				if (query->last_lineno < query->first_lineno) {
 					pr_err("last-line:%d < 1st-line:%d\n",
 						query->last_lineno,
-- 
2.11.0

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

* [added to the 4.1 stable tree] sctp: do not free asoc when it is already dead in sctp_sendmsg
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (193 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] sunrpc: Fix rpc_task_begin trace point Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] sparc64/mm: set fields in deferred pages Sasha Levin
                   ` (100 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Xin Long, David S . Miller, Sasha Levin

From: Xin Long <lucien.xin@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit ca3af4dd28cff4e7216e213ba3b671fbf9f84758 ]

Now in sctp_sendmsg sctp_wait_for_sndbuf could schedule out without
holding sock sk. It means the current asoc can be freed elsewhere,
like when receiving an abort packet.

If the asoc is just created in sctp_sendmsg and sctp_wait_for_sndbuf
returns err, the asoc will be freed again due to new_asoc is not nil.
An use-after-free issue would be triggered by this.

This patch is to fix it by setting new_asoc with nil if the asoc is
already dead when cpu schedules back, so that it will not be freed
again in sctp_sendmsg.

v1->v2:
  set new_asoc as nil in sctp_sendmsg instead of sctp_wait_for_sndbuf.

Suggested-by: Neil Horman <nhorman@tuxdriver.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/sctp/socket.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index cb7193ed4284..5ad280d102c3 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1948,8 +1948,14 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
 	timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
 	if (!sctp_wspace(asoc)) {
 		err = sctp_wait_for_sndbuf(asoc, &timeo, msg_len);
-		if (err)
+		if (err) {
+			if (err == -ESRCH) {
+				/* asoc is already dead. */
+				new_asoc = NULL;
+				err = -EPIPE;
+			}
 			goto out_free;
+		}
 	}
 
 	/* If an address is passed with the sendto/sendmsg call, it is used
@@ -6989,10 +6995,11 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
 	for (;;) {
 		prepare_to_wait_exclusive(&asoc->wait, &wait,
 					  TASK_INTERRUPTIBLE);
+		if (asoc->base.dead)
+			goto do_dead;
 		if (!*timeo_p)
 			goto do_nonblock;
-		if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING ||
-		    asoc->base.dead)
+		if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING)
 			goto do_error;
 		if (signal_pending(current))
 			goto do_interrupted;
@@ -7018,6 +7025,10 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
 
 	return err;
 
+do_dead:
+	err = -ESRCH;
+	goto out;
+
 do_error:
 	err = -EPIPE;
 	goto out;
-- 
2.11.0

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

* [added to the 4.1 stable tree] sunrpc: Fix rpc_task_begin trace point
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (192 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] dynamic-debug-howto: fix optional/omitted ending line number to be LARGE instead of 0 Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] sctp: do not free asoc when it is already dead in sctp_sendmsg Sasha Levin
                   ` (101 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Chuck Lever, Anna Schumaker, Sasha Levin

From: Chuck Lever <chuck.lever@oracle.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit b2bfe5915d5fe7577221031a39ac722a0a2a1199 ]

The rpc_task_begin trace point always display a task ID of zero.
Move the trace point call site so that it picks up the new task ID.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/sunrpc/sched.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 337ca851a350..d1907b3cf832 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -273,10 +273,9 @@ static inline void rpc_task_set_debuginfo(struct rpc_task *task)
 
 static void rpc_set_active(struct rpc_task *task)
 {
-	trace_rpc_task_begin(task->tk_client, task, NULL);
-
 	rpc_task_set_debuginfo(task);
 	set_bit(RPC_TASK_ACTIVE, &task->tk_runstate);
+	trace_rpc_task_begin(task->tk_client, task, NULL);
 }
 
 /*
-- 
2.11.0

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

* [added to the 4.1 stable tree] sparc64/mm: set fields in deferred pages
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (194 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] sctp: do not free asoc when it is already dead in sctp_sendmsg Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] atm: horizon: Fix irq release error Sasha Levin
                   ` (99 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Pavel Tatashin, Andrew Morton, Linus Torvalds, Sasha Levin

From: Pavel Tatashin <pasha.tatashin@oracle.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 2a20aa171071a334d80c4e5d5af719d8374702fc ]

Without deferred struct page feature (CONFIG_DEFERRED_STRUCT_PAGE_INIT),
flags and other fields in "struct page"es are never changed prior to
first initializing struct pages by going through __init_single_page().

With deferred struct page feature enabled there is a case where we set
some fields prior to initializing:

mem_init() {
     register_page_bootmem_info();
     free_all_bootmem();
     ...
}

When register_page_bootmem_info() is called only non-deferred struct
pages are initialized.  But, this function goes through some reserved
pages which might be part of the deferred, and thus are not yet
initialized.

mem_init
register_page_bootmem_info
register_page_bootmem_info_node
 get_page_bootmem
  .. setting fields here ..
  such as: page->freelist = (void *)type;

free_all_bootmem()
free_low_memory_core_early()
 for_each_reserved_mem_region()
  reserve_bootmem_region()
   init_reserved_page() <- Only if this is deferred reserved page
    __init_single_pfn()
     __init_single_page()
      memset(0) <-- Loose the set fields here

We end up with similar issue as in the previous patch, where currently
we do not observe problem as memory is zeroed.  But, if flag asserts are
changed we can start hitting issues.

Also, because in this patch series we will stop zeroing struct page
memory during allocation, we must make sure that struct pages are
properly initialized prior to using them.

The deferred-reserved pages are initialized in free_all_bootmem().
Therefore, the fix is to switch the above calls.

Link: http://lkml.kernel.org/r/20171013173214.27300-4-pasha.tatashin@oracle.com
Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Reviewed-by: Steven Sistare <steven.sistare@oracle.com>
Reviewed-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Reviewed-by: Bob Picco <bob.picco@oracle.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/sparc/mm/init_64.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index 214da575fdc5..49646684b42c 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -2285,10 +2285,17 @@ void __init mem_init(void)
 {
 	high_memory = __va(last_valid_pfn << PAGE_SHIFT);
 
-	register_page_bootmem_info();
 	free_all_bootmem();
 
 	/*
+	 * Must be done after boot memory is put on freelist, because here we
+	 * might set fields in deferred struct pages that have not yet been
+	 * initialized, and free_all_bootmem() initializes all the reserved
+	 * deferred pages for us.
+	 */
+	register_page_bootmem_info();
+
+	/*
 	 * Set up the zero page, mark it reserved, so that page count
 	 * is not manipulated when freeing the page from user ptes.
 	 */
-- 
2.11.0

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

* [added to the 4.1 stable tree] sctp: use the right sk after waking up from wait_buf sleep
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (196 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] atm: horizon: Fix irq release error Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] IB/mlx4: Increase maximal message size under UD QP Sasha Levin
                   ` (97 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Xin Long, David S . Miller, Sasha Levin

From: Xin Long <lucien.xin@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit cea0cc80a6777beb6eb643d4ad53690e1ad1d4ff ]

Commit dfcb9f4f99f1 ("sctp: deny peeloff operation on asocs with threads
sleeping on it") fixed the race between peeloff and wait sndbuf by
checking waitqueue_active(&asoc->wait) in sctp_do_peeloff().

But it actually doesn't work, as even if waitqueue_active returns false
the waiting sndbuf thread may still not yet hold sk lock. After asoc is
peeled off, sk is not asoc->base.sk any more, then to hold the old sk
lock couldn't make assoc safe to access.

This patch is to fix this by changing to hold the new sk lock if sk is
not asoc->base.sk, meanwhile, also set the sk in sctp_sendmsg with the
new sk.

With this fix, there is no more race between peeloff and waitbuf, the
check 'waitqueue_active' in sctp_do_peeloff can be removed.

Thanks Marcelo and Neil for making this clear.

v1->v2:
  fix it by changing to lock the new sock instead of adding a flag in asoc.

Suggested-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/sctp/socket.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 5ad280d102c3..946d1c28f93f 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -82,8 +82,8 @@
 /* Forward declarations for internal helper functions. */
 static int sctp_writeable(struct sock *sk);
 static void sctp_wfree(struct sk_buff *skb);
-static int sctp_wait_for_sndbuf(struct sctp_association *, long *timeo_p,
-				size_t msg_len);
+static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
+				size_t msg_len, struct sock **orig_sk);
 static int sctp_wait_for_packet(struct sock *sk, int *err, long *timeo_p);
 static int sctp_wait_for_connect(struct sctp_association *, long *timeo_p);
 static int sctp_wait_for_accept(struct sock *sk, long timeo);
@@ -1947,7 +1947,8 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
 
 	timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
 	if (!sctp_wspace(asoc)) {
-		err = sctp_wait_for_sndbuf(asoc, &timeo, msg_len);
+		/* sk can be changed by peel off when waiting for buf. */
+		err = sctp_wait_for_sndbuf(asoc, &timeo, msg_len, &sk);
 		if (err) {
 			if (err == -ESRCH) {
 				/* asoc is already dead. */
@@ -6978,7 +6979,7 @@ void sctp_sock_rfree(struct sk_buff *skb)
 
 /* Helper function to wait for space in the sndbuf.  */
 static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
-				size_t msg_len)
+				size_t msg_len, struct sock **orig_sk)
 {
 	struct sock *sk = asoc->base.sk;
 	int err = 0;
@@ -7013,11 +7014,17 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
 		current_timeo = schedule_timeout(current_timeo);
 		BUG_ON(sk != asoc->base.sk);
 		lock_sock(sk);
+		if (sk != asoc->base.sk) {
+			release_sock(sk);
+			sk = asoc->base.sk;
+			lock_sock(sk);
+		}
 
 		*timeo_p = current_timeo;
 	}
 
 out:
+	*orig_sk = sk;
 	finish_wait(&asoc->wait, &wait);
 
 	/* Release the association's refcnt.  */
-- 
2.11.0

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

* [added to the 4.1 stable tree] atm: horizon: Fix irq release error
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (195 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] sparc64/mm: set fields in deferred pages Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] sctp: use the right sk after waking up from wait_buf sleep Sasha Levin
                   ` (98 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Arvind Yadav, David S . Miller, Sasha Levin

From: Arvind Yadav <arvind.yadav.cs@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit bde533f2ea607cbbbe76ef8738b36243939a7bc2 ]

atm_dev_register() can fail here and passed parameters to free irq
which is not initialised. Initialization of 'dev->irq' happened after
the 'goto out_free_irq'. So using 'irq' insted of 'dev->irq' in
free_irq().

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/atm/horizon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index 527bbd595e37..d9b762a62e25 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -2804,7 +2804,7 @@ static int hrz_probe(struct pci_dev *pci_dev,
 	return err;
 
 out_free_irq:
-	free_irq(dev->irq, dev);
+	free_irq(irq, dev);
 out_free:
 	kfree(dev);
 out_release:
-- 
2.11.0

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

* [added to the 4.1 stable tree] IB/mlx4: Increase maximal message size under UD QP
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (197 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] sctp: use the right sk after waking up from wait_buf sleep Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] xfrm: Copy policy family in clone_policy Sasha Levin
                   ` (96 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Mark Bloch, Leon Romanovsky, Doug Ledford, Sasha Levin

From: Mark Bloch <markb@mellanox.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 5f22a1d87c5315a98981ecf93cd8de226cffe6ca ]

Maximal message should be used as a limit to the max message payload allowed,
without the headers. The ConnectX-3 check is done against this value includes
the headers. When the payload is 4K this will cause the NIC to drop packets.

Increase maximal message to 8K as workaround, this shouldn't change current
behaviour because we continue to set the MTU to 4k.

To reproduce;
set MTU to 4296 on the corresponding interface, for example:
ifconfig eth0 mtu 4296 (both server and client)

On server:
ib_send_bw -c UD -d mlx4_0 -s 4096 -n 1000000 -i1 -m 4096

On client:
ib_send_bw -d mlx4_0 -c UD <server_ip> -s 4096 -n 1000000 -i 1 -m 4096

Fixes: 6e0d733d9215 ("IB/mlx4: Allow 4K messages for UD QPs")
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/infiniband/hw/mlx4/qp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 02fc91c68027..ca24eebb5a35 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1496,7 +1496,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
 			context->mtu_msgmax = (IB_MTU_4096 << 5) |
 					      ilog2(dev->dev->caps.max_gso_sz);
 		else
-			context->mtu_msgmax = (IB_MTU_4096 << 5) | 12;
+			context->mtu_msgmax = (IB_MTU_4096 << 5) | 13;
 	} else if (attr_mask & IB_QP_PATH_MTU) {
 		if (attr->path_mtu < IB_MTU_256 || attr->path_mtu > IB_MTU_4096) {
 			pr_err("path MTU (%u) is invalid\n",
-- 
2.11.0

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

* [added to the 4.1 stable tree] xfrm: Copy policy family in clone_policy
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (198 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] IB/mlx4: Increase maximal message size under UD QP Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] IB/mlx5: Assign send CQ and recv CQ of UMR QP Sasha Levin
                   ` (95 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Herbert Xu, Steffen Klassert, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 0e74aa1d79a5bbc663e03a2804399cae418a0321 ]

The syzbot found an ancient bug in the IPsec code.  When we cloned
a socket policy (for example, for a child TCP socket derived from a
listening socket), we did not copy the family field.  This results
in a live policy with a zero family field.  This triggers a BUG_ON
check in the af_key code when the cloned policy is retrieved.

This patch fixes it by copying the family field over.

Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/xfrm/xfrm_policy.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 85cddb37feac..7306683a7207 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1352,6 +1352,7 @@ static struct xfrm_policy *clone_policy(const struct xfrm_policy *old, int dir)
 		newp->xfrm_nr = old->xfrm_nr;
 		newp->index = old->index;
 		newp->type = old->type;
+		newp->family = old->family;
 		memcpy(newp->xfrm_vec, old->xfrm_vec,
 		       newp->xfrm_nr*sizeof(struct xfrm_tmpl));
 		write_lock_bh(&net->xfrm.xfrm_policy_lock);
-- 
2.11.0

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

* [added to the 4.1 stable tree] afs: Connect up the CB.ProbeUuid
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (200 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] IB/mlx5: Assign send CQ and recv CQ of UMR QP Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] audit: ensure that 'audit=1' actually enables audit for PID 1 Sasha Levin
                   ` (93 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David Howells, Sasha Levin

From: David Howells <dhowells@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f4b3526d83c40dd8bf5948b9d7a1b2c340f0dcc8 ]

The handler for the CB.ProbeUuid operation in the cache manager is
implemented, but isn't listed in the switch-statement of operation
selection, so won't be used.  Fix this by adding it.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/afs/cmservice.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c
index 4b0eff6da674..83a8a33a0d73 100644
--- a/fs/afs/cmservice.c
+++ b/fs/afs/cmservice.c
@@ -115,6 +115,9 @@ bool afs_cm_incoming_call(struct afs_call *call)
 	case CBProbe:
 		call->type = &afs_SRXCBProbe;
 		return true;
+	case CBProbeUuid:
+		call->type = &afs_SRXCBProbeUuid;
+		return true;
 	case CBTellMeAboutYourself:
 		call->type = &afs_SRXCBTellMeAboutYourself;
 		return true;
-- 
2.11.0

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

* [added to the 4.1 stable tree] IB/mlx5: Assign send CQ and recv CQ of UMR QP
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (199 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] xfrm: Copy policy family in clone_policy Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Connect up the CB.ProbeUuid Sasha Levin
                   ` (94 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Majd Dibbiny, Leon Romanovsky, Doug Ledford, Sasha Levin

From: Majd Dibbiny <majd@mellanox.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 31fde034a8bd964a5c7c1a5663fc87a913158db2 ]

The UMR's QP is created by calling mlx5_ib_create_qp directly, and
therefore the send CQ and the recv CQ on the ibqp weren't assigned.

Assign them right after calling the mlx5_ib_create_qp to assure
that any access to those pointers will work as expected and won't
crash the system as might happen as part of reset flow.

Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
Signed-off-by: Majd Dibbiny <majd@mellanox.com>
Reviewed-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/infiniband/hw/mlx5/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 57c9809e8b87..031801671b80 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -1020,6 +1020,8 @@ static int create_umr_res(struct mlx5_ib_dev *dev)
 	qp->real_qp    = qp;
 	qp->uobject    = NULL;
 	qp->qp_type    = MLX5_IB_QPT_REG_UMR;
+	qp->send_cq    = init_attr->send_cq;
+	qp->recv_cq    = init_attr->recv_cq;
 
 	attr->qp_state = IB_QPS_INIT;
 	attr->port_num = 1;
-- 
2.11.0

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

* [added to the 4.1 stable tree] audit: ensure that 'audit=1' actually enables audit for PID 1
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (201 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Connect up the CB.ProbeUuid Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] sit: update frag_off info Sasha Levin
                   ` (92 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Paul Moore, Sasha Levin

From: Paul Moore <paul@paul-moore.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 173743dd99a49c956b124a74c8aacb0384739a4c ]

Prior to this patch we enabled audit in audit_init(), which is too
late for PID 1 as the standard initcalls are run after the PID 1 task
is forked.  This means that we never allocate an audit_context (see
audit_alloc()) for PID 1 and therefore miss a lot of audit events
generated by PID 1.

This patch enables audit as early as possible to help ensure that when
PID 1 is forked it can allocate an audit_context if required.

Reviewed-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 kernel/audit.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 1c13e4267de6..ae05a41d713a 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -80,13 +80,13 @@ static int	audit_initialized;
 #define AUDIT_OFF	0
 #define AUDIT_ON	1
 #define AUDIT_LOCKED	2
-u32		audit_enabled;
-u32		audit_ever_enabled;
+u32		audit_enabled = AUDIT_OFF;
+u32		audit_ever_enabled = !!AUDIT_OFF;
 
 EXPORT_SYMBOL_GPL(audit_enabled);
 
 /* Default state when kernel boots without any parameters. */
-static u32	audit_default;
+static u32	audit_default = AUDIT_OFF;
 
 /* If auditing cannot proceed, audit_failure selects what happens. */
 static u32	audit_failure = AUDIT_FAIL_PRINTK;
@@ -1165,8 +1165,6 @@ static int __init audit_init(void)
 	skb_queue_head_init(&audit_skb_queue);
 	skb_queue_head_init(&audit_skb_hold_queue);
 	audit_initialized = AUDIT_INITIALIZED;
-	audit_enabled = audit_default;
-	audit_ever_enabled |= !!audit_default;
 
 	audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL, "initialized");
 
@@ -1183,6 +1181,8 @@ static int __init audit_enable(char *str)
 	audit_default = !!simple_strtol(str, NULL, 0);
 	if (!audit_default)
 		audit_initialized = AUDIT_DISABLED;
+	audit_enabled = audit_default;
+	audit_ever_enabled = !!audit_enabled;
 
 	pr_info("%s\n", audit_default ?
 		"enabled (after initialization)" : "disabled (until reboot)");
-- 
2.11.0

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

* [added to the 4.1 stable tree] rds: Fix NULL pointer dereference in __rds_rdma_map
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (203 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] sit: update frag_off info Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net/packet: fix a race in packet_bind() and packet_notifier() Sasha Levin
                   ` (90 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Håkon Bugge, Håkon Bugge, David S . Miller, Sasha Levin

From: Håkon Bugge <Haakon.Bugge@oracle.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f3069c6d33f6ae63a1668737bc78aaaa51bff7ca ]

This is a fix for syzkaller719569, where memory registration was
attempted without any underlying transport being loaded.

Analysis of the case reveals that it is the setsockopt() RDS_GET_MR
(2) and RDS_GET_MR_FOR_DEST (7) that are vulnerable.

Here is an example stack trace when the bug is hit:

BUG: unable to handle kernel NULL pointer dereference at 00000000000000c0
IP: __rds_rdma_map+0x36/0x440 [rds]
PGD 2f93d03067 P4D 2f93d03067 PUD 2f93d02067 PMD 0
Oops: 0000 [#1] SMP
Modules linked in: bridge stp llc tun rpcsec_gss_krb5 nfsv4
dns_resolver nfs fscache rds binfmt_misc sb_edac intel_powerclamp
coretemp kvm_intel kvm irqbypass crct10dif_pclmul c rc32_pclmul
ghash_clmulni_intel pcbc aesni_intel crypto_simd glue_helper cryptd
iTCO_wdt mei_me sg iTCO_vendor_support ipmi_si mei ipmi_devintf nfsd
shpchp pcspkr i2c_i801 ioatd ma ipmi_msghandler wmi lpc_ich mfd_core
auth_rpcgss nfs_acl lockd grace sunrpc ip_tables ext4 mbcache jbd2
mgag200 i2c_algo_bit drm_kms_helper ixgbe syscopyarea ahci sysfillrect
sysimgblt libahci mdio fb_sys_fops ttm ptp libata sd_mod mlx4_core drm
crc32c_intel pps_core megaraid_sas i2c_core dca dm_mirror
dm_region_hash dm_log dm_mod
CPU: 48 PID: 45787 Comm: repro_set2 Not tainted 4.14.2-3.el7uek.x86_64 #2
Hardware name: Oracle Corporation ORACLE SERVER X5-2L/ASM,MOBO TRAY,2U, BIOS 31110000 03/03/2017
task: ffff882f9190db00 task.stack: ffffc9002b994000
RIP: 0010:__rds_rdma_map+0x36/0x440 [rds]
RSP: 0018:ffffc9002b997df0 EFLAGS: 00010202
RAX: 0000000000000000 RBX: ffff882fa2182580 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffc9002b997e40 RDI: ffff882fa2182580
RBP: ffffc9002b997e30 R08: 0000000000000000 R09: 0000000000000002
R10: ffff885fb29e3838 R11: 0000000000000000 R12: ffff882fa2182580
R13: ffff882fa2182580 R14: 0000000000000002 R15: 0000000020000ffc
FS:  00007fbffa20b700(0000) GS:ffff882fbfb80000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000000000c0 CR3: 0000002f98a66006 CR4: 00000000001606e0
Call Trace:
 rds_get_mr+0x56/0x80 [rds]
 rds_setsockopt+0x172/0x340 [rds]
 ? __fget_light+0x25/0x60
 ? __fdget+0x13/0x20
 SyS_setsockopt+0x80/0xe0
 do_syscall_64+0x67/0x1b0
 entry_SYSCALL64_slow_path+0x25/0x25
RIP: 0033:0x7fbff9b117f9
RSP: 002b:00007fbffa20aed8 EFLAGS: 00000293 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 00000000000c84a4 RCX: 00007fbff9b117f9
RDX: 0000000000000002 RSI: 0000400000000114 RDI: 000000000000109b
RBP: 00007fbffa20af10 R08: 0000000000000020 R09: 00007fbff9dd7860
R10: 0000000020000ffc R11: 0000000000000293 R12: 0000000000000000
R13: 00007fbffa20b9c0 R14: 00007fbffa20b700 R15: 0000000000000021

Code: 41 56 41 55 49 89 fd 41 54 53 48 83 ec 18 8b 87 f0 02 00 00 48
89 55 d0 48 89 4d c8 85 c0 0f 84 2d 03 00 00 48 8b 87 00 03 00 00 <48>
83 b8 c0 00 00 00 00 0f 84 25 03 00 0 0 48 8b 06 48 8b 56 08

The fix is to check the existence of an underlying transport in
__rds_rdma_map().

Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/rds/rdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 3738b1920c09..612c3050d514 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -184,7 +184,7 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
 	long i;
 	int ret;
 
-	if (rs->rs_bound_addr == 0) {
+	if (rs->rs_bound_addr == 0 || !rs->rs_transport) {
 		ret = -ENOTCONN; /* XXX not a great errno */
 		goto out;
 	}
-- 
2.11.0

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

* [added to the 4.1 stable tree] sit: update frag_off info
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (202 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] audit: ensure that 'audit=1' actually enables audit for PID 1 Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] rds: Fix NULL pointer dereference in __rds_rdma_map Sasha Levin
                   ` (91 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Hangbin Liu, David S . Miller, Sasha Levin

From: Hangbin Liu <liuhangbin@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f859b4af1c52493ec21173ccc73d0b60029b5b88 ]

After parsing the sit netlink change info, we forget to update frag_off in
ipip6_tunnel_update(). Fix it by assigning frag_off with new value.

Reported-by: Jianlin Shi <jishi@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/ipv6/sit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 85c4b2fff504..295502b261a8 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1092,6 +1092,7 @@ static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p)
 	ipip6_tunnel_link(sitn, t);
 	t->parms.iph.ttl = p->iph.ttl;
 	t->parms.iph.tos = p->iph.tos;
+	t->parms.iph.frag_off = p->iph.frag_off;
 	if (t->parms.link != p->link) {
 		t->parms.link = p->link;
 		ipip6_tunnel_bind_dev(t->dev);
-- 
2.11.0

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

* [added to the 4.1 stable tree] net/packet: fix a race in packet_bind() and packet_notifier()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (204 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] rds: Fix NULL pointer dereference in __rds_rdma_map Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] usb: gadget: ffs: Forbid usb_ep_alloc_request from sleeping Sasha Levin
                   ` (89 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Dumazet, David S . Miller, Sasha Levin

From: Eric Dumazet <edumazet@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 15fe076edea787807a7cdc168df832544b58eba6 ]

syzbot reported crashes [1] and provided a C repro easing bug hunting.

When/if packet_do_bind() calls __unregister_prot_hook() and releases
po->bind_lock, another thread can run packet_notifier() and process an
NETDEV_UP event.

This calls register_prot_hook() and hooks again the socket right before
first thread is able to grab again po->bind_lock.

Fixes this issue by temporarily setting po->num to 0, as suggested by
David Miller.

[1]
dev_remove_pack: ffff8801bf16fa80 not found
------------[ cut here ]------------
kernel BUG at net/core/dev.c:7945!  ( BUG_ON(!list_empty(&dev->ptype_all)); )
invalid opcode: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
device syz0 entered promiscuous mode
CPU: 0 PID: 3161 Comm: syzkaller404108 Not tainted 4.14.0+ #190
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
task: ffff8801cc57a500 task.stack: ffff8801cc588000
RIP: 0010:netdev_run_todo+0x772/0xae0 net/core/dev.c:7945
RSP: 0018:ffff8801cc58f598 EFLAGS: 00010293
RAX: ffff8801cc57a500 RBX: dffffc0000000000 RCX: ffffffff841f75b2
RDX: 0000000000000000 RSI: 1ffff100398b1ede RDI: ffff8801bf1f8810
device syz0 entered promiscuous mode
RBP: ffff8801cc58f898 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffff8801bf1f8cd8
R13: ffff8801cc58f870 R14: ffff8801bf1f8780 R15: ffff8801cc58f7f0
FS:  0000000001716880(0000) GS:ffff8801db400000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020b13000 CR3: 0000000005e25000 CR4: 00000000001406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 rtnl_unlock+0xe/0x10 net/core/rtnetlink.c:106
 tun_detach drivers/net/tun.c:670 [inline]
 tun_chr_close+0x49/0x60 drivers/net/tun.c:2845
 __fput+0x333/0x7f0 fs/file_table.c:210
 ____fput+0x15/0x20 fs/file_table.c:244
 task_work_run+0x199/0x270 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x9bb/0x1ae0 kernel/exit.c:865
 do_group_exit+0x149/0x400 kernel/exit.c:968
 SYSC_exit_group kernel/exit.c:979 [inline]
 SyS_exit_group+0x1d/0x20 kernel/exit.c:977
 entry_SYSCALL_64_fastpath+0x1f/0x96
RIP: 0033:0x44ad19

Fixes: 30f7ea1c2b5f ("packet: race condition in packet_bind")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Cc: Francesco Ruggeri <fruggeri@aristanetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/packet/af_packet.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 4bfdd9416e6c..7f5d147aff63 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2730,6 +2730,10 @@ static int packet_do_bind(struct sock *sk, const char *name, int ifindex,
 	if (need_rehook) {
 		if (po->running) {
 			rcu_read_unlock();
+			/* prevents packet_notifier() from calling
+			 * register_prot_hook()
+			 */
+			po->num = 0;
 			__unregister_prot_hook(sk, true);
 			rcu_read_lock();
 			dev_curr = po->prot_hook.dev;
@@ -2738,6 +2742,7 @@ static int packet_do_bind(struct sock *sk, const char *name, int ifindex,
 								 dev->ifindex);
 		}
 
+		BUG_ON(po->running);
 		po->num = proto;
 		po->prot_hook.type = proto;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] usb: gadget: ffs: Forbid usb_ep_alloc_request from sleeping
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (205 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net/packet: fix a race in packet_bind() and packet_notifier() Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] crypto: hmac - require that the underlying hash algorithm is unkeyed Sasha Levin
                   ` (88 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Vincent Pelletier, Felipe Balbi, Sasha Levin

From: Vincent Pelletier <plr.vincent@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 30bf90ccdec1da9c8198b161ecbff39ce4e5a9ba ]

Found using DEBUG_ATOMIC_SLEEP while submitting an AIO read operation:

[  100.853642] BUG: sleeping function called from invalid context at mm/slab.h:421
[  100.861148] in_atomic(): 1, irqs_disabled(): 1, pid: 1880, name: python
[  100.867954] 2 locks held by python/1880:
[  100.867961]  #0:  (&epfile->mutex){....}, at: [<f8188627>] ffs_mutex_lock+0x27/0x30 [usb_f_fs]
[  100.868020]  #1:  (&(&ffs->eps_lock)->rlock){....}, at: [<f818ad4b>] ffs_epfile_io.isra.17+0x24b/0x590 [usb_f_fs]
[  100.868076] CPU: 1 PID: 1880 Comm: python Not tainted 4.14.0-edison+ #118
[  100.868085] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48
[  100.868093] Call Trace:
[  100.868122]  dump_stack+0x47/0x62
[  100.868156]  ___might_sleep+0xfd/0x110
[  100.868182]  __might_sleep+0x68/0x70
[  100.868217]  kmem_cache_alloc_trace+0x4b/0x200
[  100.868248]  ? dwc3_gadget_ep_alloc_request+0x24/0xe0 [dwc3]
[  100.868302]  dwc3_gadget_ep_alloc_request+0x24/0xe0 [dwc3]
[  100.868343]  usb_ep_alloc_request+0x16/0xc0 [udc_core]
[  100.868386]  ffs_epfile_io.isra.17+0x444/0x590 [usb_f_fs]
[  100.868424]  ? _raw_spin_unlock_irqrestore+0x27/0x40
[  100.868457]  ? kiocb_set_cancel_fn+0x57/0x60
[  100.868477]  ? ffs_ep0_poll+0xc0/0xc0 [usb_f_fs]
[  100.868512]  ffs_epfile_read_iter+0xfe/0x157 [usb_f_fs]
[  100.868551]  ? security_file_permission+0x9c/0xd0
[  100.868587]  ? rw_verify_area+0xac/0x120
[  100.868633]  aio_read+0x9d/0x100
[  100.868692]  ? __fget+0xa2/0xd0
[  100.868727]  ? __might_sleep+0x68/0x70
[  100.868763]  SyS_io_submit+0x471/0x680
[  100.868878]  do_int80_syscall_32+0x4e/0xd0
[  100.868921]  entry_INT80_32+0x2a/0x2a
[  100.868932] EIP: 0xb7fbb676
[  100.868941] EFLAGS: 00000292 CPU: 1
[  100.868951] EAX: ffffffda EBX: b7aa2000 ECX: 00000002 EDX: b7af8368
[  100.868961] ESI: b7fbb660 EDI: b7aab000 EBP: bfb6c658 ESP: bfb6c638
[  100.868973]  DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b

Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/gadget/function/f_fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 804b209f4c08..2c25a5dec442 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -791,7 +791,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
 		}
 
 		if (io_data->aio) {
-			req = usb_ep_alloc_request(ep->ep, GFP_KERNEL);
+			req = usb_ep_alloc_request(ep->ep, GFP_ATOMIC);
 			if (unlikely(!req))
 				goto error_lock;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] crypto: salsa20 - fix blkcipher_walk API usage
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (207 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] crypto: hmac - require that the underlying hash algorithm is unkeyed Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] autofs: fix careless error in recent commit Sasha Levin
                   ` (86 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Biggers, Herbert Xu, Sasha Levin

From: Eric Biggers <ebiggers@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit ecaaab5649781c5a0effdaf298a925063020500e ]

When asked to encrypt or decrypt 0 bytes, both the generic and x86
implementations of Salsa20 crash in blkcipher_walk_done(), either when
doing 'kfree(walk->buffer)' or 'free_page((unsigned long)walk->page)',
because walk->buffer and walk->page have not been initialized.

The bug is that Salsa20 is calling blkcipher_walk_done() even when
nothing is in 'walk.nbytes'.  But blkcipher_walk_done() is only meant to
be called when a nonzero number of bytes have been provided.

The broken code is part of an optimization that tries to make only one
call to salsa20_encrypt_bytes() to process inputs that are not evenly
divisible by 64 bytes.  To fix the bug, just remove this "optimization"
and use the blkcipher_walk API the same way all the other users do.

Reproducer:

    #include <linux/if_alg.h>
    #include <sys/socket.h>
    #include <unistd.h>

    int main()
    {
            int algfd, reqfd;
            struct sockaddr_alg addr = {
                    .salg_type = "skcipher",
                    .salg_name = "salsa20",
            };
            char key[16] = { 0 };

            algfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
            bind(algfd, (void *)&addr, sizeof(addr));
            reqfd = accept(algfd, 0, 0);
            setsockopt(algfd, SOL_ALG, ALG_SET_KEY, key, sizeof(key));
            read(reqfd, key, sizeof(key));
    }

Reported-by: syzbot <syzkaller@googlegroups.com>
Fixes: eb6f13eb9f81 ("[CRYPTO] salsa20_generic: Fix multi-page processing")
Cc: <stable@vger.kernel.org> # v2.6.25+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/x86/crypto/salsa20_glue.c | 7 -------
 crypto/salsa20_generic.c       | 7 -------
 2 files changed, 14 deletions(-)

diff --git a/arch/x86/crypto/salsa20_glue.c b/arch/x86/crypto/salsa20_glue.c
index 399a29d067d6..cb91a64a99e7 100644
--- a/arch/x86/crypto/salsa20_glue.c
+++ b/arch/x86/crypto/salsa20_glue.c
@@ -59,13 +59,6 @@ static int encrypt(struct blkcipher_desc *desc,
 
 	salsa20_ivsetup(ctx, walk.iv);
 
-	if (likely(walk.nbytes == nbytes))
-	{
-		salsa20_encrypt_bytes(ctx, walk.src.virt.addr,
-				      walk.dst.virt.addr, nbytes);
-		return blkcipher_walk_done(desc, &walk, 0);
-	}
-
 	while (walk.nbytes >= 64) {
 		salsa20_encrypt_bytes(ctx, walk.src.virt.addr,
 				      walk.dst.virt.addr,
diff --git a/crypto/salsa20_generic.c b/crypto/salsa20_generic.c
index f550b5d94630..d7da0eea5622 100644
--- a/crypto/salsa20_generic.c
+++ b/crypto/salsa20_generic.c
@@ -188,13 +188,6 @@ static int encrypt(struct blkcipher_desc *desc,
 
 	salsa20_ivsetup(ctx, walk.iv);
 
-	if (likely(walk.nbytes == nbytes))
-	{
-		salsa20_encrypt_bytes(ctx, walk.dst.virt.addr,
-				      walk.src.virt.addr, nbytes);
-		return blkcipher_walk_done(desc, &walk, 0);
-	}
-
 	while (walk.nbytes >= 64) {
 		salsa20_encrypt_bytes(ctx, walk.dst.virt.addr,
 				      walk.src.virt.addr,
-- 
2.11.0

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

* [added to the 4.1 stable tree] crypto: hmac - require that the underlying hash algorithm is unkeyed
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (206 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] usb: gadget: ffs: Forbid usb_ep_alloc_request from sleeping Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] crypto: salsa20 - fix blkcipher_walk API usage Sasha Levin
                   ` (87 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eric Biggers, Herbert Xu, Sasha Levin

From: Eric Biggers <ebiggers@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit af3ff8045bbf3e32f1a448542e73abb4c8ceb6f1 ]

Because the HMAC template didn't check that its underlying hash
algorithm is unkeyed, trying to use "hmac(hmac(sha3-512-generic))"
through AF_ALG or through KEYCTL_DH_COMPUTE resulted in the inner HMAC
being used without having been keyed, resulting in sha3_update() being
called without sha3_init(), causing a stack buffer overflow.

This is a very old bug, but it seems to have only started causing real
problems when SHA-3 support was added (requires CONFIG_CRYPTO_SHA3)
because the innermost hash's state is ->import()ed from a zeroed buffer,
and it just so happens that other hash algorithms are fine with that,
but SHA-3 is not.  However, there could be arch or hardware-dependent
hash algorithms also affected; I couldn't test everything.

Fix the bug by introducing a function crypto_shash_alg_has_setkey()
which tests whether a shash algorithm is keyed.  Then update the HMAC
template to require that its underlying hash algorithm is unkeyed.

Here is a reproducer:

    #include <linux/if_alg.h>
    #include <sys/socket.h>

    int main()
    {
        int algfd;
        struct sockaddr_alg addr = {
            .salg_type = "hash",
            .salg_name = "hmac(hmac(sha3-512-generic))",
        };
        char key[4096] = { 0 };

        algfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
        bind(algfd, (const struct sockaddr *)&addr, sizeof(addr));
        setsockopt(algfd, SOL_ALG, ALG_SET_KEY, key, sizeof(key));
    }

Here was the KASAN report from syzbot:

    BUG: KASAN: stack-out-of-bounds in memcpy include/linux/string.h:341  [inline]
    BUG: KASAN: stack-out-of-bounds in sha3_update+0xdf/0x2e0  crypto/sha3_generic.c:161
    Write of size 4096 at addr ffff8801cca07c40 by task syzkaller076574/3044

    CPU: 1 PID: 3044 Comm: syzkaller076574 Not tainted 4.14.0-mm1+ #25
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  Google 01/01/2011
    Call Trace:
      __dump_stack lib/dump_stack.c:17 [inline]
      dump_stack+0x194/0x257 lib/dump_stack.c:53
      print_address_description+0x73/0x250 mm/kasan/report.c:252
      kasan_report_error mm/kasan/report.c:351 [inline]
      kasan_report+0x25b/0x340 mm/kasan/report.c:409
      check_memory_region_inline mm/kasan/kasan.c:260 [inline]
      check_memory_region+0x137/0x190 mm/kasan/kasan.c:267
      memcpy+0x37/0x50 mm/kasan/kasan.c:303
      memcpy include/linux/string.h:341 [inline]
      sha3_update+0xdf/0x2e0 crypto/sha3_generic.c:161
      crypto_shash_update+0xcb/0x220 crypto/shash.c:109
      shash_finup_unaligned+0x2a/0x60 crypto/shash.c:151
      crypto_shash_finup+0xc4/0x120 crypto/shash.c:165
      hmac_finup+0x182/0x330 crypto/hmac.c:152
      crypto_shash_finup+0xc4/0x120 crypto/shash.c:165
      shash_digest_unaligned+0x9e/0xd0 crypto/shash.c:172
      crypto_shash_digest+0xc4/0x120 crypto/shash.c:186
      hmac_setkey+0x36a/0x690 crypto/hmac.c:66
      crypto_shash_setkey+0xad/0x190 crypto/shash.c:64
      shash_async_setkey+0x47/0x60 crypto/shash.c:207
      crypto_ahash_setkey+0xaf/0x180 crypto/ahash.c:200
      hash_setkey+0x40/0x90 crypto/algif_hash.c:446
      alg_setkey crypto/af_alg.c:221 [inline]
      alg_setsockopt+0x2a1/0x350 crypto/af_alg.c:254
      SYSC_setsockopt net/socket.c:1851 [inline]
      SyS_setsockopt+0x189/0x360 net/socket.c:1830
      entry_SYSCALL_64_fastpath+0x1f/0x96

Reported-by: syzbot <syzkaller@googlegroups.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 crypto/hmac.c                  | 6 +++++-
 crypto/shash.c                 | 5 +++--
 include/crypto/internal/hash.h | 8 ++++++++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/crypto/hmac.c b/crypto/hmac.c
index 72e38c098bb3..ba07fb6221ae 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -194,11 +194,15 @@ static int hmac_create(struct crypto_template *tmpl, struct rtattr **tb)
 	salg = shash_attr_alg(tb[1], 0, 0);
 	if (IS_ERR(salg))
 		return PTR_ERR(salg);
+	alg = &salg->base;
 
+	/* The underlying hash algorithm must be unkeyed */
 	err = -EINVAL;
+	if (crypto_shash_alg_has_setkey(salg))
+		goto out_put_alg;
+
 	ds = salg->digestsize;
 	ss = salg->statesize;
-	alg = &salg->base;
 	if (ds > alg->cra_blocksize ||
 	    ss < alg->cra_blocksize)
 		goto out_put_alg;
diff --git a/crypto/shash.c b/crypto/shash.c
index 17510eaf0a36..73c065321867 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -24,11 +24,12 @@
 
 static const struct crypto_type crypto_shash_type;
 
-static int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
-			   unsigned int keylen)
+int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
+		    unsigned int keylen)
 {
 	return -ENOSYS;
 }
+EXPORT_SYMBOL_GPL(shash_no_setkey);
 
 static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
 				  unsigned int keylen)
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h
index a25414ce2898..9779c35f8454 100644
--- a/include/crypto/internal/hash.h
+++ b/include/crypto/internal/hash.h
@@ -83,6 +83,14 @@ int ahash_register_instance(struct crypto_template *tmpl,
 			    struct ahash_instance *inst);
 void ahash_free_instance(struct crypto_instance *inst);
 
+int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
+		    unsigned int keylen);
+
+static inline bool crypto_shash_alg_has_setkey(struct shash_alg *alg)
+{
+	return alg->setkey != shash_no_setkey;
+}
+
 int crypto_init_ahash_spawn(struct crypto_ahash_spawn *spawn,
 			    struct hash_alg_common *alg,
 			    struct crypto_instance *inst);
-- 
2.11.0

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

* [added to the 4.1 stable tree] autofs: fix careless error in recent commit
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (208 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] crypto: salsa20 - fix blkcipher_walk API usage Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] USB: uas and storage: Add US_FL_BROKEN_FUA for another JMicron JMS567 ID Sasha Levin
                   ` (85 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: NeilBrown, Andrew Morton, Linus Torvalds, Sasha Levin

From: NeilBrown <neilb@suse.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 302ec300ef8a545a7fc7f667e5fd743b091c2eeb ]

Commit ecc0c469f277 ("autofs: don't fail mount for transient error") was
meant to replace an 'if' with a 'switch', but instead added the 'switch'
leaving the case in place.

Link: http://lkml.kernel.org/r/87zi6wstmw.fsf@notabene.neil.brown.name
Fixes: ecc0c469f277 ("autofs: don't fail mount for transient error")
Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: NeilBrown <neilb@suse.com>
Cc: Ian Kent <raven@themaw.net>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/autofs4/waitq.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index fe6e7050fe50..98198c57370b 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -174,7 +174,6 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
 
 	mutex_unlock(&sbi->wq_mutex);
 
-	if (autofs4_write(sbi, pipe, &pkt, pktsz))
 	switch (ret = autofs4_write(sbi, pipe, &pkt, pktsz)) {
 	case 0:
 		break;
-- 
2.11.0

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

* [added to the 4.1 stable tree] tracing: Allocate mask_str buffer dynamically
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (210 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] USB: uas and storage: Add US_FL_BROKEN_FUA for another JMicron JMS567 ID Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] usbip: fix stub_send_ret_submit() vulnerability to null transfer_buffer Sasha Levin
                   ` (83 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Changbin Du, Steven Rostedt, Sasha Levin

From: Changbin Du <changbin.du@intel.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 90e406f96f630c07d631a021fd4af10aac913e77 ]

The default NR_CPUS can be very large, but actual possible nr_cpu_ids
usually is very small. For my x86 distribution, the NR_CPUS is 8192 and
nr_cpu_ids is 4. About 2 pages are wasted.

Most machines don't have so many CPUs, so define a array with NR_CPUS
just wastes memory. So let's allocate the buffer dynamically when need.

With this change, the mutext tracing_cpumask_update_lock also can be
removed now, which was used to protect mask_str.

Link: http://lkml.kernel.org/r/1512013183-19107-1-git-send-email-changbin.du@intel.com

Fixes: 36dfe9252bd4c ("ftrace: make use of tracing_cpumask")
Cc: stable@vger.kernel.org
Signed-off-by: Changbin Du <changbin.du@intel.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 kernel/trace/trace.c | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index ca1a306ea7e6..7a26798ffbf9 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3376,37 +3376,30 @@ static const struct file_operations show_traces_fops = {
 	.llseek		= seq_lseek,
 };
 
-/*
- * The tracer itself will not take this lock, but still we want
- * to provide a consistent cpumask to user-space:
- */
-static DEFINE_MUTEX(tracing_cpumask_update_lock);
-
-/*
- * Temporary storage for the character representation of the
- * CPU bitmask (and one more byte for the newline):
- */
-static char mask_str[NR_CPUS + 1];
-
 static ssize_t
 tracing_cpumask_read(struct file *filp, char __user *ubuf,
 		     size_t count, loff_t *ppos)
 {
 	struct trace_array *tr = file_inode(filp)->i_private;
+	char *mask_str;
 	int len;
 
-	mutex_lock(&tracing_cpumask_update_lock);
+	len = snprintf(NULL, 0, "%*pb\n",
+		       cpumask_pr_args(tr->tracing_cpumask)) + 1;
+	mask_str = kmalloc(len, GFP_KERNEL);
+	if (!mask_str)
+		return -ENOMEM;
 
-	len = snprintf(mask_str, count, "%*pb\n",
+	len = snprintf(mask_str, len, "%*pb\n",
 		       cpumask_pr_args(tr->tracing_cpumask));
 	if (len >= count) {
 		count = -EINVAL;
 		goto out_err;
 	}
-	count = simple_read_from_buffer(ubuf, count, ppos, mask_str, NR_CPUS+1);
+	count = simple_read_from_buffer(ubuf, count, ppos, mask_str, len);
 
 out_err:
-	mutex_unlock(&tracing_cpumask_update_lock);
+	kfree(mask_str);
 
 	return count;
 }
@@ -3426,8 +3419,6 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
 	if (err)
 		goto err_unlock;
 
-	mutex_lock(&tracing_cpumask_update_lock);
-
 	local_irq_disable();
 	arch_spin_lock(&tr->max_lock);
 	for_each_tracing_cpu(cpu) {
@@ -3450,8 +3441,6 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
 	local_irq_enable();
 
 	cpumask_copy(tr->tracing_cpumask, tracing_cpumask_new);
-
-	mutex_unlock(&tracing_cpumask_update_lock);
 	free_cpumask_var(tracing_cpumask_new);
 
 	return count;
-- 
2.11.0

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

* [added to the 4.1 stable tree] USB: uas and storage: Add US_FL_BROKEN_FUA for another JMicron JMS567 ID
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (209 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] autofs: fix careless error in recent commit Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] tracing: Allocate mask_str buffer dynamically Sasha Levin
                   ` (84 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David Kozub, Greg Kroah-Hartman, Sasha Levin

From: David Kozub <zub@linux.fjfi.cvut.cz>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 62354454625741f0569c2cbe45b2d192f8fd258e ]

There is another JMS567-based USB3 UAS enclosure (152d:0578) that fails
with the following error:

[sda] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[sda] tag#0 Sense Key : Illegal Request [current]
[sda] tag#0 Add. Sense: Invalid field in cdb

The issue occurs both with UAS (occasionally) and mass storage
(immediately after mounting a FS on a disk in the enclosure).

Enabling US_FL_BROKEN_FUA quirk solves this issue.

This patch adds an UNUSUAL_DEV with US_FL_BROKEN_FUA for the enclosure
for both UAS and mass storage.

Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/storage/unusual_devs.h | 7 +++++++
 drivers/usb/storage/unusual_uas.h  | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 8e80da125b25..cd2e880979f2 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -2138,6 +2138,13 @@ UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999,
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
 		US_FL_NO_REPORT_OPCODES),
 
+/* Reported by David Kozub <zub@linux.fjfi.cvut.cz> */
+UNUSUAL_DEV(0x152d, 0x0578, 0x0000, 0x9999,
+		"JMicron",
+		"JMS567",
+		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+		US_FL_BROKEN_FUA),
+
 /*
  * Patch by Constantin Baranov <const@tltsu.ru>
  * Report by Andreas Koenecke.
diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
index a37ed1e59e99..2f80163ffb94 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -141,6 +141,13 @@ UNUSUAL_DEV(0x152d, 0x0567, 0x0000, 0x9999,
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
 		US_FL_BROKEN_FUA | US_FL_NO_REPORT_OPCODES),
 
+/* Reported-by: David Kozub <zub@linux.fjfi.cvut.cz> */
+UNUSUAL_DEV(0x152d, 0x0578, 0x0000, 0x9999,
+		"JMicron",
+		"JMS567",
+		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+		US_FL_BROKEN_FUA),
+
 /* Reported-by: Hans de Goede <hdegoede@redhat.com> */
 UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999,
 		"VIA",
-- 
2.11.0

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

* [added to the 4.1 stable tree] usbip: fix stub_send_ret_submit() vulnerability to null transfer_buffer
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (211 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] tracing: Allocate mask_str buffer dynamically Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] USB: core: prevent malicious bNumInterfaces overflow Sasha Levin
                   ` (82 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Shuah Khan, Greg Kroah-Hartman, Sasha Levin

From: Shuah Khan <shuahkh@osg.samsung.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit be6123df1ea8f01ee2f896a16c2b7be3e4557a5a ]

stub_send_ret_submit() handles urb with a potential null transfer_buffer,
when it replays a packet with potential malicious data that could contain
a null buffer. Add a check for the condition when actual_length > 0 and
transfer_buffer is null.

Reported-by: Secunia Research <vuln@secunia.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/usbip/stub_tx.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/usbip/stub_tx.c b/drivers/usb/usbip/stub_tx.c
index 021003c4de53..af858d52608a 100644
--- a/drivers/usb/usbip/stub_tx.c
+++ b/drivers/usb/usbip/stub_tx.c
@@ -178,6 +178,13 @@ static int stub_send_ret_submit(struct stub_device *sdev)
 		memset(&pdu_header, 0, sizeof(pdu_header));
 		memset(&msg, 0, sizeof(msg));
 
+		if (urb->actual_length > 0 && !urb->transfer_buffer) {
+			dev_err(&sdev->udev->dev,
+				"urb: actual_length %d transfer_buffer null\n",
+				urb->actual_length);
+			return -1;
+		}
+
 		if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS)
 			iovnum = 2 + urb->number_of_packets;
 		else
-- 
2.11.0

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

* [added to the 4.1 stable tree] USB: core: prevent malicious bNumInterfaces overflow
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (212 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] usbip: fix stub_send_ret_submit() vulnerability to null transfer_buffer Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] Bluetooth: btusb: driver to enable the usb-wakeup feature Sasha Levin
                   ` (81 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Alan Stern, Greg Kroah-Hartman, Sasha Levin

From: Alan Stern <stern@rowland.harvard.edu>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 48a4ff1c7bb5a32d2e396b03132d20d552c0eca7 ]

A malicious USB device with crafted descriptors can cause the kernel
to access unallocated memory by setting the bNumInterfaces value too
high in a configuration descriptor.  Although the value is adjusted
during parsing, this adjustment is skipped in one of the error return
paths.

This patch prevents the problem by setting bNumInterfaces to 0
initially.  The existing code already sets it to the proper value
after parsing is complete.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
CC: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/core/config.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 0b99f913d7f2..b868e77f3bfb 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -460,6 +460,9 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 	unsigned iad_num = 0;
 
 	memcpy(&config->desc, buffer, USB_DT_CONFIG_SIZE);
+	nintf = nintf_orig = config->desc.bNumInterfaces;
+	config->desc.bNumInterfaces = 0;	// Adjusted later
+
 	if (config->desc.bDescriptorType != USB_DT_CONFIG ||
 	    config->desc.bLength < USB_DT_CONFIG_SIZE ||
 	    config->desc.bLength > size) {
@@ -473,7 +476,6 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 	buffer += config->desc.bLength;
 	size -= config->desc.bLength;
 
-	nintf = nintf_orig = config->desc.bNumInterfaces;
 	if (nintf > USB_MAXINTERFACES) {
 		dev_warn(ddev, "config %d has too many interfaces: %d, "
 		    "using maximum allowed: %d\n",
-- 
2.11.0

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

* [added to the 4.1 stable tree] xhci: Don't add a virt_dev to the devs array before it's fully allocated
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (214 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] Bluetooth: btusb: driver to enable the usb-wakeup feature Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] dmaengine: dmatest: move callback wait queue to thread context Sasha Levin
                   ` (79 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Mathias Nyman, Greg Kroah-Hartman, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 5d9b70f7d52eb14bb37861c663bae44de9521c35 ]

Avoid null pointer dereference if some function is walking through the
devs array accessing members of a new virt_dev that is mid allocation.

Add the virt_dev to xhci->devs[i] _after_ the virt_device and all its
members are properly allocated.

issue found by KASAN: null-ptr-deref in xhci_find_slot_id_by_port

"Quick analysis suggests that xhci_alloc_virt_device() is not mutex
protected. If so, there is a time frame where xhci->devs[slot_id] is set
but not fully initialized. Specifically, xhci->devs[i]->udev can be NULL."

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/host/xhci-mem.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 49b1aa48ee15..3d2b4d1482df 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1017,10 +1017,9 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
 		return 0;
 	}
 
-	xhci->devs[slot_id] = kzalloc(sizeof(*xhci->devs[slot_id]), flags);
-	if (!xhci->devs[slot_id])
+	dev = kzalloc(sizeof(*dev), flags);
+	if (!dev)
 		return 0;
-	dev = xhci->devs[slot_id];
 
 	/* Allocate the (output) device context that will be used in the HC. */
 	dev->out_ctx = xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_DEVICE, flags);
@@ -1068,9 +1067,17 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
 		 &xhci->dcbaa->dev_context_ptrs[slot_id],
 		 le64_to_cpu(xhci->dcbaa->dev_context_ptrs[slot_id]));
 
+	xhci->devs[slot_id] = dev;
+
 	return 1;
 fail:
-	xhci_free_virt_device(xhci, slot_id);
+
+	if (dev->in_ctx)
+		xhci_free_container_ctx(xhci, dev->in_ctx);
+	if (dev->out_ctx)
+		xhci_free_container_ctx(xhci, dev->out_ctx);
+	kfree(dev);
+
 	return 0;
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] Bluetooth: btusb: driver to enable the usb-wakeup feature
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (213 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] USB: core: prevent malicious bNumInterfaces overflow Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] xhci: Don't add a virt_dev to the devs array before it's fully allocated Sasha Levin
                   ` (80 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Sukumar Ghorai, Amit K Bag, Marcel Holtmann, Sasha Levin

From: Sukumar Ghorai <sukumar.ghorai@intel.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit a0085f2510e8976614ad8f766b209448b385492f ]

BT-Controller connected as platform non-root-hub device and
usb-driver initialize such device with wakeup disabled,
Ref. usb_new_device().

At present wakeup-capability get enabled by hid-input device from usb
function driver(e.g. BT HID device) at runtime. Again some functional
driver does not set usb-wakeup capability(e.g LE HID device implement
as HID-over-GATT), and can't wakeup the host on USB.

Most of the device operation (such as mass storage) initiated from host
(except HID) and USB wakeup aligned with host resume procedure. For BT
device, usb-wakeup capability need to enable form btusc driver as a
generic solution for multiple profile use case and required for USB remote
wakeup (in-bus wakeup) while host is suspended. Also usb-wakeup feature
need to enable/disable with HCI interface up and down.

Signed-off-by: Sukumar Ghorai <sukumar.ghorai@intel.com>
Signed-off-by: Amit K Bag <amit.k.bag@intel.com>
Acked-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/bluetooth/btusb.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 0c13dfd1c29d..32f5b87fe93c 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -945,6 +945,10 @@ static int btusb_open(struct hci_dev *hdev)
 		return err;
 
 	data->intf->needs_remote_wakeup = 1;
+	/* device specific wakeup source enabled and required for USB
+	 * remote wakeup while host is suspended
+	 */
+	device_wakeup_enable(&data->udev->dev);
 
 	if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
 		goto done;
@@ -1008,6 +1012,7 @@ static int btusb_close(struct hci_dev *hdev)
 		goto failed;
 
 	data->intf->needs_remote_wakeup = 0;
+	device_wakeup_disable(&data->udev->dev);
 	usb_autopm_put_interface(data->intf);
 
 failed:
-- 
2.11.0

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

* [added to the 4.1 stable tree] ext4: fix fdatasync(2) after fallocate(2) operation
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (216 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] dmaengine: dmatest: move callback wait queue to thread context Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] mac80211: Fix addition of mesh configuration element Sasha Levin
                   ` (77 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Eryu Guan, Theodore Ts'o, Sasha Levin

From: Eryu Guan <eguan@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit c894aa97577e47d3066b27b32499ecf899bfa8b0 ]

Currently, fallocate(2) with KEEP_SIZE followed by a fdatasync(2)
then crash, we'll see wrong allocated block number (stat -c %b), the
blocks allocated beyond EOF are all lost. fstests generic/468
exposes this bug.

Commit 67a7d5f561f4 ("ext4: fix fdatasync(2) after extent
manipulation operations") fixed all the other extent manipulation
operation paths such as hole punch, zero range, collapse range etc.,
but forgot the fallocate case.

So similarly, fix it by recording the correct journal tid in ext4
inode in fallocate(2) path, so that ext4_sync_file() will wait for
the right tid to be committed on fdatasync(2).

This addresses the test failure in xfstests test generic/468.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/ext4/extents.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 447d64e47c4c..dbc793e31f35 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4723,6 +4723,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
 						    EXT4_INODE_EOFBLOCKS);
 		}
 		ext4_mark_inode_dirty(handle, inode);
+		ext4_update_inode_fsync_trans(handle, inode, 1);
 		ret2 = ext4_journal_stop(handle);
 		if (ret2)
 			break;
-- 
2.11.0

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

* [added to the 4.1 stable tree] dmaengine: dmatest: move callback wait queue to thread context
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (215 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] xhci: Don't add a virt_dev to the devs array before it's fully allocated Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] ext4: fix fdatasync(2) after fallocate(2) operation Sasha Levin
                   ` (78 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Adam Wallis, Vinod Koul, Sasha Levin

From: Adam Wallis <awallis@codeaurora.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 6f6a23a213be51728502b88741ba6a10cda2441d ]

Commit adfa543e7314 ("dmatest: don't use set_freezable_with_signal()")
introduced a bug (that is in fact documented by the patch commit text)
that leaves behind a dangling pointer. Since the done_wait structure is
allocated on the stack, future invocations to the DMATEST can produce
undesirable results (e.g., corrupted spinlocks).

Commit a9df21e34b42 ("dmaengine: dmatest: warn user when dma test times
out") attempted to WARN the user that the stack was likely corrupted but
did not fix the actual issue.

This patch fixes the issue by pushing the wait queue and callback
structs into the the thread structure. If a failure occurs due to time,
dmaengine_terminate_all will force the callback to safely call
wake_up_all() without possibility of using a freed pointer.

Cc: stable@vger.kernel.org
Bug: https://bugzilla.kernel.org/show_bug.cgi?id=197605
Fixes: adfa543e7314 ("dmatest: don't use set_freezable_with_signal()")
Reviewed-by: Sinan Kaya <okaya@codeaurora.org>
Suggested-by: Shunyong Yang <shunyong.yang@hxt-semitech.com>
Signed-off-by: Adam Wallis <awallis@codeaurora.org>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/dma/dmatest.c | 55 +++++++++++++++++++++++++++++----------------------
 1 file changed, 31 insertions(+), 24 deletions(-)

diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 897ec0f8d718..2e9bc49d30ec 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -148,6 +148,12 @@ MODULE_PARM_DESC(run, "Run the test (default: false)");
 #define PATTERN_OVERWRITE	0x20
 #define PATTERN_COUNT_MASK	0x1f
 
+/* poor man's completion - we want to use wait_event_freezable() on it */
+struct dmatest_done {
+	bool			done;
+	wait_queue_head_t	*wait;
+};
+
 struct dmatest_thread {
 	struct list_head	node;
 	struct dmatest_info	*info;
@@ -156,6 +162,8 @@ struct dmatest_thread {
 	u8			**srcs;
 	u8			**dsts;
 	enum dma_transaction_type type;
+	wait_queue_head_t done_wait;
+	struct dmatest_done test_done;
 	bool			done;
 };
 
@@ -316,18 +324,25 @@ static unsigned int dmatest_verify(u8 **bufs, unsigned int start,
 	return error_count;
 }
 
-/* poor man's completion - we want to use wait_event_freezable() on it */
-struct dmatest_done {
-	bool			done;
-	wait_queue_head_t	*wait;
-};
 
 static void dmatest_callback(void *arg)
 {
 	struct dmatest_done *done = arg;
-
-	done->done = true;
-	wake_up_all(done->wait);
+	struct dmatest_thread *thread =
+		container_of(arg, struct dmatest_thread, done_wait);
+	if (!thread->done) {
+		done->done = true;
+		wake_up_all(done->wait);
+	} else {
+		/*
+		 * If thread->done, it means that this callback occurred
+		 * after the parent thread has cleaned up. This can
+		 * happen in the case that driver doesn't implement
+		 * the terminate_all() functionality and a dma operation
+		 * did not occur within the timeout period
+		 */
+		WARN(1, "dmatest: Kernel memory may be corrupted!!\n");
+	}
 }
 
 static unsigned int min_odd(unsigned int x, unsigned int y)
@@ -398,9 +413,8 @@ static unsigned long long dmatest_KBs(s64 runtime, unsigned long long len)
  */
 static int dmatest_func(void *data)
 {
-	DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_wait);
 	struct dmatest_thread	*thread = data;
-	struct dmatest_done	done = { .wait = &done_wait };
+	struct dmatest_done	*done = &thread->test_done;
 	struct dmatest_info	*info;
 	struct dmatest_params	*params;
 	struct dma_chan		*chan;
@@ -605,9 +619,9 @@ static int dmatest_func(void *data)
 			continue;
 		}
 
-		done.done = false;
+		done->done = false;
 		tx->callback = dmatest_callback;
-		tx->callback_param = &done;
+		tx->callback_param = done;
 		cookie = tx->tx_submit(tx);
 
 		if (dma_submit_error(cookie)) {
@@ -620,21 +634,12 @@ static int dmatest_func(void *data)
 		}
 		dma_async_issue_pending(chan);
 
-		wait_event_freezable_timeout(done_wait, done.done,
+		wait_event_freezable_timeout(thread->done_wait, done->done,
 					     msecs_to_jiffies(params->timeout));
 
 		status = dma_async_is_tx_complete(chan, cookie, NULL, NULL);
 
-		if (!done.done) {
-			/*
-			 * We're leaving the timed out dma operation with
-			 * dangling pointer to done_wait.  To make this
-			 * correct, we'll need to allocate wait_done for
-			 * each test iteration and perform "who's gonna
-			 * free it this time?" dancing.  For now, just
-			 * leave it dangling.
-			 */
-			WARN(1, "dmatest: Kernel stack may be corrupted!!\n");
+		if (!done->done) {
 			dmaengine_unmap_put(um);
 			result("test timed out", total_tests, src_off, dst_off,
 			       len, 0);
@@ -708,7 +713,7 @@ static int dmatest_func(void *data)
 		dmatest_KBs(runtime, total_len), ret);
 
 	/* terminate all transfers on specified channels */
-	if (ret)
+	if (ret || failed_tests)
 		dmaengine_terminate_all(chan);
 
 	thread->done = true;
@@ -766,6 +771,8 @@ static int dmatest_add_threads(struct dmatest_info *info,
 		thread->info = info;
 		thread->chan = dtc->chan;
 		thread->type = type;
+		thread->test_done.wait = &thread->done_wait;
+		init_waitqueue_head(&thread->done_wait);
 		smp_wmb();
 		thread->task = kthread_create(dmatest_func, thread, "%s-%s%u",
 				dma_chan_name(chan), op, i);
-- 
2.11.0

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

* [added to the 4.1 stable tree] ext4: fix crash when a directory's i_size is too small
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (218 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] mac80211: Fix addition of mesh configuration element Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] usb: phy: isp1301: Add OF device ID table Sasha Levin
                   ` (75 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Chandan Rajendra, Sasha Levin

From: Chandan Rajendra <chandan@linux.vnet.ibm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 9d5afec6b8bd46d6ed821aa1579634437f58ef1f ]

On a ppc64 machine, when mounting a fuzzed ext2 image (generated by
fsfuzzer) the following call trace is seen,

VFS: brelse: Trying to free free buffer
WARNING: CPU: 1 PID: 6913 at /root/repos/linux/fs/buffer.c:1165 .__brelse.part.6+0x24/0x40
.__brelse.part.6+0x20/0x40 (unreliable)
.ext4_find_entry+0x384/0x4f0
.ext4_lookup+0x84/0x250
.lookup_slow+0xdc/0x230
.walk_component+0x268/0x400
.path_lookupat+0xec/0x2d0
.filename_lookup+0x9c/0x1d0
.vfs_statx+0x98/0x140
.SyS_newfstatat+0x48/0x80
system_call+0x58/0x6c

This happens because the directory that ext4_find_entry() looks up has
inode->i_size that is less than the block size of the filesystem. This
causes 'nblocks' to have a value of zero. ext4_bread_batch() ends up not
reading any of the directory file's blocks. This renders the entries in
bh_use[] array to continue to have garbage data. buffer_uptodate() on
bh_use[0] can then return a zero value upon which brelse() function is
invoked.

This commit fixes the bug by returning -ENOENT when the directory file
has no associated blocks.

Reported-by: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/ext4/namei.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 03482c01fb3e..aa33db84ccba 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1412,6 +1412,10 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
 			       "falling back\n"));
 	}
 	nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb);
+	if (!nblocks) {
+		ret = NULL;
+		goto cleanup_and_exit;
+	}
 	start = EXT4_I(dir)->i_dir_start_lookup;
 	if (start >= nblocks)
 		start = 0;
-- 
2.11.0

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

* [added to the 4.1 stable tree] mac80211: Fix addition of mesh configuration element
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (217 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] ext4: fix fdatasync(2) after fallocate(2) operation Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] ext4: fix crash when a directory's i_size is too small Sasha Levin
                   ` (76 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Ilan peer, Johannes Berg, Sasha Levin

From: Ilan peer <ilan.peer@intel.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 57629915d568c522ac1422df7bba4bee5b5c7a7c ]

The code was setting the capabilities byte to zero,
after it was already properly set previously. Fix it.

The bug was found while debugging hwsim mesh tests failures
that happened since the commit mentioned below.

Fixes: 76f43b4c0a93 ("mac80211: Remove invalid flag operations in mesh TSF synchronization")
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Masashi Honma <masashi.honma@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/mac80211/mesh.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 48257f17688f..2ce35082a335 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -289,8 +289,6 @@ int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata,
 	/* Mesh PS mode. See IEEE802.11-2012 8.4.2.100.8 */
 	*pos |= ifmsh->ps_peers_deep_sleep ?
 			IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL : 0x00;
-	*pos++ = 0x00;
-
 	return 0;
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] usb: phy: isp1301: Add OF device ID table
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (219 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] ext4: fix crash when a directory's i_size is too small Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] md-cluster: free md_cluster_info if node leave cluster Sasha Levin
                   ` (74 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Javier Martinez Canillas, Greg Kroah-Hartman, Sasha Levin

From: Javier Martinez Canillas <javier@osg.samsung.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit fd567653bdb908009b650f079bfd4b63169e2ac4 ]

The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/phy/phy-isp1301.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/phy/phy-isp1301.c b/drivers/usb/phy/phy-isp1301.c
index 8a55b37d1a02..d2ed59a38354 100644
--- a/drivers/usb/phy/phy-isp1301.c
+++ b/drivers/usb/phy/phy-isp1301.c
@@ -32,6 +32,12 @@ static const struct i2c_device_id isp1301_id[] = {
 	{ }
 };
 
+static const struct of_device_id isp1301_of_match[] = {
+	{.compatible = "nxp,isp1301" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, isp1301_of_match);
+
 static struct i2c_client *isp1301_i2c_client;
 
 static int __isp1301_write(struct isp1301 *isp, u8 reg, u8 value, u8 clear)
@@ -129,6 +135,7 @@ static int isp1301_remove(struct i2c_client *client)
 static struct i2c_driver isp1301_driver = {
 	.driver = {
 		.name = DRV_NAME,
+		.of_match_table = of_match_ptr(isp1301_of_match),
 	},
 	.probe = isp1301_probe,
 	.remove = isp1301_remove,
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: initialize msg.msg_flags in recvfrom
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (221 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] md-cluster: free md_cluster_info if node leave cluster Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: bcmgenet: correct the RBUF_OVFL_CNT and RBUF_ERR_CNT MIB values Sasha Levin
                   ` (72 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Alexander Potapenko, David S . Miller, Sasha Levin

From: Alexander Potapenko <glider@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 9f138fa609c47403374a862a08a41394be53d461 ]

KMSAN reports a use of uninitialized memory in put_cmsg() because
msg.msg_flags in recvfrom haven't been initialized properly.
The flag values don't affect the result on this path, but it's still a
good idea to initialize them explicitly.

Signed-off-by: Alexander Potapenko <glider@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/socket.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/socket.c b/net/socket.c
index 8327df0448f4..12d681c1b66d 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1706,6 +1706,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
 	/* We assume all kernel code knows the size of sockaddr_storage */
 	msg.msg_namelen = 0;
 	msg.msg_iocb = NULL;
+	msg.msg_flags = 0;
 	if (sock->file->f_flags & O_NONBLOCK)
 		flags |= MSG_DONTWAIT;
 	err = sock_recvmsg(sock, &msg, iov_iter_count(&msg.msg_iter), flags);
-- 
2.11.0

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

* [added to the 4.1 stable tree] md-cluster: free md_cluster_info if node leave cluster
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (220 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] usb: phy: isp1301: Add OF device ID table Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: initialize msg.msg_flags in recvfrom Sasha Levin
                   ` (73 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Guoqing Jiang, Shaohua Li, Sasha Levin

From: Guoqing Jiang <gqjiang@suse.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 9c8043f337f14d1743006dfc59c03e80a42e3884 ]

To avoid memory leak, we need to free the cinfo which
is allocated when node join cluster.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/md/md-cluster.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index fcfc4b9b2672..4eb5cb18f98d 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -738,6 +738,7 @@ static int leave(struct mddev *mddev)
 	lockres_free(cinfo->sb_lock);
 	lockres_free(cinfo->bitmap_lockres);
 	dlm_release_lockspace(cinfo->lockspace, 2);
+	kfree(cinfo);
 	return 0;
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: bcmgenet: correct MIB access of UniMAC RUNT counters
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (223 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: bcmgenet: correct the RBUF_OVFL_CNT and RBUF_ERR_CNT MIB values Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: bcmgenet: Power up the internal PHY before probing the MII Sasha Levin
                   ` (70 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Doug Berger, David S . Miller, Sasha Levin

From: Doug Berger <opendmb@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 1ad3d225e5a40ca6c586989b4baaca710544c15a ]

The gap between the Tx status counters and the Rx RUNT counters is now
being added to allow correct reporting of the registers.

Fixes: 1c1008c793fa ("net: bcmgenet: add main driver file")
Signed-off-by: Doug Berger <opendmb@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index aae794656c2b..58b51595852b 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -730,13 +730,16 @@ static void bcmgenet_update_mib_counters(struct bcmgenet_priv *priv)
 		case BCMGENET_STAT_NETDEV:
 		case BCMGENET_STAT_SOFT:
 			continue;
-		case BCMGENET_STAT_MIB_RX:
-		case BCMGENET_STAT_MIB_TX:
 		case BCMGENET_STAT_RUNT:
-			if (s->type != BCMGENET_STAT_MIB_RX)
-				offset = BCMGENET_STAT_OFFSET;
+			offset += BCMGENET_STAT_OFFSET;
+			/* fall through */
+		case BCMGENET_STAT_MIB_TX:
+			offset += BCMGENET_STAT_OFFSET;
+			/* fall through */
+		case BCMGENET_STAT_MIB_RX:
 			val = bcmgenet_umac_readl(priv,
 						  UMAC_MIB_START + j + offset);
+			offset = 0;	/* Reset Offset */
 			break;
 		case BCMGENET_STAT_MISC:
 			if (GENET_IS_V1(priv)) {
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: bcmgenet: correct the RBUF_OVFL_CNT and RBUF_ERR_CNT MIB values
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (222 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: initialize msg.msg_flags in recvfrom Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: bcmgenet: correct MIB access of UniMAC RUNT counters Sasha Levin
                   ` (71 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Doug Berger, David S . Miller, Sasha Levin

From: Doug Berger <opendmb@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit ffff71328a3c321f7c14cc1edd33577717037744 ]

The location of the RBUF overflow and error counters has moved between
different version of the GENET MAC.  This commit corrects the driver to
read from the correct locations depending on the version of the GENET
MAC.

Fixes: 1c1008c793fa ("net: bcmgenet: add main driver file")
Signed-off-by: Doug Berger <opendmb@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 60 +++++++++++++++++++++++---
 drivers/net/ethernet/broadcom/genet/bcmgenet.h | 10 +++--
 2 files changed, 60 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index add05e743b6c..aae794656c2b 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1,7 +1,7 @@
 /*
  * Broadcom GENET (Gigabit Ethernet) controller driver
  *
- * Copyright (c) 2014 Broadcom Corporation
+ * Copyright (c) 2014-2017 Broadcom
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -631,8 +631,9 @@ static const struct bcmgenet_stats bcmgenet_gstrings_stats[] = {
 	STAT_GENET_RUNT("rx_runt_bytes", mib.rx_runt_bytes),
 	/* Misc UniMAC counters */
 	STAT_GENET_MISC("rbuf_ovflow_cnt", mib.rbuf_ovflow_cnt,
-			UMAC_RBUF_OVFL_CNT),
-	STAT_GENET_MISC("rbuf_err_cnt", mib.rbuf_err_cnt, UMAC_RBUF_ERR_CNT),
+			UMAC_RBUF_OVFL_CNT_V1),
+	STAT_GENET_MISC("rbuf_err_cnt", mib.rbuf_err_cnt,
+			UMAC_RBUF_ERR_CNT_V1),
 	STAT_GENET_MISC("mdf_err_cnt", mib.mdf_err_cnt, UMAC_MDF_ERR_CNT),
 	STAT_GENET_SOFT_MIB("alloc_rx_buff_failed", mib.alloc_rx_buff_failed),
 	STAT_GENET_SOFT_MIB("rx_dma_failed", mib.rx_dma_failed),
@@ -675,6 +676,45 @@ static void bcmgenet_get_strings(struct net_device *dev, u32 stringset,
 	}
 }
 
+static u32 bcmgenet_update_stat_misc(struct bcmgenet_priv *priv, u16 offset)
+{
+	u16 new_offset;
+	u32 val;
+
+	switch (offset) {
+	case UMAC_RBUF_OVFL_CNT_V1:
+		if (GENET_IS_V2(priv))
+			new_offset = RBUF_OVFL_CNT_V2;
+		else
+			new_offset = RBUF_OVFL_CNT_V3PLUS;
+
+		val = bcmgenet_rbuf_readl(priv,	new_offset);
+		/* clear if overflowed */
+		if (val == ~0)
+			bcmgenet_rbuf_writel(priv, 0, new_offset);
+		break;
+	case UMAC_RBUF_ERR_CNT_V1:
+		if (GENET_IS_V2(priv))
+			new_offset = RBUF_ERR_CNT_V2;
+		else
+			new_offset = RBUF_ERR_CNT_V3PLUS;
+
+		val = bcmgenet_rbuf_readl(priv,	new_offset);
+		/* clear if overflowed */
+		if (val == ~0)
+			bcmgenet_rbuf_writel(priv, 0, new_offset);
+		break;
+	default:
+		val = bcmgenet_umac_readl(priv, offset);
+		/* clear if overflowed */
+		if (val == ~0)
+			bcmgenet_umac_writel(priv, 0, offset);
+		break;
+	}
+
+	return val;
+}
+
 static void bcmgenet_update_mib_counters(struct bcmgenet_priv *priv)
 {
 	int i, j = 0;
@@ -699,10 +739,16 @@ static void bcmgenet_update_mib_counters(struct bcmgenet_priv *priv)
 						  UMAC_MIB_START + j + offset);
 			break;
 		case BCMGENET_STAT_MISC:
-			val = bcmgenet_umac_readl(priv, s->reg_offset);
-			/* clear if overflowed */
-			if (val == ~0)
-				bcmgenet_umac_writel(priv, 0, s->reg_offset);
+			if (GENET_IS_V1(priv)) {
+				val = bcmgenet_umac_readl(priv, s->reg_offset);
+				/* clear if overflowed */
+				if (val == ~0)
+					bcmgenet_umac_writel(priv, 0,
+							     s->reg_offset);
+			} else {
+				val = bcmgenet_update_stat_misc(priv,
+								s->reg_offset);
+			}
 			break;
 		}
 
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
index 6f2887a5e0be..ae3979a4ca93 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Broadcom Corporation
+ * Copyright (c) 2014-2017 Broadcom
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -214,7 +214,9 @@ struct bcmgenet_mib_counters {
 #define  MDIO_REG_SHIFT			16
 #define  MDIO_REG_MASK			0x1F
 
-#define UMAC_RBUF_OVFL_CNT		0x61C
+#define UMAC_RBUF_OVFL_CNT_V1		0x61C
+#define RBUF_OVFL_CNT_V2		0x80
+#define RBUF_OVFL_CNT_V3PLUS		0x94
 
 #define UMAC_MPD_CTRL			0x620
 #define  MPD_EN				(1 << 0)
@@ -224,7 +226,9 @@ struct bcmgenet_mib_counters {
 
 #define UMAC_MPD_PW_MS			0x624
 #define UMAC_MPD_PW_LS			0x628
-#define UMAC_RBUF_ERR_CNT		0x634
+#define UMAC_RBUF_ERR_CNT_V1		0x634
+#define RBUF_ERR_CNT_V2			0x84
+#define RBUF_ERR_CNT_V3PLUS		0x98
 #define UMAC_MDF_ERR_CNT		0x638
 #define UMAC_MDF_CTRL			0x650
 #define UMAC_MDF_ADDR			0x654
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: bcmgenet: reserved phy revisions must be checked first
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (225 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: bcmgenet: Power up the internal PHY before probing the MII Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] NFSD: fix nfsd_minorversion(.., NFSD_AVAIL) Sasha Levin
                   ` (68 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Doug Berger, David S . Miller, Sasha Levin

From: Doug Berger <opendmb@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit eca4bad73409aedc6ff22f823c18b67a4f08c851 ]

The reserved gphy_rev value of 0x01ff must be tested before the old
or new scheme for GPHY major versioning are tested, otherwise it will
be treated as 0xff00 according to the old scheme.

Fixes: b04a2f5b9ff5 ("net: bcmgenet: add support for new GENET PHY revision scheme")
Signed-off-by: Doug Berger <opendmb@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 58b51595852b..7ed7a30ce080 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -3067,6 +3067,12 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv)
 	 */
 	gphy_rev = reg & 0xffff;
 
+	/* This is reserved so should require special treatment */
+	if (gphy_rev == 0 || gphy_rev == 0x01ff) {
+		pr_warn("Invalid GPHY revision detected: 0x%04x\n", gphy_rev);
+		return;
+	}
+
 	/* This is the good old scheme, just GPHY major, no minor nor patch */
 	if ((gphy_rev & 0xf0) != 0)
 		priv->gphy_rev = gphy_rev << 8;
@@ -3075,12 +3081,6 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv)
 	else if ((gphy_rev & 0xff00) != 0)
 		priv->gphy_rev = gphy_rev;
 
-	/* This is reserved so should require special treatment */
-	else if (gphy_rev == 0 || gphy_rev == 0x01ff) {
-		pr_warn("Invalid GPHY revision detected: 0x%04x\n", gphy_rev);
-		return;
-	}
-
 #ifdef CONFIG_PHYS_ADDR_T_64BIT
 	if (!(params->flags & GENET_HAS_40BITS))
 		pr_warn("GENET does not support 40-bits PA\n");
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: bcmgenet: Power up the internal PHY before probing the MII
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (224 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: bcmgenet: correct MIB access of UniMAC RUNT counters Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: bcmgenet: reserved phy revisions must be checked first Sasha Levin
                   ` (69 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Doug Berger, David S . Miller, Sasha Levin

From: Doug Berger <opendmb@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 6be371b053dc86f11465cc1abce2e99bda0a0574 ]

When using the internal PHY it must be powered up when the MII is probed
or the PHY will not be detected.  Since the PHY is powered up at reset
this has not been a problem.  However, when the kernel is restarted with
kexec the PHY will likely be powered down when the kernel starts so it
will not be detected and the Ethernet link will not be established.

This commit explicitly powers up the internal PHY when the GENET driver
is probed to correct this behavior.

Fixes: 1c1008c793fa ("net: bcmgenet: add main driver file")
Signed-off-by: Doug Berger <opendmb@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 7ed7a30ce080..77fc04271244 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -3122,6 +3122,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
 	const void *macaddr;
 	struct resource *r;
 	int err = -EIO;
+	const char *phy_mode_str;
 
 	/* Up to GENET_MAX_MQ_CNT + 1 TX queues and RX queues */
 	dev = alloc_etherdev_mqs(sizeof(*priv), GENET_MAX_MQ_CNT + 1,
@@ -3224,6 +3225,13 @@ static int bcmgenet_probe(struct platform_device *pdev)
 		priv->clk_eee = NULL;
 	}
 
+	/* If this is an internal GPHY, power it on now, before UniMAC is
+	 * brought out of reset as absolutely no UniMAC activity is allowed
+	 */
+	if (dn && !of_property_read_string(dn, "phy-mode", &phy_mode_str) &&
+	    !strcasecmp(phy_mode_str, "internal"))
+		bcmgenet_power_up(priv, GENET_POWER_PASSIVE);
+
 	err = reset_umac(priv);
 	if (err)
 		goto err_clk_disable;
-- 
2.11.0

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

* [added to the 4.1 stable tree] NFSD: fix nfsd_reset_versions for NFSv4.
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (227 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] NFSD: fix nfsd_minorversion(.., NFSD_AVAIL) Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: wimax/i2400m: fix NULL-deref at probe Sasha Levin
                   ` (66 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: NeilBrown, J . Bruce Fields, Sasha Levin

From: NeilBrown <neilb@suse.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 800a938f0bf9130c8256116649c0cc5806bfb2fd ]

If you write "-2 -3 -4" to the "versions" file, it will
notice that no versions are enabled, and nfsd_reset_versions()
is called.
This enables all major versions, not no minor versions.
So we lose the invariant that NFSv4 is only advertised when
at least one minor is enabled.

Fix the code to explicitly enable minor versions for v4,
change it to use nfsd_vers() to test and set, and simplify
the code.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/nfsd/nfssvc.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index abdf8b21a4ea..a208c7ea9680 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -330,23 +330,20 @@ static void nfsd_last_thread(struct svc_serv *serv, struct net *net)
 
 void nfsd_reset_versions(void)
 {
-	int found_one = 0;
 	int i;
 
-	for (i = NFSD_MINVERS; i < NFSD_NRVERS; i++) {
-		if (nfsd_program.pg_vers[i])
-			found_one = 1;
-	}
-
-	if (!found_one) {
-		for (i = NFSD_MINVERS; i < NFSD_NRVERS; i++)
-			nfsd_program.pg_vers[i] = nfsd_version[i];
-#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
-		for (i = NFSD_ACL_MINVERS; i < NFSD_ACL_NRVERS; i++)
-			nfsd_acl_program.pg_vers[i] =
-				nfsd_acl_version[i];
-#endif
-	}
+	for (i = 0; i < NFSD_NRVERS; i++)
+		if (nfsd_vers(i, NFSD_TEST))
+			return;
+
+	for (i = 0; i < NFSD_NRVERS; i++)
+		if (i != 4)
+			nfsd_vers(i, NFSD_SET);
+		else {
+			int minor = 0;
+			while (nfsd_minorversion(minor, NFSD_SET) >= 0)
+				minor++;
+		}
 }
 
 /*
-- 
2.11.0

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

* [added to the 4.1 stable tree] NFSD: fix nfsd_minorversion(.., NFSD_AVAIL)
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (226 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: bcmgenet: reserved phy revisions must be checked first Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] NFSD: fix nfsd_reset_versions for NFSv4 Sasha Levin
                   ` (67 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: NeilBrown, J . Bruce Fields, Sasha Levin

From: NeilBrown <neilb@suse.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 928c6fb3a9bfd6c5b287aa3465226add551c13c0 ]

Current code will return 1 if the version is supported,
and -1 if it isn't.
This is confusing and inconsistent with the one place where this
is used.
So change to return 1 if it is supported, and zero if not.
i.e. an error is never returned.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/nfsd/nfssvc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index c493427e9d69..abdf8b21a4ea 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -151,7 +151,8 @@ int nfsd_vers(int vers, enum vers_op change)
 
 int nfsd_minorversion(u32 minorversion, enum vers_op change)
 {
-	if (minorversion > NFSD_SUPPORTED_MINOR_VERSION)
+	if (minorversion > NFSD_SUPPORTED_MINOR_VERSION &&
+	    change != NFSD_AVAIL)
 		return -1;
 	switch(change) {
 	case NFSD_SET:
-- 
2.11.0

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

* [added to the 4.1 stable tree] Input: i8042 - add TUXEDO BU1406 (N24_25BU) to the nomux list
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (229 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: wimax/i2400m: fix NULL-deref at probe Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: Resend IGMP memberships upon peer notification Sasha Levin
                   ` (64 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Dmitry Torokhov, Sasha Levin

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit a4c2a13129f7c5bcf81704c06851601593303fd5 ]

TUXEDO BU1406 does not implement active multiplexing mode properly,
and takes around 550 ms in i8042_set_mux_mode(). Given that the
device does not have external AUX port, there is no downside in
disabling the MUX mode.

Reported-by: Paul Menzel <pmenzel@molgen.mpg.de>
Suggested-by: Vojtech Pavlik <vojtech@suse.cz>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/input/serio/i8042-x86ia64io.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 18fd4cd6d3c7..74d69fdbdec9 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -514,6 +514,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "IC4I"),
 		},
 	},
+	{
+		/* TUXEDO BU1406 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Notebook"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "N24_25BU"),
+		},
+	},
 	{ }
 };
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: wimax/i2400m: fix NULL-deref at probe
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (228 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] NFSD: fix nfsd_reset_versions for NFSv4 Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] Input: i8042 - add TUXEDO BU1406 (N24_25BU) to the nomux list Sasha Levin
                   ` (65 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Johan Hovold, David S . Miller, Sasha Levin

From: Johan Hovold <johan@kernel.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 6e526fdff7be4f13b24f929a04c0e9ae6761291e ]

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer or accessing memory beyond the endpoint array should a
malicious device lack the expected endpoints.

The endpoints are specifically dereferenced in the i2400m_bootrom_init
path during probe (e.g. in i2400mu_tx_bulk_out).

Fixes: f398e4240fce ("i2400m/USB: probe/disconnect, dev init/shutdown
and reset backends")
Cc: Inaky Perez-Gonzalez <inaky@linux.intel.com>

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/wimax/i2400m/usb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
index e7f5910a6519..f8eb66ef2944 100644
--- a/drivers/net/wimax/i2400m/usb.c
+++ b/drivers/net/wimax/i2400m/usb.c
@@ -467,6 +467,9 @@ int i2400mu_probe(struct usb_interface *iface,
 	struct i2400mu *i2400mu;
 	struct usb_device *usb_dev = interface_to_usbdev(iface);
 
+	if (iface->cur_altsetting->desc.bNumEndpoints < 4)
+		return -ENODEV;
+
 	if (usb_dev->speed != USB_SPEED_HIGH)
 		dev_err(dev, "device not connected as high speed\n");
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] dmaengine: Fix array index out of bounds warning in __get_unmap_pool()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (231 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: Resend IGMP memberships upon peer notification Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] scsi: hpsa: limit outstanding rescans Sasha Levin
                   ` (62 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Matthias Kaehlcke, Vinod Koul, Sasha Levin

From: Matthias Kaehlcke <mka@chromium.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 23f963e91fd81f44f6b316b1c24db563354c6be8 ]

This fixes the following warning when building with clang and
CONFIG_DMA_ENGINE_RAID=n :

drivers/dma/dmaengine.c:1102:11: error: array index 2 is past the end of the array (which contains 1 element) [-Werror,-Warray-bounds]
                return &unmap_pool[2];
                        ^          ~
drivers/dma/dmaengine.c:1083:1: note: array 'unmap_pool' declared here
static struct dmaengine_unmap_pool unmap_pool[] = {
^
drivers/dma/dmaengine.c:1104:11: error: array index 3 is past the end of the array (which contains 1 element) [-Werror,-Warray-bounds]
                return &unmap_pool[3];
                        ^          ~
drivers/dma/dmaengine.c:1083:1: note: array 'unmap_pool' declared here
static struct dmaengine_unmap_pool unmap_pool[] = {

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/dma/dmaengine.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 3ddfd1f6c23c..3345a0acc975 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -1002,12 +1002,14 @@ static struct dmaengine_unmap_pool *__get_unmap_pool(int nr)
 	switch (order) {
 	case 0 ... 1:
 		return &unmap_pool[0];
+#if IS_ENABLED(CONFIG_DMA_ENGINE_RAID)
 	case 2 ... 4:
 		return &unmap_pool[1];
 	case 5 ... 7:
 		return &unmap_pool[2];
 	case 8:
 		return &unmap_pool[3];
+#endif
 	default:
 		BUG();
 		return NULL;
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: Resend IGMP memberships upon peer notification.
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (230 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] Input: i8042 - add TUXEDO BU1406 (N24_25BU) to the nomux list Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] dmaengine: Fix array index out of bounds warning in __get_unmap_pool() Sasha Levin
                   ` (63 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Vlad Yasevich, Vladislav Yasevich, David S . Miller, Sasha Levin

From: Vlad Yasevich <vyasevich@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 37c343b4f4e70e9dc328ab04903c0ec8d154c1a4 ]

When we notify peers of potential changes,  it's also good to update
IGMP memberships.  For example, during VM migration, updating IGMP
memberships will redirect existing multicast streams to the VM at the
new location.

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/core/dev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 33674208d325..4d4213b6f7f6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1268,6 +1268,7 @@ void netdev_notify_peers(struct net_device *dev)
 {
 	rtnl_lock();
 	call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, dev);
+	call_netdevice_notifiers(NETDEV_RESEND_IGMP, dev);
 	rtnl_unlock();
 }
 EXPORT_SYMBOL(netdev_notify_peers);
-- 
2.11.0

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

* [added to the 4.1 stable tree] scsi: hpsa: limit outstanding rescans
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (232 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] dmaengine: Fix array index out of bounds warning in __get_unmap_pool() Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] openrisc: fix issue handling 8 byte get_user calls Sasha Levin
                   ` (61 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Don Brace, Martin K . Petersen, Sasha Levin

From: Don Brace <don.brace@microsemi.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 87b9e6aa87d9411f1059aa245c0c79976bc557ac ]

Avoid rescan storms. No need to queue another if one is pending.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/scsi/hpsa.c | 16 +++++++++++++++-
 drivers/scsi/hpsa.h |  1 +
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 8eab107b53fb..0ef5d9286e0a 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -4158,7 +4158,7 @@ static void hpsa_scan_complete(struct ctlr_info *h)
 
 	spin_lock_irqsave(&h->scan_lock, flags);
 	h->scan_finished = 1;
-	wake_up_all(&h->scan_wait_queue);
+	wake_up(&h->scan_wait_queue);
 	spin_unlock_irqrestore(&h->scan_lock, flags);
 }
 
@@ -4176,11 +4176,23 @@ static void hpsa_scan_start(struct Scsi_Host *sh)
 	if (unlikely(lockup_detected(h)))
 		return hpsa_scan_complete(h);
 
+	/*
+	 * If a scan is already waiting to run, no need to add another
+	 */
+	spin_lock_irqsave(&h->scan_lock, flags);
+	if (h->scan_waiting) {
+		spin_unlock_irqrestore(&h->scan_lock, flags);
+		return;
+	}
+
+	spin_unlock_irqrestore(&h->scan_lock, flags);
+
 	/* wait until any scan already in progress is finished. */
 	while (1) {
 		spin_lock_irqsave(&h->scan_lock, flags);
 		if (h->scan_finished)
 			break;
+		h->scan_waiting = 1;
 		spin_unlock_irqrestore(&h->scan_lock, flags);
 		wait_event(h->scan_wait_queue, h->scan_finished);
 		/* Note: We don't need to worry about a race between this
@@ -4190,6 +4202,7 @@ static void hpsa_scan_start(struct Scsi_Host *sh)
 		 */
 	}
 	h->scan_finished = 0; /* mark scan as in progress */
+	h->scan_waiting = 0;
 	spin_unlock_irqrestore(&h->scan_lock, flags);
 
 	if (unlikely(lockup_detected(h)))
@@ -6936,6 +6949,7 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto clean4;
 	init_waitqueue_head(&h->scan_wait_queue);
 	h->scan_finished = 1; /* no scan currently in progress */
+	h->scan_waiting = 0;
 
 	pci_set_drvdata(pdev, h);
 	h->ndevices = 0;
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 657713050349..cbaf416d5456 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -166,6 +166,7 @@ struct ctlr_info {
 	dma_addr_t		errinfo_pool_dhandle;
 	unsigned long  		*cmd_pool_bits;
 	int			scan_finished;
+	u8			scan_waiting : 1;
 	spinlock_t		scan_lock;
 	wait_queue_head_t	scan_wait_queue;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] openrisc: fix issue handling 8 byte get_user calls
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (233 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] scsi: hpsa: limit outstanding rescans Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Fix missing put_page() Sasha Levin
                   ` (60 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Stafford Horne, Sasha Levin

From: Stafford Horne <shorne@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 154e67cd8e8f964809d0e75e44bb121b169c75b3 ]

Was getting the following error with allmodconfig:

  ERROR: "__get_user_bad" [lib/test_user_copy.ko] undefined!

This was simply a missing break statement, causing an unwanted fall
through.

Signed-off-by: Stafford Horne <shorne@gmail.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/openrisc/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/asm/uaccess.h
index 5cc6b4f1b795..1a836afb636d 100644
--- a/arch/openrisc/include/asm/uaccess.h
+++ b/arch/openrisc/include/asm/uaccess.h
@@ -215,7 +215,7 @@ do {									\
 	case 1: __get_user_asm(x, ptr, retval, "l.lbz"); break;		\
 	case 2: __get_user_asm(x, ptr, retval, "l.lhz"); break;		\
 	case 4: __get_user_asm(x, ptr, retval, "l.lwz"); break;		\
-	case 8: __get_user_asm2(x, ptr, retval);			\
+	case 8: __get_user_asm2(x, ptr, retval); break;			\
 	default: (x) = __get_user_bad();				\
 	}								\
 } while (0)
-- 
2.11.0

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

* [added to the 4.1 stable tree] afs: Fix missing put_page()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (234 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] openrisc: fix issue handling 8 byte get_user calls Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] sched/deadline: Use deadline instead of period when calculating overflow Sasha Levin
                   ` (59 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David Howells, Sasha Levin

From: David Howells <dhowells@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 29c8bbbd6e21daa0997d1c3ee886b897ee7ad652 ]

In afs_writepages_region(), inside the loop where we find dirty pages to
deal with, one of the if-statements is missing a put_page().

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/afs/write.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/afs/write.c b/fs/afs/write.c
index 0714abcd7f32..777ea2bbf401 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -503,6 +503,7 @@ static int afs_writepages_region(struct address_space *mapping,
 
 		if (PageWriteback(page) || !PageDirty(page)) {
 			unlock_page(page);
+			put_page(page);
 			continue;
 		}
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] sched/deadline: Use deadline instead of period when calculating overflow
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (235 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Fix missing put_page() Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Adjust mode bits processing Sasha Levin
                   ` (58 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Steven Rostedt (VMware), Peter Zijlstra, Ingo Molnar, Sasha Levin

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 2317d5f1c34913bac5971d93d69fb6c31bb74670 ]

I was testing Daniel's changes with his test case, and tweaked it a
little. Instead of having the runtime equal to the deadline, I
increased the deadline ten fold.

Daniel's test case had:

	attr.sched_runtime  = 2 * 1000 * 1000;		/* 2 ms */
	attr.sched_deadline = 2 * 1000 * 1000;		/* 2 ms */
	attr.sched_period   = 2 * 1000 * 1000 * 1000;	/* 2 s */

To make it more interesting, I changed it to:

	attr.sched_runtime  =  2 * 1000 * 1000;		/* 2 ms */
	attr.sched_deadline = 20 * 1000 * 1000;		/* 20 ms */
	attr.sched_period   =  2 * 1000 * 1000 * 1000;	/* 2 s */

The results were rather surprising. The behavior that Daniel's patch
was fixing came back. The task started using much more than .1% of the
CPU. More like 20%.

Looking into this I found that it was due to the dl_entity_overflow()
constantly returning true. That's because it uses the relative period
against relative runtime vs the absolute deadline against absolute
runtime.

  runtime / (deadline - t) > dl_runtime / dl_period

There's even a comment mentioning this, and saying that when relative
deadline equals relative period, that the equation is the same as using
deadline instead of period. That comment is backwards! What we really
want is:

  runtime / (deadline - t) > dl_runtime / dl_deadline

We care about if the runtime can make its deadline, not its period. And
then we can say "when the deadline equals the period, the equation is
the same as using dl_period instead of dl_deadline".

After correcting this, now when the task gets enqueued, it can throttle
correctly, and Daniel's fix to the throttling of sleeping deadline
tasks works even when the runtime and deadline are not the same.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Juri Lelli <juri.lelli@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luca Abeni <luca.abeni@santannapisa.it>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Romulo Silva de Oliveira <romulo.deoliveira@ufsc.br>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tommaso Cucinotta <tommaso.cucinotta@sssup.it>
Link: http://lkml.kernel.org/r/02135a27f1ae3fe5fd032568a5a2f370e190e8d7.1488392936.git.bristot@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 kernel/sched/deadline.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 5e95145088fd..e45d441176a8 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -419,13 +419,13 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se,
  *
  * This function returns true if:
  *
- *   runtime / (deadline - t) > dl_runtime / dl_period ,
+ *   runtime / (deadline - t) > dl_runtime / dl_deadline ,
  *
  * IOW we can't recycle current parameters.
  *
- * Notice that the bandwidth check is done against the period. For
+ * Notice that the bandwidth check is done against the deadline. For
  * task with deadline equal to period this is the same of using
- * dl_deadline instead of dl_period in the equation above.
+ * dl_period instead of dl_deadline in the equation above.
  */
 static bool dl_entity_overflow(struct sched_dl_entity *dl_se,
 			       struct sched_dl_entity *pi_se, u64 t)
@@ -450,7 +450,7 @@ static bool dl_entity_overflow(struct sched_dl_entity *dl_se,
 	 * of anything below microseconds resolution is actually fiction
 	 * (but still we want to give the user that illusion >;).
 	 */
-	left = (pi_se->dl_period >> DL_SCALE) * (dl_se->runtime >> DL_SCALE);
+	left = (pi_se->dl_deadline >> DL_SCALE) * (dl_se->runtime >> DL_SCALE);
 	right = ((dl_se->deadline - t) >> DL_SCALE) *
 		(pi_se->dl_runtime >> DL_SCALE);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] afs: Adjust mode bits processing
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (236 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] sched/deadline: Use deadline instead of period when calculating overflow Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Populate group ID from vnode status Sasha Levin
                   ` (57 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Marc Dionne, David Howells, Sasha Levin

From: Marc Dionne <marc.dionne@auristor.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 627f46943ff90bcc32ddeb675d881c043c6fa2ae ]

Mode bits for an afs file should not be enforced in the usual
way.

For files, the absence of user bits can restrict file access
with respect to what is granted by the server.

These bits apply regardless of the owner or the current uid; the
rest of the mode bits (group, other) are ignored.

Signed-off-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/afs/security.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/afs/security.c b/fs/afs/security.c
index 8d010422dc89..bfa9d3428383 100644
--- a/fs/afs/security.c
+++ b/fs/afs/security.c
@@ -340,17 +340,22 @@ int afs_permission(struct inode *inode, int mask)
 	} else {
 		if (!(access & AFS_ACE_LOOKUP))
 			goto permission_denied;
+		if ((mask & MAY_EXEC) && !(inode->i_mode & S_IXUSR))
+			goto permission_denied;
 		if (mask & (MAY_EXEC | MAY_READ)) {
 			if (!(access & AFS_ACE_READ))
 				goto permission_denied;
+			if (!(inode->i_mode & S_IRUSR))
+				goto permission_denied;
 		} else if (mask & MAY_WRITE) {
 			if (!(access & AFS_ACE_WRITE))
 				goto permission_denied;
+			if (!(inode->i_mode & S_IWUSR))
+				goto permission_denied;
 		}
 	}
 
 	key_put(key);
-	ret = generic_permission(inode, mask);
 	_leave(" = %d", ret);
 	return ret;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] afs: Populate group ID from vnode status
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (237 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Adjust mode bits processing Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Flush outstanding writes when an fd is closed Sasha Levin
                   ` (56 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Marc Dionne, David Howells, Sasha Levin

From: Marc Dionne <marc.dionne@auristor.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 6186f0788b31f44affceeedc7b48eb10faea120d ]

The group was hard coded to GLOBAL_ROOT_GID; use the group
ID that was received from the server.

Signed-off-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/afs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index e06f5a23352a..9580456e8902 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -69,7 +69,7 @@ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key)
 
 	set_nlink(inode, vnode->status.nlink);
 	inode->i_uid		= vnode->status.owner;
-	inode->i_gid		= GLOBAL_ROOT_GID;
+	inode->i_gid            = vnode->status.group;
 	inode->i_size		= vnode->status.size;
 	inode->i_ctime.tv_sec	= vnode->status.mtime_server;
 	inode->i_ctime.tv_nsec	= 0;
-- 
2.11.0

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

* [added to the 4.1 stable tree] afs: Flush outstanding writes when an fd is closed
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (238 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Populate group ID from vnode status Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Migrate vlocation fields to 64-bit Sasha Levin
                   ` (55 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David Howells, Sasha Levin

From: David Howells <dhowells@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 58fed94dfb17e89556b5705f20f90e5b2971b6a1 ]

Flush outstanding writes in afs when an fd is closed.  This is what NFS and
CIFS do.

Reported-by: Marc Dionne <marc.c.dionne@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/afs/file.c     |  1 +
 fs/afs/internal.h |  1 +
 fs/afs/write.c    | 14 ++++++++++++++
 3 files changed, 16 insertions(+)

diff --git a/fs/afs/file.c b/fs/afs/file.c
index 999bc3caec92..cf8a07e282a6 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -29,6 +29,7 @@ static int afs_readpages(struct file *filp, struct address_space *mapping,
 
 const struct file_operations afs_file_operations = {
 	.open		= afs_open,
+	.flush		= afs_flush,
 	.release	= afs_release,
 	.llseek		= generic_file_llseek,
 	.read_iter	= generic_file_read_iter,
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 71d5982312f3..5cb5c320b966 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -749,6 +749,7 @@ extern int afs_writepages(struct address_space *, struct writeback_control *);
 extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *);
 extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *);
 extern int afs_writeback_all(struct afs_vnode *);
+extern int afs_flush(struct file *, fl_owner_t);
 extern int afs_fsync(struct file *, loff_t, loff_t, int);
 
 
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 777ea2bbf401..cc46e8c1d46e 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -741,6 +741,20 @@ int afs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 }
 
 /*
+ * Flush out all outstanding writes on a file opened for writing when it is
+ * closed.
+ */
+int afs_flush(struct file *file, fl_owner_t id)
+{
+	_enter("");
+
+	if ((file->f_mode & FMODE_WRITE) == 0)
+		return 0;
+
+	return vfs_fsync(file, 0);
+}
+
+/*
  * notification that a previously read-only page is about to become writable
  * - if it returns an error, the caller will deliver a bus error signal
  */
-- 
2.11.0

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

* [added to the 4.1 stable tree] afs: Prevent callback expiry timer overflow
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (240 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Migrate vlocation fields to 64-bit Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Populate and use client modification time Sasha Levin
                   ` (53 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Tina Ruchandani, David Howells, Sasha Levin

From: Tina Ruchandani <ruchandani.tina@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 56e714312e7dbd6bb83b2f78d3ec19a404c7649f ]

get_seconds() returns real wall-clock seconds. On 32-bit systems
this value will overflow in year 2038 and beyond. This patch changes
afs_vnode record to use ktime_get_real_seconds() instead, for the
fields cb_expires and cb_expires_at.

Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/afs/fsclient.c | 2 +-
 fs/afs/inode.c    | 7 ++++---
 fs/afs/internal.h | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index c2e930ec2888..c775fefe3ffe 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -139,7 +139,7 @@ static void xdr_decode_AFSCallBack(const __be32 **_bp, struct afs_vnode *vnode)
 	vnode->cb_version	= ntohl(*bp++);
 	vnode->cb_expiry	= ntohl(*bp++);
 	vnode->cb_type		= ntohl(*bp++);
-	vnode->cb_expires	= vnode->cb_expiry + get_seconds();
+	vnode->cb_expires	= vnode->cb_expiry + ktime_get_real_seconds();
 	*_bp = bp;
 }
 
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 9580456e8902..2d706612f1f5 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -244,12 +244,13 @@ struct inode *afs_iget(struct super_block *sb, struct key *key,
 			vnode->cb_version = 0;
 			vnode->cb_expiry = 0;
 			vnode->cb_type = 0;
-			vnode->cb_expires = get_seconds();
+			vnode->cb_expires = ktime_get_real_seconds();
 		} else {
 			vnode->cb_version = cb->version;
 			vnode->cb_expiry = cb->expiry;
 			vnode->cb_type = cb->type;
-			vnode->cb_expires = vnode->cb_expiry + get_seconds();
+			vnode->cb_expires = vnode->cb_expiry +
+				ktime_get_real_seconds();
 		}
 	}
 
@@ -322,7 +323,7 @@ int afs_validate(struct afs_vnode *vnode, struct key *key)
 	    !test_bit(AFS_VNODE_CB_BROKEN, &vnode->flags) &&
 	    !test_bit(AFS_VNODE_MODIFIED, &vnode->flags) &&
 	    !test_bit(AFS_VNODE_ZAP_DATA, &vnode->flags)) {
-		if (vnode->cb_expires < get_seconds() + 10) {
+		if (vnode->cb_expires < ktime_get_real_seconds() + 10) {
 			_debug("callback expired");
 			set_bit(AFS_VNODE_CB_BROKEN, &vnode->flags);
 		} else {
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index c671cdb3acad..1330b2a695ff 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -375,8 +375,8 @@ struct afs_vnode {
 	struct rb_node		server_rb;	/* link in server->fs_vnodes */
 	struct rb_node		cb_promise;	/* link in server->cb_promises */
 	struct work_struct	cb_broken_work;	/* work to be done on callback break */
-	time_t			cb_expires;	/* time at which callback expires */
-	time_t			cb_expires_at;	/* time used to order cb_promise */
+	time64_t		cb_expires;	/* time at which callback expires */
+	time64_t		cb_expires_at;	/* time used to order cb_promise */
 	unsigned		cb_version;	/* callback version */
 	unsigned		cb_expiry;	/* callback expiry time */
 	afs_callback_type_t	cb_type;	/* type of callback */
-- 
2.11.0

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

* [added to the 4.1 stable tree] afs: Migrate vlocation fields to 64-bit
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (239 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Flush outstanding writes when an fd is closed Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Prevent callback expiry timer overflow Sasha Levin
                   ` (54 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Tina Ruchandani, David Howells, Sasha Levin

From: Tina Ruchandani <ruchandani.tina@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 8a79790bf0b7da216627ffb85f52cfb4adbf1e4e ]

get_seconds() returns real wall-clock seconds. On 32-bit systems
this value will overflow in year 2038 and beyond. This patch changes
afs's vlocation record to use ktime_get_real_seconds() instead, for the
fields time_of_death and update_at.

Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/afs/callback.c  |  7 ++++---
 fs/afs/internal.h  |  7 ++++---
 fs/afs/server.c    |  6 +++---
 fs/afs/vlocation.c | 16 +++++++++-------
 4 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/fs/afs/callback.c b/fs/afs/callback.c
index 7ef637d7f3a5..7d54efd73519 100644
--- a/fs/afs/callback.c
+++ b/fs/afs/callback.c
@@ -362,7 +362,7 @@ static void afs_callback_updater(struct work_struct *work)
 {
 	struct afs_server *server;
 	struct afs_vnode *vnode, *xvnode;
-	time_t now;
+	time64_t now;
 	long timeout;
 	int ret;
 
@@ -370,7 +370,7 @@ static void afs_callback_updater(struct work_struct *work)
 
 	_enter("");
 
-	now = get_seconds();
+	now = ktime_get_real_seconds();
 
 	/* find the first vnode to update */
 	spin_lock(&server->cb_lock);
@@ -424,7 +424,8 @@ static void afs_callback_updater(struct work_struct *work)
 
 	/* and then reschedule */
 	_debug("reschedule");
-	vnode->update_at = get_seconds() + afs_vnode_update_timeout;
+	vnode->update_at = ktime_get_real_seconds() +
+			afs_vnode_update_timeout;
 
 	spin_lock(&server->cb_lock);
 
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 5cb5c320b966..c671cdb3acad 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -11,6 +11,7 @@
 
 #include <linux/compiler.h>
 #include <linux/kernel.h>
+#include <linux/ktime.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/skbuff.h>
@@ -247,7 +248,7 @@ struct afs_cache_vhash {
  */
 struct afs_vlocation {
 	atomic_t		usage;
-	time_t			time_of_death;	/* time at which put reduced usage to 0 */
+	time64_t		time_of_death;	/* time at which put reduced usage to 0 */
 	struct list_head	link;		/* link in cell volume location list */
 	struct list_head	grave;		/* link in master graveyard list */
 	struct list_head	update;		/* link in master update list */
@@ -258,7 +259,7 @@ struct afs_vlocation {
 	struct afs_cache_vlocation vldb;	/* volume information DB record */
 	struct afs_volume	*vols[3];	/* volume access record pointer (index by type) */
 	wait_queue_head_t	waitq;		/* status change waitqueue */
-	time_t			update_at;	/* time at which record should be updated */
+	time64_t		update_at;	/* time at which record should be updated */
 	spinlock_t		lock;		/* access lock */
 	afs_vlocation_state_t	state;		/* volume location state */
 	unsigned short		upd_rej_cnt;	/* ENOMEDIUM count during update */
@@ -271,7 +272,7 @@ struct afs_vlocation {
  */
 struct afs_server {
 	atomic_t		usage;
-	time_t			time_of_death;	/* time at which put reduced usage to 0 */
+	time64_t		time_of_death;	/* time at which put reduced usage to 0 */
 	struct in_addr		addr;		/* server address */
 	struct afs_cell		*cell;		/* cell in which server resides */
 	struct list_head	link;		/* link in cell's server list */
diff --git a/fs/afs/server.c b/fs/afs/server.c
index f342acf3547d..3bc1a46f0bd6 100644
--- a/fs/afs/server.c
+++ b/fs/afs/server.c
@@ -237,7 +237,7 @@ void afs_put_server(struct afs_server *server)
 	spin_lock(&afs_server_graveyard_lock);
 	if (atomic_read(&server->usage) == 0) {
 		list_move_tail(&server->grave, &afs_server_graveyard);
-		server->time_of_death = get_seconds();
+		server->time_of_death = ktime_get_real_seconds();
 		queue_delayed_work(afs_wq, &afs_server_reaper,
 				   afs_server_timeout * HZ);
 	}
@@ -272,9 +272,9 @@ static void afs_reap_server(struct work_struct *work)
 	LIST_HEAD(corpses);
 	struct afs_server *server;
 	unsigned long delay, expiry;
-	time_t now;
+	time64_t now;
 
-	now = get_seconds();
+	now = ktime_get_real_seconds();
 	spin_lock(&afs_server_graveyard_lock);
 
 	while (!list_empty(&afs_server_graveyard)) {
diff --git a/fs/afs/vlocation.c b/fs/afs/vlocation.c
index 52976785a32c..ee9015c0db5a 100644
--- a/fs/afs/vlocation.c
+++ b/fs/afs/vlocation.c
@@ -340,7 +340,8 @@ static void afs_vlocation_queue_for_updates(struct afs_vlocation *vl)
 	struct afs_vlocation *xvl;
 
 	/* wait at least 10 minutes before updating... */
-	vl->update_at = get_seconds() + afs_vlocation_update_timeout;
+	vl->update_at = ktime_get_real_seconds() +
+			afs_vlocation_update_timeout;
 
 	spin_lock(&afs_vlocation_updates_lock);
 
@@ -506,7 +507,7 @@ void afs_put_vlocation(struct afs_vlocation *vl)
 	if (atomic_read(&vl->usage) == 0) {
 		_debug("buried");
 		list_move_tail(&vl->grave, &afs_vlocation_graveyard);
-		vl->time_of_death = get_seconds();
+		vl->time_of_death = ktime_get_real_seconds();
 		queue_delayed_work(afs_wq, &afs_vlocation_reap,
 				   afs_vlocation_timeout * HZ);
 
@@ -543,11 +544,11 @@ static void afs_vlocation_reaper(struct work_struct *work)
 	LIST_HEAD(corpses);
 	struct afs_vlocation *vl;
 	unsigned long delay, expiry;
-	time_t now;
+	time64_t now;
 
 	_enter("");
 
-	now = get_seconds();
+	now = ktime_get_real_seconds();
 	spin_lock(&afs_vlocation_graveyard_lock);
 
 	while (!list_empty(&afs_vlocation_graveyard)) {
@@ -622,13 +623,13 @@ static void afs_vlocation_updater(struct work_struct *work)
 {
 	struct afs_cache_vlocation vldb;
 	struct afs_vlocation *vl, *xvl;
-	time_t now;
+	time64_t now;
 	long timeout;
 	int ret;
 
 	_enter("");
 
-	now = get_seconds();
+	now = ktime_get_real_seconds();
 
 	/* find a record to update */
 	spin_lock(&afs_vlocation_updates_lock);
@@ -684,7 +685,8 @@ static void afs_vlocation_updater(struct work_struct *work)
 
 	/* and then reschedule */
 	_debug("reschedule");
-	vl->update_at = get_seconds() + afs_vlocation_update_timeout;
+	vl->update_at = ktime_get_real_seconds() +
+			afs_vlocation_update_timeout;
 
 	spin_lock(&afs_vlocation_updates_lock);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] afs: Fix the maths in afs_fs_store_data()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (242 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Populate and use client modification time Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Fix page leak in afs_write_begin() Sasha Levin
                   ` (51 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David Howells, Sasha Levin

From: David Howells <dhowells@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 146a1192783697810b63a1e41c4d59fc93387340 ]

afs_fs_store_data() works out of the size of the write it's going to make,
but it uses 32-bit unsigned subtraction in one place that gets
automatically cast to loff_t.

However, if to < offset, then the number goes negative, but as the result
isn't signed, this doesn't get sign-extended to 64-bits when placed in a
loff_t.

Fix by casting the operands to loff_t.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/afs/fsclient.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index c775fefe3ffe..0c8399e0fdac 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -1225,7 +1225,7 @@ int afs_fs_store_data(struct afs_server *server, struct afs_writeback *wb,
 	_enter(",%x,{%x:%u},,",
 	       key_serial(wb->key), vnode->fid.vid, vnode->fid.vnode);
 
-	size = to - offset;
+	size = (loff_t)to - (loff_t)offset;
 	if (first != last)
 		size += (loff_t)(last - first) << PAGE_SHIFT;
 	pos = (loff_t)first << PAGE_SHIFT;
-- 
2.11.0

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

* [added to the 4.1 stable tree] afs: Populate and use client modification time
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (241 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Prevent callback expiry timer overflow Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Fix the maths in afs_fs_store_data() Sasha Levin
                   ` (52 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Marc Dionne, David Howells, Sasha Levin

From: Marc Dionne <marc.dionne@auristor.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit ab94f5d0dd6fd82e7eeca5e7c8096eaea0a0261f ]

The inode timestamps should be set from the client time
in the status received from the server, rather than the
server time which is meant for internal server use.

Set AFS_SET_MTIME and populate the mtime for operations
that take an input status, such as file/dir creation
and StoreData.  If an input time is not provided the
server will set the vnode times based on the current server
time.

In a situation where the server has some skew with the
client, this could lead to the client seeing a timestamp
in the future for a file that it just created or wrote.

Signed-off-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/afs/fsclient.c | 18 +++++++++---------
 fs/afs/inode.c    |  2 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index 0c8399e0fdac..10ce44214005 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -105,7 +105,7 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
 			vnode->vfs_inode.i_mode = mode;
 		}
 
-		vnode->vfs_inode.i_ctime.tv_sec	= status->mtime_server;
+		vnode->vfs_inode.i_ctime.tv_sec	= status->mtime_client;
 		vnode->vfs_inode.i_mtime	= vnode->vfs_inode.i_ctime;
 		vnode->vfs_inode.i_atime	= vnode->vfs_inode.i_ctime;
 		vnode->vfs_inode.i_version	= data_version;
@@ -703,8 +703,8 @@ int afs_fs_create(struct afs_server *server,
 		memset(bp, 0, padsz);
 		bp = (void *) bp + padsz;
 	}
-	*bp++ = htonl(AFS_SET_MODE);
-	*bp++ = 0; /* mtime */
+	*bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
+	*bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec); /* mtime */
 	*bp++ = 0; /* owner */
 	*bp++ = 0; /* group */
 	*bp++ = htonl(mode & S_IALLUGO); /* unix mode */
@@ -981,8 +981,8 @@ int afs_fs_symlink(struct afs_server *server,
 		memset(bp, 0, c_padsz);
 		bp = (void *) bp + c_padsz;
 	}
-	*bp++ = htonl(AFS_SET_MODE);
-	*bp++ = 0; /* mtime */
+	*bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
+	*bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec); /* mtime */
 	*bp++ = 0; /* owner */
 	*bp++ = 0; /* group */
 	*bp++ = htonl(S_IRWXUGO); /* unix mode */
@@ -1192,8 +1192,8 @@ static int afs_fs_store_data64(struct afs_server *server,
 	*bp++ = htonl(vnode->fid.vnode);
 	*bp++ = htonl(vnode->fid.unique);
 
-	*bp++ = 0; /* mask */
-	*bp++ = 0; /* mtime */
+	*bp++ = htonl(AFS_SET_MTIME); /* mask */
+	*bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec); /* mtime */
 	*bp++ = 0; /* owner */
 	*bp++ = 0; /* group */
 	*bp++ = 0; /* unix mode */
@@ -1269,8 +1269,8 @@ int afs_fs_store_data(struct afs_server *server, struct afs_writeback *wb,
 	*bp++ = htonl(vnode->fid.vnode);
 	*bp++ = htonl(vnode->fid.unique);
 
-	*bp++ = 0; /* mask */
-	*bp++ = 0; /* mtime */
+	*bp++ = htonl(AFS_SET_MTIME); /* mask */
+	*bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec); /* mtime */
 	*bp++ = 0; /* owner */
 	*bp++ = 0; /* group */
 	*bp++ = 0; /* unix mode */
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 2d706612f1f5..f8fa92b1d43c 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -71,7 +71,7 @@ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key)
 	inode->i_uid		= vnode->status.owner;
 	inode->i_gid            = vnode->status.group;
 	inode->i_size		= vnode->status.size;
-	inode->i_ctime.tv_sec	= vnode->status.mtime_server;
+	inode->i_ctime.tv_sec	= vnode->status.mtime_client;
 	inode->i_ctime.tv_nsec	= 0;
 	inode->i_atime		= inode->i_mtime = inode->i_ctime;
 	inode->i_blocks		= 0;
-- 
2.11.0

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

* [added to the 4.1 stable tree] afs: Fix afs_kill_pages()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (244 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Fix page leak in afs_write_begin() Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net/mlx4_core: Avoid delays during VF driver device shutdown Sasha Levin
                   ` (49 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David Howells, Sasha Levin

From: David Howells <dhowells@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 7286a35e893176169b09715096a4aca557e2ccd2 ]

Fix afs_kill_pages() in two ways:

 (1) If a writeback has been partially flushed, then if we try and kill the
     pages it contains, some of them may no longer be undergoing writeback
     and end_page_writeback() will assert.

     Fix this by checking to see whether the page in question is actually
     undergoing writeback before ending that writeback.

 (2) The loop that scans for pages to kill doesn't increase the first page
     index, and so the loop may not terminate, but it will try to process
     the same pages over and over again.

     Fix this by increasing the first page index to one after the last page
     we processed.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/afs/write.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/afs/write.c b/fs/afs/write.c
index d89595155ec9..5cfc05ca184c 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -299,10 +299,14 @@ static void afs_kill_pages(struct afs_vnode *vnode, bool error,
 		ASSERTCMP(pv.nr, ==, count);
 
 		for (loop = 0; loop < count; loop++) {
-			ClearPageUptodate(pv.pages[loop]);
+			struct page *page = pv.pages[loop];
+			ClearPageUptodate(page);
 			if (error)
-				SetPageError(pv.pages[loop]);
-			end_page_writeback(pv.pages[loop]);
+				SetPageError(page);
+			if (PageWriteback(page))
+				end_page_writeback(page);
+			if (page->index >= first)
+				first = page->index + 1;
 		}
 
 		__pagevec_release(&pv);
-- 
2.11.0

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

* [added to the 4.1 stable tree] afs: Fix page leak in afs_write_begin()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (243 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Fix the maths in afs_fs_store_data() Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Fix afs_kill_pages() Sasha Levin
                   ` (50 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: David Howells, Sasha Levin

From: David Howells <dhowells@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 6d06b0d25209c80e99c1e89700f1e09694a3766b ]

afs_write_begin() leaks a ref and a lock on a page if afs_fill_page()
fails.  Fix the leak by unlocking and releasing the page in the error path.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/afs/write.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/afs/write.c b/fs/afs/write.c
index cc46e8c1d46e..d89595155ec9 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -148,12 +148,12 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
 		kfree(candidate);
 		return -ENOMEM;
 	}
-	*pagep = page;
-	/* page won't leak in error case: it eventually gets cleaned off LRU */
 
 	if (!PageUptodate(page) && len != PAGE_CACHE_SIZE) {
 		ret = afs_fill_page(vnode, key, index << PAGE_CACHE_SHIFT, page);
 		if (ret < 0) {
+			unlock_page(page);
+			put_page(page);
 			kfree(candidate);
 			_leave(" = %d [prep]", ret);
 			return ret;
@@ -161,6 +161,9 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
 		SetPageUptodate(page);
 	}
 
+	/* page won't leak in error case: it eventually gets cleaned off LRU */
+	*pagep = page;
+
 try_again:
 	spin_lock(&vnode->writeback_lock);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] net/mlx4_core: Avoid delays during VF driver device shutdown
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (245 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Fix afs_kill_pages() Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] perf symbols: Fix symbols__fixup_end heuristic for corner cases Sasha Levin
                   ` (48 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Jack Morgenstein, Tariq Toukan, David S . Miller, Sasha Levin

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 4cbe4dac82e423ecc9a0ba46af24a860853259f4 ]

Some Hypervisors detach VFs from VMs by instantly causing an FLR event
to be generated for a VF.

In the mlx4 case, this will cause that VF's comm channel to be disabled
before the VM has an opportunity to invoke the VF device's "shutdown"
method.

For such Hypervisors, there is a race condition between the VF's
shutdown method and its internal-error detection/reset thread.

The internal-error detection/reset thread (which runs every 5 seconds) also
detects a disabled comm channel. If the internal-error detection/reset
flow wins the race, we still get delays (while that flow tries repeatedly
to detect comm-channel recovery).

The cited commit fixed the command timeout problem when the
internal-error detection/reset flow loses the race.

This commit avoids the unneeded delays when the internal-error
detection/reset flow wins.

Fixes: d585df1c5ccf ("net/mlx4_core: Avoid command timeouts during VF driver device shutdown")
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Reported-by: Simon Xiao <sixiao@microsoft.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/mellanox/mlx4/cmd.c  | 11 +++++++++++
 drivers/net/ethernet/mellanox/mlx4/main.c | 11 +++++++++++
 include/linux/mlx4/device.h               |  1 +
 3 files changed, 23 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index 3756e45d8cec..1ec0b405aa81 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -2262,6 +2262,17 @@ static int sync_toggles(struct mlx4_dev *dev)
 		rd_toggle = swab32(readl(&priv->mfunc.comm->slave_read));
 		if (wr_toggle == 0xffffffff || rd_toggle == 0xffffffff) {
 			/* PCI might be offline */
+
+			/* If device removal has been requested,
+			 * do not continue retrying.
+			 */
+			if (dev->persist->interface_state &
+			    MLX4_INTERFACE_STATE_NOWAIT) {
+				mlx4_warn(dev,
+					  "communication channel is offline\n");
+				return -EIO;
+			}
+
 			msleep(100);
 			wr_toggle = swab32(readl(&priv->mfunc.comm->
 					   slave_write));
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 115d301f1f61..1f931e6ae3cb 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1717,6 +1717,14 @@ static int mlx4_comm_check_offline(struct mlx4_dev *dev)
 			       (u32)(1 << COMM_CHAN_OFFLINE_OFFSET));
 		if (!offline_bit)
 			return 0;
+
+		/* If device removal has been requested,
+		 * do not continue retrying.
+		 */
+		if (dev->persist->interface_state &
+		    MLX4_INTERFACE_STATE_NOWAIT)
+			break;
+
 		/* There are cases as part of AER/Reset flow that PF needs
 		 * around 100 msec to load. We therefore sleep for 100 msec
 		 * to allow other tasks to make use of that CPU during this
@@ -3459,6 +3467,9 @@ static void mlx4_remove_one(struct pci_dev *pdev)
 	struct mlx4_priv *priv = mlx4_priv(dev);
 	int active_vfs = 0;
 
+	if (mlx4_is_slave(dev))
+		persist->interface_state |= MLX4_INTERFACE_STATE_NOWAIT;
+
 	mutex_lock(&persist->interface_state_mutex);
 	persist->interface_state |= MLX4_INTERFACE_STATE_DELETION;
 	mutex_unlock(&persist->interface_state_mutex);
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 83e80ab94500..41fe2f858830 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -443,6 +443,7 @@ enum {
 enum {
 	MLX4_INTERFACE_STATE_UP		= 1 << 0,
 	MLX4_INTERFACE_STATE_DELETION	= 1 << 1,
+	MLX4_INTERFACE_STATE_NOWAIT	= 1 << 2,
 };
 
 #define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \
-- 
2.11.0

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

* [added to the 4.1 stable tree] perf symbols: Fix symbols__fixup_end heuristic for corner cases
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (246 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net/mlx4_core: Avoid delays during VF driver device shutdown Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] btrfs: add missing memset while reading compressed inline extents Sasha Levin
                   ` (47 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Daniel Borkmann, Arnaldo Carvalho de Melo, Sasha Levin

From: Daniel Borkmann <daniel@iogearbox.net>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e7ede72a6d40cb3a30c087142d79381ca8a31dab ]

The current symbols__fixup_end() heuristic for the last entry in the rb
tree is suboptimal as it leads to not being able to recognize the symbol
in the call graph in a couple of corner cases, for example:

 i) If the symbol has a start address (f.e. exposed via kallsyms)
    that is at a page boundary, then the roundup(curr->start, 4096)
    for the last entry will result in curr->start == curr->end with
    a symbol length of zero.

ii) If the symbol has a start address that is shortly before a page
    boundary, then also here, curr->end - curr->start will just be
    very few bytes, where it's unrealistic that we could perform a
    match against.

Instead, change the heuristic to roundup(curr->start, 4096) + 4096, so
that we can catch such corner cases and have a better chance to find
that specific symbol. It's still just best effort as the real end of the
symbol is unknown to us (and could even be at a larger offset than the
current range), but better than the current situation.

Alexei reported that he recently run into case i) with a JITed eBPF
program (these are all page aligned) as the last symbol which wasn't
properly shown in the call graph (while other eBPF program symbols in
the rb tree were displayed correctly). Since this is a generic issue,
lets try to improve the heuristic a bit.

Reported-and-Tested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Fixes: 2e538c4a1847 ("perf tools: Improve kernel/modules symbol lookup")
Link: http://lkml.kernel.org/r/bb5c80d27743be6f12afc68405f1956a330e1bc9.1489614365.git.daniel@iogearbox.net
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 tools/perf/util/symbol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 99378a5c57a7..28ee003beee1 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -194,7 +194,7 @@ void symbols__fixup_end(struct rb_root *symbols)
 
 	/* Last entry */
 	if (curr->end == curr->start)
-		curr->end = roundup(curr->start, 4096);
+		curr->end = roundup(curr->start, 4096) + 4096;
 }
 
 void __map_groups__fixup_end(struct map_groups *mg, enum map_type type)
-- 
2.11.0

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

* [added to the 4.1 stable tree] NFSv4.1 respect server's max size in CREATE_SESSION
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (248 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] btrfs: add missing memset while reading compressed inline extents Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] fbdev: controlfb: Add missing modes to fix out of bounds access Sasha Levin
                   ` (45 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Olga Kornievskaia, Anna Schumaker, Sasha Levin

From: Olga Kornievskaia <kolga@netapp.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 033853325fe3bdc70819a8b97915bd3bca41d3af ]

Currently client doesn't respect max sizes server returns in CREATE_SESSION.
nfs4_session_set_rwsize() gets called and server->rsize, server->wsize are 0
so they never get set to the sizes returned by the server.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/nfs/nfs4client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 5dea913baf46..a03ec3b53d9e 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -899,9 +899,9 @@ static void nfs4_session_set_rwsize(struct nfs_server *server)
 	server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead;
 	server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead;
 
-	if (server->rsize > server_resp_sz)
+	if (!server->rsize || server->rsize > server_resp_sz)
 		server->rsize = server_resp_sz;
-	if (server->wsize > server_rqst_sz)
+	if (!server->wsize || server->wsize > server_rqst_sz)
 		server->wsize = server_rqst_sz;
 #endif /* CONFIG_NFS_V4_1 */
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] btrfs: add missing memset while reading compressed inline extents
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (247 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] perf symbols: Fix symbols__fixup_end heuristic for corner cases Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] NFSv4.1 respect server's max size in CREATE_SESSION Sasha Levin
                   ` (46 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Zygo Blaxell, Chris Mason, Sasha Levin

From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit e1699d2d7bf6e6cce3e1baff19f9dd4595a58664 ]

This is a story about 4 distinct (and very old) btrfs bugs.

Commit c8b978188c ("Btrfs: Add zlib compression support") added
three data corruption bugs for inline extents (bugs #1-3).

Commit 93c82d5750 ("Btrfs: zero page past end of inline file items")
fixed bug #1:  uncompressed inline extents followed by a hole and more
extents could get non-zero data in the hole as they were read.  The fix
was to add a memset in btrfs_get_extent to zero out the hole.

Commit 166ae5a418 ("btrfs: fix inline compressed read err corruption")
fixed bug #2:  compressed inline extents which contained non-zero bytes
might be replaced with zero bytes in some cases.  This patch removed an
unhelpful memset from uncompress_inline, but the case where memset is
required was missed.

There is also a memset in the decompression code, but this only covers
decompressed data that is shorter than the ram_bytes from the extent
ref record.  This memset doesn't cover the region between the end of the
decompressed data and the end of the page.  It has also moved around a
few times over the years, so there's no single patch to refer to.

This patch fixes bug #3:  compressed inline extents followed by a hole
and more extents could get non-zero data in the hole as they were read
(i.e. bug #3 is the same as bug #1, but s/uncompressed/compressed/).
The fix is the same:  zero out the hole in the compressed case too,
by putting a memset back in uncompress_inline, but this time with
correct parameters.

The last and oldest bug, bug #0, is the cause of the offending inline
extent/hole/extent pattern.  Bug #0 is a subtle and mostly-harmless quirk
of behavior somewhere in the btrfs write code.  In a few special cases,
an inline extent and hole are allowed to persist where they normally
would be combined with later extents in the file.

A fast reproducer for bug #0 is presented below.  A few offending extents
are also created in the wild during large rsync transfers with the -S
flag.  A Linux kernel build (git checkout; make allyesconfig; make -j8)
will produce a handful of offending files as well.  Once an offending
file is created, it can present different content to userspace each
time it is read.

Bug #0 is at least 4 and possibly 8 years old.  I verified every vX.Y
kernel back to v3.5 has this behavior.  There are fossil records of this
bug's effects in commits all the way back to v2.6.32.  I have no reason
to believe bug #0 wasn't present at the beginning of btrfs compression
support in v2.6.29, but I can't easily test kernels that old to be sure.

It is not clear whether bug #0 is worth fixing.  A fix would likely
require injecting extra reads into currently write-only paths, and most
of the exceptional cases caused by bug #0 are already handled now.

Whether we like them or not, bug #0's inline extents followed by holes
are part of the btrfs de-facto disk format now, and we need to be able
to read them without data corruption or an infoleak.  So enough about
bug #0, let's get back to bug #3 (this patch).

An example of on-disk structure leading to data corruption found in
the wild:

        item 61 key (606890 INODE_ITEM 0) itemoff 9662 itemsize 160
                inode generation 50 transid 50 size 47424 nbytes 49141
                block group 0 mode 100644 links 1 uid 0 gid 0
                rdev 0 flags 0x0(none)
        item 62 key (606890 INODE_REF 603050) itemoff 9642 itemsize 20
                inode ref index 3 namelen 10 name: DB_File.so
        item 63 key (606890 EXTENT_DATA 0) itemoff 8280 itemsize 1362
                inline extent data size 1341 ram 4085 compress(zlib)
        item 64 key (606890 EXTENT_DATA 4096) itemoff 8227 itemsize 53
                extent data disk byte 5367308288 nr 20480
                extent data offset 0 nr 45056 ram 45056
                extent compression(zlib)

Different data appears in userspace during each read of the 11 bytes
between 4085 and 4096.  The extent in item 63 is not long enough to
fill the first page of the file, so a memset is required to fill the
space between item 63 (ending at 4085) and item 64 (beginning at 4096)
with zero.

Here is a reproducer from Liu Bo, which demonstrates another method
of creating the same inline extent and hole pattern:

Using 'page_poison=on' kernel command line (or enable
CONFIG_PAGE_POISONING) run the following:

	# touch foo
	# chattr +c foo
	# xfs_io -f -c "pwrite -W 0 1000" foo
	# xfs_io -f -c "falloc 4 8188" foo
	# od -x foo
	# echo 3 >/proc/sys/vm/drop_caches
	# od -x foo

This produce the following on my box:

Correct output:  file contains 1000 data bytes followed
by zeros:

	0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
	*
	0001740 cdcd cdcd cdcd cdcd 0000 0000 0000 0000
	0001760 0000 0000 0000 0000 0000 0000 0000 0000
	*
	0020000

Actual output:  the data after the first 1000 bytes
will be different each run:

	0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
	*
	0001740 cdcd cdcd cdcd cdcd 6c63 7400 635f 006d
	0001760 5f74 6f43 7400 435f 0053 5f74 7363 7400
	0002000 435f 0056 5f74 6164 7400 645f 0062 5f74
	(...)

Signed-off-by: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Chris Mason <clm@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/btrfs/inode.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index db6115486166..d14af5bd13d6 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6667,6 +6667,20 @@ static noinline int uncompress_inline(struct btrfs_path *path,
 	max_size = min_t(unsigned long, PAGE_CACHE_SIZE, max_size);
 	ret = btrfs_decompress(compress_type, tmp, page,
 			       extent_offset, inline_size, max_size);
+
+	/*
+	 * decompression code contains a memset to fill in any space between the end
+	 * of the uncompressed data and the end of max_size in case the decompressed
+	 * data ends up shorter than ram_bytes.  That doesn't cover the hole between
+	 * the end of an inline extent and the beginning of the next block, so we
+	 * cover that region here.
+	 */
+
+	if (max_size + pg_offset < PAGE_SIZE) {
+		char *map = kmap(page);
+		memset(map + pg_offset + max_size, 0, PAGE_SIZE - max_size - pg_offset);
+		kunmap(page);
+	}
 	kfree(tmp);
 	return ret;
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] fbdev: controlfb: Add missing modes to fix out of bounds access
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (249 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] NFSv4.1 respect server's max size in CREATE_SESSION Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] target: Use system workqueue for ALUA transitions Sasha Levin
                   ` (44 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Geert Uytterhoeven, Bartlomiej Zolnierkiewicz, Sasha Levin

From: Geert Uytterhoeven <geert@linux-m68k.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit ac831a379d34109451b3c41a44a20ee10ecb615f ]

Dan's static analysis says:

    drivers/video/fbdev/controlfb.c:560 control_setup()
    error: buffer overflow 'control_mac_modes' 20 <= 21

Indeed, control_mac_modes[] has only 20 elements, while VMODE_MAX is 22,
which may lead to an out of bounds read when parsing vmode commandline
options.

The bug was introduced in v2.4.5.6, when 2 new modes were added to
macmodes.h, but control_mac_modes[] wasn't updated:

https://kernel.opensuse.org/cgit/kernel/diff/include/video/macmodes.h?h=v2.5.2&id=29f279c764808560eaceb88fef36cbc35c529aad

Augment control_mac_modes[] with the two new video modes to fix this.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/video/fbdev/controlfb.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/fbdev/controlfb.h b/drivers/video/fbdev/controlfb.h
index 6026c60fc100..261522fabdac 100644
--- a/drivers/video/fbdev/controlfb.h
+++ b/drivers/video/fbdev/controlfb.h
@@ -141,5 +141,7 @@ static struct max_cmodes control_mac_modes[] = {
 	{{ 1, 2}},	/* 1152x870, 75Hz */
 	{{ 0, 1}},	/* 1280x960, 75Hz */
 	{{ 0, 1}},	/* 1280x1024, 75Hz */
+	{{ 1, 2}},	/* 1152x768, 60Hz */
+	{{ 0, 1}},	/* 1600x1024, 60Hz */
 };
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] target: Use system workqueue for ALUA transitions
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (250 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] fbdev: controlfb: Add missing modes to fix out of bounds access Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] video: udlfb: Fix read EDID timeout Sasha Levin
                   ` (43 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Mike Christie, Nicholas Bellinger, Sasha Levin

From: Mike Christie <mchristi@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 207ee84133c00a8a2a5bdec94df4a5b37d78881c ]

If tcmu-runner is processing a STPG and needs to change the kernel's
ALUA state then we cannot use the same work queue for task management
requests and ALUA transitions, because we could deadlock. The problem
occurs when a STPG times out before tcmu-runner is able to
call into target_tg_pt_gp_alua_access_state_store->
core_alua_do_port_transition -> core_alua_do_transition_tg_pt ->
queue_work. In this case, the tmr is on the work queue waiting for
the STPG to complete, but the STPG transition is now queued behind
the waiting tmr.

Note:
This bug will also be fixed by this patch:
http://www.spinics.net/lists/target-devel/msg14560.html
which switches the tmr code to use the system workqueues.

For both, I am not sure if we need a dedicated workqueue since
it is not a performance path and I do not think we need WQ_MEM_RECLAIM
to make forward progress to free up memory like the block layer does.

Signed-off-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/target/target_core_alua.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 4f8d4d459aa4..edb880faa754 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -1126,13 +1126,11 @@ static int core_alua_do_transition_tg_pt(
 		unsigned long transition_tmo;
 
 		transition_tmo = tg_pt_gp->tg_pt_gp_implicit_trans_secs * HZ;
-		queue_delayed_work(tg_pt_gp->tg_pt_gp_dev->tmr_wq,
-				   &tg_pt_gp->tg_pt_gp_transition_work,
-				   transition_tmo);
+		schedule_delayed_work(&tg_pt_gp->tg_pt_gp_transition_work,
+				      transition_tmo);
 	} else {
 		tg_pt_gp->tg_pt_gp_transition_complete = &wait;
-		queue_delayed_work(tg_pt_gp->tg_pt_gp_dev->tmr_wq,
-				   &tg_pt_gp->tg_pt_gp_transition_work, 0);
+		schedule_delayed_work(&tg_pt_gp->tg_pt_gp_transition_work, 0);
 		wait_for_completion(&wait);
 		tg_pt_gp->tg_pt_gp_transition_complete = NULL;
 	}
-- 
2.11.0

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

* [added to the 4.1 stable tree] video: fbdev: au1200fb: Release some resources if a memory allocation fails
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (252 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] video: udlfb: Fix read EDID timeout Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] video: fbdev: au1200fb: Return an error code " Sasha Levin
                   ` (41 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Christophe JAILLET, Bartlomiej Zolnierkiewicz, Sasha Levin

From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 451f130602619a17c8883dd0b71b11624faffd51 ]

We should go through the error handling code instead of returning -ENOMEM
directly.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/video/fbdev/au1200fb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c
index f9507b1894df..e5897fce3c03 100644
--- a/drivers/video/fbdev/au1200fb.c
+++ b/drivers/video/fbdev/au1200fb.c
@@ -1699,7 +1699,8 @@ static int au1200fb_drv_probe(struct platform_device *dev)
 		if (!fbdev->fb_mem) {
 			print_err("fail to allocate frambuffer (size: %dK))",
 				  fbdev->fb_len / 1024);
-			return -ENOMEM;
+			ret = -ENOMEM;
+			goto failed;
 		}
 
 		/*
-- 
2.11.0

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

* [added to the 4.1 stable tree] video: udlfb: Fix read EDID timeout
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (251 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] target: Use system workqueue for ALUA transitions Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] video: fbdev: au1200fb: Release some resources if a memory allocation fails Sasha Levin
                   ` (42 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Ladislav Michl, Bartlomiej Zolnierkiewicz, Sasha Levin

From: Ladislav Michl <ladis@linux-mips.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit c98769475575c8a585f5b3952f4b5f90266f699b ]

While usb_control_msg function expects timeout in miliseconds, a value
of HZ is used. Replace it with USB_CTRL_GET_TIMEOUT and also fix error
message which looks like:
udlfb: Read EDID byte 78 failed err ffffff92
as error is either negative errno or number of bytes transferred use %d
format specifier.

Returned EDID is in second byte, so return error when less than two bytes
are received.

Fixes: 18dffdf8913a ("staging: udlfb: enhance EDID and mode handling support")
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Cc: Bernie Thompson <bernie@plugable.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/video/fbdev/udlfb.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
index ff2b8731a2dc..d2a985e59fcd 100644
--- a/drivers/video/fbdev/udlfb.c
+++ b/drivers/video/fbdev/udlfb.c
@@ -769,11 +769,11 @@ static int dlfb_get_edid(struct dlfb_data *dev, char *edid, int len)
 
 	for (i = 0; i < len; i++) {
 		ret = usb_control_msg(dev->udev,
-				    usb_rcvctrlpipe(dev->udev, 0), (0x02),
-				    (0x80 | (0x02 << 5)), i << 8, 0xA1, rbuf, 2,
-				    HZ);
-		if (ret < 1) {
-			pr_err("Read EDID byte %d failed err %x\n", i, ret);
+				      usb_rcvctrlpipe(dev->udev, 0), 0x02,
+				      (0x80 | (0x02 << 5)), i << 8, 0xA1,
+				      rbuf, 2, USB_CTRL_GET_TIMEOUT);
+		if (ret < 2) {
+			pr_err("Read EDID byte %d failed: %d\n", i, ret);
 			i--;
 			break;
 		}
-- 
2.11.0

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

* [added to the 4.1 stable tree] PCI/PME: Handle invalid data when reading Root Status
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (254 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] video: fbdev: au1200fb: Return an error code " Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] powerpc/powernv/cpufreq: Fix the frequency read by /proc/cpuinfo Sasha Levin
                   ` (39 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Qiang, Bjorn Helgaas, Sasha Levin

From: Qiang <zhengqiang10@huawei.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 3ad3f8ce50914288731a3018b27ee44ab803e170 ]

PCIe PME and native hotplug share the same interrupt number, so hotplug
interrupts are also processed by PME.  In some cases, e.g., a Link Down
interrupt, a device may be present but unreachable, so when we try to
read its Root Status register, the read fails and we get all ones data
(0xffffffff).

Previously, we interpreted that data as PCI_EXP_RTSTA_PME being set, i.e.,
"some device has asserted PME," so we scheduled pcie_pme_work_fn().  This
caused an infinite loop because pcie_pme_work_fn() tried to handle PME
requests until PCI_EXP_RTSTA_PME is cleared, but with the link down,
PCI_EXP_RTSTA_PME can't be cleared.

Check for the invalid 0xffffffff data everywhere we read the Root Status
register.

1469d17dd341 ("PCI: pciehp: Handle invalid data when reading from
non-existent devices") added similar checks in the hotplug driver.

Signed-off-by: Qiang Zheng <zhengqiang10@huawei.com>
[bhelgaas: changelog, also check in pcie_pme_work_fn(), use "~0" to follow
other similar checks]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/pci/pcie/pme.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c
index 63fc63911295..deb903112974 100644
--- a/drivers/pci/pcie/pme.c
+++ b/drivers/pci/pcie/pme.c
@@ -233,6 +233,9 @@ static void pcie_pme_work_fn(struct work_struct *work)
 			break;
 
 		pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta);
+		if (rtsta == (u32) ~0)
+			break;
+
 		if (rtsta & PCI_EXP_RTSTA_PME) {
 			/*
 			 * Clear PME status of the port.  If there are other
@@ -280,7 +283,7 @@ static irqreturn_t pcie_pme_irq(int irq, void *context)
 	spin_lock_irqsave(&data->lock, flags);
 	pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta);
 
-	if (!(rtsta & PCI_EXP_RTSTA_PME)) {
+	if (rtsta == (u32) ~0 || !(rtsta & PCI_EXP_RTSTA_PME)) {
 		spin_unlock_irqrestore(&data->lock, flags);
 		return IRQ_NONE;
 	}
-- 
2.11.0

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

* [added to the 4.1 stable tree] video: fbdev: au1200fb: Return an error code if a memory allocation fails
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (253 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] video: fbdev: au1200fb: Release some resources if a memory allocation fails Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] PCI/PME: Handle invalid data when reading Root Status Sasha Levin
                   ` (40 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Christophe JAILLET, Bartlomiej Zolnierkiewicz, Sasha Levin

From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 8cae353e6b01ac3f18097f631cdbceb5ff28c7f3 ]

'ret' is known to be 0 at this point.
In case of memory allocation error in 'framebuffer_alloc()', return
-ENOMEM instead.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/video/fbdev/au1200fb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c
index e5897fce3c03..789d3f16ff9f 100644
--- a/drivers/video/fbdev/au1200fb.c
+++ b/drivers/video/fbdev/au1200fb.c
@@ -1680,8 +1680,10 @@ static int au1200fb_drv_probe(struct platform_device *dev)
 
 		fbi = framebuffer_alloc(sizeof(struct au1200fb_device),
 					&dev->dev);
-		if (!fbi)
+		if (!fbi) {
+			ret = -ENOMEM;
 			goto failed;
+		}
 
 		_au1200fb_infos[plane] = fbi;
 		fbdev = fbi->par;
-- 
2.11.0

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

* [added to the 4.1 stable tree] powerpc/powernv/cpufreq: Fix the frequency read by /proc/cpuinfo
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (255 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] PCI/PME: Handle invalid data when reading Root Status Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] powerpc/ipic: Fix status get and status clear Sasha Levin
                   ` (38 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Shriya, Michael Ellerman, Sasha Levin

From: Shriya <shriyak@linux.vnet.ibm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit cd77b5ce208c153260ed7882d8910f2395bfaabd ]

The call to /proc/cpuinfo in turn calls cpufreq_quick_get() which
returns the last frequency requested by the kernel, but may not
reflect the actual frequency the processor is running at. This patch
makes a call to cpufreq_get() instead which returns the current
frequency reported by the hardware.

Fixes: fb5153d05a7d ("powerpc: powernv: Implement ppc_md.get_proc_freq()")
Signed-off-by: Shriya <shriyak@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/powerpc/platforms/powernv/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index 16fdcb23f4c3..20974478f8d0 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -469,7 +469,7 @@ static unsigned long pnv_get_proc_freq(unsigned int cpu)
 {
 	unsigned long ret_freq;
 
-	ret_freq = cpufreq_quick_get(cpu) * 1000ul;
+	ret_freq = cpufreq_get(cpu) * 1000ul;
 
 	/*
 	 * If the backend cpufreq driver does not exist,
-- 
2.11.0

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

* [added to the 4.1 stable tree] powerpc/ipic: Fix status get and status clear
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (256 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] powerpc/powernv/cpufreq: Fix the frequency read by /proc/cpuinfo Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] powerpc/opal: Fix EBUSY bug in acquiring tokens Sasha Levin
                   ` (37 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Christophe Leroy, Michael Ellerman, Sasha Levin

From: Christophe Leroy <christophe.leroy@c-s.fr>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 6b148a7ce72a7f87c81cbcde48af014abc0516a9 ]

IPIC Status is provided by register IPIC_SERSR and not by IPIC_SERMR
which is the mask register.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/powerpc/sysdev/ipic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index b28733727ed3..2e41a73ad80a 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -843,12 +843,12 @@ void ipic_disable_mcp(enum ipic_mcp_irq mcp_irq)
 
 u32 ipic_get_mcp_status(void)
 {
-	return ipic_read(primary_ipic->regs, IPIC_SERMR);
+	return ipic_read(primary_ipic->regs, IPIC_SERSR);
 }
 
 void ipic_clear_mcp_status(u32 mask)
 {
-	ipic_write(primary_ipic->regs, IPIC_SERMR, mask);
+	ipic_write(primary_ipic->regs, IPIC_SERSR, mask);
 }
 
 /* Return an interrupt vector or NO_IRQ if no interrupt is pending. */
-- 
2.11.0

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

* [added to the 4.1 stable tree] powerpc/opal: Fix EBUSY bug in acquiring tokens
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (257 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] powerpc/ipic: Fix status get and status clear Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] iscsi-target: fix memory leak in lio_target_tiqn_addtpg() Sasha Levin
                   ` (36 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: William A. Kennington III, Michael Ellerman, Sasha Levin

From: "William A. Kennington III" <wak@google.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 71e24d7731a2903b1ae2bba2b2971c654d9c2aa6 ]

The current code checks the completion map to look for the first token
that is complete. In some cases, a completion can come in but the
token can still be on lease to the caller processing the completion.
If this completed but unreleased token is the first token found in the
bitmap by another tasks trying to acquire a token, then the
__test_and_set_bit call will fail since the token will still be on
lease. The acquisition will then fail with an EBUSY.

This patch reorganizes the acquisition code to look at the
opal_async_token_map for an unleased token. If the token has no lease
it must have no outstanding completions so we should never see an
EBUSY, unless we have leased out too many tokens. Since
opal_async_get_token_inrerruptible is protected by a semaphore, we
will practically never see EBUSY anymore.

Fixes: 8d7248232208 ("powerpc/powernv: Infrastructure to support OPAL async completion")
Signed-off-by: William A. Kennington III <wak@google.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/powerpc/platforms/powernv/opal-async.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal-async.c b/arch/powerpc/platforms/powernv/opal-async.c
index 693b6cdac691..3fcaa9ef447b 100644
--- a/arch/powerpc/platforms/powernv/opal-async.c
+++ b/arch/powerpc/platforms/powernv/opal-async.c
@@ -39,18 +39,18 @@ int __opal_async_get_token(void)
 	int token;
 
 	spin_lock_irqsave(&opal_async_comp_lock, flags);
-	token = find_first_bit(opal_async_complete_map, opal_max_async_tokens);
+	token = find_first_zero_bit(opal_async_token_map, opal_max_async_tokens);
 	if (token >= opal_max_async_tokens) {
 		token = -EBUSY;
 		goto out;
 	}
 
-	if (__test_and_set_bit(token, opal_async_token_map)) {
+	if (!__test_and_clear_bit(token, opal_async_complete_map)) {
 		token = -EBUSY;
 		goto out;
 	}
 
-	__clear_bit(token, opal_async_complete_map);
+	__set_bit(token, opal_async_token_map);
 
 out:
 	spin_unlock_irqrestore(&opal_async_comp_lock, flags);
-- 
2.11.0

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

* [added to the 4.1 stable tree] target/iscsi: Fix a race condition in iscsit_add_reject_from_cmd()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (259 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] iscsi-target: fix memory leak in lio_target_tiqn_addtpg() Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] target:fix condition return in core_pr_dump_initiator_port() Sasha Levin
                   ` (34 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Bart Van Assche, Nicholas Bellinger, Sasha Levin

From: Bart Van Assche <bart.vanassche@wdc.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit cfe2b621bb18d86e93271febf8c6e37622da2d14 ]

Avoid that cmd->se_cmd.se_tfo is read after a command has already been
freed.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Mike Christie <mchristi@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/target/iscsi/iscsi_target.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 8df1ff3766c4..2d6b0cf0929e 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -682,6 +682,7 @@ static int iscsit_add_reject_from_cmd(
 	unsigned char *buf)
 {
 	struct iscsi_conn *conn;
+	const bool do_put = cmd->se_cmd.se_tfo != NULL;
 
 	if (!cmd->conn) {
 		pr_err("cmd->conn is NULL for ITT: 0x%08x\n",
@@ -712,7 +713,7 @@ static int iscsit_add_reject_from_cmd(
 	 * Perform the kref_put now if se_cmd has already been setup by
 	 * scsit_setup_scsi_cmd()
 	 */
-	if (cmd->se_cmd.se_tfo != NULL) {
+	if (do_put) {
 		pr_debug("iscsi reject: calling target_put_sess_cmd >>>>>>\n");
 		target_put_sess_cmd(&cmd->se_cmd);
 	}
-- 
2.11.0

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

* [added to the 4.1 stable tree] iscsi-target: fix memory leak in lio_target_tiqn_addtpg()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (258 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] powerpc/opal: Fix EBUSY bug in acquiring tokens Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] target/iscsi: Fix a race condition in iscsit_add_reject_from_cmd() Sasha Levin
                   ` (35 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: tangwenji, Nicholas Bellinger, Sasha Levin

From: tangwenji <tang.wenji@zte.com.cn>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 12d5a43b2dffb6cd28062b4e19024f7982393288 ]

tpg must free when call core_tpg_register() return fail

Signed-off-by: tangwenji <tang.wenji@zte.com.cn>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/target/iscsi/iscsi_target_configfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
index f6169f722991..bc578d3d2178 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -1466,7 +1466,7 @@ static struct se_portal_group *lio_target_tiqn_addtpg(
 	ret = core_tpg_register(&iscsi_ops, wwn, &tpg->tpg_se_tpg,
 				tpg, TRANSPORT_TPG_TYPE_NORMAL);
 	if (ret < 0)
-		return NULL;
+		goto free_out;
 
 	ret = iscsit_tpg_add_portal_group(tiqn, tpg);
 	if (ret != 0)
@@ -1478,6 +1478,7 @@ static struct se_portal_group *lio_target_tiqn_addtpg(
 	return &tpg->tpg_se_tpg;
 out:
 	core_tpg_deregister(&tpg->tpg_se_tpg);
+free_out:
 	kfree(tpg);
 	return NULL;
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] target:fix condition return in core_pr_dump_initiator_port()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (260 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] target/iscsi: Fix a race condition in iscsit_add_reject_from_cmd() Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] target/file: Do not return error for UNMAP if length is zero Sasha Levin
                   ` (33 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: tangwenji, Nicholas Bellinger, Sasha Levin

From: tangwenji <tang.wenji@zte.com.cn>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 24528f089d0a444070aa4f715ace537e8d6bf168 ]

When is pr_reg->isid_present_at_reg is false,this function should return.

This fixes a regression originally introduced by:

  commit d2843c173ee53cf4c12e7dfedc069a5bc76f0ac5
  Author: Andy Grover <agrover@redhat.com>
  Date:   Thu May 16 10:40:55 2013 -0700

      target: Alter core_pr_dump_initiator_port for ease of use

Signed-off-by: tangwenji <tang.wenji@zte.com.cn>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/target/target_core_pr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 57fd4e14d4eb..770fc5ae26a7 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -58,8 +58,10 @@ void core_pr_dump_initiator_port(
 	char *buf,
 	u32 size)
 {
-	if (!pr_reg->isid_present_at_reg)
+	if (!pr_reg->isid_present_at_reg) {
 		buf[0] = '\0';
+		return;
+	}
 
 	snprintf(buf, size, ",i,0x%s", pr_reg->pr_reg_isid);
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] target/file: Do not return error for UNMAP if length is zero
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (261 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] target:fix condition return in core_pr_dump_initiator_port() Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] arm-ccn: perf: Prevent module unload while PMU is in use Sasha Levin
                   ` (32 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jiang Yi, Nicholas Bellinger, Sasha Levin

From: Jiang Yi <jiangyilism@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 594e25e73440863981032d76c9b1e33409ceff6e ]

The function fd_execute_unmap() in target_core_file.c calles

ret = file->f_op->fallocate(file, mode, pos, len);

Some filesystems implement fallocate() to return error if
length is zero (e.g. btrfs) but according to SCSI Block
Commands spec UNMAP should return success for zero length.

Signed-off-by: Jiang Yi <jiangyilism@gmail.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/target/target_core_file.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index dee7dfdf203a..5d5e5cd77261 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -539,6 +539,10 @@ fd_do_unmap(struct se_cmd *cmd, void *priv, sector_t lba, sector_t nolb)
 	struct inode *inode = file->f_mapping->host;
 	int ret;
 
+	if (!nolb) {
+		return 0;
+	}
+
 	if (cmd->se_dev->dev_attrib.pi_prot_type) {
 		ret = fd_do_prot_unmap(cmd, lba, nolb);
 		if (ret)
-- 
2.11.0

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

* [added to the 4.1 stable tree] mm: Handle 0 flags in _calc_vm_trans() macro
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (263 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] arm-ccn: perf: Prevent module unload while PMU is in use Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] clk: tegra: Fix cclk_lp divisor register Sasha Levin
                   ` (30 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jan Kara, Dan Williams, Sasha Levin

From: Jan Kara <jack@suse.cz>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 592e254502041f953e84d091eae2c68cba04c10b ]

_calc_vm_trans() does not handle the situation when some of the passed
flags are 0 (which can happen if these VM flags do not make sense for
the architecture). Improve the _calc_vm_trans() macro to return 0 in
such situation. Since all passed flags are constant, this does not add
any runtime overhead.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 include/linux/mman.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/mman.h b/include/linux/mman.h
index 16373c8f5f57..369bc3405a6d 100644
--- a/include/linux/mman.h
+++ b/include/linux/mman.h
@@ -63,8 +63,9 @@ static inline int arch_validate_prot(unsigned long prot)
  * ("bit1" and "bit2" must be single bits)
  */
 #define _calc_vm_trans(x, bit1, bit2) \
+  ((!(bit1) || !(bit2)) ? 0 : \
   ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \
-   : ((x) & (bit1)) / ((bit1) / (bit2)))
+   : ((x) & (bit1)) / ((bit1) / (bit2))))
 
 /*
  * Combine the mmap "prot" argument into "vm_flags" used internally.
-- 
2.11.0

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

* [added to the 4.1 stable tree] arm-ccn: perf: Prevent module unload while PMU is in use
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (262 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] target/file: Do not return error for UNMAP if length is zero Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] mm: Handle 0 flags in _calc_vm_trans() macro Sasha Levin
                   ` (31 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Suzuki K Poulose, Will Deacon, Sasha Levin

From: Suzuki K Poulose <suzuki.poulose@arm.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit c7f5828bf77dcbd61d51f4736c1d5aa35663fbb4 ]

When the PMU driver is built as a module, the perf expects the
pmu->module to be valid, so that the driver is prevented from
being unloaded while it is in use. Fix the CCN pmu driver to
fill in this field.

Fixes: a33b0daab73a0 ("bus: ARM CCN PMU driver")
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/bus/arm-ccn.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c
index 4d523cfe51ce..31342fccd290 100644
--- a/drivers/bus/arm-ccn.c
+++ b/drivers/bus/arm-ccn.c
@@ -1157,6 +1157,7 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
 
 	/* Perf driver registration */
 	ccn->dt.pmu = (struct pmu) {
+		.module = THIS_MODULE,
 		.attr_groups = arm_ccn_pmu_attr_groups,
 		.task_ctx_nr = perf_invalid_context,
 		.event_init = arm_ccn_pmu_event_init,
-- 
2.11.0

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

* [added to the 4.1 stable tree] clk: tegra: Fix cclk_lp divisor register
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (264 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] mm: Handle 0 flags in _calc_vm_trans() macro Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] ppp: Destroy the mutex when cleanup Sasha Levin
                   ` (29 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Michał Mirosław, Thierry Reding, Sasha Levin

From: Michał Mirosław <mirq-linux@rere.qmqm.pl>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 54eff2264d3e9fd7e3987de1d7eba1d3581c631e ]

According to comments in code and common sense, cclk_lp uses its
own divisor, not cclk_g's.

Fixes: b08e8c0ecc42 ("clk: tegra: add clock support for Tegra30")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-By: Peter De Schrijver <pdeschrijver@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/clk/tegra/clk-tegra30.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/tegra/clk-tegra30.c b/drivers/clk/tegra/clk-tegra30.c
index 4b26509fc218..803ef926d682 100644
--- a/drivers/clk/tegra/clk-tegra30.c
+++ b/drivers/clk/tegra/clk-tegra30.c
@@ -1064,7 +1064,7 @@ static void __init tegra30_super_clk_init(void)
 	 * U71 divider of cclk_lp.
 	 */
 	clk = tegra_clk_register_divider("pll_p_out3_cclklp", "pll_p_out3",
-				clk_base + SUPER_CCLKG_DIVIDER, 0,
+				clk_base + SUPER_CCLKLP_DIVIDER, 0,
 				TEGRA_DIVIDER_INT, 16, 8, 1, NULL);
 	clk_register_clkdev(clk, "pll_p_out3_cclklp", NULL);
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] ppp: Destroy the mutex when cleanup
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (265 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] clk: tegra: Fix cclk_lp divisor register Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] thermal/drivers/step_wise: Fix temperature regulation misbehavior Sasha Levin
                   ` (28 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Gao Feng, David S . Miller, Sasha Levin

From: Gao Feng <gfree.wind@vip.163.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f02b2320b27c16b644691267ee3b5c110846f49e ]

The mutex_destroy only makes sense when enable DEBUG_MUTEX. For the
good readbility, it's better to invoke it in exit func when the init
func invokes mutex_init.

Signed-off-by: Gao Feng <gfree.wind@vip.163.com>
Acked-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ppp/ppp_generic.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 51ba895f0522..c30c1fc7889a 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -918,6 +918,7 @@ static __net_exit void ppp_exit_net(struct net *net)
 {
 	struct ppp_net *pn = net_generic(net, ppp_net_id);
 
+	mutex_destroy(&pn->all_ppp_mutex);
 	idr_destroy(&pn->units_idr);
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] thermal/drivers/step_wise: Fix temperature regulation misbehavior
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (266 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] ppp: Destroy the mutex when cleanup Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] bcache: explicitly destroy mutex while exiting Sasha Levin
                   ` (27 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Daniel Lezcano, Eduardo Valentin, Sasha Levin

From: Daniel Lezcano <daniel.lezcano@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 07209fcf33542c1ff1e29df2dbdf8f29cdaacb10 ]

There is a particular situation when the cooling device is cpufreq and the heat
dissipation is not efficient enough where the temperature increases little by
little until reaching the critical threshold and leading to a SoC reset.

The behavior is reproducible on a hikey6220 with bad heat dissipation (eg.
stacked with other boards).

Running a simple C program doing while(1); for each CPU of the SoC makes the
temperature to reach the passive regulation trip point and ends up to the
maximum allowed temperature followed by a reset.

This issue has been also reported by running the libhugetlbfs test suite.

What is observed is a ping pong between two cpu frequencies, 1.2GHz and 900MHz
while the temperature continues to grow.

It appears the step wise governor calls get_target_state() the first time with
the throttle set to true and the trend to 'raising'. The code selects logically
the next state, so the cpu frequency decreases from 1.2GHz to 900MHz, so far so
good. The temperature decreases immediately but still stays greater than the
trip point, then get_target_state() is called again, this time with the
throttle set to true *and* the trend to 'dropping'. From there the algorithm
assumes we have to step down the state and the cpu frequency jumps back to
1.2GHz. But the temperature is still higher than the trip point, so
get_target_state() is called with throttle=1 and trend='raising' again, we jump
to 900MHz, then get_target_state() is called with throttle=1 and
trend='dropping', we jump to 1.2GHz, etc ... but the temperature does not
stabilizes and continues to increase.

[  237.922654] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=1,throttle=1
[  237.922678] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=1,throttle=1
[  237.922690] thermal cooling_device0: cur_state=0
[  237.922701] thermal cooling_device0: old_target=0, target=1
[  238.026656] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=2,throttle=1
[  238.026680] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=2,throttle=1
[  238.026694] thermal cooling_device0: cur_state=1
[  238.026707] thermal cooling_device0: old_target=1, target=0
[  238.134647] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=1,throttle=1
[  238.134667] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=1,throttle=1
[  238.134679] thermal cooling_device0: cur_state=0
[  238.134690] thermal cooling_device0: old_target=0, target=1

In this situation the temperature continues to increase while the trend is
oscillating between 'dropping' and 'raising'. We need to keep the current state
untouched if the throttle is set, so the temperature can decrease or a higher
state could be selected, thus preventing this oscillation.

Keeping the next_target untouched when 'throttle' is true at 'dropping' time
fixes the issue.

The following traces show the governor does not change the next state if
trend==2 (dropping) and throttle==1.

[ 2306.127987] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=1,throttle=1
[ 2306.128009] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=1,throttle=1
[ 2306.128021] thermal cooling_device0: cur_state=0
[ 2306.128031] thermal cooling_device0: old_target=0, target=1
[ 2306.231991] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=2,throttle=1
[ 2306.232016] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=2,throttle=1
[ 2306.232030] thermal cooling_device0: cur_state=1
[ 2306.232042] thermal cooling_device0: old_target=1, target=1
[ 2306.335982] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=0,throttle=1
[ 2306.336006] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=0,throttle=1
[ 2306.336021] thermal cooling_device0: cur_state=1
[ 2306.336034] thermal cooling_device0: old_target=1, target=1
[ 2306.439984] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=2,throttle=1
[ 2306.440008] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=2,throttle=0
[ 2306.440022] thermal cooling_device0: cur_state=1
[ 2306.440034] thermal cooling_device0: old_target=1, target=0

[ ... ]

After a while, if the temperature continues to increase, the next state becomes
2 which is 720MHz on the hikey. That results in the temperature stabilizing
around the trip point.

[ 2455.831982] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=1,throttle=1
[ 2455.832006] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=1,throttle=0
[ 2455.832019] thermal cooling_device0: cur_state=1
[ 2455.832032] thermal cooling_device0: old_target=1, target=1
[ 2455.935985] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=0,throttle=1
[ 2455.936013] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=0,throttle=0
[ 2455.936027] thermal cooling_device0: cur_state=1
[ 2455.936040] thermal cooling_device0: old_target=1, target=1
[ 2456.043984] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=0,throttle=1
[ 2456.044009] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=0,throttle=0
[ 2456.044023] thermal cooling_device0: cur_state=1
[ 2456.044036] thermal cooling_device0: old_target=1, target=1
[ 2456.148001] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=1,throttle=1
[ 2456.148028] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=1,throttle=1
[ 2456.148042] thermal cooling_device0: cur_state=1
[ 2456.148055] thermal cooling_device0: old_target=1, target=2
[ 2456.252009] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=2,throttle=1
[ 2456.252041] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=2,throttle=0
[ 2456.252058] thermal cooling_device0: cur_state=2
[ 2456.252075] thermal cooling_device0: old_target=2, target=1

IOW, this change is needed to keep the state for a cooling device if the
temperature trend is oscillating while the temperature increases slightly.

Without this change, the situation above leads to a catastrophic crash by a
hardware reset on hikey. This issue has been reported to happen on an OMAP
dra7xx also.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Keerthy <j-keerthy@ti.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Leo Yan <leo.yan@linaro.org>
Tested-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/thermal/step_wise.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
index ec4ea5940bf7..96932e88464d 100644
--- a/drivers/thermal/step_wise.c
+++ b/drivers/thermal/step_wise.c
@@ -31,8 +31,7 @@
  * If the temperature is higher than a trip point,
  *    a. if the trend is THERMAL_TREND_RAISING, use higher cooling
  *       state for this trip point
- *    b. if the trend is THERMAL_TREND_DROPPING, use lower cooling
- *       state for this trip point
+ *    b. if the trend is THERMAL_TREND_DROPPING, do nothing
  *    c. if the trend is THERMAL_TREND_RAISE_FULL, use upper limit
  *       for this trip point
  *    d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit
@@ -94,9 +93,11 @@ static unsigned long get_target_state(struct thermal_instance *instance,
 			if (!throttle)
 				next_target = THERMAL_NO_TARGET;
 		} else {
-			next_target = cur_state - 1;
-			if (next_target > instance->upper)
-				next_target = instance->upper;
+			if (!throttle) {
+				next_target = cur_state - 1;
+				if (next_target > instance->upper)
+					next_target = instance->upper;
+			}
 		}
 		break;
 	case THERMAL_TREND_DROP_FULL:
-- 
2.11.0

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

* [added to the 4.1 stable tree] bcache: explicitly destroy mutex while exiting
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (267 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] thermal/drivers/step_wise: Fix temperature regulation misbehavior Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] GFS2: Take inode off order_write list when setting jdata flag Sasha Levin
                   ` (26 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Liang Chen, Jens Axboe, Sasha Levin

From: Liang Chen <liangchen.linux@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 330a4db89d39a6b43f36da16824eaa7a7509d34d ]

mutex_destroy does nothing most of time, but it's better to call
it to make the code future proof and it also has some meaning
for like mutex debug.

As Coly pointed out in a previous review, bcache_exit() may not be
able to handle all the references properly if userspace registers
cache and backing devices right before bch_debug_init runs and
bch_debug_init failes later. So not exposing userspace interface
until everything is ready to avoid that issue.

Signed-off-by: Liang Chen <liangchen.linux@gmail.com>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Reviewed-by: Coly Li <colyli@suse.de>
Reviewed-by: Eric Wheeler <bcache@linux.ewheeler.net>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/md/bcache/super.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index b911a7d7a06b..6f7bc8a8674b 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2122,6 +2122,7 @@ static void bcache_exit(void)
 	if (bcache_major)
 		unregister_blkdev(bcache_major, "bcache");
 	unregister_reboot_notifier(&reboot);
+	mutex_destroy(&bch_register_lock);
 }
 
 static int __init bcache_init(void)
@@ -2140,14 +2141,15 @@ static int __init bcache_init(void)
 	bcache_major = register_blkdev(0, "bcache");
 	if (bcache_major < 0) {
 		unregister_reboot_notifier(&reboot);
+		mutex_destroy(&bch_register_lock);
 		return bcache_major;
 	}
 
 	if (!(bcache_wq = create_workqueue("bcache")) ||
 	    !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) ||
-	    sysfs_create_files(bcache_kobj, files) ||
 	    bch_request_init() ||
-	    bch_debug_init(bcache_kobj))
+	    bch_debug_init(bcache_kobj) ||
+	    sysfs_create_files(bcache_kobj, files))
 		goto err;
 
 	return 0;
-- 
2.11.0

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

* [added to the 4.1 stable tree] GFS2: Take inode off order_write list when setting jdata flag
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (268 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] bcache: explicitly destroy mutex while exiting Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] l2tp: cleanup l2tp_tunnel_delete calls Sasha Levin
                   ` (25 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Bob Peterson, Andreas Gruenbacher, Sasha Levin

From: Bob Peterson <rpeterso@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit cc555b09d8c3817aeebda43a14ab67049a5653f7 ]

This patch fixes a deadlock caused when the jdata flag is set for
inodes that are already on the ordered write list. Since it is
on the ordered write list, log_flush calls gfs2_ordered_write which
calls filemap_fdatawrite. But since the inode had the jdata flag
set, that calls gfs2_jdata_writepages, which tries to start a new
transaction. A new transaction cannot be started because it tries
to acquire the log_flush rwsem which is already locked by the log
flush operation.

The bottom line is: We cannot switch an inode from ordered to jdata
until we eliminate any ordered data pages (via log flush) or any
log_flush operation afterward will create the circular dependency
above. So we need to flush the log before setting the diskflags to
switch the file mode, then we need to remove the inode from the
ordered writes list.

Before this patch, the log flush was done for jdata->ordered, but
that's wrong. If we're going from jdata to ordered, we don't need
to call gfs2_log_flush because the call to filemap_fdatawrite will
do it for us:

   filemap_fdatawrite() -> __filemap_fdatawrite_range()
      __filemap_fdatawrite_range() -> do_writepages()
         do_writepages() -> gfs2_jdata_writepages()
            gfs2_jdata_writepages() -> gfs2_log_flush()

This patch modifies function do_gfs2_set_flags so that if a file
has its jdata flag set, and it's already on the ordered write list,
the log will be flushed and it will be removed from the list
before setting the flag.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Acked-by: Abhijith Das <adas@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/gfs2/file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 31892871ea87..2f45f0ce5d66 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -255,7 +255,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
 			goto out;
 	}
 	if ((flags ^ new_flags) & GFS2_DIF_JDATA) {
-		if (flags & GFS2_DIF_JDATA)
+		if (new_flags & GFS2_DIF_JDATA)
 			gfs2_log_flush(sdp, ip->i_gl, NORMAL_FLUSH);
 		error = filemap_fdatawrite(inode->i_mapping);
 		if (error)
@@ -263,6 +263,8 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
 		error = filemap_fdatawait(inode->i_mapping);
 		if (error)
 			goto out;
+		if (new_flags & GFS2_DIF_JDATA)
+			gfs2_ordered_del_inode(ip);
 	}
 	error = gfs2_trans_begin(sdp, RES_DINODE, 0);
 	if (error)
-- 
2.11.0

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

* [added to the 4.1 stable tree] l2tp: cleanup l2tp_tunnel_delete calls
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (269 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] GFS2: Take inode off order_write list when setting jdata flag Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] xfs: fix incorrect extent state in xfs_bmap_add_extent_unwritten_real Sasha Levin
                   ` (24 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jiri Slaby, David S . Miller, Sasha Levin

From: Jiri Slaby <jslaby@suse.cz>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 4dc12ffeaeac939097a3f55c881d3dc3523dff0c ]

l2tp_tunnel_delete does not return anything since commit 62b982eeb458
("l2tp: fix race condition in l2tp_tunnel_delete").  But call sites of
l2tp_tunnel_delete still do casts to void to avoid unused return value
warnings.

Kill these now useless casts.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Sabrina Dubroca <sd@queasysnail.net>
Cc: Guillaume Nault <g.nault@alphalink.fr>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Acked-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 net/l2tp/l2tp_core.c    | 2 +-
 net/l2tp/l2tp_netlink.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index 8a1d1542eb2f..0c4de8dd58bf 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -1859,7 +1859,7 @@ static __net_exit void l2tp_exit_net(struct net *net)
 
 	rcu_read_lock_bh();
 	list_for_each_entry_rcu(tunnel, &pn->l2tp_tunnel_list, list) {
-		(void)l2tp_tunnel_delete(tunnel);
+		l2tp_tunnel_delete(tunnel);
 	}
 	rcu_read_unlock_bh();
 }
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
index 4c0ce67329ca..1e412ad6ced5 100644
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -285,7 +285,7 @@ static int l2tp_nl_cmd_tunnel_delete(struct sk_buff *skb, struct genl_info *info
 	l2tp_tunnel_notify(&l2tp_nl_family, info,
 			   tunnel, L2TP_CMD_TUNNEL_DELETE);
 
-	(void) l2tp_tunnel_delete(tunnel);
+	l2tp_tunnel_delete(tunnel);
 
 out:
 	return ret;
-- 
2.11.0

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

* [added to the 4.1 stable tree] xfs: fix incorrect extent state in xfs_bmap_add_extent_unwritten_real
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (270 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] l2tp: cleanup l2tp_tunnel_delete calls Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] xfs: fix log block underflow during recovery cycle verification Sasha Levin
                   ` (23 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Christoph Hellwig, Darrick J . Wong, Sasha Levin

From: Christoph Hellwig <hch@lst.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 5e422f5e4fd71d18bc6b851eeb3864477b3d842e ]

There was one spot in xfs_bmap_add_extent_unwritten_real that didn't use the
passed in new extent state but always converted to normal, leading to wrong
behavior when converting from normal to unwritten.

Only found by code inspection, it seems like this code path to move partial
extent from written to unwritten while merging it with the next extent is
rarely exercised.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/xfs/libxfs/xfs_bmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 51c85b6a0c34..cf9029d9a3f3 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -2671,7 +2671,7 @@ xfs_bmap_add_extent_unwritten_real(
 					&i)))
 				goto done;
 			XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
-			cur->bc_rec.b.br_state = XFS_EXT_NORM;
+			cur->bc_rec.b.br_state = new->br_state;
 			if ((error = xfs_btree_insert(cur, &i)))
 				goto done;
 			XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
-- 
2.11.0

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

* [added to the 4.1 stable tree] xfs: fix log block underflow during recovery cycle verification
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (271 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] xfs: fix incorrect extent state in xfs_bmap_add_extent_unwritten_real Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] PCI: Detach driver before procfs & sysfs teardown on device remove Sasha Levin
                   ` (22 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Brian Foster, Darrick J . Wong, Sasha Levin

From: Brian Foster <bfoster@redhat.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 9f2a4505800607e537e9dd9dea4f55c4b0c30c7a ]

It is possible for mkfs to format very small filesystems with too
small of an internal log with respect to the various minimum size
and block count requirements. If this occurs when the log happens to
be smaller than the scan window used for cycle verification and the
scan wraps the end of the log, the start_blk calculation in
xlog_find_head() underflows and leads to an attempt to scan an
invalid range of log blocks. This results in log recovery failure
and a failed mount.

Since there may be filesystems out in the wild with this kind of
geometry, we cannot simply refuse to mount. Instead, cap the scan
window for cycle verification to the size of the physical log. This
ensures that the cycle verification proceeds as expected when the
scan wraps the end of the log.

Reported-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/xfs/xfs_log_recover.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 4aefff89949d..c0065697498c 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -738,7 +738,7 @@ xlog_find_head(
 	 * in the in-core log.  The following number can be made tighter if
 	 * we actually look at the block size of the filesystem.
 	 */
-	num_scan_bblks = XLOG_TOTAL_REC_SHIFT(log);
+	num_scan_bblks = min_t(int, log_bbnum, XLOG_TOTAL_REC_SHIFT(log));
 	if (head_blk >= num_scan_bblks) {
 		/*
 		 * We are guaranteed that the entire check can be performed
-- 
2.11.0

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

* [added to the 4.1 stable tree] PCI: Detach driver before procfs & sysfs teardown on device remove
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (272 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] xfs: fix log block underflow during recovery cycle verification Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] powerpc/perf/hv-24x7: Fix incorrect comparison in memord Sasha Levin
                   ` (21 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Alex Williamson, Bjorn Helgaas, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 16b6c8bb687cc3bec914de09061fcb8411951fda ]

When removing a device, for example a VF being removed due to SR-IOV
teardown, a "soft" hot-unplug via 'echo 1 > remove' in sysfs, or an actual
hot-unplug, we first remove the procfs and sysfs attributes for the device
before attempting to release the device from any driver bound to it.
Unbinding the driver from the device can take time.  The device might need
to write out data or it might be actively in use.  If it's in use by
userspace through a vfio driver, the unbind might block until the user
releases the device.  This leads to a potentially non-trivial amount of
time where the device exists, but we've torn down the interfaces that
userspace uses to examine devices, for instance lspci might generate this
sort of error:

  pcilib: Cannot open /sys/bus/pci/devices/0000:01:0a.3/config
  lspci: Unable to read the standard configuration space header of device 0000:01:0a.3

We don't seem to have any dependence on this teardown ordering in the
kernel, so let's unbind the driver first, which is also more symmetric with
the instantiation of the device in pci_bus_add_device().

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/pci/remove.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 8a280e9c2ad1..7e67af2bb366 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -20,9 +20,9 @@ static void pci_stop_dev(struct pci_dev *dev)
 	pci_pme_active(dev, false);
 
 	if (dev->is_added) {
+		device_release_driver(&dev->dev);
 		pci_proc_detach_device(dev);
 		pci_remove_sysfs_dev_files(dev);
-		device_release_driver(&dev->dev);
 		dev->is_added = 0;
 	}
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] powerpc/perf/hv-24x7: Fix incorrect comparison in memord
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (273 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] PCI: Detach driver before procfs & sysfs teardown on device remove Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] tty fix oops when rmmod 8250 Sasha Levin
                   ` (20 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Michael Ellerman, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 05c14c03138532a3cb2aa29c2960445c8753343b ]

In the hv-24x7 code there is a function memord() which tries to
implement a sort function return -1, 0, 1. However one of the
conditions is incorrect, such that it can never be true, because we
will have already returned.

I don't believe there is a bug in practice though, because the
comparisons are an optimisation prior to calling memcmp().

Fix it by swapping the second comparision, so it can be true.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/powerpc/perf/hv-24x7.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index ec2eb20631d1..14ac699d30aa 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -503,7 +503,7 @@ static int memord(const void *d1, size_t s1, const void *d2, size_t s2)
 {
 	if (s1 < s2)
 		return 1;
-	if (s2 > s1)
+	if (s1 > s2)
 		return -1;
 
 	return memcmp(d1, d2, s1);
-- 
2.11.0

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

* [added to the 4.1 stable tree] usb: musb: da8xx: fix babble condition handling
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (275 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] tty fix oops when rmmod 8250 Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] pinctrl: adi2: Fix Kconfig build problem Sasha Levin
                   ` (18 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Bin Liu, Greg Kroah-Hartman, Sasha Levin

From: Bin Liu <b-liu@ti.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit bd3486ded7a0c313a6575343e6c2b21d14476645 ]

When babble condition happens, the musb controller might automatically
turns off VBUS. On DA8xx platform, the controller generates drvvbus
interrupt for turning off VBUS along with the babble interrupt.

In this case, we should handle the babble interrupt first and recover
from the babble condition.

This change ignores the drvvbus interrupt if babble interrupt is also
generated at the same time, so the babble recovery routine works
properly.

Cc: stable@vger.kernel.org # v3.16+
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/musb/da8xx.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 9a9c82a4d35d..d6a8e325950c 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -350,7 +350,15 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
 			musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
 			portstate(musb->port1_status |= USB_PORT_STAT_POWER);
 			del_timer(&otg_workaround);
-		} else {
+		} else if (!(musb->int_usb & MUSB_INTR_BABBLE)){
+			/*
+			 * When babble condition happens, drvvbus interrupt
+			 * is also generated. Ignore this drvvbus interrupt
+			 * and let babble interrupt handler recovers the
+			 * controller; otherwise, the host-mode flag is lost
+			 * due to the MUSB_DEV_MODE() call below and babble
+			 * recovery logic will not called.
+			 */
 			musb->is_active = 0;
 			MUSB_DEV_MODE(musb);
 			otg->default_a = 0;
-- 
2.11.0

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

* [added to the 4.1 stable tree] tty fix oops when rmmod 8250
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (274 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] powerpc/perf/hv-24x7: Fix incorrect comparison in memord Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] usb: musb: da8xx: fix babble condition handling Sasha Levin
                   ` (19 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: nixiaoming, Greg Kroah-Hartman, Sasha Levin

From: nixiaoming <nixiaoming@huawei.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit c79dde629d2027ca80329c62854a7635e623d527 ]

After rmmod 8250.ko
tty_kref_put starts kwork (release_one_tty) to release proc interface
oops when accessing driver->driver_name in proc_tty_unregister_driver

Use jprobe, found driver->driver_name point to 8250.ko
static static struct uart_driver serial8250_reg
.driver_name= serial,

Use name in proc_dir_entry instead of driver->driver_name to fix oops

test on linux 4.1.12:

BUG: unable to handle kernel paging request at ffffffffa01979de
IP: [<ffffffff81310f40>] strchr+0x0/0x30
PGD 1a0d067 PUD 1a0e063 PMD 851c1f067 PTE 0
Oops: 0000 [#1] PREEMPT SMP
Modules linked in: ... ...  [last unloaded: 8250]
CPU: 7 PID: 116 Comm: kworker/7:1 Tainted: G           O    4.1.12 #1
Hardware name: Insyde RiverForest/Type2 - Board Product Name1, BIOS NE5KV904 12/21/2015
Workqueue: events release_one_tty
task: ffff88085b684960 ti: ffff880852884000 task.ti: ffff880852884000
RIP: 0010:[<ffffffff81310f40>]  [<ffffffff81310f40>] strchr+0x0/0x30
RSP: 0018:ffff880852887c90  EFLAGS: 00010282
RAX: ffffffff81a5eca0 RBX: ffffffffa01979de RCX: 0000000000000004
RDX: ffff880852887d10 RSI: 000000000000002f RDI: ffffffffa01979de
RBP: ffff880852887cd8 R08: 0000000000000000 R09: ffff88085f5d94d0
R10: 0000000000000195 R11: 0000000000000000 R12: ffffffffa01979de
R13: ffff880852887d00 R14: ffffffffa01979de R15: ffff88085f02e840
FS:  0000000000000000(0000) GS:ffff88085f5c0000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffa01979de CR3: 0000000001a0c000 CR4: 00000000001406e0
Stack:
 ffffffff812349b1 ffff880852887cb8 ffff880852887d10 ffff88085f5cd6c2
 ffff880852800a80 ffffffffa01979de ffff880852800a84 0000000000000010
 ffff88085bb28bd8 ffff880852887d38 ffffffff812354f0 ffff880852887d08
Call Trace:
 [<ffffffff812349b1>] ? __xlate_proc_name+0x71/0xd0
 [<ffffffff812354f0>] remove_proc_entry+0x40/0x180
 [<ffffffff815f6811>] ? _raw_spin_lock_irqsave+0x41/0x60
 [<ffffffff813be520>] ? destruct_tty_driver+0x60/0xe0
 [<ffffffff81237c68>] proc_tty_unregister_driver+0x28/0x40
 [<ffffffff813be548>] destruct_tty_driver+0x88/0xe0
 [<ffffffff813be5bd>] tty_driver_kref_put+0x1d/0x20
 [<ffffffff813becca>] release_one_tty+0x5a/0xd0
 [<ffffffff81074159>] process_one_work+0x139/0x420
 [<ffffffff810745a1>] worker_thread+0x121/0x450
 [<ffffffff81074480>] ? process_scheduled_works+0x40/0x40
 [<ffffffff8107a16c>] kthread+0xec/0x110
 [<ffffffff81080000>] ? tg_rt_schedulable+0x210/0x220
 [<ffffffff8107a080>] ? kthread_freezable_should_stop+0x80/0x80
 [<ffffffff815f7292>] ret_from_fork+0x42/0x70
 [<ffffffff8107a080>] ? kthread_freezable_should_stop+0x80/0x80

Signed-off-by: nixiaoming <nixiaoming@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/proc/proc_tty.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/proc/proc_tty.c b/fs/proc/proc_tty.c
index 15f327bed8c6..7340c36978a3 100644
--- a/fs/proc/proc_tty.c
+++ b/fs/proc/proc_tty.c
@@ -14,6 +14,7 @@
 #include <linux/tty.h>
 #include <linux/seq_file.h>
 #include <linux/bitops.h>
+#include "internal.h"
 
 /*
  * The /proc/tty directory inodes...
@@ -164,7 +165,7 @@ void proc_tty_unregister_driver(struct tty_driver *driver)
 	if (!ent)
 		return;
 		
-	remove_proc_entry(driver->driver_name, proc_tty_driver);
+	remove_proc_entry(ent->name, proc_tty_driver);
 	
 	driver->proc_entry = NULL;
 }
-- 
2.11.0

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

* [added to the 4.1 stable tree] raid5: Set R5_Expanded on parity devices as well as data.
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (277 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] pinctrl: adi2: Fix Kconfig build problem Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] scsi: scsi_devinfo: Add REPORTLUN2 to EMC SYMMETRIX blacklist entry Sasha Levin
                   ` (16 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: NeilBrown, Shaohua Li, Sasha Levin

From: NeilBrown <neilb@suse.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 235b6003fb28f0dd8e7ed8fbdb088bb548291766 ]

When reshaping a fully degraded raid5/raid6 to a larger
nubmer of devices, the new device(s) are not in-sync
and so that can make the newly grown stripe appear to be
"failed".
To avoid this, we set the R5_Expanded flag to say "Even though
this device is not fully in-sync, this block is safe so
don't treat the device as failed for this stripe".
This flag is set for data devices, not not for parity devices.

Consequently, if you have a RAID6 with two devices that are partly
recovered and a spare, and start a reshape to include the spare,
then when the reshape gets past the point where the recovery was
up to, it will think the stripes are failed and will get into
an infinite loop, failing to make progress.

So when contructing parity on an EXPAND_READY stripe,
set R5_Expanded.

Reported-by: Curt <lightspd@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/md/raid5.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 02e6d335f178..907aa9c6e894 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1679,8 +1679,11 @@ static void ops_complete_reconstruct(void *stripe_head_ref)
 		struct r5dev *dev = &sh->dev[i];
 
 		if (dev->written || i == pd_idx || i == qd_idx) {
-			if (!discard && !test_bit(R5_SkipCopy, &dev->flags))
+			if (!discard && !test_bit(R5_SkipCopy, &dev->flags)) {
 				set_bit(R5_UPTODATE, &dev->flags);
+				if (test_bit(STRIPE_EXPAND_READY, &sh->state))
+					set_bit(R5_Expanded, &dev->flags);
+			}
 			if (fua)
 				set_bit(R5_WantFUA, &dev->flags);
 			if (sync)
-- 
2.11.0

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

* [added to the 4.1 stable tree] pinctrl: adi2: Fix Kconfig build problem
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (276 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] usb: musb: da8xx: fix babble condition handling Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] raid5: Set R5_Expanded on parity devices as well as data Sasha Levin
                   ` (17 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Linus Walleij, Sasha Levin

From: Linus Walleij <linus.walleij@linaro.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 1c363531dd814dc4fe10865722bf6b0f72ce4673 ]

The build robot is complaining on Blackfin:

drivers/pinctrl/pinctrl-adi2.c: In function 'port_setup':
>> drivers/pinctrl/pinctrl-adi2.c:221:21: error: dereferencing
   pointer to incomplete type 'struct gpio_port_t'
      writew(readw(&regs->port_fer) & ~BIT(offset),
                        ^~
drivers/pinctrl/pinctrl-adi2.c: In function 'adi_gpio_ack_irq':
>> drivers/pinctrl/pinctrl-adi2.c:266:18: error: dereferencing
pointer to incomplete type 'struct bfin_pint_regs'
      if (readl(&regs->invert_set) & pintbit)
                     ^~
It seems the driver need to include <asm/gpio.h> and <asm/irq.h>
to compile.

The Blackfin architecture was re-defining the Kconfig
PINCTRL symbol which is not OK, so replaced this with
PINCTRL_BLACKFIN_ADI2 which selects PINCTRL and PINCTRL_ADI2
just like most arches do.

Further, the old GPIO driver symbol GPIO_ADI was possible to
select at the same time as selecting PINCTRL. This was not
working because the arch-local <asm/gpio.h> header contains
an explicit #ifndef PINCTRL clause making compilation break
if you combine them. The same is true for DEBUG_MMRS.

Make sure the ADI2 pinctrl driver is not selected at the same
time as the old GPIO implementation. (This should be converted
to use gpiolib or pincontrol and move to drivers/...) Also make
sure the old GPIO_ADI driver or DEBUG_MMRS is not selected at
the same time as the new PINCTRL implementation, and only make
PINCTRL_ADI2 selectable for the Blackfin families that actually
have it.

This way it is still possible to add e.g. I2C-based pin
control expanders on the Blackfin.

Cc: Steven Miao <realmz6@gmail.com>
Cc: Huanhuan Feng <huanhuan.feng@analog.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/blackfin/Kconfig       | 7 +++++--
 arch/blackfin/Kconfig.debug | 1 +
 drivers/pinctrl/Kconfig     | 3 ++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index af76634f8d98..934573cc1134 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -318,11 +318,14 @@ config BF53x
 
 config GPIO_ADI
 	def_bool y
+	depends on !PINCTRL
 	depends on (BF51x || BF52x || BF53x || BF538 || BF539 || BF561)
 
-config PINCTRL
+config PINCTRL_BLACKFIN_ADI2
 	def_bool y
-	depends on BF54x || BF60x
+	depends on (BF54x || BF60x)
+	select PINCTRL
+	select PINCTRL_ADI2
 
 config MEM_MT48LC64M4A2FB_7E
 	bool
diff --git a/arch/blackfin/Kconfig.debug b/arch/blackfin/Kconfig.debug
index f3337ee03621..a93cf06a4d6f 100644
--- a/arch/blackfin/Kconfig.debug
+++ b/arch/blackfin/Kconfig.debug
@@ -17,6 +17,7 @@ config DEBUG_VERBOSE
 
 config DEBUG_MMRS
 	tristate "Generate Blackfin MMR tree"
+	depends on !PINCTRL
 	select DEBUG_FS
 	help
 	  Create a tree of Blackfin MMRs via the debugfs tree.  If
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index aeb5729fbda6..029ff74ec53c 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -28,7 +28,8 @@ config DEBUG_PINCTRL
 
 config PINCTRL_ADI2
 	bool "ADI pin controller driver"
-	depends on BLACKFIN
+	depends on (BF54x || BF60x)
+	depends on !GPIO_ADI
 	select PINMUX
 	select IRQ_DOMAIN
 	help
-- 
2.11.0

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

* [added to the 4.1 stable tree] scsi: scsi_devinfo: Add REPORTLUN2 to EMC SYMMETRIX blacklist entry
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (278 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] raid5: Set R5_Expanded on parity devices as well as data Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] scsi: bfa: integer overflow in debugfs Sasha Levin
                   ` (15 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Kurt Garloff, Hannes Reinecke, Martin K . Petersen, Sasha Levin

From: Kurt Garloff <garloff@suse.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 909cf3e16a5274fe2127cf3cea5c8dba77b2c412 ]

All EMC SYMMETRIX support REPORT_LUNS, even if configured to report
SCSI-2 for whatever reason.

Signed-off-by: Kurt Garloff <garloff@suse.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/scsi/scsi_devinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 42d3f82e75c7..55df57341858 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -160,7 +160,7 @@ static struct {
 	{"DGC", "RAID", NULL, BLIST_SPARSELUN},	/* Dell PV 650F, storage on LUN 0 */
 	{"DGC", "DISK", NULL, BLIST_SPARSELUN},	/* Dell PV 650F, no storage on LUN 0 */
 	{"EMC",  "Invista", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
-	{"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_FORCELUN},
+	{"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_REPORTLUN2},
 	{"EMULEX", "MD21/S2     ESDI", NULL, BLIST_SINGLELUN},
 	{"easyRAID", "16P", NULL, BLIST_NOREPORTLUN},
 	{"easyRAID", "X6P", NULL, BLIST_NOREPORTLUN},
-- 
2.11.0

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

* [added to the 4.1 stable tree] scsi: bfa: integer overflow in debugfs
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (279 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] scsi: scsi_devinfo: Add REPORTLUN2 to EMC SYMMETRIX blacklist entry Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] vt6655: Fix a possible sleep-in-atomic bug in vt6655_suspend Sasha Levin
                   ` (14 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Dan Carpenter, Martin K . Petersen, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 3e351275655d3c84dc28abf170def9786db5176d ]

We could allocate less memory than intended because we do:

	bfad->regdata = kzalloc(len << 2, GFP_KERNEL);

The shift can overflow leading to a crash.  This is debugfs code so the
impact is very small.  I fixed the network version of this in March with
commit 13e2d5187f6b ("bna: integer overflow bug in debugfs").

Fixes: ab2a9ba189e8 ("[SCSI] bfa: add debugfs support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/scsi/bfa/bfad_debugfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c
index 74a307c0a240..8f1c58d4d5b5 100644
--- a/drivers/scsi/bfa/bfad_debugfs.c
+++ b/drivers/scsi/bfa/bfad_debugfs.c
@@ -254,7 +254,8 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
 	struct bfad_s *bfad = port->bfad;
 	struct bfa_s *bfa = &bfad->bfa;
 	struct bfa_ioc_s *ioc = &bfa->ioc;
-	int addr, len, rc, i;
+	int addr, rc, i;
+	u32 len;
 	u32 *regbuf;
 	void __iomem *rb, *reg_addr;
 	unsigned long flags;
@@ -265,7 +266,7 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
 		return PTR_ERR(kern_buf);
 
 	rc = sscanf(kern_buf, "%x:%x", &addr, &len);
-	if (rc < 2) {
+	if (rc < 2 || len > (UINT_MAX >> 2)) {
 		printk(KERN_INFO
 			"bfad[%d]: %s failed to read user buf\n",
 			bfad->inst_no, __func__);
-- 
2.11.0

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

* [added to the 4.1 stable tree] vt6655: Fix a possible sleep-in-atomic bug in vt6655_suspend
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (280 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] scsi: bfa: integer overflow in debugfs Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] udf: Avoid overflow when session starts at large offset Sasha Levin
                   ` (13 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jia-Ju Bai, Greg Kroah-Hartman, Sasha Levin

From: Jia-Ju Bai <baijiaju1990@163.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 42c8eb3f6e15367981b274cb79ee4657e2c6949d ]

The driver may sleep under a spinlock, and the function call path is:
vt6655_suspend (acquire the spinlock)
  pci_set_power_state
    __pci_start_power_transition (drivers/pci/pci.c)
      msleep --> may sleep

To fix it, pci_set_power_state is called without having a spinlock.

This bug is found by my static analysis tool and my code review.

Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/staging/vt6655/device_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 376e4a0c15c6..8f1844f0547e 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -1838,10 +1838,11 @@ static int vt6655_suspend(struct pci_dev *pcid, pm_message_t state)
 	MACbShutdown(priv->PortOffset);
 
 	pci_disable_device(pcid);
-	pci_set_power_state(pcid, pci_choose_state(pcid, state));
 
 	spin_unlock_irqrestore(&priv->lock, flags);
 
+	pci_set_power_state(pcid, pci_choose_state(pcid, state));
+
 	return 0;
 }
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] macvlan: Only deliver one copy of the frame to the macvlan interface
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (282 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] udf: Avoid overflow when session starts at large offset Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] ath9k: fix tx99 potential info leak Sasha Levin
                   ` (11 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Alexander Duyck, David S . Miller, Sasha Levin

From: Alexander Duyck <alexander.h.duyck@intel.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit dd6b9c2c332b40f142740d1b11fb77c653ff98ea ]

This patch intoduces a slight adjustment for macvlan to address the fact
that in source mode I was seeing two copies of any packet addressed to the
macvlan interface being delivered where there should have been only one.

The issue appears to be that one copy was delivered based on the source MAC
address and then the second copy was being delivered based on the
destination MAC address. To fix it I am just treating a unicast address
match as though it is not a match since source based macvlan isn't supposed
to be matching based on the destination MAC anyway.

Fixes: 79cf79abce71 ("macvlan: add source mode")
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/macvlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 9f59f17dc317..e10cff854b24 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -440,7 +440,7 @@ static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb)
 					      struct macvlan_dev, list);
 	else
 		vlan = macvlan_hash_lookup(port, eth->h_dest);
-	if (vlan == NULL)
+	if (!vlan || vlan->mode == MACVLAN_MODE_SOURCE)
 		return RX_HANDLER_PASS;
 
 	dev = vlan->dev;
-- 
2.11.0

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

* [added to the 4.1 stable tree] udf: Avoid overflow when session starts at large offset
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (281 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] vt6655: Fix a possible sleep-in-atomic bug in vt6655_suspend Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] macvlan: Only deliver one copy of the frame to the macvlan interface Sasha Levin
                   ` (12 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jan Kara, Sasha Levin

From: Jan Kara <jack@suse.cz>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit abdc0eb06964fe1d2fea6dd1391b734d0590365d ]

When session starts beyond offset 2^31 the arithmetics in
udf_check_vsd() would overflow. Make sure the computation is done in
large enough type.

Reported-by: Cezary Sliwa <sliwa@ifpan.edu.pl>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 fs/udf/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 6299f341967b..97bbcea2978a 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -705,7 +705,7 @@ static loff_t udf_check_vsd(struct super_block *sb)
 	else
 		sectorsize = sb->s_blocksize;
 
-	sector += (sbi->s_session << sb->s_blocksize_bits);
+	sector += (((loff_t)sbi->s_session) << sb->s_blocksize_bits);
 
 	udf_debug("Starting at sector %u (%ld byte sectors)\n",
 		  (unsigned int)(sector >> sb->s_blocksize_bits),
-- 
2.11.0

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

* [added to the 4.1 stable tree] IB/ipoib: Grab rtnl lock on heavy flush when calling ndo_open/stop
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (284 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] ath9k: fix tx99 potential info leak Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: tulip: turn compile-time warning into dev_warn() Sasha Levin
                   ` (9 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Alex Vesker, Sasha Levin

From: Alex Vesker <valex@mellanox.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit b4b678b06f6eef18bff44a338c01870234db0bc9 ]

When ndo_open and ndo_stop are called RTNL lock should be held.
In this specific case ipoib_ib_dev_open calls the offloaded ndo_open
which re-sets the number of TX queue assuming RTNL lock is held.
Since RTNL lock is not held, RTNL assert will fail.

Signed-off-by: Alex Vesker <valex@mellanox.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/infiniband/ulp/ipoib/ipoib_ib.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 63b92cbb29ad..545c7ef480e8 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -1052,10 +1052,15 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv,
 		ipoib_ib_dev_down(dev);
 
 	if (level == IPOIB_FLUSH_HEAVY) {
+		rtnl_lock();
 		if (test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags))
 			ipoib_ib_dev_stop(dev);
-		if (ipoib_ib_dev_open(dev) != 0)
+
+		result = ipoib_ib_dev_open(dev);
+		rtnl_unlock();
+		if (result)
 			return;
+
 		if (netif_queue_stopped(dev))
 			netif_start_queue(dev);
 	}
-- 
2.11.0

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

* [added to the 4.1 stable tree] ath9k: fix tx99 potential info leak
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (283 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] macvlan: Only deliver one copy of the frame to the macvlan interface Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:01 ` [added to the 4.1 stable tree] IB/ipoib: Grab rtnl lock on heavy flush when calling ndo_open/stop Sasha Levin
                   ` (10 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Miaoqing Pan, Kalle Valo, Sasha Levin

From: Miaoqing Pan <miaoqing@codeaurora.org>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit ee0a47186e2fa9aa1c56cadcea470ca0ba8c8692 ]

When the user sets count to zero the string buffer would remain
completely uninitialized which causes the kernel to parse its
own stack data, potentially leading to an info leak. In addition
to that, the string might be not terminated properly when the
user data does not contain a 0-terminator.

Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
Reviewed-by: Christoph Böhmwalder <christoph@boehmwalder.at>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/wireless/ath/ath9k/tx99.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/tx99.c b/drivers/net/wireless/ath/ath9k/tx99.c
index b4e6304afd40..7ee1a3183a06 100644
--- a/drivers/net/wireless/ath/ath9k/tx99.c
+++ b/drivers/net/wireless/ath/ath9k/tx99.c
@@ -180,6 +180,9 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
 	ssize_t len;
 	int r;
 
+	if (count < 1)
+		return -EINVAL;
+
 	if (sc->cur_chan->nvifs > 1)
 		return -EOPNOTSUPP;
 
@@ -187,6 +190,8 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
 	if (copy_from_user(buf, user_buf, len))
 		return -EFAULT;
 
+	buf[len] = '\0';
+
 	if (strtobool(buf, &start))
 		return -EINVAL;
 
-- 
2.11.0

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

* [added to the 4.1 stable tree] net: tulip: turn compile-time warning into dev_warn()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (285 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] IB/ipoib: Grab rtnl lock on heavy flush when calling ndo_open/stop Sasha Levin
@ 2018-01-18 21:01 ` Sasha Levin
  2018-01-18 21:02 ` [added to the 4.1 stable tree] gcov: add support for gcc version >= 6 Sasha Levin
                   ` (8 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:01 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Arnd Bergmann, David S . Miller, Sasha Levin

From: Arnd Bergmann <arnd@arndb.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit de92718883ddbcd11b738d36ffcf57617b97fa12 ]

The tulip driver causes annoying build-time warnings for allmodconfig
builds for all recent architectures:

dec/tulip/winbond-840.c:910:2: warning: #warning Processor architecture undefined
dec/tulip/tulip_core.c:101:2: warning: #warning Processor architecture undefined!

This is the last remaining warning for arm64, and I'd like to get rid of
it. We don't really know the cache line size, architecturally it would
be at least 16 bytes, but all implementations I found have 64 or 128
bytes. Configuring tulip for 32-byte lines as we do on ARM32 seems to
be the safe but slow default, and nobody who cares about performance these
days would use a tulip chip anyway, so we can just use that.

To save the next person the job of trying to find out what this is for
and picking a default for their architecture just to kill off the warning,
I'm now removing the preprocessor #warning and turning it into a pr_warn
or dev_warn that prints the equivalent information when the driver gets
loaded.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Grant Grundler <grundler@parisc-linux.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/ethernet/dec/tulip/tulip_core.c  | 9 +++++++--
 drivers/net/ethernet/dec/tulip/winbond-840.c | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/dec/tulip/tulip_core.c b/drivers/net/ethernet/dec/tulip/tulip_core.c
index ed41559bae77..b553409e04ad 100644
--- a/drivers/net/ethernet/dec/tulip/tulip_core.c
+++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
@@ -98,8 +98,7 @@ static int csr0 = 0x01A00000 | 0x4800;
 #elif defined(__mips__)
 static int csr0 = 0x00200000 | 0x4000;
 #else
-#warning Processor architecture undefined!
-static int csr0 = 0x00A00000 | 0x4800;
+static int csr0;
 #endif
 
 /* Operational parameters that usually are not changed. */
@@ -1982,6 +1981,12 @@ static int __init tulip_init (void)
 	pr_info("%s", version);
 #endif
 
+	if (!csr0) {
+		pr_warn("tulip: unknown CPU architecture, using default csr0\n");
+		/* default to 8 longword cache line alignment */
+		csr0 = 0x00A00000 | 0x4800;
+	}
+
 	/* copy module parms into globals */
 	tulip_rx_copybreak = rx_copybreak;
 	tulip_max_interrupt_work = max_interrupt_work;
diff --git a/drivers/net/ethernet/dec/tulip/winbond-840.c b/drivers/net/ethernet/dec/tulip/winbond-840.c
index 9beb3d34d4ba..3c0e4d5c5fef 100644
--- a/drivers/net/ethernet/dec/tulip/winbond-840.c
+++ b/drivers/net/ethernet/dec/tulip/winbond-840.c
@@ -907,7 +907,7 @@ static void init_registers(struct net_device *dev)
 #elif defined(CONFIG_SPARC) || defined (CONFIG_PARISC) || defined(CONFIG_ARM)
 	i |= 0x4800;
 #else
-#warning Processor architecture undefined
+	dev_warn(&dev->dev, "unknown CPU architecture, using default csr0 setting\n");
 	i |= 0x4800;
 #endif
 	iowrite32(i, ioaddr + PCIBusCfg);
-- 
2.11.0

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

* [added to the 4.1 stable tree] gcov: add support for GCC 5.1
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (287 preceding siblings ...)
  2018-01-18 21:02 ` [added to the 4.1 stable tree] gcov: add support for gcc version >= 6 Sasha Levin
@ 2018-01-18 21:02 ` Sasha Levin
  2018-01-18 21:02 ` [added to the 4.1 stable tree] irda: fix overly long udelay() Sasha Levin
                   ` (6 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:02 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Lorenzo Stoakes, Andrew Morton, Linus Torvalds, Sasha Levin

From: Lorenzo Stoakes <lstoakes@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 3e44c471a2dab210f7e9b1e5f7d4d54d52df59eb ]

Fix kernel gcov support for GCC 5.1.  Similar to commit a992bf836f9
("gcov: add support for GCC 4.9"), this patch takes into account the
existence of a new gcov counter (see gcc's gcc/gcov-counter.def.)

Firstly, it increments GCOV_COUNTERS (to 10), which makes the data
structure struct gcov_info compatible with GCC 5.1.

Secondly, a corresponding counter function __gcov_merge_icall_topn (Top N
value tracking for indirect calls) is included in base.c with the other
gcov counters unused for kernel profiling.

Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
Cc: Andrey Ryabinin <a.ryabinin@samsung.com>
Cc: Yuan Pengfei <coolypf@qq.com>
Tested-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 kernel/gcov/base.c    | 6 ++++++
 kernel/gcov/gcc_4_7.c | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
index a744098e4eb7..7080ae1eb6c1 100644
--- a/kernel/gcov/base.c
+++ b/kernel/gcov/base.c
@@ -92,6 +92,12 @@ void __gcov_merge_time_profile(gcov_type *counters, unsigned int n_counters)
 }
 EXPORT_SYMBOL(__gcov_merge_time_profile);
 
+void __gcov_merge_icall_topn(gcov_type *counters, unsigned int n_counters)
+{
+	/* Unused. */
+}
+EXPORT_SYMBOL(__gcov_merge_icall_topn);
+
 /**
  * gcov_enable_events - enable event reporting through gcov_event()
  *
diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c
index 826ba9fb5e32..e25e92fb44fa 100644
--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -18,7 +18,9 @@
 #include <linux/vmalloc.h>
 #include "gcov.h"
 
-#if __GNUC__ == 4 && __GNUC_MINOR__ >= 9
+#if __GNUC__ == 5 && __GNUC_MINOR__ >= 1
+#define GCOV_COUNTERS			10
+#elif __GNUC__ == 4 && __GNUC_MINOR__ >= 9
 #define GCOV_COUNTERS			9
 #else
 #define GCOV_COUNTERS			8
-- 
2.11.0

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

* [added to the 4.1 stable tree] gcov: add support for gcc version >= 6
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (286 preceding siblings ...)
  2018-01-18 21:01 ` [added to the 4.1 stable tree] net: tulip: turn compile-time warning into dev_warn() Sasha Levin
@ 2018-01-18 21:02 ` Sasha Levin
  2018-01-18 21:02 ` [added to the 4.1 stable tree] gcov: add support for GCC 5.1 Sasha Levin
                   ` (7 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:02 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Florian Meier, Andrew Morton, Linus Torvalds, Sasha Levin

From: Florian Meier <Florian.Meier@informatik.uni-erlangen.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit d02038f972538b93011d78c068f44514fbde0a8c ]

Link: http://lkml.kernel.org/r/20160701130914.GA23225@styxhp
Signed-off-by: Florian Meier <Florian.Meier@informatik.uni-erlangen.de>
Reviewed-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Tested-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 kernel/gcov/gcc_4_7.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c
index e25e92fb44fa..6a5c239c7669 100644
--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -18,7 +18,7 @@
 #include <linux/vmalloc.h>
 #include "gcov.h"
 
-#if __GNUC__ == 5 && __GNUC_MINOR__ >= 1
+#if (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
 #define GCOV_COUNTERS			10
 #elif __GNUC__ == 4 && __GNUC_MINOR__ >= 9
 #define GCOV_COUNTERS			9
-- 
2.11.0

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

* [added to the 4.1 stable tree] gcov: support GCC 7.1
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (289 preceding siblings ...)
  2018-01-18 21:02 ` [added to the 4.1 stable tree] irda: fix overly long udelay() Sasha Levin
@ 2018-01-18 21:02 ` Sasha Levin
  2018-01-18 21:02 ` [added to the 4.1 stable tree] ARM: ux500: fix prcmu_is_cpu_in_wfi() calculation Sasha Levin
                   ` (4 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:02 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Martin Liska, Andrew Morton, Linus Torvalds, Sasha Levin

From: Martin Liska <mliska@suse.cz>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 05384213436ab690c46d9dfec706b80ef8d671ab ]

Starting from GCC 7.1, __gcov_exit is a new symbol expected to be
implemented in a profiling runtime.

[akpm@linux-foundation.org: coding-style fixes]
[mliska@suse.cz: v2]
  Link: http://lkml.kernel.org/r/e63a3c59-0149-c97e-4084-20ca8f146b26@suse.cz
Link: http://lkml.kernel.org/r/8c4084fa-3885-29fe-5fc4-0d4ca199c785@suse.cz
Signed-off-by: Martin Liska <mliska@suse.cz>
Acked-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 kernel/gcov/base.c    | 6 ++++++
 kernel/gcov/gcc_4_7.c | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
index 7080ae1eb6c1..f850e906564b 100644
--- a/kernel/gcov/base.c
+++ b/kernel/gcov/base.c
@@ -98,6 +98,12 @@ void __gcov_merge_icall_topn(gcov_type *counters, unsigned int n_counters)
 }
 EXPORT_SYMBOL(__gcov_merge_icall_topn);
 
+void __gcov_exit(void)
+{
+	/* Unused. */
+}
+EXPORT_SYMBOL(__gcov_exit);
+
 /**
  * gcov_enable_events - enable event reporting through gcov_event()
  *
diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c
index 6a5c239c7669..46a18e72bce6 100644
--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -18,7 +18,9 @@
 #include <linux/vmalloc.h>
 #include "gcov.h"
 
-#if (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
+#if (__GNUC__ >= 7)
+#define GCOV_COUNTERS			9
+#elif (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
 #define GCOV_COUNTERS			10
 #elif __GNUC__ == 4 && __GNUC_MINOR__ >= 9
 #define GCOV_COUNTERS			9
-- 
2.11.0

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

* [added to the 4.1 stable tree] irda: fix overly long udelay()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (288 preceding siblings ...)
  2018-01-18 21:02 ` [added to the 4.1 stable tree] gcov: add support for GCC 5.1 Sasha Levin
@ 2018-01-18 21:02 ` Sasha Levin
  2018-01-18 21:02 ` [added to the 4.1 stable tree] gcov: support GCC 7.1 Sasha Levin
                   ` (5 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:02 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Arnd Bergmann, David S . Miller, Sasha Levin

From: Arnd Bergmann <arnd@arndb.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit c9bd28233b6d0d82ac3ba0215723be0a8262c39c ]

irda_get_mtt() returns a hardcoded '10000' in some cases,
and with gcc-7, we get a build error because this triggers a
compile-time check in udelay():

drivers/net/irda/w83977af_ir.o: In function `w83977af_hard_xmit':
w83977af_ir.c:(.text.w83977af_hard_xmit+0x14c): undefined reference to `__bad_udelay'

Older compilers did not run into this because they either did not
completely inline the irda_get_mtt() or did not consider the
10000 value a constant expression.

The code has been wrong since the start of git history.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/net/irda/w83977af_ir.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c
index 4e3d2e7c697c..e8c3a8c32534 100644
--- a/drivers/net/irda/w83977af_ir.c
+++ b/drivers/net/irda/w83977af_ir.c
@@ -518,7 +518,9 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
 		
 		mtt = irda_get_mtt(skb);
 		pr_debug("%s(%ld), mtt=%d\n", __func__ , jiffies, mtt);
-			if (mtt)
+			if (mtt > 1000)
+				mdelay(mtt/1000);
+			else if (mtt)
 				udelay(mtt);
 
 			/* Enable DMA interrupt */
-- 
2.11.0

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

* [added to the 4.1 stable tree] disable new gcc-7.1.1 warnings for now
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (291 preceding siblings ...)
  2018-01-18 21:02 ` [added to the 4.1 stable tree] ARM: ux500: fix prcmu_is_cpu_in_wfi() calculation Sasha Levin
@ 2018-01-18 21:02 ` Sasha Levin
  2018-01-18 21:02 ` [added to the 4.1 stable tree] gpio: 74xx: Fix build warning about void to integer cast Sasha Levin
                   ` (2 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:02 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Linus Torvalds, Sasha Levin

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

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit bd664f6b3e376a8ef4990f87d08271cc2d01ba9a ]

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

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

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

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

So warnings disabled for now.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 Makefile | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Makefile b/Makefile
index 97edf556bfe4..0db9ee6c9fee 100644
--- a/Makefile
+++ b/Makefile
@@ -612,6 +612,10 @@ include arch/$(SRCARCH)/Makefile
 KBUILD_CFLAGS	+= $(call cc-option,-fno-delete-null-pointer-checks,)
 KBUILD_CFLAGS	+= $(call cc-option,-fno-PIE)
 KBUILD_AFLAGS	+= $(call cc-option,-fno-PIE)
+KBUILD_CFLAGS	+= $(call cc-disable-warning,frame-address,)
+KBUILD_CFLAGS	+= $(call cc-disable-warning, format-truncation)
+KBUILD_CFLAGS	+= $(call cc-disable-warning, format-overflow)
+KBUILD_CFLAGS	+= $(call cc-disable-warning, int-in-bool-context)
 
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS	+= -Os $(call cc-disable-warning,maybe-uninitialized,)
-- 
2.11.0

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

* [added to the 4.1 stable tree] ARM: ux500: fix prcmu_is_cpu_in_wfi() calculation
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (290 preceding siblings ...)
  2018-01-18 21:02 ` [added to the 4.1 stable tree] gcov: support GCC 7.1 Sasha Levin
@ 2018-01-18 21:02 ` Sasha Levin
  2018-01-18 21:02 ` [added to the 4.1 stable tree] disable new gcc-7.1.1 warnings for now Sasha Levin
                   ` (3 subsequent siblings)
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:02 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Arnd Bergmann, Linus Walleij, Sasha Levin

From: Arnd Bergmann <arnd@arndb.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit f0e8faa7a5e894b0fc99d24be1b18685a92ea466 ]

This function clearly never worked and always returns true,
as pointed out by gcc-7:

arch/arm/mach-ux500/pm.c: In function 'prcmu_is_cpu_in_wfi':
arch/arm/mach-ux500/pm.c:137:212: error: ?:
using integer constants in boolean context, the expression
will always evaluate to 'true' [-Werror=int-in-bool-context]

With the added braces, the condition actually makes sense.

Fixes: 34fe6f107eab ("mfd : Check if the other db8500 core is in WFI")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/arm/mach-ux500/pm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-ux500/pm.c b/arch/arm/mach-ux500/pm.c
index 2cb587b50905..7ae4f94db1e8 100644
--- a/arch/arm/mach-ux500/pm.c
+++ b/arch/arm/mach-ux500/pm.c
@@ -132,8 +132,8 @@ bool prcmu_pending_irq(void)
  */
 bool prcmu_is_cpu_in_wfi(int cpu)
 {
-	return readl(PRCM_ARM_WFI_STANDBY) & cpu ? PRCM_ARM_WFI_STANDBY_WFI1 :
-		     PRCM_ARM_WFI_STANDBY_WFI0;
+	return readl(PRCM_ARM_WFI_STANDBY) &
+		(cpu ? PRCM_ARM_WFI_STANDBY_WFI1 : PRCM_ARM_WFI_STANDBY_WFI0);
 }
 
 /*
-- 
2.11.0

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

* [added to the 4.1 stable tree] ARM: 8584/1: floppy: avoid gcc-6 warning
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (293 preceding siblings ...)
  2018-01-18 21:02 ` [added to the 4.1 stable tree] gpio: 74xx: Fix build warning about void to integer cast Sasha Levin
@ 2018-01-18 21:02 ` Sasha Levin
  2018-01-18 21:02 ` [added to the 4.1 stable tree] bitops.h: add sign_extend64() Sasha Levin
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:02 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Arnd Bergmann, Russell King, Sasha Levin

From: Arnd Bergmann <arnd@arndb.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit dd665be0e243873343a28e18f9f345927b658daf ]

gcc-6.0 warns about comparisons between two identical expressions,
which is what we get in the floppy driver when writing to the FD_DOR
register:

drivers/block/floppy.c: In function 'set_dor':
drivers/block/floppy.c:810:44: error: self-comparison always evaluates to true [-Werror=tautological-compare]
   fd_outb(newdor, FD_DOR);

It would be nice to use a static inline function instead of the
macro, to avoid the warning, but we cannot do that because the
FD_DOR definition is incomplete at this point.

Adding a cast to (u32) is a harmless way to shut up the warning,
just not very nice.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 arch/arm/include/asm/floppy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/floppy.h b/arch/arm/include/asm/floppy.h
index f4882553fbb0..85a34cc8316a 100644
--- a/arch/arm/include/asm/floppy.h
+++ b/arch/arm/include/asm/floppy.h
@@ -17,7 +17,7 @@
 
 #define fd_outb(val,port)			\
 	do {					\
-		if ((port) == FD_DOR)		\
+		if ((port) == (u32)FD_DOR)	\
 			fd_setdor((val));	\
 		else				\
 			outb((val),(port));	\
-- 
2.11.0

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

* [added to the 4.1 stable tree] gpio: 74xx: Fix build warning about void to integer cast
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (292 preceding siblings ...)
  2018-01-18 21:02 ` [added to the 4.1 stable tree] disable new gcc-7.1.1 warnings for now Sasha Levin
@ 2018-01-18 21:02 ` Sasha Levin
  2018-01-18 21:02 ` [added to the 4.1 stable tree] ARM: 8584/1: floppy: avoid gcc-6 warning Sasha Levin
  2018-01-18 21:02 ` [added to the 4.1 stable tree] bitops.h: add sign_extend64() Sasha Levin
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:02 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Nicholas Krause, Linus Walleij, Sasha Levin

From: Nicholas Krause <xerofoify@gmail.com>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 54442658d8e83b0589731620bd958cc8b2857167 ]

This fixes the build warning , warning: cast from pointer to integer
of different size when building this file on a x86 allmodconfig
configuration. In order for me to fix this build warning I changed
the cast in the function mmio_74xx_gpio_probe from casting the
variable data of the stucture pointer of_id to uintptr_t rather
then unsigned when assigning to the variable flag of the structure
pointer priv of the structure type mmio_74xx_gpio_priv.

Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/gpio/gpio-74xx-mmio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
index 0763655cca6c..6ed7c0fb3378 100644
--- a/drivers/gpio/gpio-74xx-mmio.c
+++ b/drivers/gpio/gpio-74xx-mmio.c
@@ -129,7 +129,7 @@ static int mmio_74xx_gpio_probe(struct platform_device *pdev)
 	if (IS_ERR(dat))
 		return PTR_ERR(dat);
 
-	priv->flags = (unsigned)of_id->data;
+	priv->flags = (uintptr_t) of_id->data;
 
 	err = bgpio_init(&priv->bgc, &pdev->dev,
 			 DIV_ROUND_UP(MMIO_74XX_BIT_CNT(priv->flags), 8),
-- 
2.11.0

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

* [added to the 4.1 stable tree] bitops.h: add sign_extend64()
  2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
                   ` (294 preceding siblings ...)
  2018-01-18 21:02 ` [added to the 4.1 stable tree] ARM: 8584/1: floppy: avoid gcc-6 warning Sasha Levin
@ 2018-01-18 21:02 ` Sasha Levin
  295 siblings, 0 replies; 297+ messages in thread
From: Sasha Levin @ 2018-01-18 21:02 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Martin Kepplinger, Martin Kepplinger, Andrew Morton,
	Linus Torvalds, Sasha Levin

From: Martin Kepplinger <martink@posteo.de>

This patch has been added to the  stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 48e203e21b29cd4b2c58403fe8bca68e2e854895 ]

Months back, this was discussed, see https://lkml.org/lkml/2015/1/18/289
The result was the 64-bit version being "likely fine", "valuable" and
"correct".  The discussion fell asleep but since there are possible users,
let's add it.

Signed-off-by: Martin Kepplinger <martin.kepplinger@theobroma-systems.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: George Spelvin <linux@horizon.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Maxime Coquelin <maxime.coquelin@st.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 include/linux/bitops.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 297f5bda4fdf..858020682ac8 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -171,6 +171,17 @@ static inline __s32 sign_extend32(__u32 value, int index)
 	return (__s32)(value << shift) >> shift;
 }
 
+/**
+ * sign_extend64 - sign extend a 64-bit value using specified bit as sign-bit
+ * @value: value to sign extend
+ * @index: 0 based bit index (0<=index<64) to sign bit
+ */
+static inline __s64 sign_extend64(__u64 value, int index)
+{
+	__u8 shift = 63 - index;
+	return (__s64)(value << shift) >> shift;
+}
+
 static inline unsigned fls_long(unsigned long l)
 {
 	if (sizeof(l) == 4)
-- 
2.11.0

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

end of thread, other threads:[~2018-01-18 21:07 UTC | newest]

Thread overview: 297+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-18 20:59 [added to the 4.1 stable tree] scsi: don't BUG_ON() empty DMA transfers Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] bcache: Make gc wakeup sane, remove set_task_state() Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] rtc: interface: ignore expired timers when enqueuing new timers Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] net/llc: avoid BUG_ON() in skb_orphan() Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] packet: fix races in fanout_add() Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] irda: Fix lockdep annotations in hashbin_delete() Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] net: socket: fix recvmmsg not returning error from sock_error Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] [media] uvcvideo: Fix a wrong macro Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] ext4: preserve the needs_recovery flag when the journal is aborted Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] sd: get disk reference in sd_check_events() Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] iio: pressure: mpl3115: do not rely on structure field ordering Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] iio: pressure: mpl115: " Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] nfsd: special case truncates some more Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] nfsd: minor nfsd_setattr cleanup Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: IP22: Reformat inline assembler code to modern standards Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] scsi: lpfc: Correct WQ creation for pagesize Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] TTY: n_hdlc, fix lockdep false positive Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] KVM: VMX: use correct vmcs_read/write for guest segment selector/base Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] tty: n_hdlc: get rid of racy n_hdlc.tbuf Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] libceph: use BUG() instead of BUG_ON(1) Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] s390: use correct input data address for setup_randomness Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] s390: make setup_randomness work Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] crypto: improve gcc optimization flags for serpent and wp512 Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: ip22: Fix ip28 build for modern gcc Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: ip27: Disable qlge driver in defconfig Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: ralink: Cosmetic change to prom_init() Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: ralink: Remove unused rt*_wdt_reset functions Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] cpmac: remove hopeless #warning Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] MIPS: DEC: Avoid la pseudo-instruction in delay slots Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] mvsas: fix misleading indentation Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] dm: flush queued bios when process blocks to avoid deadlock Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] ext4: don't BUG when truncating encrypted inodes on the orphan list Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] vxlan: correctly validate VXLAN ID against VXLAN_N_VID Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] ipv4: mask tos for input route Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] vti6: return GRE_KEY for vti6 Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] net: don't call strlen() on the user buffer in packet_bind_spkt() Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] l2tp: avoid use-after-free caused by l2tp_ip_backlog_recv Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] dccp: Unlock sock before calling sk_free() Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] tcp: fix various issues for sockets morphing to listen state Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] net: fix socket refcounting in skb_complete_wifi_ack() Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] net: fix socket refcounting in skb_complete_tx_timestamp() Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] uapi: fix linux/packet_diag.h userspace compilation error Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] act_connmark: avoid crashing on malformed nlattrs with null parms Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] mpls: Send route delete notifications when router module is unloaded Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] ipv6: make ECMP route replacement less greedy Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] dccp/tcp: fix routing redirect race Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] dccp: fix memory leak during tear-down of unsuccessful connection request Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] net sched actions: decrement module reference count after table flush Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] crypto: ghash-clmulni - Fix load failure Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] crypto: cryptd - Assign statesize properly Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] crypto: mcryptd - Fix load failure Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] ACPI / video: skip evaluating _DOD when it does not exist Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] KVM: PPC: Book3S PR: Fix illegal opcode emulation Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] Drivers: hv: balloon: don't crash when memory is added in non-sorted order Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] s390/pci: fix use after free in dma_init Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] tpm_tis: Use devm_free_irq not free_irq Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] give up on gcc ilog2() constant optimizations Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] net: properly release sk_frag.page Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] net: bcmgenet: Do not suspend PHY if Wake-on-LAN is enabled Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] net: unix: properly re-increment inflight counter of GC discarded candidates Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] net/mlx5: Increase number of max QPs in default profile Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] ipv4: provide stronger user input validation in nl_fib_input() Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] iio: adc: ti_am335x_adc: fix fifo overrun recovery Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] tcp: initialize icsk_ack.lrcvtime at session start time Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] iio: hid-sensor-trigger: Change get poll value function order to avoid sensor properties losing after resume from S3 Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] libceph: don't set weight to IN when OSD is destroyed Sasha Levin
2018-01-18 20:59 ` [added to the 4.1 stable tree] raid10: increment write counter after bio is split Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] igb: Workaround for igb i210 firmware issue Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] xfs: clear _XBF_PAGES from buffers when readahead page Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] xfs: don't allow di_size with high bit set Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Separate VF BAR updates from standard BAR updates Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] igb: add i211 to i210 PHY workaround Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Add comments about ROM BAR updating Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Remove pci_resource_bar() and pci_iov_resource_bar() Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Decouple IORESOURCE_ROM_ENABLE and PCI_ROM_ADDRESS_ENABLE Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Don't update VF BARs while VF memory space is enabled Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Update BARs using property bits appropriate for type Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] block: allow WRITE_SAME commands with the SG_IO ioctl Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] PCI: Do any VF BAR updates before enabling the BARs Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] serial: 8250_pci: Detach low-level driver during PCI error recovery Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] [media] uvcvideo: uvc_scan_fallback() for webcams with broken chain Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] crypto: algif_hash - avoid zero-sized array Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] fbcon: Fix vc attr at deinit Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] xfrm_user: validate XFRM_MSG_NEWAE XFRMA_REPLAY_ESN_VAL replay_window Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] xfrm: policy: init locks early Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] c6x/ptrace: Remove useless PTRACE_SETREGSET implementation Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] mips/ptrace: Preserve previous registers for short regset write Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] sparc/ptrace: " Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] metag/ptrace: Reject partial NT_METAG_RPIPE writes Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] metag/ptrace: Preserve previous registers for short regset write Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] libceph: force GFP_NOIO for socket allocations Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] MIPS: Lantiq: Fix cascaded IRQ setup Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] KVM: x86: clear bus pointer when destroyed Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] rtc: s35390a: fix reading out alarm Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] rtc: s35390a: implement reset routine as suggested by the reference Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] rtc: s35390a: improve irq handling Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] KVM: kvm_io_bus_unregister_dev() should never fail Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] padata: avoid race in reordering Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] KEYS: fix dereferencing NULL payload with nonzero length Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] 8250_pci: Fix potential use-after-free in error path Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] arm64: hw_breakpoint: fix watchpoint matching for tagged pointers Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] net: phy: fix marvell phy status reading Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] ipv6: avoid unregistering inet6_dev for loopback Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] tcp: reset sk_rx_dst in tcp_disconnect() Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] bcache: do not subtract sectors_to_gc for bypassed IO Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] bcache: only permit to recovery read error when cache device is clean Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] bcache: recover data from backing when data " Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: quirks: Add no-lpm quirk for KY-688 USB 3.1 Type-C Hub Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] uas: Always apply US_FL_NO_ATA_1X quirk to Seagate devices Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] serial: 8250_pci: Add Amazon PCI serial device ID Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] s390/pci: do not require AIS facility Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] ima: fix hash algorithm initialization Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] spi: sh-msiof: Fix DMA transfer size check Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] serial: 8250_fintek: Fix rs485 disablement on invalid ioctl() Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] EDAC, sb_edac: Fix missing break in switch Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] sysrq : fix Show Regs call trace on ARM Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] perf test attr: Fix ignored test case result Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] net: systemport: Utilize skb_put_padto() Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] kprobes/x86: Disable preemption in ftrace-based jprobes Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] net: systemport: Pad packet before inserting TSB Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] ARM: OMAP1: DMA: Correct the number of logical channels Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] net/appletalk: Fix kernel memory disclosure Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] vti6: fix device register to report IFLA_INFO_KIND Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] nfs: Don't take a reference on fl->fl_file for LOCK operation Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] NFSv4: Fix client recovery when server reboots multiple times Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] net: sctp: fix array overrun read on sctp_timer_tbl Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] tipc: fix cleanup at module unload Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] tcp: correct memory barrier usage in tcp_check_space() Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] dmaengine: pl330: fix double lock Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] net: fec: fix multicast filtering hardware setup Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] mm: avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: hub: Cycle HUB power when initialization fails Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: xhci: fix panic in xhci_free_virt_devices_depth_first Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] USB: devio: Prevent integer overflow in proc_do_submiturb() Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] USB: Increase usbfs transfer limit Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] USB: usbfs: Filter flags passed in from user space Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: host: fix incorrect updating of offset Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] can: kvaser_usb: free buf in error paths Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] can: ti_hecc: Fix napi poll return value for repoll Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] can: kvaser_usb: Fix comparison bug in kvaser_usb_read_bulk_callback() Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] can: kvaser_usb: cancel urb on -EPIPE and -EPROTO Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] can: kvaser_usb: ratelimit errors if incomplete messages are received Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] can: ems_usb: cancel urb on -EPIPE and -EPROTO Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] can: esd_usb2: " Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] can: usb_8dev: " Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] virtio: release virtio index when fail to device_register Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] isa: Prevent NULL dereference in isa_bus driver callbacks Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] hv: kvp: Avoid reading past allocated blocks from KVP file Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] ASN.1: check for error from ASN1_OP_END__ACT actions Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] scsi: libsas: align sata_device's rps_resp on a cacheline Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] X.509: reject invalid BIT STRING for subjectPublicKey Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] x86/PCI: Make broadcom_postcore_init() check acpi_disabled Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] ALSA: seq: Remove spurious WARN_ON() at timer check Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] ALSA: pcm: prevent UAF in snd_pcm_info Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] ALSA: usb-audio: Fix out-of-bound error Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] ALSA: usb-audio: Add check return value for usb_string() Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] iommu/vt-d: Fix scatterlist offset handling Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] kdb: Fix handling of kallsyms_symbol_next() return value Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] drm: extra printk() wrapper macros Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] media: dvb: i2c transfers over usb cannot be done from stack Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] KVM: VMX: remove I/O port 0x80 bypass on Intel hosts Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] arm64: fpsimd: Prevent registers leaking from dead tasks Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] scsi: storvsc: Workaround for virtual DVD SCSI version Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] vti6: Don't report path MTU below IPV6_MIN_MTU Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] ARM: OMAP2+: gpmc-onenand: propagate error on initialization failure Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] module: set __jump_table alignment to 8 Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] selftest/powerpc: Fix false failures for skipped tests Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] libata: drop WARN from protocol error in ata_sff_qc_issue() Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] usb: gadget: configs: plug memory leak Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] USB: gadgetfs: Fix a potential memory leak in 'dev_config()' Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] scsi: lpfc: Fix crash during Hardware error recovery on SLI3 adapters Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] workqueue: trigger WARN if queue_delayed_work() is called with NULL @wq Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] KVM: nVMX: reset nested_run_pending if the vCPU is going to be reset Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] irqchip/crossbar: Fix incorrect type of register size Sasha Levin
2018-01-18 21:00 ` [added to the 4.1 stable tree] arm: KVM: Survive unknown traps from guests Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] spi_ks8995: fix "BUG: key accdaa28 not in .data!" Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] bnx2x: prevent crash when accessing PTP with interface down Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] bnx2x: fix possible overrun of VFPF multicast addresses array Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] ipv6: reorder icmpv6_init() and ip6_mr_init() Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] crypto: s5p-sss - Fix completing crypto request in IRQ handler Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] axonram: Fix gendisk handling Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] i2c: riic: fix restart condition Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] EDAC, i5000, i5400: Fix use of MTR_DRAM_WIDTH macro Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] EDAC, i5000, i5400: Fix definition of NRECMEMB register Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] route: also update fnhe_genid when updating a route cache Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] mac80211_hwsim: Fix memory leak in hwsim_new_radio_nl() Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] route: update fnhe_expires for redirect when the fnhe exists Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] lib/genalloc.c: make the avail variable an atomic_long_t Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] NFS: Fix a typo in nfs_rename() Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] dynamic-debug-howto: fix optional/omitted ending line number to be LARGE instead of 0 Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] sunrpc: Fix rpc_task_begin trace point Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] sctp: do not free asoc when it is already dead in sctp_sendmsg Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] sparc64/mm: set fields in deferred pages Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] atm: horizon: Fix irq release error Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] sctp: use the right sk after waking up from wait_buf sleep Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] IB/mlx4: Increase maximal message size under UD QP Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] xfrm: Copy policy family in clone_policy Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] IB/mlx5: Assign send CQ and recv CQ of UMR QP Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Connect up the CB.ProbeUuid Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] audit: ensure that 'audit=1' actually enables audit for PID 1 Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] sit: update frag_off info Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] rds: Fix NULL pointer dereference in __rds_rdma_map Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] net/packet: fix a race in packet_bind() and packet_notifier() Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] usb: gadget: ffs: Forbid usb_ep_alloc_request from sleeping Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] crypto: hmac - require that the underlying hash algorithm is unkeyed Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] crypto: salsa20 - fix blkcipher_walk API usage Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] autofs: fix careless error in recent commit Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] USB: uas and storage: Add US_FL_BROKEN_FUA for another JMicron JMS567 ID Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] tracing: Allocate mask_str buffer dynamically Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] usbip: fix stub_send_ret_submit() vulnerability to null transfer_buffer Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] USB: core: prevent malicious bNumInterfaces overflow Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] Bluetooth: btusb: driver to enable the usb-wakeup feature Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] xhci: Don't add a virt_dev to the devs array before it's fully allocated Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] dmaengine: dmatest: move callback wait queue to thread context Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] ext4: fix fdatasync(2) after fallocate(2) operation Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] mac80211: Fix addition of mesh configuration element Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] ext4: fix crash when a directory's i_size is too small Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] usb: phy: isp1301: Add OF device ID table Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] md-cluster: free md_cluster_info if node leave cluster Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] net: initialize msg.msg_flags in recvfrom Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] net: bcmgenet: correct the RBUF_OVFL_CNT and RBUF_ERR_CNT MIB values Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] net: bcmgenet: correct MIB access of UniMAC RUNT counters Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] net: bcmgenet: Power up the internal PHY before probing the MII Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] net: bcmgenet: reserved phy revisions must be checked first Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] NFSD: fix nfsd_minorversion(.., NFSD_AVAIL) Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] NFSD: fix nfsd_reset_versions for NFSv4 Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] net: wimax/i2400m: fix NULL-deref at probe Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] Input: i8042 - add TUXEDO BU1406 (N24_25BU) to the nomux list Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] net: Resend IGMP memberships upon peer notification Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] dmaengine: Fix array index out of bounds warning in __get_unmap_pool() Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] scsi: hpsa: limit outstanding rescans Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] openrisc: fix issue handling 8 byte get_user calls Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Fix missing put_page() Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] sched/deadline: Use deadline instead of period when calculating overflow Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Adjust mode bits processing Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Populate group ID from vnode status Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Flush outstanding writes when an fd is closed Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Migrate vlocation fields to 64-bit Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Prevent callback expiry timer overflow Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Populate and use client modification time Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Fix the maths in afs_fs_store_data() Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Fix page leak in afs_write_begin() Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] afs: Fix afs_kill_pages() Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] net/mlx4_core: Avoid delays during VF driver device shutdown Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] perf symbols: Fix symbols__fixup_end heuristic for corner cases Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] btrfs: add missing memset while reading compressed inline extents Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] NFSv4.1 respect server's max size in CREATE_SESSION Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] fbdev: controlfb: Add missing modes to fix out of bounds access Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] target: Use system workqueue for ALUA transitions Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] video: udlfb: Fix read EDID timeout Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] video: fbdev: au1200fb: Release some resources if a memory allocation fails Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] video: fbdev: au1200fb: Return an error code " Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] PCI/PME: Handle invalid data when reading Root Status Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] powerpc/powernv/cpufreq: Fix the frequency read by /proc/cpuinfo Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] powerpc/ipic: Fix status get and status clear Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] powerpc/opal: Fix EBUSY bug in acquiring tokens Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] iscsi-target: fix memory leak in lio_target_tiqn_addtpg() Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] target/iscsi: Fix a race condition in iscsit_add_reject_from_cmd() Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] target:fix condition return in core_pr_dump_initiator_port() Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] target/file: Do not return error for UNMAP if length is zero Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] arm-ccn: perf: Prevent module unload while PMU is in use Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] mm: Handle 0 flags in _calc_vm_trans() macro Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] clk: tegra: Fix cclk_lp divisor register Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] ppp: Destroy the mutex when cleanup Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] thermal/drivers/step_wise: Fix temperature regulation misbehavior Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] bcache: explicitly destroy mutex while exiting Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] GFS2: Take inode off order_write list when setting jdata flag Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] l2tp: cleanup l2tp_tunnel_delete calls Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] xfs: fix incorrect extent state in xfs_bmap_add_extent_unwritten_real Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] xfs: fix log block underflow during recovery cycle verification Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] PCI: Detach driver before procfs & sysfs teardown on device remove Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] powerpc/perf/hv-24x7: Fix incorrect comparison in memord Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] tty fix oops when rmmod 8250 Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] usb: musb: da8xx: fix babble condition handling Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] pinctrl: adi2: Fix Kconfig build problem Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] raid5: Set R5_Expanded on parity devices as well as data Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] scsi: scsi_devinfo: Add REPORTLUN2 to EMC SYMMETRIX blacklist entry Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] scsi: bfa: integer overflow in debugfs Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] vt6655: Fix a possible sleep-in-atomic bug in vt6655_suspend Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] udf: Avoid overflow when session starts at large offset Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] macvlan: Only deliver one copy of the frame to the macvlan interface Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] ath9k: fix tx99 potential info leak Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] IB/ipoib: Grab rtnl lock on heavy flush when calling ndo_open/stop Sasha Levin
2018-01-18 21:01 ` [added to the 4.1 stable tree] net: tulip: turn compile-time warning into dev_warn() Sasha Levin
2018-01-18 21:02 ` [added to the 4.1 stable tree] gcov: add support for gcc version >= 6 Sasha Levin
2018-01-18 21:02 ` [added to the 4.1 stable tree] gcov: add support for GCC 5.1 Sasha Levin
2018-01-18 21:02 ` [added to the 4.1 stable tree] irda: fix overly long udelay() Sasha Levin
2018-01-18 21:02 ` [added to the 4.1 stable tree] gcov: support GCC 7.1 Sasha Levin
2018-01-18 21:02 ` [added to the 4.1 stable tree] ARM: ux500: fix prcmu_is_cpu_in_wfi() calculation Sasha Levin
2018-01-18 21:02 ` [added to the 4.1 stable tree] disable new gcc-7.1.1 warnings for now Sasha Levin
2018-01-18 21:02 ` [added to the 4.1 stable tree] gpio: 74xx: Fix build warning about void to integer cast Sasha Levin
2018-01-18 21:02 ` [added to the 4.1 stable tree] ARM: 8584/1: floppy: avoid gcc-6 warning Sasha Levin
2018-01-18 21:02 ` [added to the 4.1 stable tree] bitops.h: add sign_extend64() Sasha Levin

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.