All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c
@ 2016-01-05 17:29 Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] module: Call module notifier on failure after complete_formation() Jiri Slaby
                   ` (37 more replies)
  0 siblings, 38 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable; +Cc: Kosuke Tatsukawa, Greg Kroah-Hartman, Joseph Salisbury, Jiri Slaby

From: Kosuke Tatsukawa <tatsu@ab.jp.nec.com>

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

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

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

commit e81107d4c6bd098878af9796b24edc8d4a9524fd upstream.

My colleague ran into a program stall on a x86_64 server, where
n_tty_read() was waiting for data even if there was data in the buffer
in the pty.  kernel stack for the stuck process looks like below.
 #0 [ffff88303d107b58] __schedule at ffffffff815c4b20
 #1 [ffff88303d107bd0] schedule at ffffffff815c513e
 #2 [ffff88303d107bf0] schedule_timeout at ffffffff815c7818
 #3 [ffff88303d107ca0] wait_woken at ffffffff81096bd2
 #4 [ffff88303d107ce0] n_tty_read at ffffffff8136fa23
 #5 [ffff88303d107dd0] tty_read at ffffffff81368013
 #6 [ffff88303d107e20] __vfs_read at ffffffff811a3704
 #7 [ffff88303d107ec0] vfs_read at ffffffff811a3a57
 #8 [ffff88303d107f00] sys_read at ffffffff811a4306
 #9 [ffff88303d107f50] entry_SYSCALL_64_fastpath at ffffffff815c86d7

There seems to be two problems causing this issue.

First, in drivers/tty/n_tty.c, __receive_buf() stores the data and
updates ldata->commit_head using smp_store_release() and then checks
the wait queue using waitqueue_active().  However, since there is no
memory barrier, __receive_buf() could return without calling
wake_up_interactive_poll(), and at the same time, n_tty_read() could
start to wait in wait_woken() as in the following chart.

        __receive_buf()                         n_tty_read()
------------------------------------------------------------------------
if (waitqueue_active(&tty->read_wait))
/* Memory operations issued after the
   RELEASE may be completed before the
   RELEASE operation has completed */
                                        add_wait_queue(&tty->read_wait, &wait);
                                        ...
                                        if (!input_available_p(tty, 0)) {
smp_store_release(&ldata->commit_head,
                  ldata->read_head);
                                        ...
                                        timeout = wait_woken(&wait,
                                          TASK_INTERRUPTIBLE, timeout);
------------------------------------------------------------------------

The second problem is that n_tty_read() also lacks a memory barrier
call and could also cause __receive_buf() to return without calling
wake_up_interactive_poll(), and n_tty_read() to wait in wait_woken()
as in the chart below.

        __receive_buf()                         n_tty_read()
------------------------------------------------------------------------
                                        spin_lock_irqsave(&q->lock, flags);
                                        /* from add_wait_queue() */
                                        ...
                                        if (!input_available_p(tty, 0)) {
                                        /* Memory operations issued after the
                                           RELEASE may be completed before the
                                           RELEASE operation has completed */
smp_store_release(&ldata->commit_head,
                  ldata->read_head);
if (waitqueue_active(&tty->read_wait))
                                        __add_wait_queue(q, wait);
                                        spin_unlock_irqrestore(&q->lock,flags);
                                        /* from add_wait_queue() */
                                        ...
                                        timeout = wait_woken(&wait,
                                          TASK_INTERRUPTIBLE, timeout);
------------------------------------------------------------------------

There are also other places in drivers/tty/n_tty.c which have similar
calls to waitqueue_active(), so instead of adding many memory barrier
calls, this patch simply removes the call to waitqueue_active(),
leaving just wake_up*() behind.

This fixes both problems because, even though the memory access before
or after the spinlocks in both wake_up*() and add_wait_queue() can
sneak into the critical section, it cannot go past it and the critical
section assures that they will be serialized (please see "INTER-CPU
ACQUIRING BARRIER EFFECTS" in Documentation/memory-barriers.txt for a
better explanation).  Moreover, the resulting code is much simpler.

Latency measurement using a ping-pong test over a pty doesn't show any
visible performance drop.

Signed-off-by: Kosuke Tatsukawa <tatsu@ab.jp.nec.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[jsalisbury: Backported to 3.13.y:
 - Use wake_up_interruptible(), not wake_up_interruptible_poll()
 - There are only two spurious uses of waitqueue_active() to remove]
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/n_tty.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 1352f9de1463..d93ceeabed27 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1384,8 +1384,7 @@ handle_newline:
 			put_tty_queue(c, ldata);
 			ldata->canon_head = ldata->read_head;
 			kill_fasync(&tty->fasync, SIGIO, POLL_IN);
-			if (waitqueue_active(&tty->read_wait))
-				wake_up_interruptible(&tty->read_wait);
+			wake_up_interruptible(&tty->read_wait);
 			return 0;
 		}
 	}
@@ -1670,8 +1669,7 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
 	if ((!ldata->icanon && (read_cnt(ldata) >= ldata->minimum_to_wake)) ||
 		L_EXTPROC(tty)) {
 		kill_fasync(&tty->fasync, SIGIO, POLL_IN);
-		if (waitqueue_active(&tty->read_wait))
-			wake_up_interruptible(&tty->read_wait);
+		wake_up_interruptible(&tty->read_wait);
 	}
 }
 
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] module: Call module notifier on failure after complete_formation()
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] netfilter: ipt_rpfilter: remove the nh_scope test in rpfilter_lookup_reverse Jiri Slaby
                   ` (36 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable; +Cc: Steven Rostedt, Rusty Russell, Jiri Slaby

From: Steven Rostedt <rostedt@goodmis.org>

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

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

commit 37815bf866ab6722a47550f8d25ad3f1a16a680c upstream.

The module notifier call chain for MODULE_STATE_COMING was moved up before
the parsing of args, into the complete_formation() call. But if the module failed
to load after that, the notifier call chain for MODULE_STATE_GOING was
never called and that prevented the users of those call chains from
cleaning up anything that was allocated.

Link: http://lkml.kernel.org/r/554C52B9.9060700@gmail.com

Reported-by: Pontus Fuchs <pontus.fuchs@gmail.com>
Fixes: 4982223e51e8 "module: set nx before marking module MODULE_STATE_COMING"
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 kernel/module.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/module.c b/kernel/module.c
index 3e3f90d82ecc..7d1c2ea27898 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3337,6 +3337,9 @@ static int load_module(struct load_info *info, const char __user *uargs,
 	module_bug_cleanup(mod);
 	mutex_unlock(&module_mutex);
 
+	blocking_notifier_call_chain(&module_notify_list,
+				     MODULE_STATE_GOING, mod);
+
 	/* we can't deallocate the module until we clear memory protection */
 	unset_module_init_ro_nx(mod);
 	unset_module_core_ro_nx(mod);
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] netfilter: ipt_rpfilter: remove the nh_scope test in rpfilter_lookup_reverse
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] module: Call module notifier on failure after complete_formation() Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] netfilter: ip6t_SYNPROXY: fix NULL pointer dereference Jiri Slaby
                   ` (35 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable; +Cc: lucien, Pablo Neira Ayuso, Jiri Slaby

From: lucien <lucien.xin@gmail.com>

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

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

commit cc4998febd567d1c671684abce5595344bd4e8b2 upstream.

--accept-local  option works for res.type == RTN_LOCAL, which should be
from the local table, but there, the fib_info's nh->nh_scope =
RT_SCOPE_NOWHERE ( > RT_SCOPE_HOST). in fib_create_info().

	if (cfg->fc_scope == RT_SCOPE_HOST) {
		struct fib_nh *nh = fi->fib_nh;

		/* Local address is added. */
		if (nhs != 1 || nh->nh_gw)
			goto err_inval;
		nh->nh_scope = RT_SCOPE_NOWHERE;   <===
		nh->nh_dev = dev_get_by_index(net, fi->fib_nh->nh_oif);
		err = -ENODEV;
		if (!nh->nh_dev)
			goto failure;

but in our rpfilter_lookup_reverse():

	if (dev_match || flags & XT_RPFILTER_LOOSE)
		return FIB_RES_NH(res).nh_scope <= RT_SCOPE_HOST;

if nh->nh_scope > RT_SCOPE_HOST, it will fail. --accept-local option
will never be passed.

it seems the test is bogus and can be removed to fix this issue.

	if (dev_match || flags & XT_RPFILTER_LOOSE)
		return FIB_RES_NH(res).nh_scope <= RT_SCOPE_HOST;

ipv6 does not have this issue.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/ipv4/netfilter/ipt_rpfilter.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/ipv4/netfilter/ipt_rpfilter.c b/net/ipv4/netfilter/ipt_rpfilter.c
index c49dcd0284a0..56dd8ac6d28b 100644
--- a/net/ipv4/netfilter/ipt_rpfilter.c
+++ b/net/ipv4/netfilter/ipt_rpfilter.c
@@ -61,9 +61,7 @@ static bool rpfilter_lookup_reverse(struct flowi4 *fl4,
 	if (FIB_RES_DEV(res) == dev)
 		dev_match = true;
 #endif
-	if (dev_match || flags & XT_RPFILTER_LOOSE)
-		return FIB_RES_NH(res).nh_scope <= RT_SCOPE_HOST;
-	return dev_match;
+	return dev_match || flags & XT_RPFILTER_LOOSE;
 }
 
 static bool rpfilter_is_local(const struct sk_buff *skb)
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] netfilter: ip6t_SYNPROXY: fix NULL pointer dereference
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] module: Call module notifier on failure after complete_formation() Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] netfilter: ipt_rpfilter: remove the nh_scope test in rpfilter_lookup_reverse Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] firewire: core: use correct vendor/model IDs Jiri Slaby
                   ` (34 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable; +Cc: Phil Sutter, Pablo Neira Ayuso, Jiri Slaby

From: Phil Sutter <phil@nwl.cc>

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

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

commit 96fffb4f23f124f297d51dedc9cf51d19eb88ee1 upstream.

This happens when networking namespaces are enabled.

Suggested-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/ipv6/netfilter/ip6t_SYNPROXY.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/net/ipv6/netfilter/ip6t_SYNPROXY.c b/net/ipv6/netfilter/ip6t_SYNPROXY.c
index 2748b042da72..3072c09cde8b 100644
--- a/net/ipv6/netfilter/ip6t_SYNPROXY.c
+++ b/net/ipv6/netfilter/ip6t_SYNPROXY.c
@@ -37,12 +37,13 @@ synproxy_build_ip(struct sk_buff *skb, const struct in6_addr *saddr,
 }
 
 static void
-synproxy_send_tcp(const struct sk_buff *skb, struct sk_buff *nskb,
+synproxy_send_tcp(const struct synproxy_net *snet,
+		  const struct sk_buff *skb, struct sk_buff *nskb,
 		  struct nf_conntrack *nfct, enum ip_conntrack_info ctinfo,
 		  struct ipv6hdr *niph, struct tcphdr *nth,
 		  unsigned int tcp_hdr_size)
 {
-	struct net *net = nf_ct_net((struct nf_conn *)nfct);
+	struct net *net = nf_ct_net(snet->tmpl);
 	struct dst_entry *dst;
 	struct flowi6 fl6;
 
@@ -83,7 +84,8 @@ free_nskb:
 }
 
 static void
-synproxy_send_client_synack(const struct sk_buff *skb, const struct tcphdr *th,
+synproxy_send_client_synack(const struct synproxy_net *snet,
+			    const struct sk_buff *skb, const struct tcphdr *th,
 			    const struct synproxy_options *opts)
 {
 	struct sk_buff *nskb;
@@ -119,7 +121,7 @@ synproxy_send_client_synack(const struct sk_buff *skb, const struct tcphdr *th,
 
 	synproxy_build_options(nth, opts);
 
-	synproxy_send_tcp(skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY,
+	synproxy_send_tcp(snet, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY,
 			  niph, nth, tcp_hdr_size);
 }
 
@@ -163,7 +165,7 @@ synproxy_send_server_syn(const struct synproxy_net *snet,
 
 	synproxy_build_options(nth, opts);
 
-	synproxy_send_tcp(skb, nskb, &snet->tmpl->ct_general, IP_CT_NEW,
+	synproxy_send_tcp(snet, skb, nskb, &snet->tmpl->ct_general, IP_CT_NEW,
 			  niph, nth, tcp_hdr_size);
 }
 
@@ -203,7 +205,7 @@ synproxy_send_server_ack(const struct synproxy_net *snet,
 
 	synproxy_build_options(nth, opts);
 
-	synproxy_send_tcp(skb, nskb, NULL, 0, niph, nth, tcp_hdr_size);
+	synproxy_send_tcp(snet, skb, nskb, NULL, 0, niph, nth, tcp_hdr_size);
 }
 
 static void
@@ -241,7 +243,7 @@ synproxy_send_client_ack(const struct synproxy_net *snet,
 
 	synproxy_build_options(nth, opts);
 
-	synproxy_send_tcp(skb, nskb, NULL, 0, niph, nth, tcp_hdr_size);
+	synproxy_send_tcp(snet, skb, nskb, NULL, 0, niph, nth, tcp_hdr_size);
 }
 
 static bool
@@ -300,7 +302,7 @@ synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par)
 					  XT_SYNPROXY_OPT_SACK_PERM |
 					  XT_SYNPROXY_OPT_ECN);
 
-		synproxy_send_client_synack(skb, th, &opts);
+		synproxy_send_client_synack(snet, skb, th, &opts);
 		return NF_DROP;
 
 	} else if (th->ack && !(th->fin || th->rst || th->syn)) {
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] firewire: core: use correct vendor/model IDs
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (2 preceding siblings ...)
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] netfilter: ip6t_SYNPROXY: fix NULL pointer dereference Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] ip6mr: call del_timer_sync() in ip6mr_free_table() Jiri Slaby
                   ` (33 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable; +Cc: Clemens Ladisch, Stefan Richter, Oliver Neukum, Jiri Slaby

From: Clemens Ladisch <clemens@ladisch.de>

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

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

commit d71e6a11737f4b3d857425a1d6f893231cbd1296 upstream.

The kernel was using the vendor ID 0xd00d1e, which was inherited from
the old ieee1394 driver stack.  However, this ID was not registered, and
invalid.

Instead, use the vendor/model IDs that are now officially assigned to
the kernel:
https://ieee1394.wiki.kernel.org/index.php/IEEE_OUI_Assignments

[stefanr:
  - The vendor ID 001f11 is Openmoko, Inc.'s identifier, registered at
    IEEE Registration Authority.
  - The range of model IDs 023900...0239ff are the Linux kernel 1394
    subsystem's identifiers, registered at Openmoko.
  - Model ID 023901 is picked by the subsystem developers as
    firewire-core's model ID.]

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: "Oliver Neukum" <ONeukum@suse.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/firewire/core-transaction.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index e5af0e3a26ec..d8714808f2c2 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -1246,14 +1246,14 @@ static const u32 model_textual_descriptor[] = {
 
 static struct fw_descriptor vendor_id_descriptor = {
 	.length = ARRAY_SIZE(vendor_textual_descriptor),
-	.immediate = 0x03d00d1e,
+	.immediate = 0x03001f11,
 	.key = 0x81000000,
 	.data = vendor_textual_descriptor,
 };
 
 static struct fw_descriptor model_id_descriptor = {
 	.length = ARRAY_SIZE(model_textual_descriptor),
-	.immediate = 0x17000001,
+	.immediate = 0x17023901,
 	.key = 0x81000000,
 	.data = model_textual_descriptor,
 };
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] ip6mr: call del_timer_sync() in ip6mr_free_table()
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (3 preceding siblings ...)
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] firewire: core: use correct vendor/model IDs Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] Btrfs: fix race leading to incorrect item deletion when dropping extents Jiri Slaby
                   ` (32 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable
  Cc: WANG Cong, Hannes Frederic Sowa, David S . Miller, Ben Hutchings,
	Jiri Slaby

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

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

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

commit 7ba0c47c34a1ea5bc7a24ca67309996cce0569b5 upstream.

We need to wait for the flying timers, since we
are going to free the mrtable right after it.

Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/ipv6/ip6mr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 9ad561152eb6..8b61288e5746 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -336,7 +336,7 @@ static struct mr6_table *ip6mr_new_table(struct net *net, u32 id)
 
 static void ip6mr_free_table(struct mr6_table *mrt)
 {
-	del_timer(&mrt->ipmr_expire_timer);
+	del_timer_sync(&mrt->ipmr_expire_timer);
 	mroute_clean_tables(mrt, true);
 	kfree(mrt);
 }
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] Btrfs: fix race leading to incorrect item deletion when dropping extents
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (4 preceding siblings ...)
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] ip6mr: call del_timer_sync() in ip6mr_free_table() Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] Btrfs: fix race leading to BUG_ON when running delalloc for nodatacow Jiri Slaby
                   ` (31 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable; +Cc: Filipe Manana, Jiri Slaby

From: Filipe Manana <fdmanana@suse.com>

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

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

commit aeafbf8486c9e2bd53f5cc3c10c0b7fd7149d69c upstream.

While running a stress test I got the following warning triggered:

  [191627.672810] ------------[ cut here ]------------
  [191627.673949] WARNING: CPU: 8 PID: 8447 at fs/btrfs/file.c:779 __btrfs_drop_extents+0x391/0xa50 [btrfs]()
  (...)
  [191627.701485] Call Trace:
  [191627.702037]  [<ffffffff8145f077>] dump_stack+0x4f/0x7b
  [191627.702992]  [<ffffffff81095de5>] ? console_unlock+0x356/0x3a2
  [191627.704091]  [<ffffffff8104b3b0>] warn_slowpath_common+0xa1/0xbb
  [191627.705380]  [<ffffffffa0664499>] ? __btrfs_drop_extents+0x391/0xa50 [btrfs]
  [191627.706637]  [<ffffffff8104b46d>] warn_slowpath_null+0x1a/0x1c
  [191627.707789]  [<ffffffffa0664499>] __btrfs_drop_extents+0x391/0xa50 [btrfs]
  [191627.709155]  [<ffffffff8115663c>] ? cache_alloc_debugcheck_after.isra.32+0x171/0x1d0
  [191627.712444]  [<ffffffff81155007>] ? kmemleak_alloc_recursive.constprop.40+0x16/0x18
  [191627.714162]  [<ffffffffa06570c9>] insert_reserved_file_extent.constprop.40+0x83/0x24e [btrfs]
  [191627.715887]  [<ffffffffa065422b>] ? start_transaction+0x3bb/0x610 [btrfs]
  [191627.717287]  [<ffffffffa065b604>] btrfs_finish_ordered_io+0x273/0x4e2 [btrfs]
  [191627.728865]  [<ffffffffa065b888>] finish_ordered_fn+0x15/0x17 [btrfs]
  [191627.730045]  [<ffffffffa067d688>] normal_work_helper+0x14c/0x32c [btrfs]
  [191627.731256]  [<ffffffffa067d96a>] btrfs_endio_write_helper+0x12/0x14 [btrfs]
  [191627.732661]  [<ffffffff81061119>] process_one_work+0x24c/0x4ae
  [191627.733822]  [<ffffffff810615b0>] worker_thread+0x206/0x2c2
  [191627.734857]  [<ffffffff810613aa>] ? process_scheduled_works+0x2f/0x2f
  [191627.736052]  [<ffffffff810613aa>] ? process_scheduled_works+0x2f/0x2f
  [191627.737349]  [<ffffffff810669a6>] kthread+0xef/0xf7
  [191627.738267]  [<ffffffff810f3b3a>] ? time_hardirqs_on+0x15/0x28
  [191627.739330]  [<ffffffff810668b7>] ? __kthread_parkme+0xad/0xad
  [191627.741976]  [<ffffffff81465592>] ret_from_fork+0x42/0x70
  [191627.743080]  [<ffffffff810668b7>] ? __kthread_parkme+0xad/0xad
  [191627.744206] ---[ end trace bbfddacb7aaada8d ]---

  $ cat -n fs/btrfs/file.c
  691  int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
  (...)
  758                  btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
  759                  if (key.objectid > ino ||
  760                      key.type > BTRFS_EXTENT_DATA_KEY || key.offset >= end)
  761                          break;
  762
  763                  fi = btrfs_item_ptr(leaf, path->slots[0],
  764                                      struct btrfs_file_extent_item);
  765                  extent_type = btrfs_file_extent_type(leaf, fi);
  766
  767                  if (extent_type == BTRFS_FILE_EXTENT_REG ||
  768                      extent_type == BTRFS_FILE_EXTENT_PREALLOC) {
  (...)
  774                  } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
  (...)
  778                  } else {
  779                          WARN_ON(1);
  780                          extent_end = search_start;
  781                  }
  (...)

This happened because the item we were processing did not match a file
extent item (its key type != BTRFS_EXTENT_DATA_KEY), and even on this
case we cast the item to a struct btrfs_file_extent_item pointer and
then find a type field value that does not match any of the expected
values (BTRFS_FILE_EXTENT_[REG|PREALLOC|INLINE]). This scenario happens
due to a tiny time window where a race can happen as exemplified below.
For example, consider the following scenario where we're using the
NO_HOLES feature and we have the following two neighbour leafs:

               Leaf X (has N items)                    Leaf Y

[ ... (257 INODE_ITEM 0) (257 INODE_REF 256) ]  [ (257 EXTENT_DATA 8192), ... ]
          slot N - 2         slot N - 1              slot 0

Our inode 257 has an implicit hole in the range [0, 8K[ (implicit rather
than explicit because NO_HOLES is enabled). Now if our inode has an
ordered extent for the range [4K, 8K[ that is finishing, the following
can happen:

          CPU 1                                       CPU 2

  btrfs_finish_ordered_io()
    insert_reserved_file_extent()
      __btrfs_drop_extents()
         Searches for the key
          (257 EXTENT_DATA 4096) through
          btrfs_lookup_file_extent()

         Key not found and we get a path where
         path->nodes[0] == leaf X and
         path->slots[0] == N

         Because path->slots[0] is >=
         btrfs_header_nritems(leaf X), we call
         btrfs_next_leaf()

         btrfs_next_leaf() releases the path

                                                  inserts key
                                                  (257 INODE_REF 4096)
                                                  at the end of leaf X,
                                                  leaf X now has N + 1 keys,
                                                  and the new key is at
                                                  slot N

         btrfs_next_leaf() searches for
         key (257 INODE_REF 256), with
         path->keep_locks set to 1,
         because it was the last key it
         saw in leaf X

           finds it in leaf X again and
           notices it's no longer the last
           key of the leaf, so it returns 0
           with path->nodes[0] == leaf X and
           path->slots[0] == N (which is now
           < btrfs_header_nritems(leaf X)),
           pointing to the new key
           (257 INODE_REF 4096)

         __btrfs_drop_extents() casts the
         item at path->nodes[0], slot
         path->slots[0], to a struct
         btrfs_file_extent_item - it does
         not skip keys for the target
         inode with a type less than
         BTRFS_EXTENT_DATA_KEY
         (BTRFS_INODE_REF_KEY < BTRFS_EXTENT_DATA_KEY)

         sees a bogus value for the type
         field triggering the WARN_ON in
         the trace shown above, and sets
         extent_end = search_start (4096)

         does the if-then-else logic to
         fixup 0 length extent items created
         by a past bug from hole punching:

           if (extent_end == key.offset &&
               extent_end >= search_start)
               goto delete_extent_item;

         that evaluates to true and it ends
         up deleting the key pointed to by
         path->slots[0], (257 INODE_REF 4096),
         from leaf X

The same could happen for example for a xattr that ends up having a key
with an offset value that matches search_start (very unlikely but not
impossible).

So fix this by ensuring that keys smaller than BTRFS_EXTENT_DATA_KEY are
skipped, never casted to struct btrfs_file_extent_item and never deleted
by accident. Also protect against the unexpected case of getting a key
for a lower inode number by skipping that key and issuing a warning.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/btrfs/file.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 9663f6600973..f0cd2f2fe0af 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -746,8 +746,16 @@ next_slot:
 		}
 
 		btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
-		if (key.objectid > ino ||
-		    key.type > BTRFS_EXTENT_DATA_KEY || key.offset >= end)
+
+		if (key.objectid > ino)
+			break;
+		if (WARN_ON_ONCE(key.objectid < ino) ||
+		    key.type < BTRFS_EXTENT_DATA_KEY) {
+			ASSERT(del_nr == 0);
+			path->slots[0]++;
+			goto next_slot;
+		}
+		if (key.type > BTRFS_EXTENT_DATA_KEY || key.offset >= end)
 			break;
 
 		fi = btrfs_item_ptr(leaf, path->slots[0],
@@ -765,8 +773,8 @@ next_slot:
 			extent_end = key.offset +
 				btrfs_file_extent_inline_len(leaf, fi);
 		} else {
-			WARN_ON(1);
-			extent_end = search_start;
+			/* can't happen */
+			BUG();
 		}
 
 		if (extent_end <= search_start) {
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] Btrfs: fix race leading to BUG_ON when running delalloc for nodatacow
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (5 preceding siblings ...)
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] Btrfs: fix race leading to incorrect item deletion when dropping extents Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] ext4: fix potential use after free in __ext4_journal_stop Jiri Slaby
                   ` (30 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable; +Cc: Filipe Manana, Jiri Slaby

From: Filipe Manana <fdmanana@suse.com>

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

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

commit 1d512cb77bdbda80f0dd0620a3b260d697fd581d upstream.

If we are using the NO_HOLES feature, we have a tiny time window when
running delalloc for a nodatacow inode where we can race with a concurrent
link or xattr add operation leading to a BUG_ON.

This happens because at run_delalloc_nocow() we end up casting a leaf item
of type BTRFS_INODE_[REF|EXTREF]_KEY or of type BTRFS_XATTR_ITEM_KEY to a
file extent item (struct btrfs_file_extent_item) and then analyse its
extent type field, which won't match any of the expected extent types
(values BTRFS_FILE_EXTENT_[REG|PREALLOC|INLINE]) and therefore trigger an
explicit BUG_ON(1).

The following sequence diagram shows how the race happens when running a
no-cow dellaloc range [4K, 8K[ for inode 257 and we have the following
neighbour leafs:

             Leaf X (has N items)                    Leaf Y

 [ ... (257 INODE_ITEM 0) (257 INODE_REF 256) ]  [ (257 EXTENT_DATA 8192), ... ]
              slot N - 2         slot N - 1              slot 0

 (Note the implicit hole for inode 257 regarding the [0, 8K[ range)

       CPU 1                                         CPU 2

 run_dealloc_nocow()
   btrfs_lookup_file_extent()
     --> searches for a key with value
         (257 EXTENT_DATA 4096) in the
         fs/subvol tree
     --> returns us a path with
         path->nodes[0] == leaf X and
         path->slots[0] == N

   because path->slots[0] is >=
   btrfs_header_nritems(leaf X), it
   calls btrfs_next_leaf()

   btrfs_next_leaf()
     --> releases the path

                                              hard link added to our inode,
                                              with key (257 INODE_REF 500)
                                              added to the end of leaf X,
                                              so leaf X now has N + 1 keys

     --> searches for the key
         (257 INODE_REF 256), because
         it was the last key in leaf X
         before it released the path,
         with path->keep_locks set to 1

     --> ends up at leaf X again and
         it verifies that the key
         (257 INODE_REF 256) is no longer
         the last key in the leaf, so it
         returns with path->nodes[0] ==
         leaf X and path->slots[0] == N,
         pointing to the new item with
         key (257 INODE_REF 500)

   the loop iteration of run_dealloc_nocow()
   does not break out the loop and continues
   because the key referenced in the path
   at path->nodes[0] and path->slots[0] is
   for inode 257, its type is < BTRFS_EXTENT_DATA_KEY
   and its offset (500) is less then our delalloc
   range's end (8192)

   the item pointed by the path, an inode reference item,
   is (incorrectly) interpreted as a file extent item and
   we get an invalid extent type, leading to the BUG_ON(1):

   if (extent_type == BTRFS_FILE_EXTENT_REG ||
      extent_type == BTRFS_FILE_EXTENT_PREALLOC) {
       (...)
   } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
       (...)
   } else {
       BUG_ON(1)
   }

The same can happen if a xattr is added concurrently and ends up having
a key with an offset smaller then the delalloc's range end.

So fix this by skipping keys with a type smaller than
BTRFS_EXTENT_DATA_KEY.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/btrfs/inode.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 50f08d5f9cbb..5074a1607812 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1221,8 +1221,14 @@ next_slot:
 		num_bytes = 0;
 		btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
 
-		if (found_key.objectid > ino ||
-		    found_key.type > BTRFS_EXTENT_DATA_KEY ||
+		if (found_key.objectid > ino)
+			break;
+		if (WARN_ON_ONCE(found_key.objectid < ino) ||
+		    found_key.type < BTRFS_EXTENT_DATA_KEY) {
+			path->slots[0]++;
+			goto next_slot;
+		}
+		if (found_key.type > BTRFS_EXTENT_DATA_KEY ||
 		    found_key.offset > end)
 			break;
 
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] ext4: fix potential use after free in __ext4_journal_stop
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (6 preceding siblings ...)
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] Btrfs: fix race leading to BUG_ON when running delalloc for nodatacow Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] ext4, jbd2: ensure entering into panic after recording an error in superblock Jiri Slaby
                   ` (29 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable; +Cc: Lukas Czerner, Jiri Slaby

From: Lukas Czerner <lczerner@redhat.com>

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

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

commit 6934da9238da947628be83635e365df41064b09b upstream.

There is a use-after-free possibility in __ext4_journal_stop() in the
case that we free the handle in the first jbd2_journal_stop() because
we're referencing handle->h_err afterwards. This was introduced in
9705acd63b125dee8b15c705216d7186daea4625 and it is wrong. Fix it by
storing the handle->h_err value beforehand and avoid referencing
potentially freed handle.

Fixes: 9705acd63b125dee8b15c705216d7186daea4625
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/ext4/ext4_jbd2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index ff42208417b9..0b3af57acaef 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -88,13 +88,13 @@ int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle)
 		return 0;
 	}
 
+	err = handle->h_err;
 	if (!handle->h_transaction) {
-		err = jbd2_journal_stop(handle);
-		return handle->h_err ? handle->h_err : err;
+		rc = jbd2_journal_stop(handle);
+		return err ? err : rc;
 	}
 
 	sb = handle->h_transaction->t_journal->j_private;
-	err = handle->h_err;
 	rc = jbd2_journal_stop(handle);
 
 	if (!err)
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] ext4, jbd2: ensure entering into panic after recording an error in superblock
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (7 preceding siblings ...)
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] ext4: fix potential use after free in __ext4_journal_stop Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] firewire: ohci: fix JMicron JMB38x IT context discovery Jiri Slaby
                   ` (28 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable; +Cc: Daeho Jeong, Theodore Ts'o, Jiri Slaby

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

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

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

commit 4327ba52afd03fc4b5afa0ee1d774c9c5b0e85c5 upstream.

If a EXT4 filesystem utilizes JBD2 journaling and an error occurs, the
journaling will be aborted first and the error number will be recorded
into JBD2 superblock and, finally, the system will enter into the
panic state in "errors=panic" option.  But, in the rare case, this
sequence is little twisted like the below figure and it will happen
that the system enters into panic state, which means the system reset
in mobile environment, before completion of recording an error in the
journal superblock. In this case, e2fsck cannot recognize that the
filesystem failure occurred in the previous run and the corruption
wouldn't be fixed.

Task A                        Task B
ext4_handle_error()
-> jbd2_journal_abort()
  -> __journal_abort_soft()
    -> __jbd2_journal_abort_hard()
    | -> journal->j_flags |= JBD2_ABORT;
    |
    |                         __ext4_abort()
    |                         -> jbd2_journal_abort()
    |                         | -> __journal_abort_soft()
    |                         |   -> if (journal->j_flags & JBD2_ABORT)
    |                         |           return;
    |                         -> panic()
    |
    -> jbd2_journal_update_sb_errno()

Tested-by: Hobin Woo <hobin.woo@samsung.com>
Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/ext4/super.c      | 12 ++++++++++--
 fs/jbd2/journal.c    |  6 +++++-
 include/linux/jbd2.h |  1 +
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index d520064ceddb..49f45464518f 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -404,9 +404,13 @@ static void ext4_handle_error(struct super_block *sb)
 		smp_wmb();
 		sb->s_flags |= MS_RDONLY;
 	}
-	if (test_opt(sb, ERRORS_PANIC))
+	if (test_opt(sb, ERRORS_PANIC)) {
+		if (EXT4_SB(sb)->s_journal &&
+		  !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR))
+			return;
 		panic("EXT4-fs (device %s): panic forced after error\n",
 			sb->s_id);
+	}
 }
 
 void __ext4_error(struct super_block *sb, const char *function,
@@ -585,8 +589,12 @@ void __ext4_abort(struct super_block *sb, const char *function,
 			jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO);
 		save_error_info(sb, function, line);
 	}
-	if (test_opt(sb, ERRORS_PANIC))
+	if (test_opt(sb, ERRORS_PANIC)) {
+		if (EXT4_SB(sb)->s_journal &&
+		  !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR))
+			return;
 		panic("EXT4-fs panic from previous error\n");
+	}
 }
 
 void __ext4_msg(struct super_block *sb,
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 2ebb7aadb381..e2d9856a015a 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2090,8 +2090,12 @@ static void __journal_abort_soft (journal_t *journal, int errno)
 
 	__jbd2_journal_abort_hard(journal);
 
-	if (errno)
+	if (errno) {
 		jbd2_journal_update_sb_errno(journal);
+		write_lock(&journal->j_state_lock);
+		journal->j_flags |= JBD2_REC_ERR;
+		write_unlock(&journal->j_state_lock);
+	}
 }
 
 /**
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 385593d748f6..e137e962834b 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1007,6 +1007,7 @@ struct journal_s
 #define JBD2_ABORT_ON_SYNCDATA_ERR	0x040	/* Abort the journal on file
 						 * data write error in ordered
 						 * mode */
+#define JBD2_REC_ERR	0x080	/* The errno in the sb has been recorded */
 
 /*
  * Function declarations for the journaling transaction and buffer
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] firewire: ohci: fix JMicron JMB38x IT context discovery
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (8 preceding siblings ...)
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] ext4, jbd2: ensure entering into panic after recording an error in superblock Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] nfs4: start callback_ident at idr 1 Jiri Slaby
                   ` (27 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable; +Cc: Stefan Richter, Jiri Slaby

From: Stefan Richter <stefanr@s5r6.in-berlin.de>

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

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

commit 100ceb66d5c40cc0c7018e06a9474302470be73c upstream.

Reported by Clifford and Craig for JMicron OHCI-1394 + SDHCI combo
controllers:  Often or even most of the time, the controller is
initialized with the message "added OHCI v1.10 device as card 0, 4 IR +
0 IT contexts, quirks 0x10".  With 0 isochronous transmit DMA contexts
(IT contexts), applications like audio output are impossible.

However, OHCI-1394 demands that at least 4 IT contexts are implemented
by the link layer controller, and indeed JMicron JMB38x do implement
four of them.  Only their IsoXmitIntMask register is unreliable at early
access.

With my own JMB381 single function controller I found:
  - I can reproduce the problem with a lower probability than Craig's.
  - If I put a loop around the section which clears and reads
    IsoXmitIntMask, then either the first or the second attempt will
    return the correct initial mask of 0x0000000f.  I never encountered
    a case of needing more than a second attempt.
  - Consequently, if I put a dummy reg_read(...IsoXmitIntMaskSet)
    before the first write, the subsequent read will return the correct
    result.
  - If I merely ignore a wrong read result and force the known real
    result, later isochronous transmit DMA usage works just fine.

So let's just fix this chip bug up by the latter method.  Tested with
JMB381 on kernel 3.13 and 4.3.

Since OHCI-1394 generally requires 4 IT contexts at a minium, this
workaround is simply applied whenever the initial read of IsoXmitIntMask
returns 0, regardless whether it's a JMicron chip or not.  I never heard
of this issue together with any other chip though.

I am not 100% sure that this fix works on the OHCI-1394 part of JMB380
and JMB388 combo controllers exactly the same as on the JMB381 single-
function controller, but so far I haven't had a chance to let an owner
of a combo chip run a patched kernel.

Strangely enough, IsoRecvIntMask is always reported correctly, even
though it is probed right before IsoXmitIntMask.

Reported-by: Clifford Dunn
Reported-by: Craig Moore <craig.moore@qenos.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/firewire/ohci.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index ee805a57b72d..81b45c43a91f 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -3672,6 +3672,11 @@ static int pci_probe(struct pci_dev *dev,
 
 	reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, ~0);
 	ohci->it_context_support = reg_read(ohci, OHCI1394_IsoXmitIntMaskSet);
+	/* JMicron JMB38x often shows 0 at first read, just ignore it */
+	if (!ohci->it_context_support) {
+		ohci_notice(ohci, "overriding IsoXmitIntMask\n");
+		ohci->it_context_support = 0xf;
+	}
 	reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, ~0);
 	ohci->it_context_mask = ohci->it_context_support;
 	ohci->n_it = hweight32(ohci->it_context_mask);
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] nfs4: start callback_ident at idr 1
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (9 preceding siblings ...)
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] firewire: ohci: fix JMicron JMB38x IT context discovery Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] nfs: if we have no valid attrs, then don't declare the attribute cache valid Jiri Slaby
                   ` (26 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable; +Cc: Benjamin Coddington, Trond Myklebust, Jiri Slaby

From: Benjamin Coddington <bcodding@redhat.com>

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

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

commit c68a027c05709330fe5b2f50c50d5fa02124b5d8 upstream.

If clp->cl_cb_ident is zero, then nfs_cb_idr_remove_locked() skips removing
it when the nfs_client is freed.  A decoding or server bug can then find
and try to put that first nfs_client which would lead to a crash.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Fixes: d6870312659d ("nfs4client: convert to idr_alloc()")
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/nfs/nfs4client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 28e1f211600d..cf8b0a4794dd 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -32,7 +32,7 @@ static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion)
 		return ret;
 	idr_preload(GFP_KERNEL);
 	spin_lock(&nn->nfs_client_lock);
-	ret = idr_alloc(&nn->cb_ident_idr, clp, 0, 0, GFP_NOWAIT);
+	ret = idr_alloc(&nn->cb_ident_idr, clp, 1, 0, GFP_NOWAIT);
 	if (ret >= 0)
 		clp->cl_cb_ident = ret;
 	spin_unlock(&nn->nfs_client_lock);
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] nfs: if we have no valid attrs, then don't declare the attribute cache valid
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (10 preceding siblings ...)
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] nfs4: start callback_ident at idr 1 Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] ocfs2: fix umask ignored issue Jiri Slaby
                   ` (25 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable; +Cc: Jeff Layton, Jeff Layton, Trond Myklebust, Jiri Slaby

From: Jeff Layton <jlayton@poochiereds.net>

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

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

commit c812012f9ca7cf89c9e1a1cd512e6c3b5be04b85 upstream.

If we pass in an empty nfs_fattr struct to nfs_update_inode, it will
(correctly) not update any of the attributes, but it then clears the
NFS_INO_INVALID_ATTR flag, which indicates that the attributes are
up to date. Don't clear the flag if the fattr struct has no valid
attrs to apply.

Reviewed-by: Steve French <steve.french@primarydata.com>
Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/nfs/inode.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 127a6d9d81b7..6f5457245a75 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1668,7 +1668,11 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 			nfsi->attrtimeo_timestamp = now;
 		}
 	}
-	invalid &= ~NFS_INO_INVALID_ATTR;
+
+	/* Don't declare attrcache up to date if there were no attrs! */
+	if (fattr->valid != 0)
+		invalid &= ~NFS_INO_INVALID_ATTR;
+
 	/* Don't invalidate the data if we were to blame */
 	if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)
 				|| S_ISLNK(inode->i_mode)))
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] ocfs2: fix umask ignored issue
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (11 preceding siblings ...)
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] nfs: if we have no valid attrs, then don't declare the attribute cache valid Jiri Slaby
@ 2016-01-05 17:29 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: cdc_acm: Ignore Infineon Flash Loader utility Jiri Slaby
                   ` (24 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:29 UTC (permalink / raw)
  To: stable
  Cc: Junxiao Bi, Gang He, Mark Fasheh, Joel Becker, Andrew Morton,
	Linus Torvalds, Jiri Slaby

From: Junxiao Bi <junxiao.bi@oracle.com>

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

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

commit 8f1eb48758aacf6c1ffce18179295adbf3bd7640 upstream.

New created file's mode is not masked with umask, and this makes umask not
work for ocfs2 volume.

Fixes: 702e5bc ("ocfs2: use generic posix ACL infrastructure")
Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Gang He <ghe@suse.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/ocfs2/namei.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index c19c2c57650b..9523fcd86c31 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -330,6 +330,8 @@ static int ocfs2_mknod(struct inode *dir,
 			mlog_errno(status);
 		goto leave;
 	}
+	/* update inode->i_mode after mask with "umask". */
+	inode->i_mode = mode;
 
 	handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb,
 							    S_ISDIR(mode),
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] USB: cdc_acm: Ignore Infineon Flash Loader utility
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (12 preceding siblings ...)
  2016-01-05 17:29 ` [patch added to the 3.12 stable tree] ocfs2: fix umask ignored issue Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: serial: Another Infineon flash loader USB ID Jiri Slaby
                   ` (23 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Jonas Jonsson, Johan Hovold, Jiri Slaby

From: Jonas Jonsson <jonas@ludd.ltu.se>

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

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

commit f33a7f72e5fc033daccbb8d4753d7c5c41a4d67b upstream.

Some modems, such as the Telit UE910, are using an Infineon Flash Loader
utility. It has two interfaces, 2/2/0 (Abstract Modem) and 10/0/0 (CDC
Data). The latter can be used as a serial interface to upgrade the
firmware of the modem. However, that isn't possible when the cdc-acm
driver takes control of the device.

The following is an explanation of the behaviour by Daniele Palmas during
discussion on linux-usb.

"This is what happens when the device is turned on (without modifying
the drivers):

[155492.352031] usb 1-3: new high-speed USB device number 27 using ehci-pci
[155492.485429] usb 1-3: config 1 interface 0 altsetting 0 endpoint 0x81 has an invalid bInterval 255, changing to 11
[155492.485436] usb 1-3: New USB device found, idVendor=058b, idProduct=0041
[155492.485439] usb 1-3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[155492.485952] cdc_acm 1-3:1.0: ttyACM0: USB ACM device

This is the flashing device that is caught by the cdc-acm driver. Once
the ttyACM appears, the application starts sending a magic string
(simple write on the file descriptor) to keep the device in flashing
mode. If this magic string is not properly received in a certain time
interval, the modem goes on in normal operative mode:

[155493.748094] usb 1-3: USB disconnect, device number 27
[155494.916025] usb 1-3: new high-speed USB device number 28 using ehci-pci
[155495.059978] usb 1-3: New USB device found, idVendor=1bc7, idProduct=0021
[155495.059983] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[155495.059986] usb 1-3: Product: 6 CDC-ACM + 1 CDC-ECM
[155495.059989] usb 1-3: Manufacturer: Telit
[155495.059992] usb 1-3: SerialNumber: 359658044004697
[155495.138958] cdc_acm 1-3:1.0: ttyACM0: USB ACM device
[155495.140832] cdc_acm 1-3:1.2: ttyACM1: USB ACM device
[155495.142827] cdc_acm 1-3:1.4: ttyACM2: USB ACM device
[155495.144462] cdc_acm 1-3:1.6: ttyACM3: USB ACM device
[155495.145967] cdc_acm 1-3:1.8: ttyACM4: USB ACM device
[155495.147588] cdc_acm 1-3:1.10: ttyACM5: USB ACM device
[155495.154322] cdc_ether 1-3:1.12 wwan0: register 'cdc_ether' at usb-0000:00:1a.7-3, Mobile Broadband Network Device, 00:00:11:12:13:14

Using the cdc-acm driver, the string, though being sent in the same way
than using the usb-serial-simple driver (I can confirm that the data is
passing properly since I used an hw usb sniffer), does not make the
device to stay in flashing mode."

Signed-off-by: Jonas Jonsson <jonas@ludd.ltu.se>
Tested-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/class/cdc-acm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index e2b4ea7fb2b1..0822bf1ed2e5 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1720,6 +1720,11 @@ static const struct usb_device_id acm_ids[] = {
 	},
 #endif
 
+	/* Exclude Infineon Flash Loader utility */
+	{ USB_DEVICE(0x058b, 0x0041),
+	.driver_info = IGNORE_DEVICE,
+	},
+
 	/* control interfaces without any protocol set */
 	{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
 		USB_CDC_PROTO_NONE) },
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] USB: serial: Another Infineon flash loader USB ID
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (13 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: cdc_acm: Ignore Infineon Flash Loader utility Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: cp210x: Remove CP2110 ID from compatibility list Jiri Slaby
                   ` (22 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Jonas Jonsson, Johan Hovold, Jiri Slaby

From: Jonas Jonsson <jonas@ludd.ltu.se>

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

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

commit a0e80fbd56b4573de997c9a088a33abbc1121400 upstream.

The flash loader has been seen on a Telit UE910 modem. The flash loader
is a bit special, it presents both an ACM and CDC Data interface but
only the latter is useful. Unless a magic string is sent to the device
it will disappear and the regular modem device appears instead.

Signed-off-by: Jonas Jonsson <jonas@ludd.ltu.se>
Tested-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/serial/usb-serial-simple.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/serial/usb-serial-simple.c b/drivers/usb/serial/usb-serial-simple.c
index cc61d3781c21..13630428700e 100644
--- a/drivers/usb/serial/usb-serial-simple.c
+++ b/drivers/usb/serial/usb-serial-simple.c
@@ -48,6 +48,7 @@ DEVICE(funsoft, FUNSOFT_IDS);
 
 /* Infineon Flashloader driver */
 #define FLASHLOADER_IDS()		\
+	{ USB_DEVICE_INTERFACE_CLASS(0x058b, 0x0041, USB_CLASS_CDC_DATA) }, \
 	{ USB_DEVICE(0x8087, 0x0716) }
 DEVICE(flashloader, FLASHLOADER_IDS);
 
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] USB: cp210x: Remove CP2110 ID from compatibility list
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (14 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: serial: Another Infineon flash loader USB ID Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: add quirk for devices with broken LPM Jiri Slaby
                   ` (21 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Konstantin Shkolnyy, Johan Hovold, Jiri Slaby

From: Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>

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

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

commit 7c90e610b60cd1ed6abafd806acfaedccbbe52d1 upstream.

CP2110 ID (0x10c4, 0xea80) doesn't belong here because it's a HID
and completely different from CP210x devices.

Signed-off-by: Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/serial/cp210x.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 4be065afc499..3597be0a5ae4 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -132,7 +132,6 @@ static const struct usb_device_id id_table[] = {
 	{ USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
 	{ USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
 	{ USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */
-	{ USB_DEVICE(0x10C4, 0xEA80) }, /* Silicon Labs factory default */
 	{ USB_DEVICE(0x10C4, 0xEA71) }, /* Infinity GPS-MIC-1 Radio Monophone */
 	{ USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */
 	{ USB_DEVICE(0x10C4, 0xF002) }, /* Elan Digital Systems USBwave12 */
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] USB: add quirk for devices with broken LPM
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (15 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: cp210x: Remove CP2110 ID from compatibility list Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: whci-hcd: add check for dma mapping error Jiri Slaby
                   ` (20 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Alan Stern, Jiri Slaby

From: Alan Stern <stern@rowland.harvard.edu>

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

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

commit ad87e03213b552a5c33d5e1e7a19a73768397010 upstream.

Some USB device / host controller combinations seem to have problems
with Link Power Management.  For example, Steinar found that his xHCI
controller wouldn't handle bandwidth calculations correctly for two
video cards simultaneously when LPM was enabled, even though the bus
had plenty of bandwidth available.

This patch introduces a new quirk flag for devices that should remain
disabled for LPM, and creates quirk entries for Steinar's devices.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Steinar H. Gunderson <sgunderson@bigfoot.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/core/hub.c     | 7 ++++++-
 drivers/usb/core/quirks.c  | 6 ++++++
 include/linux/usb/quirks.h | 3 +++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index f9af3bf33e1b..3afe47870e95 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -137,6 +137,10 @@ struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev)
 
 static int usb_device_supports_lpm(struct usb_device *udev)
 {
+	/* Some devices have trouble with LPM */
+	if (udev->quirks & USB_QUIRK_NO_LPM)
+		return 0;
+
 	/* USB 2.1 (and greater) devices indicate LPM support through
 	 * their USB 2.0 Extended Capabilities BOS descriptor.
 	 */
@@ -4303,6 +4307,8 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
 		goto fail;
 	}
 
+	usb_detect_quirks(udev);
+
 	if (udev->wusb == 0 && le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0201) {
 		retval = usb_get_bos_descriptor(udev);
 		if (!retval) {
@@ -4548,7 +4554,6 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
 		if (status < 0)
 			goto loop;
 
-		usb_detect_quirks(udev);
 		if (udev->quirks & USB_QUIRK_DELAY_INIT)
 			msleep(1000);
 
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 08f321904fb7..a6956cd27334 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -222,6 +222,12 @@ static const struct usb_device_id usb_amd_resume_quirk_list[] = {
 	/* Logitech Optical Mouse M90/M100 */
 	{ USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME },
 
+	/* Blackmagic Design Intensity Shuttle */
+	{ USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM },
+
+	/* Blackmagic Design UltraStudio SDI */
+	{ USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM },
+
 	{ }  /* terminating entry must be last */
 };
 
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
index a4abaeb3fb00..7eb814c60b5d 100644
--- a/include/linux/usb/quirks.h
+++ b/include/linux/usb/quirks.h
@@ -47,4 +47,7 @@
 /* device generates spurious wakeup, ignore remote wakeup capability */
 #define USB_QUIRK_IGNORE_REMOTE_WAKEUP	0x00000200
 
+/* device can't handle Link Power Management */
+#define USB_QUIRK_NO_LPM			BIT(10)
+
 #endif /* __LINUX_USB_QUIRKS_H */
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] USB: whci-hcd: add check for dma mapping error
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (16 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: add quirk for devices with broken LPM Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] usb: Use the USB_SS_MULT() macro to decode burst multiplier for log message Jiri Slaby
                   ` (19 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Alexey Khoroshilov, Jiri Slaby

From: Alexey Khoroshilov <khoroshilov@ispras.ru>

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

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

commit f9fa1887dcf26bd346665a6ae3d3f53dec54cba1 upstream.

qset_fill_page_list() do not check for dma mapping errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/host/whci/qset.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/whci/qset.c b/drivers/usb/host/whci/qset.c
index dc31c425ce01..9f1c0538b211 100644
--- a/drivers/usb/host/whci/qset.c
+++ b/drivers/usb/host/whci/qset.c
@@ -377,6 +377,10 @@ static int qset_fill_page_list(struct whc *whc, struct whc_std *std, gfp_t mem_f
 	if (std->pl_virt == NULL)
 		return -ENOMEM;
 	std->dma_addr = dma_map_single(whc->wusbhc.dev, std->pl_virt, pl_len, DMA_TO_DEVICE);
+	if (dma_mapping_error(whc->wusbhc.dev, std->dma_addr)) {
+		kfree(std->pl_virt);
+		return -EFAULT;
+	}
 
 	for (p = 0; p < std->num_pointers; p++) {
 		std->pl_virt[p].buf_ptr = cpu_to_le64(dma_addr);
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] usb: Use the USB_SS_MULT() macro to decode burst multiplier for log message
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (17 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: whci-hcd: add check for dma mapping error Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] gre6: allow to update all parameters via rtnl Jiri Slaby
                   ` (18 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Ben Hutchings, Jiri Slaby

From: Ben Hutchings <ben@decadent.org.uk>

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

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

commit 5377adb092664d336ac212499961cac5e8728794 upstream.

usb_parse_ss_endpoint_companion() now decodes the burst multiplier
correctly in order to check that it's <= 3, but still uses the wrong
expression if warning that it's > 3.

Fixes: ff30cbc8da42 ("usb: Use the USB_SS_MULT() macro to get the ...")
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/core/config.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index b9560f485d21..5c11adc6a5d6 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -117,7 +117,8 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 		   USB_SS_MULT(desc->bmAttributes) > 3) {
 		dev_warn(ddev, "Isoc endpoint has Mult of %d in "
 				"config %d interface %d altsetting %d ep %d: "
-				"setting to 3\n", desc->bmAttributes + 1,
+				"setting to 3\n",
+				USB_SS_MULT(desc->bmAttributes),
 				cfgno, inum, asnum, ep->desc.bEndpointAddress);
 		ep->ss_ep_comp.bmAttributes = 2;
 	}
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] gre6: allow to update all parameters via rtnl
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (18 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] usb: Use the USB_SS_MULT() macro to decode burst multiplier for log message Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] atl1c: Improve driver not to do order 4 GFP_ATOMIC allocation Jiri Slaby
                   ` (17 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Nicolas Dichtel, David S . Miller, Jiri Slaby

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>

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

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

[ Upstream commit 6a61d4dbf4f54b5683e0f1e58d873cecca7cb977 ]

Parameters were updated only if the kernel was unable to find the tunnel
with the new parameters, ie only if core pamareters were updated (keys,
addr, link, type).
Now it's possible to update ttl, hoplimit, flowinfo and flags.

Fixes: c12b395a4664 ("gre: Support GRE over IPv6")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/ipv6/ip6_gre.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index b2e4c77d9a8c..f719c51369fc 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1546,13 +1546,11 @@ static int ip6gre_changelink(struct net_device *dev, struct nlattr *tb[],
 			return -EEXIST;
 	} else {
 		t = nt;
-
-		ip6gre_tunnel_unlink(ign, t);
-		ip6gre_tnl_change(t, &p, !tb[IFLA_MTU]);
-		ip6gre_tunnel_link(ign, t);
-		netdev_state_change(dev);
 	}
 
+	ip6gre_tunnel_unlink(ign, t);
+	ip6gre_tnl_change(t, &p, !tb[IFLA_MTU]);
+	ip6gre_tunnel_link(ign, t);
 	return 0;
 }
 
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] atl1c: Improve driver not to do order 4 GFP_ATOMIC allocation
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (19 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] gre6: allow to update all parameters via rtnl Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] sctp: use the same clock as if sock source timestamps were on Jiri Slaby
                   ` (16 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Pavel Machek, David S . Miller, Jiri Slaby

From: Pavel Machek <pavel@ucw.cz>

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

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

[ Upstream commit f2a3771ae8aca879c32336c76ad05a017629bae2 ]

atl1c driver is doing order-4 allocation with GFP_ATOMIC
priority. That often breaks  networking after resume. Switch to
GFP_KERNEL. Still not ideal, but should be significantly better.

atl1c_setup_ring_resources() is called from .open() function, and
already uses GFP_KERNEL, so this change is safe.

Signed-off-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index a36a760ada28..fd1b0019b6f9 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -1016,13 +1016,12 @@ static int atl1c_setup_ring_resources(struct atl1c_adapter *adapter)
 		sizeof(struct atl1c_recv_ret_status) * rx_desc_count +
 		8 * 4;
 
-	ring_header->desc = pci_alloc_consistent(pdev, ring_header->size,
-				&ring_header->dma);
+	ring_header->desc = dma_zalloc_coherent(&pdev->dev, ring_header->size,
+						&ring_header->dma, GFP_KERNEL);
 	if (unlikely(!ring_header->desc)) {
-		dev_err(&pdev->dev, "pci_alloc_consistend failed\n");
+		dev_err(&pdev->dev, "could not get memory for DMA buffer\n");
 		goto err_nomem;
 	}
-	memset(ring_header->desc, 0, ring_header->size);
 	/* init TPD ring */
 
 	tpd_ring[0].dma = roundup(ring_header->dma, 8);
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] sctp: use the same clock as if sock source timestamps were on
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (20 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] atl1c: Improve driver not to do order 4 GFP_ATOMIC allocation Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] sctp: update the netstamp_needed counter when copying sockets Jiri Slaby
                   ` (15 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Marcelo Ricardo Leitner, David S . Miller, Jiri Slaby

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

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

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

[ Upstream commit cb5e173ed7c03a0d4630ce68a95a186cce3cc872 ]

SCTP echoes a cookie o INIT ACK chunks that contains a timestamp, for
detecting stale cookies. This cookie is echoed back to the server by the
client and then that timestamp is checked.

Thing is, if the listening socket is using packet timestamping, the
cookie is encoded with ktime_get() value and checked against
ktime_get_real(), as done by __net_timestamp().

The fix is to sctp also use ktime_get_real(), so we can compare bananas
with bananas later no matter if packet timestamping was enabled or not.

Fixes: 52db882f3fc2 ("net: sctp: migrate cookie life from timeval to ktime")
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/sctp/sm_make_chunk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index eb5012b03cfb..a15b78de8e7c 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1664,7 +1664,7 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
 
 	/* Set an expiration time for the cookie.  */
 	cookie->c.expiration = ktime_add(asoc->cookie_life,
-					 ktime_get());
+					 ktime_get_real());
 
 	/* Copy the peer's init packet.  */
 	memcpy(&cookie->c.peer_init[0], init_chunk->chunk_hdr,
@@ -1792,7 +1792,7 @@ no_hmac:
 	if (sock_flag(ep->base.sk, SOCK_TIMESTAMP))
 		kt = skb_get_ktime(skb);
 	else
-		kt = ktime_get();
+		kt = ktime_get_real();
 
 	if (!asoc && ktime_compare(bear_cookie->expiration, kt) < 0) {
 		/*
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] sctp: update the netstamp_needed counter when copying sockets
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (21 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] sctp: use the same clock as if sock source timestamps were on Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] ipv6: sctp: clone options to avoid use after free Jiri Slaby
                   ` (14 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Marcelo Ricardo Leitner, David S . Miller, Jiri Slaby

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

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

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

[ Upstream commit 01ce63c90170283a9855d1db4fe81934dddce648 ]

Dmitry Vyukov reported that SCTP was triggering a WARN on socket destroy
related to disabling sock timestamp.

When SCTP accepts an association or peel one off, it copies sock flags
but forgot to call net_enable_timestamp() if a packet timestamping flag
was copied, leading to extra calls to net_disable_timestamp() whenever
such clones were closed.

The fix is to call net_enable_timestamp() whenever we copy a sock with
that flag on, like tcp does.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 include/net/sock.h | 2 ++
 net/core/sock.c    | 2 --
 net/sctp/socket.c  | 3 +++
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index 4f355e69e5d2..4d631bd6fd16 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -683,6 +683,8 @@ enum sock_flags {
 	SOCK_SELECT_ERR_QUEUE, /* Wake select on error queue */
 };
 
+#define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE))
+
 static inline void sock_copy_flags(struct sock *nsk, struct sock *osk)
 {
 	nsk->sk_flags = osk->sk_flags;
diff --git a/net/core/sock.c b/net/core/sock.c
index 2335a7a130f2..4ac4c13352ab 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -422,8 +422,6 @@ static void sock_warn_obsolete_bsdism(const char *name)
 	}
 }
 
-#define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE))
-
 static void sock_disable_timestamp(struct sock *sk, unsigned long flags)
 {
 	if (sk->sk_flags & flags) {
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index cf9ea9dacfe5..e2b1da09dc79 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -6950,6 +6950,9 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
 	newinet->mc_ttl = 1;
 	newinet->mc_index = 0;
 	newinet->mc_list = NULL;
+
+	if (newsk->sk_flags & SK_FLAGS_TIMESTAMP)
+		net_enable_timestamp();
 }
 
 static inline void sctp_copy_descendant(struct sock *sk_to,
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] ipv6: sctp: clone options to avoid use after free
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (22 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] sctp: update the netstamp_needed counter when copying sockets Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] net: add validation for the socket syscall protocol argument Jiri Slaby
                   ` (13 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Eric Dumazet, David S . Miller, Jiri Slaby

From: Eric Dumazet <edumazet@google.com>

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

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

[ Upstream commit 9470e24f35ab81574da54e69df90c1eb4a96b43f ]

SCTP is lacking proper np->opt cloning at accept() time.

TCP and DCCP use ipv6_dup_options() helper, do the same
in SCTP.

We might later factorize this code in a common helper to avoid
future mistakes.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/sctp/ipv6.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index e7b2d4fe2b6a..a4b6365464bb 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -636,6 +636,7 @@ static struct sock *sctp_v6_create_accept_sk(struct sock *sk,
 	struct sock *newsk;
 	struct ipv6_pinfo *newnp, *np = inet6_sk(sk);
 	struct sctp6_sock *newsctp6sk;
+	struct ipv6_txoptions *opt;
 
 	newsk = sk_alloc(sock_net(sk), PF_INET6, GFP_KERNEL, sk->sk_prot);
 	if (!newsk)
@@ -655,6 +656,13 @@ static struct sock *sctp_v6_create_accept_sk(struct sock *sk,
 
 	memcpy(newnp, np, sizeof(struct ipv6_pinfo));
 
+	rcu_read_lock();
+	opt = rcu_dereference(np->opt);
+	if (opt)
+		opt = ipv6_dup_options(newsk, opt);
+	RCU_INIT_POINTER(newnp->opt, opt);
+	rcu_read_unlock();
+
 	/* Initialize sk's sport, dport, rcv_saddr and daddr for getsockname()
 	 * and getpeername().
 	 */
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] net: add validation for the socket syscall protocol argument
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (23 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] ipv6: sctp: clone options to avoid use after free Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] sh_eth: fix kernel oops in skb_put() Jiri Slaby
                   ` (12 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Hannes Frederic Sowa, Cong Wang, David S . Miller, Jiri Slaby

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

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

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

[ Upstream commit 79462ad02e861803b3840cc782248c7359451cd9 ]

郭永刚 reported that one could simply crash the kernel as root by
using a simple program:

	int socket_fd;
	struct sockaddr_in addr;
	addr.sin_port = 0;
	addr.sin_addr.s_addr = INADDR_ANY;
	addr.sin_family = 10;

	socket_fd = socket(10,3,0x40000000);
	connect(socket_fd , &addr,16);

AF_INET, AF_INET6 sockets actually only support 8-bit protocol
identifiers. inet_sock's skc_protocol field thus is sized accordingly,
thus larger protocol identifiers simply cut off the higher bits and
store a zero in the protocol fields.

This could lead to e.g. NULL function pointer because as a result of
the cut off inet_num is zero and we call down to inet_autobind, which
is NULL for raw sockets.

kernel: Call Trace:
kernel:  [<ffffffff816db90e>] ? inet_autobind+0x2e/0x70
kernel:  [<ffffffff816db9a4>] inet_dgram_connect+0x54/0x80
kernel:  [<ffffffff81645069>] SYSC_connect+0xd9/0x110
kernel:  [<ffffffff810ac51b>] ? ptrace_notify+0x5b/0x80
kernel:  [<ffffffff810236d8>] ? syscall_trace_enter_phase2+0x108/0x200
kernel:  [<ffffffff81645e0e>] SyS_connect+0xe/0x10
kernel:  [<ffffffff81779515>] tracesys_phase2+0x84/0x89

I found no particular commit which introduced this problem.

CVE: CVE-2015-8543
Cc: Cong Wang <cwang@twopensource.com>
Reported-by: 郭永刚 <guoyonggang@360.cn>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 include/net/sock.h     | 1 +
 net/ax25/af_ax25.c     | 3 +++
 net/decnet/af_decnet.c | 3 +++
 net/ipv4/af_inet.c     | 3 +++
 net/ipv6/af_inet6.c    | 3 +++
 net/irda/af_irda.c     | 3 +++
 6 files changed, 16 insertions(+)

diff --git a/include/net/sock.h b/include/net/sock.h
index 4d631bd6fd16..41d98f1d0459 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -358,6 +358,7 @@ struct sock {
 				sk_no_check  : 2,
 				sk_userlocks : 4,
 				sk_protocol  : 8,
+#define SK_PROTOCOL_MAX U8_MAX
 				sk_type      : 16;
 	kmemcheck_bitfield_end(flags);
 	int			sk_wmem_queued;
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 78c474f8f615..c4ee710b2057 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -806,6 +806,9 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol,
 	struct sock *sk;
 	ax25_cb *ax25;
 
+	if (protocol < 0 || protocol > SK_PROTOCOL_MAX)
+		return -EINVAL;
+
 	if (!net_eq(net, &init_net))
 		return -EAFNOSUPPORT;
 
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index dd4d506ef923..c030d5c07178 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -677,6 +677,9 @@ static int dn_create(struct net *net, struct socket *sock, int protocol,
 {
 	struct sock *sk;
 
+	if (protocol < 0 || protocol > SK_PROTOCOL_MAX)
+		return -EINVAL;
+
 	if (!net_eq(net, &init_net))
 		return -EAFNOSUPPORT;
 
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index cfeb85cff4f0..09f9c045aa9c 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -288,6 +288,9 @@ static int inet_create(struct net *net, struct socket *sock, int protocol,
 		if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
 			build_ehash_secret();
 
+	if (protocol < 0 || protocol >= IPPROTO_MAX)
+		return -EINVAL;
+
 	sock->state = SS_UNCONNECTED;
 
 	/* Look for the requested type/protocol pair. */
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 98e09df2d769..0747e1406af6 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -115,6 +115,9 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
 	    !inet_ehash_secret)
 		build_ehash_secret();
 
+	if (protocol < 0 || protocol >= IPPROTO_MAX)
+		return -EINVAL;
+
 	/* Look for the requested type/protocol pair. */
 lookup_protocol:
 	err = -ESOCKTNOSUPPORT;
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index a5e62ef57155..f8133ff5b081 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -1105,6 +1105,9 @@ static int irda_create(struct net *net, struct socket *sock, int protocol,
 
 	IRDA_DEBUG(2, "%s()\n", __func__);
 
+	if (protocol < 0 || protocol > SK_PROTOCOL_MAX)
+		return -EINVAL;
+
 	if (net != &init_net)
 		return -EAFNOSUPPORT;
 
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] sh_eth: fix kernel oops in skb_put()
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (24 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] net: add validation for the socket syscall protocol argument Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] net: fix IP early demux races Jiri Slaby
                   ` (11 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Sergei Shtylyov, David S . Miller, Jiri Slaby

From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

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

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

[ Upstream commit 248be83dcb3feb3f6332eb3d010a016402138484 ]

In a low memory situation the following kernel oops occurs:

Unable to handle kernel NULL pointer dereference at virtual address 00000050
pgd = 8490c000
[00000050] *pgd=4651e831, *pte=00000000, *ppte=00000000
Internal error: Oops: 17 [#1] PREEMPT ARM
Modules linked in:
CPU: 0    Not tainted  (3.4-at16 #9)
PC is at skb_put+0x10/0x98
LR is at sh_eth_poll+0x2c8/0xa10
pc : [<8035f780>]    lr : [<8028bf50>]    psr: 60000113
sp : 84eb1a90  ip : 84eb1ac8  fp : 84eb1ac4
r10: 0000003f  r9 : 000005ea  r8 : 00000000
r7 : 00000000  r6 : 940453b0  r5 : 00030000  r4 : 9381b180
r3 : 00000000  r2 : 00000000  r1 : 000005ea  r0 : 00000000
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
Control: 10c53c7d  Table: 4248c059  DAC: 00000015
Process klogd (pid: 2046, stack limit = 0x84eb02e8)
[...]

This is  because netdev_alloc_skb() fails and 'mdp->rx_skbuff[entry]' is left
NULL but sh_eth_rx() later  uses it without checking.  Add such check...

Reported-by: Yasushi SHOJI <yashi@atmark-techno.com>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/net/ethernet/renesas/sh_eth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 36119b3303d7..bee6e49c5542 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1338,6 +1338,7 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
 		if (mdp->cd->shift_rd0)
 			desc_status >>= 16;
 
+		skb = mdp->rx_skbuff[entry];
 		if (desc_status & (RD_RFS1 | RD_RFS2 | RD_RFS3 | RD_RFS4 |
 				   RD_RFS5 | RD_RFS6 | RD_RFS10)) {
 			ndev->stats.rx_errors++;
@@ -1353,12 +1354,11 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
 				ndev->stats.rx_missed_errors++;
 			if (desc_status & RD_RFS10)
 				ndev->stats.rx_over_errors++;
-		} else {
+		} else	if (skb) {
 			if (!mdp->cd->hw_swap)
 				sh_eth_soft_swap(
 					phys_to_virt(ALIGN(rxdesc->addr, 4)),
 					pkt_len + 2);
-			skb = mdp->rx_skbuff[entry];
 			mdp->rx_skbuff[entry] = NULL;
 			if (mdp->cd->rpadir)
 				skb_reserve(skb, NET_IP_ALIGN);
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] net: fix IP early demux races
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (25 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] sh_eth: fix kernel oops in skb_put() Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] vlan: Fix untag operations of stacked vlans with REORDER_HEADER off Jiri Slaby
                   ` (10 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Eric Dumazet, David S . Miller, Jiri Slaby

From: Eric Dumazet <edumazet@google.com>

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

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

[ Upstream commit 5037e9ef9454917b047f9f3a19b4dd179fbf7cd4 ]

David Wilder reported crashes caused by dst reuse.

<quote David>
  I am seeing a crash on a distro V4.2.3 kernel caused by a double
  release of a dst_entry.  In ipv4_dst_destroy() the call to
  list_empty() finds a poisoned next pointer, indicating the dst_entry
  has already been removed from the list and freed. The crash occurs
  18 to 24 hours into a run of a network stress exerciser.
</quote>

Thanks to his detailed report and analysis, we were able to understand
the core issue.

IP early demux can associate a dst to skb, after a lookup in TCP/UDP
sockets.

When socket cache is not properly set, we want to store into
sk->sk_dst_cache the dst for future IP early demux lookups,
by acquiring a stable refcount on the dst.

Problem is this acquisition is simply using an atomic_inc(),
which works well, unless the dst was queued for destruction from
dst_release() noticing dst refcount went to zero, if DST_NOCACHE
was set on dst.

We need to make sure current refcount is not zero before incrementing
it, or risk double free as David reported.

This patch, being a stable candidate, adds two new helpers, and use
them only from IP early demux problematic paths.

It might be possible to merge in net-next skb_dst_force() and
skb_dst_force_safe(), but I prefer having the smallest patch for stable
kernels : Maybe some skb_dst_force() callers do not expect skb->dst
can suddenly be cleared.

Can probably be backported back to linux-3.6 kernels

Reported-by: David J. Wilder <dwilder@us.ibm.com>
Tested-by: David J. Wilder <dwilder@us.ibm.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 include/net/dst.h   | 33 +++++++++++++++++++++++++++++++++
 include/net/sock.h  |  2 +-
 net/ipv4/tcp_ipv4.c |  9 +++++----
 net/ipv6/tcp_ipv6.c | 11 ++++++-----
 4 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/include/net/dst.h b/include/net/dst.h
index 30cd2f9cd1dd..d30afbdc1a59 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -306,6 +306,39 @@ static inline void skb_dst_force(struct sk_buff *skb)
 	}
 }
 
+/**
+ * dst_hold_safe - Take a reference on a dst if possible
+ * @dst: pointer to dst entry
+ *
+ * This helper returns false if it could not safely
+ * take a reference on a dst.
+ */
+static inline bool dst_hold_safe(struct dst_entry *dst)
+{
+	if (dst->flags & DST_NOCACHE)
+		return atomic_inc_not_zero(&dst->__refcnt);
+	dst_hold(dst);
+	return true;
+}
+
+/**
+ * skb_dst_force_safe - makes sure skb dst is refcounted
+ * @skb: buffer
+ *
+ * If dst is not yet refcounted and not destroyed, grab a ref on it.
+ */
+static inline void skb_dst_force_safe(struct sk_buff *skb)
+{
+	if (skb_dst_is_noref(skb)) {
+		struct dst_entry *dst = skb_dst(skb);
+
+		if (!dst_hold_safe(dst))
+			dst = NULL;
+
+		skb->_skb_refdst = (unsigned long)dst;
+	}
+}
+
 
 /**
  *	__skb_tunnel_rx - prepare skb for rx reinsert
diff --git a/include/net/sock.h b/include/net/sock.h
index 41d98f1d0459..6ed6df149bce 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -760,7 +760,7 @@ extern void sk_stream_write_space(struct sock *sk);
 static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb)
 {
 	/* dont let skb dst not refcounted, we are going to leave rcu lock */
-	skb_dst_force(skb);
+	skb_dst_force_safe(skb);
 
 	if (!sk->sk_backlog.tail)
 		sk->sk_backlog.head = skb;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 624ceca7ffd1..09451a2cbd6a 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1905,7 +1905,7 @@ bool tcp_prequeue(struct sock *sk, struct sk_buff *skb)
 	    skb_queue_len(&tp->ucopy.prequeue) == 0)
 		return false;
 
-	skb_dst_force(skb);
+	skb_dst_force_safe(skb);
 	__skb_queue_tail(&tp->ucopy.prequeue, skb);
 	tp->ucopy.memory += skb->truesize;
 	if (tp->ucopy.memory > sk->sk_rcvbuf) {
@@ -2098,9 +2098,10 @@ void inet_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
 {
 	struct dst_entry *dst = skb_dst(skb);
 
-	dst_hold(dst);
-	sk->sk_rx_dst = dst;
-	inet_sk(sk)->rx_dst_ifindex = skb->skb_iif;
+	if (dst_hold_safe(dst)) {
+		sk->sk_rx_dst = dst;
+		inet_sk(sk)->rx_dst_ifindex = skb->skb_iif;
+	}
 }
 EXPORT_SYMBOL(inet_sk_rx_dst_set);
 
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 65c310d6e92a..90004c6e3bff 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -97,11 +97,12 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
 	struct dst_entry *dst = skb_dst(skb);
 	const struct rt6_info *rt = (const struct rt6_info *)dst;
 
-	dst_hold(dst);
-	sk->sk_rx_dst = dst;
-	inet_sk(sk)->rx_dst_ifindex = skb->skb_iif;
-	if (rt->rt6i_node)
-		inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
+	if (dst_hold_safe(dst)) {
+		sk->sk_rx_dst = dst;
+		inet_sk(sk)->rx_dst_ifindex = skb->skb_iif;
+		if (rt->rt6i_node)
+			inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
+	}
 }
 
 static void tcp_v6_hash(struct sock *sk)
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] vlan: Fix untag operations of stacked vlans with REORDER_HEADER off
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (26 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] net: fix IP early demux races Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] skbuff: Fix offset error in skb_reorder_vlan_header Jiri Slaby
                   ` (9 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Vlad Yasevich, Vladislav Yasevich, David S . Miller, Jiri Slaby

From: Vlad Yasevich <vyasevich@gmail.com>

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

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

[ Upstream commit a6e18ff111701b4ff6947605bfbe9594ec42a6e8 ]

When we have multiple stacked vlan devices all of which have
turned off REORDER_HEADER flag, the untag operation does not
locate the ethernet addresses correctly for nested vlans.
The reason is that in case of REORDER_HEADER flag being off,
the outer vlan headers are put back and the mac_len is adjusted
to account for the presense of the header.  Then, the subsequent
untag operation, for the next level vlan, always use VLAN_ETH_HLEN
to locate the begining of the ethernet header and that ends up
being a multiple of 4 bytes short of the actuall beginning
of the mac header (the multiple depending on the how many vlan
encapsulations ethere are).

As a reslult, if there are multiple levles of vlan devices
with REODER_HEADER being off, the recevied packets end up
being dropped.

To solve this, we use skb->mac_len as the offset.  The value
is always set on receive path and starts out as a ETH_HLEN.
The value is also updated when the vlan header manupations occur
so we know it will be correct.

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/core/skbuff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index de76393a9916..be70fe425542 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3583,7 +3583,8 @@ static struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb)
 		return NULL;
 	}
 
-	memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN);
+	memmove(skb->data - ETH_HLEN, skb->data - skb->mac_len,
+		2 * ETH_ALEN);
 	skb->mac_header += VLAN_HLEN;
 	return skb;
 }
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] skbuff: Fix offset error in skb_reorder_vlan_header
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (27 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] vlan: Fix untag operations of stacked vlans with REORDER_HEADER off Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] pptp: verify sockaddr_len in pptp_bind() and pptp_connect() Jiri Slaby
                   ` (8 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable
  Cc: Vlad Yasevich, Nicolas Dichtel, Patrick McHardy,
	David S . Miller, Jiri Slaby

From: Vlad Yasevich <vyasevich@gmail.com>

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

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

[ Upstream commit f654861569872d10dcb79d9d7ca219b316f94ff0 ]

skb_reorder_vlan_header is called after the vlan header has
been pulled.  As a result the offset of the begining of
the mac header has been incrased by 4 bytes (VLAN_HLEN).
When moving the mac addresses, include this incrase in
the offset calcualation so that the mac addresses are
copied correctly.

Fixes: a6e18ff1117 (vlan: Fix untag operations of stacked vlans with REORDER_HEADER off)
CC: Nicolas Dichtel <nicolas.dichtel@6wind.com>
CC: Patrick McHardy <kaber@trash.net>
Signed-off-by: Vladislav Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/core/skbuff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index be70fe425542..56cdf3bb1e7f 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3583,7 +3583,7 @@ static struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb)
 		return NULL;
 	}
 
-	memmove(skb->data - ETH_HLEN, skb->data - skb->mac_len,
+	memmove(skb->data - ETH_HLEN, skb->data - skb->mac_len - VLAN_HLEN,
 		2 * ETH_ALEN);
 	skb->mac_header += VLAN_HLEN;
 	return skb;
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] pptp: verify sockaddr_len in pptp_bind() and pptp_connect()
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (28 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] skbuff: Fix offset error in skb_reorder_vlan_header Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] bluetooth: Validate socket address length in sco_sock_bind() Jiri Slaby
                   ` (7 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: WANG Cong, David S . Miller, Jiri Slaby

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

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

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

[ Upstream commit 09ccfd238e5a0e670d8178cf50180ea81ae09ae1 ]

Reported-by: Dmitry Vyukov <dvyukov@gmail.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/net/ppp/pptp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index 1dc628ffce2b..0710214df2bf 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -420,6 +420,9 @@ static int pptp_bind(struct socket *sock, struct sockaddr *uservaddr,
 	struct pptp_opt *opt = &po->proto.pptp;
 	int error = 0;
 
+	if (sockaddr_len < sizeof(struct sockaddr_pppox))
+		return -EINVAL;
+
 	lock_sock(sk);
 
 	opt->src_addr = sp->sa_addr.pptp;
@@ -441,6 +444,9 @@ static int pptp_connect(struct socket *sock, struct sockaddr *uservaddr,
 	struct flowi4 fl4;
 	int error = 0;
 
+	if (sockaddr_len < sizeof(struct sockaddr_pppox))
+		return -EINVAL;
+
 	if (sp->sa_protocol != PX_PROTO_PPTP)
 		return -EINVAL;
 
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] bluetooth: Validate socket address length in sco_sock_bind().
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (29 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] pptp: verify sockaddr_len in pptp_bind() and pptp_connect() Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] af_unix: Revert 'lock_interruptible' in stream receive code Jiri Slaby
                   ` (6 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: David S. Miller, Jiri Slaby

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

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

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

[ Upstream commit 5233252fce714053f0151680933571a2da9cbfb4 ]

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/bluetooth/sco.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 4f5f01b779b5..6bfdd333f0d5 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -463,6 +463,9 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
 	if (!addr || addr->sa_family != AF_BLUETOOTH)
 		return -EINVAL;
 
+	if (addr_len < sizeof(struct sockaddr_sco))
+		return -EINVAL;
+
 	lock_sock(sk);
 
 	if (sk->sk_state != BT_OPEN) {
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] af_unix: Revert 'lock_interruptible' in stream receive code
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (30 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] bluetooth: Validate socket address length in sco_sock_bind() Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] x86/setup: Do not reserve crashkernel high memory if low reservation failed Jiri Slaby
                   ` (5 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Rainer Weikusat, David S . Miller, Jiri Slaby

From: Rainer Weikusat <rweikusat@mobileactivedefense.com>

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

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

[ Upstream commit 3822b5c2fc62e3de8a0f33806ff279fb7df92432 ]

With b3ca9b02b00704053a38bfe4c31dbbb9c13595d0, the AF_UNIX SOCK_STREAM
receive code was changed from using mutex_lock(&u->readlock) to
mutex_lock_interruptible(&u->readlock) to prevent signals from being
delayed for an indefinite time if a thread sleeping on the mutex
happened to be selected for handling the signal. But this was never a
problem with the stream receive code (as opposed to its datagram
counterpart) as that never went to sleep waiting for new messages with the
mutex held and thus, wouldn't cause secondary readers to block on the
mutex waiting for the sleeping primary reader. As the interruptible
locking makes the code more complicated in exchange for no benefit,
change it back to using mutex_lock.

Signed-off-by: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/unix/af_unix.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 9ce79ed792cd..31b88dcb0f01 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2088,14 +2088,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
 		memset(&tmp_scm, 0, sizeof(tmp_scm));
 	}
 
-	err = mutex_lock_interruptible(&u->readlock);
-	if (unlikely(err)) {
-		/* recvmsg() in non blocking mode is supposed to return -EAGAIN
-		 * sk_rcvtimeo is not honored by mutex_lock_interruptible()
-		 */
-		err = noblock ? -EAGAIN : -ERESTARTSYS;
-		goto out;
-	}
+	mutex_lock(&u->readlock);
 
 	if (flags & MSG_PEEK)
 		skip = sk_peek_offset(sk, flags);
@@ -2136,12 +2129,12 @@ again:
 
 			timeo = unix_stream_data_wait(sk, timeo, last);
 
-			if (signal_pending(current)
-			    ||  mutex_lock_interruptible(&u->readlock)) {
+			if (signal_pending(current)) {
 				err = sock_intr_errno(timeo);
 				goto out;
 			}
 
+			mutex_lock(&u->readlock);
 			continue;
  unlock:
 			unix_state_unlock(sk);
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] x86/setup: Do not reserve crashkernel high memory if low reservation failed
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (31 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] af_unix: Revert 'lock_interruptible' in stream receive code Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] ahci: Add Marvell 88se91a2 device id Jiri Slaby
                   ` (4 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable
  Cc: Baoquan He, Borislav Petkov, Andrew Morton, Andy Lutomirski,
	Dave Young, H . Peter Anvin, Jiri Kosina, Juergen Gross,
	Linus Torvalds, Mark Salter, Peter Zijlstra, Thomas Gleixner,
	WANG Chao, jerry_hoemann, yinghai, Ingo Molnar, Jiri Slaby

From: Baoquan He <bhe@redhat.com>

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

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

commit eb6db83d105914c246ac5875be76fd4b944833d5 upstream.

People reported that when allocating crashkernel memory using
the ",high" and ",low" syntax, there were cases where the
reservation of the high portion succeeds but the reservation of
the low portion fails.

Then kexec can load the kdump kernel successfully, but booting
the kdump kernel fails as there's no low memory.

The low memory allocation for the kdump kernel can fail on large
systems for a couple of reasons. For example, the manually
specified crashkernel low memory can be too large and thus no
adequate memblock region would be found.

Therefore, we try to reserve low memory for the crash kernel
*after* the high memory portion has been allocated. If that
fails, we free crashkernel high memory too and return. The user
can then take measures accordingly.

Tested-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Baoquan He <bhe@redhat.com>
[ Massage text. ]
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Joerg Roedel <jroedel@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Young <dyoung@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Salter <msalter@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: WANG Chao <chaowang@redhat.com>
Cc: jerry_hoemann@hp.com
Cc: yinghai@kernel.org
Link: http://lkml.kernel.org/r/1445246268-26285-2-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/x86/kernel/setup.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 3ebbd1fdc0a8..158c4751fa6c 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -511,7 +511,7 @@ static void __init memblock_x86_reserve_range_setup_data(void)
 # define CRASH_KERNEL_ADDR_HIGH_MAX	MAXMEM
 #endif
 
-static void __init reserve_crashkernel_low(void)
+static int __init reserve_crashkernel_low(void)
 {
 #ifdef CONFIG_X86_64
 	const unsigned long long alignment = 16<<20;	/* 16M */
@@ -538,17 +538,16 @@ static void __init reserve_crashkernel_low(void)
 	} else {
 		/* passed with crashkernel=0,low ? */
 		if (!low_size)
-			return;
+			return 0;
 	}
 
 	low_base = memblock_find_in_range(low_size, (1ULL<<32),
 					low_size, alignment);
 
 	if (!low_base) {
-		if (!auto_set)
-			pr_info("crashkernel low reservation failed - No suitable area found.\n");
-
-		return;
+		pr_err("Cannot reserve %ldMB crashkernel low memory, please try smaller size.\n",
+		       (unsigned long)(low_size >> 20));
+		return -ENOMEM;
 	}
 
 	memblock_reserve(low_base, low_size);
@@ -560,6 +559,7 @@ static void __init reserve_crashkernel_low(void)
 	crashk_low_res.end   = low_base + low_size - 1;
 	insert_resource(&iomem_resource, &crashk_low_res);
 #endif
+	return 0;
 }
 
 static void __init reserve_crashkernel(void)
@@ -611,6 +611,11 @@ static void __init reserve_crashkernel(void)
 	}
 	memblock_reserve(crash_base, crash_size);
 
+	if (crash_base >= (1ULL << 32) && reserve_crashkernel_low()) {
+		memblock_free(crash_base, crash_size);
+		return;
+	}
+
 	printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
 			"for crashkernel (System RAM: %ldMB)\n",
 			(unsigned long)(crash_size >> 20),
@@ -620,9 +625,6 @@ static void __init reserve_crashkernel(void)
 	crashk_res.start = crash_base;
 	crashk_res.end   = crash_base + crash_size - 1;
 	insert_resource(&iomem_resource, &crashk_res);
-
-	if (crash_base >= (1ULL<<32))
-		reserve_crashkernel_low();
 }
 #else
 static void __init reserve_crashkernel(void)
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] ahci: Add Marvell 88se91a2 device id
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (32 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] x86/setup: Do not reserve crashkernel high memory if low reservation failed Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] ahci: add new Intel device IDs Jiri Slaby
                   ` (3 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Johannes Thumshirn, Tejun Heo, Jiri Slaby

From: Johannes Thumshirn <jthumshirn@suse.de>

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

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

commit a40cf3f38881ce8543ceb9667150b4f2ead4c437 upstream.

Add device id for Marvell 88se91a2

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/ata/ahci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index f354867a3b95..22aefefeff81 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -486,6 +486,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
 	  .driver_data = board_ahci_yes_fbs },			/* 88se9172 on some Gigabyte */
 	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a0),
 	  .driver_data = board_ahci_yes_fbs },
+	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a2), 	/* 88se91a2 */
+	  .driver_data = board_ahci_yes_fbs },
 	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a3),
 	  .driver_data = board_ahci_yes_fbs },
 	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230),
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] ahci: add new Intel device IDs
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (33 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] ahci: Add Marvell 88se91a2 device id Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] target/stat: print full t10_wwn.model buffer Jiri Slaby
                   ` (2 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Alexandra Yates, Tejun Heo, Jiri Slaby

From: Alexandra Yates <alexandra.yates@linux.intel.com>

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

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

commit 56e74338a535cbcc2f2da08b1ea1a92920194364 upstream.

Adding Intel codename Lewisburg platform device IDs for SATA.

Signed-off-by: Alexandra Yates <alexandra.yates@linux.intel.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/ata/ahci.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 22aefefeff81..5bdf151d321c 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -311,6 +311,16 @@ static const struct pci_device_id ahci_pci_tbl[] = {
 	{ PCI_VDEVICE(INTEL, 0x1f37), board_ahci_avn }, /* Avoton RAID */
 	{ PCI_VDEVICE(INTEL, 0x1f3e), board_ahci_avn }, /* Avoton RAID */
 	{ PCI_VDEVICE(INTEL, 0x1f3f), board_ahci_avn }, /* Avoton RAID */
+	{ PCI_VDEVICE(INTEL, 0xa182), board_ahci }, /* Lewisburg AHCI*/
+	{ PCI_VDEVICE(INTEL, 0xa202), board_ahci }, /* Lewisburg AHCI*/
+	{ PCI_VDEVICE(INTEL, 0xa184), board_ahci }, /* Lewisburg RAID*/
+	{ PCI_VDEVICE(INTEL, 0xa204), board_ahci }, /* Lewisburg RAID*/
+	{ PCI_VDEVICE(INTEL, 0xa186), board_ahci }, /* Lewisburg RAID*/
+	{ PCI_VDEVICE(INTEL, 0xa206), board_ahci }, /* Lewisburg RAID*/
+	{ PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* Lewisburg RAID*/
+	{ PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* Lewisburg RAID*/
+	{ PCI_VDEVICE(INTEL, 0xa18e), board_ahci }, /* Lewisburg RAID*/
+	{ PCI_VDEVICE(INTEL, 0xa20e), board_ahci }, /* Lewisburg RAID*/
 	{ PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Wellsburg RAID */
 	{ PCI_VDEVICE(INTEL, 0x2827), board_ahci }, /* Wellsburg RAID */
 	{ PCI_VDEVICE(INTEL, 0x8d02), board_ahci }, /* Wellsburg AHCI */
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] target/stat: print full t10_wwn.model buffer
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (34 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] ahci: add new Intel device IDs Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] RDS: fix race condition when sending a message on unbound socket Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] ALSA: hda - Disable 64bit address for Creative HDA controllers Jiri Slaby
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: David Disseldorp, Nicholas Bellinger, Jiri Slaby

From: David Disseldorp <ddiss@suse.de>

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

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

commit 8f90353950b2da8d877c6ac3dde5e1109257a117 upstream.

Cut 'n paste error saw it only process sizeof(t10_wwn.vendor) characters.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/target/target_core_stat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c
index 9c642e02cba1..5a87ddeb9b13 100644
--- a/drivers/target/target_core_stat.c
+++ b/drivers/target/target_core_stat.c
@@ -333,7 +333,7 @@ static ssize_t target_stat_scsi_lu_show_attr_prod(
 	char str[sizeof(dev->t10_wwn.model)+1];
 
 	/* scsiLuProductId */
-	for (i = 0; i < sizeof(dev->t10_wwn.vendor); i++)
+	for (i = 0; i < sizeof(dev->t10_wwn.model); i++)
 		str[i] = ISPRINT(dev->t10_wwn.model[i]) ?
 			dev->t10_wwn.model[i] : ' ';
 	str[i] = '\0';
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] RDS: fix race condition when sending a message on unbound socket
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (35 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] target/stat: print full t10_wwn.model buffer Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] ALSA: hda - Disable 64bit address for Creative HDA controllers Jiri Slaby
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Quentin Casasnovas, David S . Miller, Jiri Slaby

From: Quentin Casasnovas <quentin.casasnovas@oracle.com>

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

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

commit 8c7188b23474cca017b3ef354c4a58456f68303a upstream.

Sasha's found a NULL pointer dereference in the RDS connection code when
sending a message to an apparently unbound socket.  The problem is caused
by the code checking if the socket is bound in rds_sendmsg(), which checks
the rs_bound_addr field without taking a lock on the socket.  This opens a
race where rs_bound_addr is temporarily set but where the transport is not
in rds_bind(), leading to a NULL pointer dereference when trying to
dereference 'trans' in __rds_conn_create().

Vegard wrote a reproducer for this issue, so kindly ask him to share if
you're interested.

I cannot reproduce the NULL pointer dereference using Vegard's reproducer
with this patch, whereas I could without.

Complete earlier incomplete fix to CVE-2015-6937:

  74e98eb08588 ("RDS: verify the underlying transport exists before creating a connection")

Cc: David S. Miller <davem@davemloft.net>

Reviewed-by: Vegard Nossum <vegard.nossum@oracle.com>
Reviewed-by: Sasha Levin <sasha.levin@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/rds/connection.c | 6 ------
 net/rds/send.c       | 4 +++-
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/net/rds/connection.c b/net/rds/connection.c
index e88bf3976e54..642ad42c416b 100644
--- a/net/rds/connection.c
+++ b/net/rds/connection.c
@@ -177,12 +177,6 @@ static struct rds_connection *__rds_conn_create(__be32 laddr, __be32 faddr,
 		}
 	}
 
-	if (trans == NULL) {
-		kmem_cache_free(rds_conn_slab, conn);
-		conn = ERR_PTR(-ENODEV);
-		goto out;
-	}
-
 	conn->c_trans = trans;
 
 	ret = trans->conn_alloc(conn, gfp);
diff --git a/net/rds/send.c b/net/rds/send.c
index 88eace57dd6b..31c9fa464b11 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -955,11 +955,13 @@ int rds_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
 		release_sock(sk);
 	}
 
-	/* racing with another thread binding seems ok here */
+	lock_sock(sk);
 	if (daddr == 0 || rs->rs_bound_addr == 0) {
+		release_sock(sk);
 		ret = -ENOTCONN; /* XXX not a great errno */
 		goto out;
 	}
+	release_sock(sk);
 
 	/* size of rm including all sgs */
 	ret = rds_rm_size(msg, payload_len);
-- 
2.6.4


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

* [patch added to the 3.12 stable tree] ALSA: hda - Disable 64bit address for Creative HDA controllers
  2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
                   ` (36 preceding siblings ...)
  2016-01-05 17:30 ` [patch added to the 3.12 stable tree] RDS: fix race condition when sending a message on unbound socket Jiri Slaby
@ 2016-01-05 17:30 ` Jiri Slaby
  37 siblings, 0 replies; 39+ messages in thread
From: Jiri Slaby @ 2016-01-05 17:30 UTC (permalink / raw)
  To: stable; +Cc: Takashi Iwai, Jiri Slaby

From: Takashi Iwai <tiwai@suse.de>

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

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

commit cadd16ea33a938d49aee99edd4758cc76048b399 upstream.

We've had many reports that some Creative sound cards with CA0132
don't work well.  Some reported that it starts working after reloading
the module, while some reported it starts working when a 32bit kernel
is used.  All these facts seem implying that the chip fails to
communicate when the buffer is located in 64bit address.

This patch addresses these issues by just adding AZX_DCAPS_NO_64BIT
flag to the corresponding PCI entries.  I casually had a chance to
test an SB Recon3D board, and indeed this seems helping.

Although this hasn't been tested on all Creative devices, it's safer
to assume that this restriction applies to the rest of them, too.  So
the flag is applied to all Creative entries.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 sound/pci/hda/hda_intel.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index ab4b984ef607..a7315298ee10 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -640,7 +640,9 @@ enum {
 	 AZX_DCAPS_ALIGN_BUFSIZE | AZX_DCAPS_NO_64BIT)
 
 #define AZX_DCAPS_PRESET_CTHDA \
-	(AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_4K_BDLE_BOUNDARY)
+	(AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB |\
+	 AZX_DCAPS_NO_64BIT |\
+	 AZX_DCAPS_4K_BDLE_BOUNDARY)
 
 /*
  * VGA-switcher support
@@ -4247,11 +4249,13 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
 	  .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8,
 	  .class_mask = 0xffffff,
 	  .driver_data = AZX_DRIVER_CTX | AZX_DCAPS_CTX_WORKAROUND |
+	  AZX_DCAPS_NO_64BIT |
 	  AZX_DCAPS_RIRB_PRE_DELAY | AZX_DCAPS_POSFIX_LPIB },
 #else
 	/* this entry seems still valid -- i.e. without emu20kx chip */
 	{ PCI_DEVICE(0x1102, 0x0009),
 	  .driver_data = AZX_DRIVER_CTX | AZX_DCAPS_CTX_WORKAROUND |
+	  AZX_DCAPS_NO_64BIT |
 	  AZX_DCAPS_RIRB_PRE_DELAY | AZX_DCAPS_POSFIX_LPIB },
 #endif
 	/* Vortex86MX */
-- 
2.6.4


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

end of thread, other threads:[~2016-01-05 17:30 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-05 17:29 [patch added to the 3.12 stable tree] tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] module: Call module notifier on failure after complete_formation() Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] netfilter: ipt_rpfilter: remove the nh_scope test in rpfilter_lookup_reverse Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] netfilter: ip6t_SYNPROXY: fix NULL pointer dereference Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] firewire: core: use correct vendor/model IDs Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] ip6mr: call del_timer_sync() in ip6mr_free_table() Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] Btrfs: fix race leading to incorrect item deletion when dropping extents Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] Btrfs: fix race leading to BUG_ON when running delalloc for nodatacow Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] ext4: fix potential use after free in __ext4_journal_stop Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] ext4, jbd2: ensure entering into panic after recording an error in superblock Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] firewire: ohci: fix JMicron JMB38x IT context discovery Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] nfs4: start callback_ident at idr 1 Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] nfs: if we have no valid attrs, then don't declare the attribute cache valid Jiri Slaby
2016-01-05 17:29 ` [patch added to the 3.12 stable tree] ocfs2: fix umask ignored issue Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: cdc_acm: Ignore Infineon Flash Loader utility Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: serial: Another Infineon flash loader USB ID Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: cp210x: Remove CP2110 ID from compatibility list Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: add quirk for devices with broken LPM Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] USB: whci-hcd: add check for dma mapping error Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] usb: Use the USB_SS_MULT() macro to decode burst multiplier for log message Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] gre6: allow to update all parameters via rtnl Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] atl1c: Improve driver not to do order 4 GFP_ATOMIC allocation Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] sctp: use the same clock as if sock source timestamps were on Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] sctp: update the netstamp_needed counter when copying sockets Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] ipv6: sctp: clone options to avoid use after free Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] net: add validation for the socket syscall protocol argument Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] sh_eth: fix kernel oops in skb_put() Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] net: fix IP early demux races Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] vlan: Fix untag operations of stacked vlans with REORDER_HEADER off Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] skbuff: Fix offset error in skb_reorder_vlan_header Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] pptp: verify sockaddr_len in pptp_bind() and pptp_connect() Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] bluetooth: Validate socket address length in sco_sock_bind() Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] af_unix: Revert 'lock_interruptible' in stream receive code Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] x86/setup: Do not reserve crashkernel high memory if low reservation failed Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] ahci: Add Marvell 88se91a2 device id Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] ahci: add new Intel device IDs Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] target/stat: print full t10_wwn.model buffer Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] RDS: fix race condition when sending a message on unbound socket Jiri Slaby
2016-01-05 17:30 ` [patch added to the 3.12 stable tree] ALSA: hda - Disable 64bit address for Creative HDA controllers Jiri Slaby

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.