All of lore.kernel.org
 help / color / mirror / Atom feed
* [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build"
@ 2015-06-16 11:56 Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] ARM: 8221/1: PJ4: allow building in Thumb-2 mode Sasha Levin
                   ` (28 more replies)
  0 siblings, 29 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Sasha Levin

This reverts commit a821ac4c66382f9d6387c8311608f13c6749fea9.

That patch is not suitable for 3.18.

Reported-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 tools/vm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/vm/Makefile b/tools/vm/Makefile
index c604f3e..3d907da 100644
--- a/tools/vm/Makefile
+++ b/tools/vm/Makefile
@@ -3,7 +3,7 @@
 TARGETS=page-types slabinfo
 
 LIB_DIR = ../lib/api
-LIBS = $(LIB_DIR)/libapi.a
+LIBS = $(LIB_DIR)/libapikfs.a
 
 CC = $(CROSS_COMPILE)gcc
 CFLAGS = -Wall -Wextra -I../lib/
-- 
2.1.0


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

* [added to the 3.18 stable tree] ARM: 8221/1: PJ4: allow building in Thumb-2 mode
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 12:31   ` Ard Biesheuvel
  2015-06-16 11:56 ` [added to the 3.18 stable tree] fs/binfmt_elf.c:load_elf_binary(): return -EINVAL on zero-length mappings Sasha Levin
                   ` (27 subsequent siblings)
  28 siblings, 1 reply; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Ard Biesheuvel, Russell King, Kevin Hilman, Sasha Levin

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Two files that get included when building the multi_v7_defconfig target
fail to build when selecting THUMB2_KERNEL for this configuration.

In both cases, we can just build the file as ARM code, as none of its
symbols are exported to modules, so there are no interworking concerns.
In the iwmmxt.S case, add ENDPROC() declarations so the symbols are
annotated as functions, resulting in the linker to emit the appropriate
mode switches.

Acked-by: Nicolas Pitre <nico@linaro.org>
Tested-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
(cherry picked from commit 13d1b9575ac2c2da143cd2236b6cf0fc314570f8)
Cc: <stable@vger.kernel.org> # v3.18+
Signed-off-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 arch/arm/kernel/Makefile |  1 +
 arch/arm/kernel/iwmmxt.S | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 03120e6..2ecc7d1 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -84,6 +84,7 @@ obj-$(CONFIG_CPU_PJ4B)		+= pj4-cp0.o
 obj-$(CONFIG_IWMMXT)		+= iwmmxt.o
 obj-$(CONFIG_PERF_EVENTS)	+= perf_regs.o
 obj-$(CONFIG_HW_PERF_EVENTS)	+= perf_event.o perf_event_cpu.o
+CFLAGS_pj4-cp0.o		:= -marm
 AFLAGS_iwmmxt.o			:= -Wa,-mcpu=iwmmxt
 obj-$(CONFIG_ARM_CPU_TOPOLOGY)  += topology.o
 
diff --git a/arch/arm/kernel/iwmmxt.S b/arch/arm/kernel/iwmmxt.S
index ad58e56..49fadbd 100644
--- a/arch/arm/kernel/iwmmxt.S
+++ b/arch/arm/kernel/iwmmxt.S
@@ -58,6 +58,7 @@
 #define MMX_SIZE		(0x98)
 
 	.text
+	.arm
 
 /*
  * Lazy switching of Concan coprocessor context
@@ -182,6 +183,8 @@ concan_load:
 	tmcr	wCon, r2
 	ret	lr
 
+ENDPROC(iwmmxt_task_enable)
+
 /*
  * Back up Concan regs to save area and disable access to them
  * (mainly for gdb or sleep mode usage)
@@ -232,6 +235,8 @@ ENTRY(iwmmxt_task_disable)
 1:	msr	cpsr_c, ip			@ restore interrupt mode
 	ldmfd	sp!, {r4, pc}
 
+ENDPROC(iwmmxt_task_disable)
+
 /*
  * Copy Concan state to given memory address
  *
@@ -268,6 +273,8 @@ ENTRY(iwmmxt_task_copy)
 	msr	cpsr_c, ip			@ restore interrupt mode
 	ret	r3
 
+ENDPROC(iwmmxt_task_copy)
+
 /*
  * Restore Concan state from given memory address
  *
@@ -304,6 +311,8 @@ ENTRY(iwmmxt_task_restore)
 	msr	cpsr_c, ip			@ restore interrupt mode
 	ret	r3
 
+ENDPROC(iwmmxt_task_restore)
+
 /*
  * Concan handling on task switch
  *
@@ -335,6 +344,8 @@ ENTRY(iwmmxt_task_switch)
 	mrc	p15, 0, r1, c2, c0, 0
 	sub	pc, lr, r1, lsr #32		@ cpwait and return
 
+ENDPROC(iwmmxt_task_switch)
+
 /*
  * Remove Concan ownership of given task
  *
@@ -353,6 +364,8 @@ ENTRY(iwmmxt_task_release)
 	msr	cpsr_c, r2			@ restore interrupts
 	ret	lr
 
+ENDPROC(iwmmxt_task_release)
+
 	.data
 concan_owner:
 	.word	0
-- 
2.1.0


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

* [added to the 3.18 stable tree] fs/binfmt_elf.c:load_elf_binary(): return -EINVAL on zero-length mappings
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] ARM: 8221/1: PJ4: allow building in Thumb-2 mode Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net: core: Correct an over-stringent device loop detection Sasha Levin
                   ` (26 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Andrew Morton, Michael Davidson, Linus Torvalds,
	Greg Kroah-Hartman, Sasha Levin

From: Andrew Morton <akpm@linux-foundation.org>

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

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

[ Upstream commit 073aba98f6a2235e2ac4a8402b1a131ab032876e ]

commit 2b1d3ae940acd11be44c6eced5873d47c2e00ffa upstream.

load_elf_binary() returns `retval', not `error'.

Fixes: a87938b2e246b81b4fb ("fs/binfmt_elf.c: fix bug in loading of PIE binaries")
Reported-by: James Hogan <james.hogan@imgtec.com>
Cc: Michael Davidson <md@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 3dd2497..e39fe28 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -816,7 +816,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
 			total_size = total_mapping_size(elf_phdata,
 							loc->elf_ex.e_phnum);
 			if (!total_size) {
-				error = -EINVAL;
+				retval = -EINVAL;
 				goto out_free_dentry;
 			}
 		}
-- 
2.1.0


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

* [added to the 3.18 stable tree] net: core: Correct an over-stringent device loop detection.
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] ARM: 8221/1: PJ4: allow building in Thumb-2 mode Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] fs/binfmt_elf.c:load_elf_binary(): return -EINVAL on zero-length mappings Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] x86: bpf_jit: fix FROM_BE16 and FROM_LE16/32 instructions Sasha Levin
                   ` (25 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Vlad Yasevich, Vladislav Yasevich, David S. Miller, Sasha Levin

From: Vlad Yasevich <vyasevich@gmail.com>

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

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

[ Upstream commit d66bf7dd27573ee5ea90484899ee952c19ccb194 ]

The code in __netdev_upper_dev_link() has an over-stringent
loop detection logic that actually prevents valid configurations
from working correctly.

In particular, the logic returns an error if an upper device
is already in the list of all upper devices for a given dev.
This particular check seems to be a overzealous as it disallows
perfectly valid configurations.  For example:
  # ip l a link eth0 name eth0.10 type vlan id 10
  # ip l a dev br0 typ bridge
  # ip l s eth0.10 master br0
  # ip l s eth0 master br0  <--- Will fail

If you switch the last two commands (add eth0 first), then both
will succeed.  If after that, you remove eth0 and try to re-add
it, it will fail!

It appears to be enough to simply check adj_list to keeps things
safe.

I've tried stacking multiple devices multiple times in all different
combinations, and either rx_handler registration prevented the stacking
of the device linking cought the error.

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
Acked-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Veaceslav Falico <vfalico@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 5cdbc1b..fb96258 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5080,7 +5080,7 @@ static int __netdev_upper_dev_link(struct net_device *dev,
 	if (__netdev_find_adj(upper_dev, dev, &upper_dev->all_adj_list.upper))
 		return -EBUSY;
 
-	if (__netdev_find_adj(dev, upper_dev, &dev->all_adj_list.upper))
+	if (__netdev_find_adj(dev, upper_dev, &dev->adj_list.upper))
 		return -EEXIST;
 
 	if (master && netdev_master_upper_dev_get(dev))
-- 
2.1.0


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

* [added to the 3.18 stable tree] x86: bpf_jit: fix FROM_BE16 and FROM_LE16/32 instructions
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (2 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net: core: Correct an over-stringent device loop detection Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] x86: bpf_jit: fix compilation of large bpf programs Sasha Levin
                   ` (24 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Alexei Starovoitov, David S. Miller, Sasha Levin

From: Alexei Starovoitov <ast@plumgrid.com>

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

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

[ Upstream commit 343f845b375989f1753f605902931fa939aa2223 ]

FROM_BE16:
'ror %reg, 8' doesn't clear upper bits of the register,
so use additional 'movzwl' insn to zero extend 16 bits into 64

FROM_LE16:
should zero extend lower 16 bits into 64 bit

FROM_LE32:
should zero extend lower 32 bits into 64 bit

Fixes: 89aa075832b0 ("net: sock: allow eBPF programs to be attached to sockets")
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 arch/x86/net/bpf_jit_comp.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 3f62734..3de886f 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -558,6 +558,13 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
 				if (is_ereg(dst_reg))
 					EMIT1(0x41);
 				EMIT3(0xC1, add_1reg(0xC8, dst_reg), 8);
+
+				/* emit 'movzwl eax, ax' */
+				if (is_ereg(dst_reg))
+					EMIT3(0x45, 0x0F, 0xB7);
+				else
+					EMIT2(0x0F, 0xB7);
+				EMIT1(add_2reg(0xC0, dst_reg, dst_reg));
 				break;
 			case 32:
 				/* emit 'bswap eax' to swap lower 4 bytes */
@@ -576,6 +583,27 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
 			break;
 
 		case BPF_ALU | BPF_END | BPF_FROM_LE:
+			switch (imm32) {
+			case 16:
+				/* emit 'movzwl eax, ax' to zero extend 16-bit
+				 * into 64 bit
+				 */
+				if (is_ereg(dst_reg))
+					EMIT3(0x45, 0x0F, 0xB7);
+				else
+					EMIT2(0x0F, 0xB7);
+				EMIT1(add_2reg(0xC0, dst_reg, dst_reg));
+				break;
+			case 32:
+				/* emit 'mov eax, eax' to clear upper 32-bits */
+				if (is_ereg(dst_reg))
+					EMIT1(0x45);
+				EMIT2(0x89, add_2reg(0xC0, dst_reg, dst_reg));
+				break;
+			case 64:
+				/* nop */
+				break;
+			}
 			break;
 
 			/* ST: *(u8*)(dst_reg + off) = imm */
-- 
2.1.0


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

* [added to the 3.18 stable tree] x86: bpf_jit: fix compilation of large bpf programs
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (3 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] x86: bpf_jit: fix FROM_BE16 and FROM_LE16/32 instructions Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net: phy: Allow EEE for all RGMII variants Sasha Levin
                   ` (23 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Alexei Starovoitov, David S. Miller, Sasha Levin

From: Alexei Starovoitov <ast@plumgrid.com>

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

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

[ Upstream commit 3f7352bf21f8fd7ba3e2fcef9488756f188e12be ]

x86 has variable length encoding. x86 JIT compiler is trying
to pick the shortest encoding for given bpf instruction.
While doing so the jump targets are changing, so JIT is doing
multiple passes over the program. Typical program needs 3 passes.
Some very short programs converge with 2 passes. Large programs
may need 4 or 5. But specially crafted bpf programs may hit the
pass limit and if the program converges on the last iteration
the JIT compiler will be producing an image full of 'int 3' insns.
Fix this corner case by doing final iteration over bpf program.

Fixes: 0a14842f5a3c ("net: filter: Just In Time compiler for x86-64")
Reported-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Tested-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 arch/x86/net/bpf_jit_comp.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 3de886f..82003a3 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -964,7 +964,12 @@ void bpf_int_jit_compile(struct bpf_prog *prog)
 	}
 	ctx.cleanup_addr = proglen;
 
-	for (pass = 0; pass < 10; pass++) {
+	/* JITed image shrinks with every pass and the loop iterates
+	 * until the image stops shrinking. Very large bpf programs
+	 * may converge on the last pass. In such case do one more
+	 * pass to emit the final image
+	 */
+	for (pass = 0; pass < 10 || image; pass++) {
 		proglen = do_jit(prog, addrs, image, oldproglen, &ctx);
 		if (proglen <= 0) {
 			image = NULL;
-- 
2.1.0


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

* [added to the 3.18 stable tree] net: phy: Allow EEE for all RGMII variants
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (4 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] x86: bpf_jit: fix compilation of large bpf programs Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] rtnl/bond: don't send rtnl msg for unregistered iface Sasha Levin
                   ` (22 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Florian Fainelli, David S. Miller, Sasha Levin

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

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

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

[ Upstream commit 7e14069651591c81046ffaec13c3dac8cb70f5fb ]

RGMII interfaces come in multiple flavors: RGMII with transmit or
receive internal delay, no delays at all, or delays in both direction.

This change extends the initial check for PHY_INTERFACE_MODE_RGMII to
cover all of these variants since EEE should be allowed for any of these
modes, since it is a property of the RGMII, hence Gigabit PHY capability
more than the RGMII electrical interface and its delays.

Fixes: a59a4d192166 ("phy: add the EEE support and the way to access to the MMD registers")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 drivers/net/phy/phy.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index dc1f6f0..91d6d03 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1050,13 +1050,14 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
 {
 	/* According to 802.3az,the EEE is supported only in full duplex-mode.
 	 * Also EEE feature is active when core is operating with MII, GMII
-	 * or RGMII. Internal PHYs are also allowed to proceed and should
-	 * return an error if they do not support EEE.
+	 * or RGMII (all kinds). Internal PHYs are also allowed to proceed and
+	 * should return an error if they do not support EEE.
 	 */
 	if ((phydev->duplex == DUPLEX_FULL) &&
 	    ((phydev->interface == PHY_INTERFACE_MODE_MII) ||
 	    (phydev->interface == PHY_INTERFACE_MODE_GMII) ||
-	    (phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
+	    (phydev->interface >= PHY_INTERFACE_MODE_RGMII &&
+	     phydev->interface <= PHY_INTERFACE_MODE_RGMII_TXID) ||
 	     phy_is_internal(phydev))) {
 		int eee_lp, eee_cap, eee_adv;
 		u32 lp, cap, adv;
-- 
2.1.0


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

* [added to the 3.18 stable tree] rtnl/bond: don't send rtnl msg for unregistered iface
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (5 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net: phy: Allow EEE for all RGMII variants Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] tcp/ipv6: fix flow label setting in TIME_WAIT state Sasha Levin
                   ` (21 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Nicolas Dichtel, Jiri Pirko, David S. Miller, Sasha Levin

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

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

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

[ Upstream commit ed2a80ab7b76f11af0b2c6255709c4ebf164b667 ]

Before the patch, the command 'ip link add bond2 type bond mode 802.3ad'
causes the kernel to send a rtnl message for the bond2 interface, with an
ifindex 0.

'ip monitor' shows:
0: bond2: <BROADCAST,MULTICAST,MASTER> mtu 1500 state DOWN group default
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
9: bond2@NONE: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default
    link/ether ea:3e:1f:53:92:7b brd ff:ff:ff:ff:ff:ff
[snip]

The patch fixes the spotted bug by checking in bond driver if the interface
is registered before calling the notifier chain.
It also adds a check in rtmsg_ifinfo() to prevent this kind of bug in the
future.

Fixes: d4261e565000 ("bonding: create netlink event when bonding option is changed")
CC: Jiri Pirko <jiri@resnulli.us>
Reported-by: Julien Meunier <julien.meunier@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 drivers/net/bonding/bond_options.c | 2 +-
 net/core/rtnetlink.c               | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index b62697f..f1c5394 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -625,7 +625,7 @@ int __bond_opt_set(struct bonding *bond,
 out:
 	if (ret)
 		bond_opt_error_interpret(bond, opt, ret, val);
-	else
+	else if (bond->dev->reg_state == NETREG_REGISTERED)
 		call_netdevice_notifiers(NETDEV_CHANGEINFODATA, bond->dev);
 
 	return ret;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index c522f7a..24d3242 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2229,6 +2229,9 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned int change,
 	int err = -ENOBUFS;
 	size_t if_info_size;
 
+	if (dev->reg_state != NETREG_REGISTERED)
+		return;
+
 	skb = nlmsg_new((if_info_size = if_nlmsg_size(dev, 0)), flags);
 	if (skb == NULL)
 		goto errout;
-- 
2.1.0


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

* [added to the 3.18 stable tree] tcp/ipv6: fix flow label setting in TIME_WAIT state
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (6 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] rtnl/bond: don't send rtnl msg for unregistered iface Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net/ipv6/udp: Fix ipv6 multicast socket filter regression Sasha Levin
                   ` (20 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Florent Fourcot, David S. Miller, Sasha Levin

From: Florent Fourcot <florent.fourcot@enst-bretagne.fr>

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

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

[ Upstream commit 21858cd02dabcf290564cbf4769b101eba54d7bb ]

commit 1d13a96c74fc ("ipv6: tcp: fix flowlabel value in ACK messages
send from TIME_WAIT") added the flow label in the last TCP packets.
Unfortunately, it was not casted properly.

This patch replace the buggy shift with be32_to_cpu/cpu_to_be32.

Fixes: 1d13a96c74fc ("ipv6: tcp: fix flowlabel value in ACK messages")
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/ipv4/tcp_minisocks.c | 2 +-
 net/ipv6/tcp_ipv6.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 63d2680..71d001d 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -297,7 +297,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
 			tw->tw_v6_daddr = sk->sk_v6_daddr;
 			tw->tw_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
 			tw->tw_tclass = np->tclass;
-			tw->tw_flowlabel = np->flow_label >> 12;
+			tw->tw_flowlabel = be32_to_cpu(np->flow_label & IPV6_FLOWLABEL_MASK);
 			tw->tw_ipv6only = sk->sk_ipv6only;
 		}
 #endif
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 79fe5851..a3f9f11 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -975,7 +975,7 @@ static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)
 			tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale,
 			tcp_time_stamp + tcptw->tw_ts_offset,
 			tcptw->tw_ts_recent, tw->tw_bound_dev_if, tcp_twsk_md5_key(tcptw),
-			tw->tw_tclass, (tw->tw_flowlabel << 12));
+			tw->tw_tclass, cpu_to_be32(tw->tw_flowlabel));
 
 	inet_twsk_put(tw);
 }
-- 
2.1.0


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

* [added to the 3.18 stable tree] net/ipv6/udp: Fix ipv6 multicast socket filter regression
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (7 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] tcp/ipv6: fix flow label setting in TIME_WAIT state Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net: sched: fix call_rcu() race on classifier module unloads Sasha Levin
                   ` (19 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Henning Rogge, David S. Miller, Sasha Levin

From: Henning Rogge <hrogge@gmail.com>

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

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

[ Upstream commit 33b4b015e1a1ca7a8fdce40af5e71642a8ea355c ]

Commit <5cf3d46192fc> ("udp: Simplify__udp*_lib_mcast_deliver")
simplified the filter for incoming IPv6 multicast but removed
the check of the local socket address and the UDP destination
address.

This patch restores the filter to prevent sockets bound to a IPv6
multicast IP to receive other UDP traffic link unicast.

Signed-off-by: Henning Rogge <hrogge@gmail.com>
Fixes: 5cf3d46192fc ("udp: Simplify__udp*_lib_mcast_deliver")
Cc: "David S. Miller" <davem@davemloft.net>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/ipv6/udp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index f6ba535..d651691 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -721,7 +721,9 @@ static bool __udp_v6_is_mcast_sock(struct net *net, struct sock *sk,
 	    (inet->inet_dport && inet->inet_dport != rmt_port) ||
 	    (!ipv6_addr_any(&sk->sk_v6_daddr) &&
 		    !ipv6_addr_equal(&sk->sk_v6_daddr, rmt_addr)) ||
-	    (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
+	    (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif) ||
+	    (!ipv6_addr_any(&sk->sk_v6_rcv_saddr) &&
+		    !ipv6_addr_equal(&sk->sk_v6_rcv_saddr, loc_addr)))
 		return false;
 	if (!inet6_mc_check(sk, loc_addr, rmt_addr))
 		return false;
-- 
2.1.0


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

* [added to the 3.18 stable tree] net: sched: fix call_rcu() race on classifier module unloads
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (8 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net/ipv6/udp: Fix ipv6 multicast socket filter regression Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] ipv4: Avoid crashing in ip_error Sasha Levin
                   ` (18 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Daniel Borkmann, John Fastabend, Eric Dumazet, Thomas Graf,
	Jamal Hadi Salim, Alexei Starovoitov, David S. Miller,
	Sasha Levin

From: Daniel Borkmann <daniel@iogearbox.net>

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

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

[ Upstream commit c78e1746d3ad7d548bdf3fe491898cc453911a49 ]

Vijay reported that a loop as simple as ...

  while true; do
    tc qdisc add dev foo root handle 1: prio
    tc filter add dev foo parent 1: u32 match u32 0 0  flowid 1
    tc qdisc del dev foo root
    rmmod cls_u32
  done

... will panic the kernel. Moreover, he bisected the change
apparently introducing it to 78fd1d0ab072 ("netlink: Re-add
locking to netlink_lookup() and seq walker").

The removal of synchronize_net() from the netlink socket
triggering the qdisc to be removed, seems to have uncovered
an RCU resp. module reference count race from the tc API.
Given that RCU conversion was done after e341694e3eb5 ("netlink:
Convert netlink_lookup() to use RCU protected hash table")
which added the synchronize_net() originally, occasion of
hitting the bug was less likely (not impossible though):

When qdiscs that i) support attaching classifiers and,
ii) have at least one of them attached, get deleted, they
invoke tcf_destroy_chain(), and thus call into ->destroy()
handler from a classifier module.

After RCU conversion, all classifier that have an internal
prio list, unlink them and initiate freeing via call_rcu()
deferral.

Meanhile, tcf_destroy() releases already reference to the
tp->ops->owner module before the queued RCU callback handler
has been invoked.

Subsequent rmmod on the classifier module is then not prevented
since all module references are already dropped.

By the time, the kernel invokes the RCU callback handler from
the module, that function address is then invalid.

One way to fix it would be to add an rcu_barrier() to
unregister_tcf_proto_ops() to wait for all pending call_rcu()s
to complete.

synchronize_rcu() is not appropriate as under heavy RCU
callback load, registered call_rcu()s could be deferred
longer than a grace period. In case we don't have any pending
call_rcu()s, the barrier is allowed to return immediately.

Since we came here via unregister_tcf_proto_ops(), there
are no users of a given classifier anymore. Further nested
call_rcu()s pointing into the module space are not being
done anywhere.

Only cls_bpf_delete_prog() may schedule a work item, to
unlock pages eventually, but that is not in the range/context
of cls_bpf anymore.

Fixes: 25d8c0d55f24 ("net: rcu-ify tcf_proto")
Fixes: 9888faefe132 ("net: sched: cls_basic use RCU")
Reported-by: Vijay Subramanian <subramanian.vijay@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: John Fastabend <john.r.fastabend@intel.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Thomas Graf <tgraf@suug.ch>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Tested-by: Vijay Subramanian <subramanian.vijay@gmail.com>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/sched/cls_api.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index aad6a67..fae8870 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -81,6 +81,11 @@ int unregister_tcf_proto_ops(struct tcf_proto_ops *ops)
 	struct tcf_proto_ops *t;
 	int rc = -ENOENT;
 
+	/* Wait for outstanding call_rcu()s, if any, from a
+	 * tcf_proto_ops's destroy() handler.
+	 */
+	rcu_barrier();
+
 	write_lock(&cls_mod_lock);
 	list_for_each_entry(t, &tcf_proto_base, head) {
 		if (t == ops) {
-- 
2.1.0


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

* [added to the 3.18 stable tree] ipv4: Avoid crashing in ip_error
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (9 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net: sched: fix call_rcu() race on classifier module unloads Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] cdc_ncm: Fix tx_bytes statistics Sasha Levin
                   ` (17 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Eric W. Biederman, Vittorio Gambaletta, David S. Miller, Sasha Levin

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

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

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

[ Upstream commit 381c759d9916c42959515ad34a6d467e24a88e93 ]

ip_error does not check if in_dev is NULL before dereferencing it.

IThe following sequence of calls is possible:
CPU A                          CPU B
ip_rcv_finish
    ip_route_input_noref()
        ip_route_input_slow()
                               inetdev_destroy()
    dst_input()

With the result that a network device can be destroyed while processing
an input packet.

A crash was triggered with only unicast packets in flight, and
forwarding enabled on the only network device.   The error condition
was created by the removal of the network device.

As such it is likely the that error code was -EHOSTUNREACH, and the
action taken by ip_error (if in_dev had been accessible) would have
been to not increment any counters and to have tried and likely failed
to send an icmp error as the network device is going away.

Therefore handle this weird case by just dropping the packet if
!in_dev.  It will result in dropping the packet sooner, and will not
result in an actual change of behavior.

Fixes: 251da4130115b ("ipv4: Cache ip_error() routes even when not forwarding.")
Reported-by: Vittorio Gambaletta <linuxbugs@vittgam.net>
Tested-by: Vittorio Gambaletta <linuxbugs@vittgam.net>
Signed-off-by: Vittorio Gambaletta <linuxbugs@vittgam.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/ipv4/route.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index d58dd0e..b7ac498 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -903,6 +903,10 @@ static int ip_error(struct sk_buff *skb)
 	bool send;
 	int code;
 
+	/* IP on this device is disabled. */
+	if (!in_dev)
+		goto out;
+
 	net = dev_net(rt->dst.dev);
 	if (!IN_DEV_FORWARD(in_dev)) {
 		switch (rt->dst.error) {
-- 
2.1.0


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

* [added to the 3.18 stable tree] cdc_ncm: Fix tx_bytes statistics
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (10 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] ipv4: Avoid crashing in ip_error Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] bridge: fix parsing of MLDv2 reports Sasha Levin
                   ` (16 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Bjørn Mork, Ben Hutchings, David S. Miller, Sasha Levin

From: Bjørn Mork <bjorn@mork.no>

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

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

[ Upstream commit 44f6731d8b68fa02f5ed65eaceac41f8c3c9279e ]

The tx_curr_frame_payload field is u32. When we try to calculate a
small negative delta based on it, we end up with a positive integer
close to 2^32 instead.  So the tx_bytes pointer increases by about
2^32 for every transmitted frame.

Fix by calculating the delta as a signed long.

Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
Reported-by: Florian Bruhin <me@the-compiler.org>
Fixes: 7a1e890e2168 ("usbnet: Fix tx_bytes statistic running backward in cdc_ncm")
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 drivers/net/usb/cdc_ncm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index c3e4da9..8067b8f 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1182,7 +1182,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
 	 * payload data instead.
 	 */
 	usbnet_set_skb_tx_stats(skb_out, n,
-				ctx->tx_curr_frame_payload - skb_out->len);
+				(long)ctx->tx_curr_frame_payload - skb_out->len);
 
 	return skb_out;
 
-- 
2.1.0


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

* [added to the 3.18 stable tree] bridge: fix parsing of MLDv2 reports
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (11 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] cdc_ncm: Fix tx_bytes statistics Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net: dp83640: fix broken calibration routine Sasha Levin
                   ` (15 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Thadeu Lima de Souza Cascardo, David S. Miller, Sasha Levin

From: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>

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

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

[ Upstream commit 47cc84ce0c2fe75c99ea5963c4b5704dd78ead54 ]

When more than a multicast address is present in a MLDv2 report, all but
the first address is ignored, because the code breaks out of the loop if
there has not been an error adding that address.

This has caused failures when two guests connected through the bridge
tried to communicate using IPv6. Neighbor discoveries would not be
transmitted to the other guest when both used a link-local address and a
static address.

This only happens when there is a MLDv2 querier in the network.

The fix will only break out of the loop when there is a failure adding a
multicast address.

The mdb before the patch:

dev ovirtmgmt port vnet0 grp ff02::1:ff7d:6603 temp
dev ovirtmgmt port vnet1 grp ff02::1:ff7d:6604 temp
dev ovirtmgmt port bond0.86 grp ff02::2 temp

After the patch:

dev ovirtmgmt port vnet0 grp ff02::1:ff7d:6603 temp
dev ovirtmgmt port vnet1 grp ff02::1:ff7d:6604 temp
dev ovirtmgmt port bond0.86 grp ff02::fb temp
dev ovirtmgmt port bond0.86 grp ff02::2 temp
dev ovirtmgmt port bond0.86 grp ff02::d temp
dev ovirtmgmt port vnet0 grp ff02::1:ff00:76 temp
dev ovirtmgmt port bond0.86 grp ff02::16 temp
dev ovirtmgmt port vnet1 grp ff02::1:ff00:77 temp
dev ovirtmgmt port bond0.86 grp ff02::1:ff00:def temp
dev ovirtmgmt port bond0.86 grp ff02::1:ffa1:40bf temp

Fixes: 08b202b67264 ("bridge br_multicast: IPv6 MLD support.")
Reported-by: Rik Theys <Rik.Theys@esat.kuleuven.be>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Tested-by: Rik Theys <Rik.Theys@esat.kuleuven.be>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/bridge/br_multicast.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index c465876..cd02185 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1071,7 +1071,7 @@ static int br_ip6_multicast_mld2_report(struct net_bridge *br,
 
 		err = br_ip6_multicast_add_group(br, port, &grec->grec_mca,
 						 vid);
-		if (!err)
+		if (err)
 			break;
 	}
 
-- 
2.1.0


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

* [added to the 3.18 stable tree] net: dp83640: fix broken calibration routine.
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (12 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] bridge: fix parsing of MLDv2 reports Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net: dp83640: reinforce locking rules Sasha Levin
                   ` (14 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Richard Cochran, David S. Miller, Sasha Levin

From: Richard Cochran <richardcochran@gmail.com>

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

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

[ Upstream commit 397a253af5031de4a4612210055935309af4472c ]

Currently, the calibration function that corrects the initial offsets
among multiple devices only works the first time.  If the function is
called more than once, the calibration fails and bogus offsets will be
programmed into the devices.

In a well hidden spot, the device documentation tells that trigger indexes
0 and 1 are special in allowing the TRIG_IF_LATE flag to actually work.

This patch fixes the issue by using one of the special triggers during the
recalibration method.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 drivers/net/phy/dp83640.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index e22e602..5eb3c8e 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -47,7 +47,7 @@
 #define PSF_TX		0x1000
 #define EXT_EVENT	1
 #define CAL_EVENT	7
-#define CAL_TRIGGER	7
+#define CAL_TRIGGER	1
 #define DP83640_N_PINS	12
 
 #define MII_DP83640_MICR 0x11
-- 
2.1.0


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

* [added to the 3.18 stable tree] net: dp83640: reinforce locking rules.
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (13 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net: dp83640: fix broken calibration routine Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net: dp83640: fix improper double spin locking Sasha Levin
                   ` (13 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Richard Cochran, David S. Miller, Sasha Levin

From: Richard Cochran <richardcochran@gmail.com>

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

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

[ Upstream commit a935865c828c8cd20501f618c69f659a5b6d6a5f ]

Callers of the ext_write function are supposed to hold a mutex that
protects the state of the dialed page, but one caller was missing the
lock from the very start, and over time the code has been changed
without following the rule.  This patch cleans up the call sites in
violation of the rule.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 drivers/net/phy/dp83640.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 5eb3c8e..4f3cf1b 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -495,7 +495,9 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp,
 			else
 				evnt |= EVNT_RISE;
 		}
+		mutex_lock(&clock->extreg_lock);
 		ext_write(0, phydev, PAGE5, PTP_EVNT, evnt);
+		mutex_unlock(&clock->extreg_lock);
 		return 0;
 
 	case PTP_CLK_REQ_PEROUT:
@@ -531,6 +533,8 @@ static u8 status_frame_src[6] = { 0x08, 0x00, 0x17, 0x0B, 0x6B, 0x0F };
 
 static void enable_status_frames(struct phy_device *phydev, bool on)
 {
+	struct dp83640_private *dp83640 = phydev->priv;
+	struct dp83640_clock *clock = dp83640->clock;
 	u16 cfg0 = 0, ver;
 
 	if (on)
@@ -538,9 +542,13 @@ static void enable_status_frames(struct phy_device *phydev, bool on)
 
 	ver = (PSF_PTPVER & VERSIONPTP_MASK) << VERSIONPTP_SHIFT;
 
+	mutex_lock(&clock->extreg_lock);
+
 	ext_write(0, phydev, PAGE5, PSF_CFG0, cfg0);
 	ext_write(0, phydev, PAGE6, PSF_CFG1, ver);
 
+	mutex_unlock(&clock->extreg_lock);
+
 	if (!phydev->attached_dev) {
 		pr_warn("expected to find an attached netdevice\n");
 		return;
@@ -1172,11 +1180,18 @@ static int dp83640_config_init(struct phy_device *phydev)
 
 	if (clock->chosen && !list_empty(&clock->phylist))
 		recalibrate(clock);
-	else
+	else {
+		mutex_lock(&clock->extreg_lock);
 		enable_broadcast(phydev, clock->page, 1);
+		mutex_unlock(&clock->extreg_lock);
+	}
 
 	enable_status_frames(phydev, true);
+
+	mutex_lock(&clock->extreg_lock);
 	ext_write(0, phydev, PAGE4, PTP_CTL, PTP_ENABLE);
+	mutex_unlock(&clock->extreg_lock);
+
 	return 0;
 }
 
-- 
2.1.0


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

* [added to the 3.18 stable tree] net: dp83640: fix improper double spin locking.
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (14 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net: dp83640: reinforce locking rules Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] unix/caif: sk_socket can disappear when state is unlocked Sasha Levin
                   ` (12 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Richard Cochran, David S. Miller, Sasha Levin

From: Richard Cochran <richardcochran@gmail.com>

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

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

[ Upstream commit adbe088f6f8b0b7701fe07f51fe6f2bd602a6665 ]

A pair of nested spin locks was introduced in commit 63502b8d0
"dp83640: Fix receive timestamp race condition".

Unfortunately the 'flags' parameter was reused for the inner lock,
clobbering the originally saved IRQ state.  This patch fixes the issue
by changing the inner lock to plain spin_lock without irqsave.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 drivers/net/phy/dp83640.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 4f3cf1b..c5789cd 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -845,7 +845,7 @@ static void decode_rxts(struct dp83640_private *dp83640,
 	list_del_init(&rxts->list);
 	phy2rxts(phy_rxts, rxts);
 
-	spin_lock_irqsave(&dp83640->rx_queue.lock, flags);
+	spin_lock(&dp83640->rx_queue.lock);
 	skb_queue_walk(&dp83640->rx_queue, skb) {
 		struct dp83640_skb_info *skb_info;
 
@@ -860,7 +860,7 @@ static void decode_rxts(struct dp83640_private *dp83640,
 			break;
 		}
 	}
-	spin_unlock_irqrestore(&dp83640->rx_queue.lock, flags);
+	spin_unlock(&dp83640->rx_queue.lock);
 
 	if (!shhwtstamps)
 		list_add_tail(&rxts->list, &dp83640->rxts);
-- 
2.1.0


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

* [added to the 3.18 stable tree] unix/caif: sk_socket can disappear when state is unlocked
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (15 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net: dp83640: fix improper double spin locking Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] xen/netback: Properly initialize credit_bytes Sasha Levin
                   ` (11 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Mark Salyzyn, David S. Miller, Sasha Levin

From: Mark Salyzyn <salyzyn@android.com>

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

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

[ Upstream commit b48732e4a48d80ed4a14812f0bab09560846514e ]

got a rare NULL pointer dereference in clear_bit

Signed-off-by: Mark Salyzyn <salyzyn@android.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
----
v2: switch to sock_flag(sk, SOCK_DEAD) and added net/caif/caif_socket.c
v3: return -ECONNRESET in upstream caller of wait function for SOCK_DEAD
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/caif/caif_socket.c | 8 ++++++++
 net/unix/af_unix.c     | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
index 765c781..5e10ee0 100644
--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -330,6 +330,10 @@ static long caif_stream_data_wait(struct sock *sk, long timeo)
 		release_sock(sk);
 		timeo = schedule_timeout(timeo);
 		lock_sock(sk);
+
+		if (sock_flag(sk, SOCK_DEAD))
+			break;
+
 		clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
 	}
 
@@ -374,6 +378,10 @@ static int caif_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
 		struct sk_buff *skb;
 
 		lock_sock(sk);
+		if (sock_flag(sk, SOCK_DEAD)) {
+			err = -ECONNRESET;
+			goto unlock;
+		}
 		skb = skb_dequeue(&sk->sk_receive_queue);
 		caif_check_flow_release(sk);
 
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index e968843..8232118 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1899,6 +1899,10 @@ static long unix_stream_data_wait(struct sock *sk, long timeo,
 		unix_state_unlock(sk);
 		timeo = freezable_schedule_timeout(timeo);
 		unix_state_lock(sk);
+
+		if (sock_flag(sk, SOCK_DEAD))
+			break;
+
 		clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
 	}
 
@@ -1963,6 +1967,10 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
 		struct sk_buff *skb, *last;
 
 		unix_state_lock(sk);
+		if (sock_flag(sk, SOCK_DEAD)) {
+			err = -ECONNRESET;
+			goto unlock;
+		}
 		last = skb = skb_peek(&sk->sk_receive_queue);
 again:
 		if (skb == NULL) {
-- 
2.1.0


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

* [added to the 3.18 stable tree] xen/netback: Properly initialize credit_bytes
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (16 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] unix/caif: sk_socket can disappear when state is unlocked Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net_sched: invoke ->attach() after setting dev->qdisc Sasha Levin
                   ` (10 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Ross Lagerwall, David S. Miller, Sasha Levin

From: Ross Lagerwall <ross.lagerwall@citrix.com>

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

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

[ Upstream commit ce0e5c522d3924090c20e774359809a7aa08c44c ]

Commit e9ce7cb6b107 ("xen-netback: Factor queue-specific data into queue
struct") introduced a regression when moving queue-specific data into
the queue struct by failing to set the credit_bytes field. This
prevented bandwidth limiting from working. Initialize the field as it
was done before multiqueue support was added.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 drivers/net/xen-netback/xenbus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index c047282..7cda7a4 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -735,6 +735,7 @@ static void connect(struct backend_info *be)
 			goto err;
 		}
 
+		queue->credit_bytes = credit_bytes;
 		queue->remaining_credit = credit_bytes;
 		queue->credit_usec = credit_usec;
 
-- 
2.1.0


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

* [added to the 3.18 stable tree] net_sched: invoke ->attach() after setting dev->qdisc
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (17 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] xen/netback: Properly initialize credit_bytes Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] sctp: Fix mangled IPv4 addresses on a IPv6 listening socket Sasha Levin
                   ` (9 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: WANG Cong, Jamal Hadi Salim, David S. Miller, Sasha Levin

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

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

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

[ Upstream commit 86e363dc3b50bfd50a1f315934583fbda673ab8d ]

For mq qdisc, we add per tx queue qdisc to root qdisc
for display purpose, however, that happens too early,
before the new dev->qdisc is finally set, this causes
q->list points to an old root qdisc which is going to be
freed right before assigning with a new one.

Fix this by moving ->attach() after setting dev->qdisc.

For the record, this fixes the following crash:

 ------------[ cut here ]------------
 WARNING: CPU: 1 PID: 975 at lib/list_debug.c:59 __list_del_entry+0x5a/0x98()
 list_del corruption. prev->next should be ffff8800d1998ae8, but was 6b6b6b6b6b6b6b6b
 CPU: 1 PID: 975 Comm: tc Not tainted 4.1.0-rc4+ #1019
 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
  0000000000000009 ffff8800d73fb928 ffffffff81a44e7f 0000000047574756
  ffff8800d73fb978 ffff8800d73fb968 ffffffff810790da ffff8800cfc4cd20
  ffffffff814e725b ffff8800d1998ae8 ffffffff82381250 0000000000000000
 Call Trace:
  [<ffffffff81a44e7f>] dump_stack+0x4c/0x65
  [<ffffffff810790da>] warn_slowpath_common+0x9c/0xb6
  [<ffffffff814e725b>] ? __list_del_entry+0x5a/0x98
  [<ffffffff81079162>] warn_slowpath_fmt+0x46/0x48
  [<ffffffff81820eb0>] ? dev_graft_qdisc+0x5e/0x6a
  [<ffffffff814e725b>] __list_del_entry+0x5a/0x98
  [<ffffffff814e72a7>] list_del+0xe/0x2d
  [<ffffffff81822f05>] qdisc_list_del+0x1e/0x20
  [<ffffffff81820cd1>] qdisc_destroy+0x30/0xd6
  [<ffffffff81822676>] qdisc_graft+0x11d/0x243
  [<ffffffff818233c1>] tc_get_qdisc+0x1a6/0x1d4
  [<ffffffff810b5eaf>] ? mark_lock+0x2e/0x226
  [<ffffffff817ff8f5>] rtnetlink_rcv_msg+0x181/0x194
  [<ffffffff817ff72e>] ? rtnl_lock+0x17/0x19
  [<ffffffff817ff72e>] ? rtnl_lock+0x17/0x19
  [<ffffffff817ff774>] ? __rtnl_unlock+0x17/0x17
  [<ffffffff81855dc6>] netlink_rcv_skb+0x4d/0x93
  [<ffffffff817ff756>] rtnetlink_rcv+0x26/0x2d
  [<ffffffff818544b2>] netlink_unicast+0xcb/0x150
  [<ffffffff81161db9>] ? might_fault+0x59/0xa9
  [<ffffffff81854f78>] netlink_sendmsg+0x4fa/0x51c
  [<ffffffff817d6e09>] sock_sendmsg_nosec+0x12/0x1d
  [<ffffffff817d8967>] sock_sendmsg+0x29/0x2e
  [<ffffffff817d8cf3>] ___sys_sendmsg+0x1b4/0x23a
  [<ffffffff8100a1b8>] ? native_sched_clock+0x35/0x37
  [<ffffffff810a1d83>] ? sched_clock_local+0x12/0x72
  [<ffffffff810a1fd4>] ? sched_clock_cpu+0x9e/0xb7
  [<ffffffff810def2a>] ? current_kernel_time+0xe/0x32
  [<ffffffff810b4bc5>] ? lock_release_holdtime.part.29+0x71/0x7f
  [<ffffffff810ddebf>] ? read_seqcount_begin.constprop.27+0x5f/0x76
  [<ffffffff810b6292>] ? trace_hardirqs_on_caller+0x17d/0x199
  [<ffffffff811b14d5>] ? __fget_light+0x50/0x78
  [<ffffffff817d9808>] __sys_sendmsg+0x42/0x60
  [<ffffffff817d9838>] SyS_sendmsg+0x12/0x1c
  [<ffffffff81a50e97>] system_call_fastpath+0x12/0x6f
 ---[ end trace ef29d3fb28e97ae7 ]---

For long term, we probably need to clean up the qdisc_graft() code
in case it hides other bugs like this.

Fixes: 95dc19299f74 ("pkt_sched: give visibility to mq slave qdiscs")
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/sched/sch_api.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 76f402e..a25fae3 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -815,10 +815,8 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
 		if (dev->flags & IFF_UP)
 			dev_deactivate(dev);
 
-		if (new && new->ops->attach) {
-			new->ops->attach(new);
-			num_q = 0;
-		}
+		if (new && new->ops->attach)
+			goto skip;
 
 		for (i = 0; i < num_q; i++) {
 			struct netdev_queue *dev_queue = dev_ingress_queue(dev);
@@ -834,12 +832,16 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
 				qdisc_destroy(old);
 		}
 
+skip:
 		if (!ingress) {
 			notify_and_destroy(net, skb, n, classid,
 					   dev->qdisc, new);
 			if (new && !new->ops->attach)
 				atomic_inc(&new->refcnt);
 			dev->qdisc = new ? : &noop_qdisc;
+
+			if (new && new->ops->attach)
+				new->ops->attach(new);
 		} else {
 			notify_and_destroy(net, skb, n, classid, old, new);
 		}
-- 
2.1.0


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

* [added to the 3.18 stable tree] sctp: Fix mangled IPv4 addresses on a IPv6 listening socket
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (18 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] net_sched: invoke ->attach() after setting dev->qdisc Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] bridge: fix br_multicast_query_expired() bug Sasha Levin
                   ` (8 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Jason Gunthorpe, David S. Miller, Sasha Levin

From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>

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

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

[ Upstream commit 9302d7bb0c5cd46be5706859301f18c137b2439f ]

sctp_v4_map_v6 was subtly writing and reading from members
of a union in a way the clobbered data it needed to read before
it read it.

Zeroing the v6 flowinfo overwrites the v4 sin_addr with 0, meaning
that every place that calls sctp_v4_map_v6 gets ::ffff:0.0.0.0 as the
result.

Reorder things to guarantee correct behaviour no matter what the
union layout is.

This impacts user space clients that open an IPv6 SCTP socket and
receive IPv4 connections. Prior to 299ee user space would see a
sockaddr with AF_INET and a correct address, after 299ee the sockaddr
is AF_INET6, but the address is wrong.

Fixes: 299ee123e198 (sctp: Fixup v4mapped behaviour to comply with Sock API)
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 include/net/sctp/sctp.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 856f01c..230775f 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -571,11 +571,14 @@ static inline void sctp_v6_map_v4(union sctp_addr *addr)
 /* Map v4 address to v4-mapped v6 address */
 static inline void sctp_v4_map_v6(union sctp_addr *addr)
 {
+	__be16 port;
+
+	port = addr->v4.sin_port;
+	addr->v6.sin6_addr.s6_addr32[3] = addr->v4.sin_addr.s_addr;
+	addr->v6.sin6_port = port;
 	addr->v6.sin6_family = AF_INET6;
 	addr->v6.sin6_flowinfo = 0;
 	addr->v6.sin6_scope_id = 0;
-	addr->v6.sin6_port = addr->v4.sin_port;
-	addr->v6.sin6_addr.s6_addr32[3] = addr->v4.sin_addr.s_addr;
 	addr->v6.sin6_addr.s6_addr32[0] = 0;
 	addr->v6.sin6_addr.s6_addr32[1] = 0;
 	addr->v6.sin6_addr.s6_addr32[2] = htonl(0x0000ffff);
-- 
2.1.0


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

* [added to the 3.18 stable tree] bridge: fix br_multicast_query_expired() bug
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (19 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] sctp: Fix mangled IPv4 addresses on a IPv6 listening socket Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] udp: fix behavior of wrong checksums Sasha Levin
                   ` (7 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Eric Dumazet, Linus Lüssing, Steinar H. Gunderson,
	David S. Miller, Sasha Levin

From: Eric Dumazet <edumazet@google.com>

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

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

[ Upstream commit 71d9f6149cac8fc6646adfb2a6f3b0de6ddd23f6 ]

br_multicast_query_expired() querier argument is a pointer to
a struct bridge_mcast_querier :

struct bridge_mcast_querier {
        struct br_ip addr;
        struct net_bridge_port __rcu    *port;
};

Intent of the code was to clear port field, not the pointer to querier.

Fixes: 2cd4143192e8 ("bridge: memorize and export selected IGMP/MLD querier port")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Acked-by: Linus Lüssing <linus.luessing@c0d3.blue>
Cc: Linus Lüssing <linus.luessing@web.de>
Cc: Steinar H. Gunderson <sesse@samfundet.no>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/bridge/br_multicast.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index cd02185..b0aee78 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1821,7 +1821,7 @@ static void br_multicast_query_expired(struct net_bridge *br,
 	if (query->startup_sent < br->multicast_startup_query_count)
 		query->startup_sent++;
 
-	RCU_INIT_POINTER(querier, NULL);
+	RCU_INIT_POINTER(querier->port, NULL);
 	br_multicast_send_query(br, NULL, query);
 	spin_unlock(&br->multicast_lock);
 }
-- 
2.1.0


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

* [added to the 3.18 stable tree] udp: fix behavior of wrong checksums
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (20 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] bridge: fix br_multicast_query_expired() bug Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] tcp: fix child sockets to use system default congestion control if not set Sasha Levin
                   ` (6 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Eric Dumazet, Willem de Bruijn, David S. Miller, Sasha Levin

From: Eric Dumazet <edumazet@google.com>

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

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

[ Upstream commit beb39db59d14990e401e235faf66a6b9b31240b0 ]

We have two problems in UDP stack related to bogus checksums :

1) We return -EAGAIN to application even if receive queue is not empty.
   This breaks applications using edge trigger epoll()

2) Under UDP flood, we can loop forever without yielding to other
   processes, potentially hanging the host, especially on non SMP.

This patch is an attempt to make things better.

We might in the future add extra support for rt applications
wanting to better control time spent doing a recv() in a hostile
environment. For example we could validate checksums before queuing
packets in socket receive queue.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/ipv4/udp.c | 6 ++----
 net/ipv6/udp.c | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index cd0db54..52d2db8 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1336,10 +1336,8 @@ csum_copy_err:
 	}
 	unlock_sock_fast(sk, slow);
 
-	if (noblock)
-		return -EAGAIN;
-
-	/* starting over for a new packet */
+	/* starting over for a new packet, but check if we need to yield */
+	cond_resched();
 	msg->msg_flags &= ~MSG_TRUNC;
 	goto try_again;
 }
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index d651691..dd530f0 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -514,10 +514,8 @@ csum_copy_err:
 	}
 	unlock_sock_fast(sk, slow);
 
-	if (noblock)
-		return -EAGAIN;
-
-	/* starting over for a new packet */
+	/* starting over for a new packet, but check if we need to yield */
+	cond_resched();
 	msg->msg_flags &= ~MSG_TRUNC;
 	goto try_again;
 }
-- 
2.1.0


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

* [added to the 3.18 stable tree] tcp: fix child sockets to use system default congestion control if not set
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (21 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] udp: fix behavior of wrong checksums Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] xen: netback: read hotplug script once at start of day Sasha Levin
                   ` (5 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Neal Cardwell, Florian Westphal, Daniel Borkmann, Glenn Judd,
	Stephen Hemminger, Eric Dumazet, Yuchung Cheng, David S. Miller,
	Sasha Levin

From: Neal Cardwell <ncardwell@google.com>

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

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

[ Upstream commit 9f950415e4e28e7cfae2e416b43e862e8101d996 ]

Linux 3.17 and earlier are explicitly engineered so that if the app
doesn't specifically request a CC module on a listener before the SYN
arrives, then the child gets the system default CC when the connection
is established. See tcp_init_congestion_control() in 3.17 or earlier,
which says "if no choice made yet assign the current value set as
default". The change ("net: tcp: assign tcp cong_ops when tcp sk is
created") altered these semantics, so that children got their parent
listener's congestion control even if the system default had changed
after the listener was created.

This commit returns to those original semantics from 3.17 and earlier,
since they are the original semantics from 2007 in 4d4d3d1e8 ("[TCP]:
Congestion control initialization."), and some Linux congestion
control workflows depend on that.

In summary, if a listener socket specifically sets TCP_CONGESTION to
"x", or the route locks the CC module to "x", then the child gets
"x". Otherwise the child gets current system default from
net.ipv4.tcp_congestion_control. That's the behavior in 3.17 and
earlier, and this commit restores that.

Fixes: 55d8694fa82c ("net: tcp: assign tcp cong_ops when tcp sk is created")
Cc: Florian Westphal <fw@strlen.de>
Cc: Daniel Borkmann <dborkman@redhat.com>
Cc: Glenn Judd <glenn.judd@morganstanley.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 include/net/inet_connection_sock.h | 3 ++-
 net/ipv4/tcp_cong.c                | 6 ++++--
 net/ipv4/tcp_minisocks.c           | 3 ++-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index 848e85c..24d5c09 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -98,7 +98,8 @@ struct inet_connection_sock {
 	const struct tcp_congestion_ops *icsk_ca_ops;
 	const struct inet_connection_sock_af_ops *icsk_af_ops;
 	unsigned int		  (*icsk_sync_mss)(struct sock *sk, u32 pmtu);
-	__u8			  icsk_ca_state;
+	__u8			  icsk_ca_state:7,
+				  icsk_ca_setsockopt:1;
 	__u8			  icsk_retransmits;
 	__u8			  icsk_pending;
 	__u8			  icsk_backoff;
diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index b1c5970..b3316c8 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -248,9 +248,10 @@ int tcp_set_congestion_control(struct sock *sk, const char *name)
 	ca = tcp_ca_find(name);
 
 	/* no change asking for existing value */
-	if (ca == icsk->icsk_ca_ops)
+	if (ca == icsk->icsk_ca_ops) {
+		icsk->icsk_ca_setsockopt = 1;
 		goto out;
-
+	}
 #ifdef CONFIG_MODULES
 	/* not found attempt to autoload module */
 	if (!ca && capable(CAP_NET_ADMIN)) {
@@ -273,6 +274,7 @@ int tcp_set_congestion_control(struct sock *sk, const char *name)
 	else {
 		tcp_cleanup_congestion_control(sk);
 		icsk->icsk_ca_ops = ca;
+		icsk->icsk_ca_setsockopt = 1;
 
 		if (sk->sk_state != TCP_CLOSE && icsk->icsk_ca_ops->init)
 			icsk->icsk_ca_ops->init(sk);
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 71d001d..2f66671 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -451,7 +451,8 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
 		newtp->snd_cwnd = TCP_INIT_CWND;
 		newtp->snd_cwnd_cnt = 0;
 
-		if (!try_module_get(newicsk->icsk_ca_ops->owner))
+		if (!newicsk->icsk_ca_setsockopt ||
+		    !try_module_get(newicsk->icsk_ca_ops->owner))
 			tcp_assign_congestion_control(newsk);
 
 		tcp_set_ca_state(newsk, TCP_CA_Open);
-- 
2.1.0


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

* [added to the 3.18 stable tree] xen: netback: read hotplug script once at start of day.
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (22 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] tcp: fix child sockets to use system default congestion control if not set Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] ipv4/udp: Verify multicast group is ours in upd_v4_early_demux() Sasha Levin
                   ` (4 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Ian Campbell, Ian Campbell, David S. Miller, Sasha Levin

From: Ian Campbell <Ian.Campbell@citrix.com>

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

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

[ Upstream commit 31a418986a5852034d520a5bab546821ff1ccf3d ]

When we come to tear things down in netback_remove() and generate the
uevent it is possible that the xenstore directory has already been
removed (details below).

In such cases netback_uevent() won't be able to read the hotplug
script and will write a xenstore error node.

A recent change to the hypervisor exposed this race such that we now
sometimes lose it (where apparently we didn't ever before).

Instead read the hotplug script configuration during setup and use it
for the lifetime of the backend device.

The apparently more obvious fix of moving the transition to
state=Closed in netback_remove() to after the uevent does not work
because it is possible that we are already in state=Closed (in
reaction to the guest having disconnected as it shutdown). Being
already in Closed means the toolstack is at liberty to start tearing
down the xenstore directories. In principal it might be possible to
arrange to unregister the device sooner (e.g on transition to Closing)
such that xenstore would still be there but this state machine is
fragile and prone to anger...

A modern Xen system only relies on the hotplug uevent for driver
domains, when the backend is in the same domain as the toolstack it
will run the necessary setup/teardown directly in the correct sequence
wrt xenstore changes.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 drivers/net/xen-netback/xenbus.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 7cda7a4..d9d1e2a 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -34,6 +34,8 @@ struct backend_info {
 	enum xenbus_state frontend_state;
 	struct xenbus_watch hotplug_status_watch;
 	u8 have_hotplug_status_watch:1;
+
+	const char *hotplug_script;
 };
 
 static int connect_rings(struct backend_info *be, struct xenvif_queue *queue);
@@ -236,6 +238,7 @@ static int netback_remove(struct xenbus_device *dev)
 		xenvif_free(be->vif);
 		be->vif = NULL;
 	}
+	kfree(be->hotplug_script);
 	kfree(be);
 	dev_set_drvdata(&dev->dev, NULL);
 	return 0;
@@ -253,6 +256,7 @@ static int netback_probe(struct xenbus_device *dev,
 	struct xenbus_transaction xbt;
 	int err;
 	int sg;
+	const char *script;
 	struct backend_info *be = kzalloc(sizeof(struct backend_info),
 					  GFP_KERNEL);
 	if (!be) {
@@ -345,6 +349,15 @@ static int netback_probe(struct xenbus_device *dev,
 	if (err)
 		pr_debug("Error writing multi-queue-max-queues\n");
 
+	script = xenbus_read(XBT_NIL, dev->nodename, "script", NULL);
+	if (IS_ERR(script)) {
+		err = PTR_ERR(script);
+		xenbus_dev_fatal(dev, err, "reading script");
+		goto fail;
+	}
+
+	be->hotplug_script = script;
+
 	err = xenbus_switch_state(dev, XenbusStateInitWait);
 	if (err)
 		goto fail;
@@ -377,22 +390,14 @@ static int netback_uevent(struct xenbus_device *xdev,
 			  struct kobj_uevent_env *env)
 {
 	struct backend_info *be = dev_get_drvdata(&xdev->dev);
-	char *val;
 
-	val = xenbus_read(XBT_NIL, xdev->nodename, "script", NULL);
-	if (IS_ERR(val)) {
-		int err = PTR_ERR(val);
-		xenbus_dev_fatal(xdev, err, "reading script");
-		return err;
-	} else {
-		if (add_uevent_var(env, "script=%s", val)) {
-			kfree(val);
-			return -ENOMEM;
-		}
-		kfree(val);
-	}
+	if (!be)
+		return 0;
+
+	if (add_uevent_var(env, "script=%s", be->hotplug_script))
+		return -ENOMEM;
 
-	if (!be || !be->vif)
+	if (!be->vif)
 		return 0;
 
 	return add_uevent_var(env, "vif=%s", be->vif->dev->name);
-- 
2.1.0


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

* [added to the 3.18 stable tree] ipv4/udp: Verify multicast group is ours in upd_v4_early_demux()
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (23 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] xen: netback: read hotplug script once at start of day Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] be2net: Replace dma/pci_alloc_coherent() calls with dma_zalloc_coherent() Sasha Levin
                   ` (3 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Shawn Bohrer, David S. Miller, Sasha Levin

From: Shawn Bohrer <sbohrer@rgmadvisors.com>

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

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

[ Upstream commit 6e540309326188f769e03bb4c6dd8ff6752930c2 ]

421b3885bf6d56391297844f43fb7154a6396e12 "udp: ipv4: Add udp early
demux" introduced a regression that allowed sockets bound to INADDR_ANY
to receive packets from multicast groups that the socket had not joined.
For example a socket that had joined 224.168.2.9 could also receive
packets from 225.168.2.9 despite not having joined that group if
ip_early_demux is enabled.

Fix this by calling ip_check_mc_rcu() in udp_v4_early_demux() to verify
that the multicast packet is indeed ours.

Signed-off-by: Shawn Bohrer <sbohrer@rgmadvisors.com>
Reported-by: Yurij M. Plotnikov <Yurij.Plotnikov@oktetlabs.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/ipv4/udp.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 52d2db8..c5e3194 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -90,6 +90,7 @@
 #include <linux/socket.h>
 #include <linux/sockios.h>
 #include <linux/igmp.h>
+#include <linux/inetdevice.h>
 #include <linux/in.h>
 #include <linux/errno.h>
 #include <linux/timer.h>
@@ -1948,6 +1949,7 @@ void udp_v4_early_demux(struct sk_buff *skb)
 	struct sock *sk;
 	struct dst_entry *dst;
 	int dif = skb->dev->ifindex;
+	int ours;
 
 	/* validate the packet */
 	if (!pskb_may_pull(skb, skb_transport_offset(skb) + sizeof(struct udphdr)))
@@ -1957,14 +1959,24 @@ void udp_v4_early_demux(struct sk_buff *skb)
 	uh = udp_hdr(skb);
 
 	if (skb->pkt_type == PACKET_BROADCAST ||
-	    skb->pkt_type == PACKET_MULTICAST)
+	    skb->pkt_type == PACKET_MULTICAST) {
+		struct in_device *in_dev = __in_dev_get_rcu(skb->dev);
+
+		if (!in_dev)
+			return;
+
+		ours = ip_check_mc_rcu(in_dev, iph->daddr, iph->saddr,
+				       iph->protocol);
+		if (!ours)
+			return;
 		sk = __udp4_lib_mcast_demux_lookup(net, uh->dest, iph->daddr,
 						   uh->source, iph->saddr, dif);
-	else if (skb->pkt_type == PACKET_HOST)
+	} else if (skb->pkt_type == PACKET_HOST) {
 		sk = __udp4_lib_demux_lookup(net, uh->dest, iph->daddr,
 					     uh->source, iph->saddr, dif);
-	else
+	} else {
 		return;
+	}
 
 	if (!sk)
 		return;
-- 
2.1.0


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

* [added to the 3.18 stable tree] be2net: Replace dma/pci_alloc_coherent() calls with dma_zalloc_coherent()
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (24 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] ipv4/udp: Verify multicast group is ours in upd_v4_early_demux() Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] bridge: disable softirqs around br_fdb_update to avoid lockup Sasha Levin
                   ` (2 subsequent siblings)
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits
  Cc: Sriharsha Basavapatna, David S. Miller, Sasha Levin

From: Sriharsha Basavapatna <sriharsha.basavapatna@avagotech.com>

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

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

[ Upstream commit e51000db4c880165eab06ec0990605f24e75203f ]

There are several places in the driver (all in control paths) where
coherent dma memory is being allocated using either dma_alloc_coherent()
or the deprecated pci_alloc_consistent(). All these calls should be
changed to use dma_zalloc_coherent() to avoid uninitialized fields in
data structures backed by this memory.

Reported-by: Joerg Roedel <jroedel@suse.de>
Tested-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@avagotech.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 drivers/net/ethernet/emulex/benet/be_cmds.c    | 87 +++++++++++++++-----------
 drivers/net/ethernet/emulex/benet/be_ethtool.c | 18 +++---
 drivers/net/ethernet/emulex/benet/be_main.c    | 16 ++---
 3 files changed, 68 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index fead5c6..9c827b7 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1705,9 +1705,9 @@ int be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf)
 	total_size = buf_len;
 
 	get_fat_cmd.size = sizeof(struct be_cmd_req_get_fat) + 60*1024;
-	get_fat_cmd.va = pci_alloc_consistent(adapter->pdev,
-					      get_fat_cmd.size,
-					      &get_fat_cmd.dma);
+	get_fat_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
+					     get_fat_cmd.size,
+					     &get_fat_cmd.dma, GFP_ATOMIC);
 	if (!get_fat_cmd.va) {
 		dev_err(&adapter->pdev->dev,
 			"Memory allocation failure while reading FAT data\n");
@@ -1752,8 +1752,8 @@ int be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf)
 		log_offset += buf_size;
 	}
 err:
-	pci_free_consistent(adapter->pdev, get_fat_cmd.size,
-			    get_fat_cmd.va, get_fat_cmd.dma);
+	dma_free_coherent(&adapter->pdev->dev, get_fat_cmd.size,
+			  get_fat_cmd.va, get_fat_cmd.dma);
 	spin_unlock_bh(&adapter->mcc_lock);
 	return status;
 }
@@ -2223,12 +2223,12 @@ int be_cmd_read_port_transceiver_data(struct be_adapter *adapter,
 		return -EINVAL;
 
 	cmd.size = sizeof(struct be_cmd_resp_port_type);
-	cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma);
+	cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
+				     GFP_ATOMIC);
 	if (!cmd.va) {
 		dev_err(&adapter->pdev->dev, "Memory allocation failed\n");
 		return -ENOMEM;
 	}
-	memset(cmd.va, 0, cmd.size);
 
 	spin_lock_bh(&adapter->mcc_lock);
 
@@ -2253,7 +2253,7 @@ int be_cmd_read_port_transceiver_data(struct be_adapter *adapter,
 	}
 err:
 	spin_unlock_bh(&adapter->mcc_lock);
-	pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
+	dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va, cmd.dma);
 	return status;
 }
 
@@ -2702,7 +2702,8 @@ int be_cmd_get_phy_info(struct be_adapter *adapter)
 		goto err;
 	}
 	cmd.size = sizeof(struct be_cmd_req_get_phy_info);
-	cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma);
+	cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
+				     GFP_ATOMIC);
 	if (!cmd.va) {
 		dev_err(&adapter->pdev->dev, "Memory alloc failure\n");
 		status = -ENOMEM;
@@ -2736,7 +2737,7 @@ int be_cmd_get_phy_info(struct be_adapter *adapter)
 				BE_SUPPORTED_SPEED_1GBPS;
 		}
 	}
-	pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
+	dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va, cmd.dma);
 err:
 	spin_unlock_bh(&adapter->mcc_lock);
 	return status;
@@ -2787,8 +2788,9 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
 
 	memset(&attribs_cmd, 0, sizeof(struct be_dma_mem));
 	attribs_cmd.size = sizeof(struct be_cmd_resp_cntl_attribs);
-	attribs_cmd.va = pci_alloc_consistent(adapter->pdev, attribs_cmd.size,
-					      &attribs_cmd.dma);
+	attribs_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
+					     attribs_cmd.size,
+					     &attribs_cmd.dma, GFP_ATOMIC);
 	if (!attribs_cmd.va) {
 		dev_err(&adapter->pdev->dev, "Memory allocation failure\n");
 		status = -ENOMEM;
@@ -2815,8 +2817,8 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
 err:
 	mutex_unlock(&adapter->mbox_lock);
 	if (attribs_cmd.va)
-		pci_free_consistent(adapter->pdev, attribs_cmd.size,
-				    attribs_cmd.va, attribs_cmd.dma);
+		dma_free_coherent(&adapter->pdev->dev, attribs_cmd.size,
+				  attribs_cmd.va, attribs_cmd.dma);
 	return status;
 }
 
@@ -2954,9 +2956,10 @@ int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
 
 	memset(&get_mac_list_cmd, 0, sizeof(struct be_dma_mem));
 	get_mac_list_cmd.size = sizeof(struct be_cmd_resp_get_mac_list);
-	get_mac_list_cmd.va = pci_alloc_consistent(adapter->pdev,
-						   get_mac_list_cmd.size,
-						   &get_mac_list_cmd.dma);
+	get_mac_list_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
+						  get_mac_list_cmd.size,
+						  &get_mac_list_cmd.dma,
+						  GFP_ATOMIC);
 
 	if (!get_mac_list_cmd.va) {
 		dev_err(&adapter->pdev->dev,
@@ -3029,8 +3032,8 @@ int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
 
 out:
 	spin_unlock_bh(&adapter->mcc_lock);
-	pci_free_consistent(adapter->pdev, get_mac_list_cmd.size,
-			    get_mac_list_cmd.va, get_mac_list_cmd.dma);
+	dma_free_coherent(&adapter->pdev->dev, get_mac_list_cmd.size,
+			  get_mac_list_cmd.va, get_mac_list_cmd.dma);
 	return status;
 }
 
@@ -3083,8 +3086,8 @@ int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array,
 
 	memset(&cmd, 0, sizeof(struct be_dma_mem));
 	cmd.size = sizeof(struct be_cmd_req_set_mac_list);
-	cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size,
-				    &cmd.dma, GFP_KERNEL);
+	cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
+				     GFP_KERNEL);
 	if (!cmd.va)
 		return -ENOMEM;
 
@@ -3255,7 +3258,8 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter)
 
 	memset(&cmd, 0, sizeof(struct be_dma_mem));
 	cmd.size = sizeof(struct be_cmd_resp_acpi_wol_magic_config_v1);
-	cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma);
+	cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
+				     GFP_ATOMIC);
 	if (!cmd.va) {
 		dev_err(&adapter->pdev->dev, "Memory allocation failure\n");
 		status = -ENOMEM;
@@ -3290,7 +3294,8 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter)
 err:
 	mutex_unlock(&adapter->mbox_lock);
 	if (cmd.va)
-		pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
+		dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va,
+				  cmd.dma);
 	return status;
 
 }
@@ -3304,8 +3309,9 @@ int be_cmd_set_fw_log_level(struct be_adapter *adapter, u32 level)
 
 	memset(&extfat_cmd, 0, sizeof(struct be_dma_mem));
 	extfat_cmd.size = sizeof(struct be_cmd_resp_get_ext_fat_caps);
-	extfat_cmd.va = pci_alloc_consistent(adapter->pdev, extfat_cmd.size,
-					     &extfat_cmd.dma);
+	extfat_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
+					    extfat_cmd.size, &extfat_cmd.dma,
+					    GFP_ATOMIC);
 	if (!extfat_cmd.va)
 		return -ENOMEM;
 
@@ -3327,8 +3333,8 @@ int be_cmd_set_fw_log_level(struct be_adapter *adapter, u32 level)
 
 	status = be_cmd_set_ext_fat_capabilites(adapter, &extfat_cmd, cfgs);
 err:
-	pci_free_consistent(adapter->pdev, extfat_cmd.size, extfat_cmd.va,
-			    extfat_cmd.dma);
+	dma_free_coherent(&adapter->pdev->dev, extfat_cmd.size, extfat_cmd.va,
+			  extfat_cmd.dma);
 	return status;
 }
 
@@ -3341,8 +3347,9 @@ int be_cmd_get_fw_log_level(struct be_adapter *adapter)
 
 	memset(&extfat_cmd, 0, sizeof(struct be_dma_mem));
 	extfat_cmd.size = sizeof(struct be_cmd_resp_get_ext_fat_caps);
-	extfat_cmd.va = pci_alloc_consistent(adapter->pdev, extfat_cmd.size,
-					     &extfat_cmd.dma);
+	extfat_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
+					    extfat_cmd.size, &extfat_cmd.dma,
+					    GFP_ATOMIC);
 
 	if (!extfat_cmd.va) {
 		dev_err(&adapter->pdev->dev, "%s: Memory allocation failure\n",
@@ -3360,8 +3367,8 @@ int be_cmd_get_fw_log_level(struct be_adapter *adapter)
 				level = cfgs->module[0].trace_lvl[j].dbg_lvl;
 		}
 	}
-	pci_free_consistent(adapter->pdev, extfat_cmd.size, extfat_cmd.va,
-			    extfat_cmd.dma);
+	dma_free_coherent(&adapter->pdev->dev, extfat_cmd.size, extfat_cmd.va,
+			  extfat_cmd.dma);
 err:
 	return level;
 }
@@ -3567,7 +3574,8 @@ int be_cmd_get_func_config(struct be_adapter *adapter, struct be_resources *res)
 
 	memset(&cmd, 0, sizeof(struct be_dma_mem));
 	cmd.size = sizeof(struct be_cmd_resp_get_func_config);
-	cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma);
+	cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
+				     GFP_ATOMIC);
 	if (!cmd.va) {
 		dev_err(&adapter->pdev->dev, "Memory alloc failure\n");
 		status = -ENOMEM;
@@ -3607,7 +3615,8 @@ int be_cmd_get_func_config(struct be_adapter *adapter, struct be_resources *res)
 err:
 	mutex_unlock(&adapter->mbox_lock);
 	if (cmd.va)
-		pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
+		dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va,
+				  cmd.dma);
 	return status;
 }
 
@@ -3628,7 +3637,8 @@ int be_cmd_get_profile_config(struct be_adapter *adapter,
 
 	memset(&cmd, 0, sizeof(struct be_dma_mem));
 	cmd.size = sizeof(struct be_cmd_resp_get_profile_config);
-	cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma);
+	cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
+				     GFP_ATOMIC);
 	if (!cmd.va)
 		return -ENOMEM;
 
@@ -3667,7 +3677,8 @@ int be_cmd_get_profile_config(struct be_adapter *adapter,
 		res->vf_if_cap_flags = vf_res->cap_flags;
 err:
 	if (cmd.va)
-		pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
+		dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va,
+				  cmd.dma);
 	return status;
 }
 
@@ -3682,7 +3693,8 @@ static int be_cmd_set_profile_config(struct be_adapter *adapter, void *desc,
 
 	memset(&cmd, 0, sizeof(struct be_dma_mem));
 	cmd.size = sizeof(struct be_cmd_req_set_profile_config);
-	cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma);
+	cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
+				     GFP_ATOMIC);
 	if (!cmd.va)
 		return -ENOMEM;
 
@@ -3698,7 +3710,8 @@ static int be_cmd_set_profile_config(struct be_adapter *adapter, void *desc,
 	status = be_cmd_notify_wait(adapter, &wrb);
 
 	if (cmd.va)
-		pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
+		dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va,
+				  cmd.dma);
 	return status;
 }
 
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c
index e42a791..a11c5e0 100644
--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
+++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
@@ -266,8 +266,8 @@ static int lancer_cmd_read_file(struct be_adapter *adapter, u8 *file_name,
 	int status = 0;
 
 	read_cmd.size = LANCER_READ_FILE_CHUNK;
-	read_cmd.va = pci_alloc_consistent(adapter->pdev, read_cmd.size,
-					   &read_cmd.dma);
+	read_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, read_cmd.size,
+					  &read_cmd.dma, GFP_ATOMIC);
 
 	if (!read_cmd.va) {
 		dev_err(&adapter->pdev->dev,
@@ -291,8 +291,8 @@ static int lancer_cmd_read_file(struct be_adapter *adapter, u8 *file_name,
 			break;
 		}
 	}
-	pci_free_consistent(adapter->pdev, read_cmd.size, read_cmd.va,
-			    read_cmd.dma);
+	dma_free_coherent(&adapter->pdev->dev, read_cmd.size, read_cmd.va,
+			  read_cmd.dma);
 
 	return status;
 }
@@ -818,8 +818,9 @@ static int be_test_ddr_dma(struct be_adapter *adapter)
 	};
 
 	ddrdma_cmd.size = sizeof(struct be_cmd_req_ddrdma_test);
-	ddrdma_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, ddrdma_cmd.size,
-					   &ddrdma_cmd.dma, GFP_KERNEL);
+	ddrdma_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
+					    ddrdma_cmd.size, &ddrdma_cmd.dma,
+					    GFP_KERNEL);
 	if (!ddrdma_cmd.va)
 		return -ENOMEM;
 
@@ -941,8 +942,9 @@ static int be_read_eeprom(struct net_device *netdev,
 
 	memset(&eeprom_cmd, 0, sizeof(struct be_dma_mem));
 	eeprom_cmd.size = sizeof(struct be_cmd_req_seeprom_read);
-	eeprom_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, eeprom_cmd.size,
-					   &eeprom_cmd.dma, GFP_KERNEL);
+	eeprom_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
+					    eeprom_cmd.size, &eeprom_cmd.dma,
+					    GFP_KERNEL);
 
 	if (!eeprom_cmd.va)
 		return -ENOMEM;
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index e51faf0..fdd3679 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4113,8 +4113,8 @@ static int lancer_fw_download(struct be_adapter *adapter,
 
 	flash_cmd.size = sizeof(struct lancer_cmd_req_write_object)
 				+ LANCER_FW_DOWNLOAD_CHUNK;
-	flash_cmd.va = dma_alloc_coherent(dev, flash_cmd.size,
-					  &flash_cmd.dma, GFP_KERNEL);
+	flash_cmd.va = dma_zalloc_coherent(dev, flash_cmd.size,
+					   &flash_cmd.dma, GFP_KERNEL);
 	if (!flash_cmd.va)
 		return -ENOMEM;
 
@@ -4209,8 +4209,8 @@ static int be_fw_download(struct be_adapter *adapter, const struct firmware* fw)
 	int status = 0, i = 0, num_imgs = 0, ufi_type = 0;
 
 	flash_cmd.size = sizeof(struct be_cmd_write_flashrom);
-	flash_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, flash_cmd.size,
-					  &flash_cmd.dma, GFP_KERNEL);
+	flash_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, flash_cmd.size,
+					   &flash_cmd.dma, GFP_KERNEL);
 	if (!flash_cmd.va) {
 		status = -ENOMEM;
 		goto be_fw_exit;
@@ -4587,10 +4587,10 @@ static int be_ctrl_init(struct be_adapter *adapter)
 		goto done;
 
 	mbox_mem_alloc->size = sizeof(struct be_mcc_mailbox) + 16;
-	mbox_mem_alloc->va = dma_alloc_coherent(&adapter->pdev->dev,
-						mbox_mem_alloc->size,
-						&mbox_mem_alloc->dma,
-						GFP_KERNEL);
+	mbox_mem_alloc->va = dma_zalloc_coherent(&adapter->pdev->dev,
+						 mbox_mem_alloc->size,
+						 &mbox_mem_alloc->dma,
+						 GFP_KERNEL);
 	if (!mbox_mem_alloc->va) {
 		status = -ENOMEM;
 		goto unmap_pci_bars;
-- 
2.1.0


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

* [added to the 3.18 stable tree] bridge: disable softirqs around br_fdb_update to avoid lockup
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (25 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] be2net: Replace dma/pci_alloc_coherent() calls with dma_zalloc_coherent() Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-16 11:56 ` [added to the 3.18 stable tree] crush: ensuring at most num-rep osds are selected Sasha Levin
  2015-06-22 13:19 ` [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Luis Henriques
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Nikolay Aleksandrov, David S. Miller, Sasha Levin

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

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

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

[ Upstream commit c4c832f89dc468cf11dc0dd17206bace44526651 ]

br_fdb_update() can be called in process context in the following way:
br_fdb_add() -> __br_fdb_add() -> br_fdb_update() (if NTF_USE flag is set)
so we need to disable softirqs because there are softirq users of the
hash_lock. One easy way to reproduce this is to modify the bridge utility
to set NTF_USE, enable stp and then set maxageing to a low value so
br_fdb_cleanup() is called frequently and then just add new entries in
a loop. This happens because br_fdb_cleanup() is called from timer/softirq
context. The spin locks in br_fdb_update were _bh before commit f8ae737deea1
("[BRIDGE]: forwarding remove unneeded preempt and bh diasables")
and at the time that commit was correct because br_fdb_update() couldn't be
called from process context, but that changed after commit:
292d1398983f ("bridge: add NTF_USE support")
Using local_bh_disable/enable around br_fdb_update() allows us to keep
using the spin_lock/unlock in br_fdb_update for the fast-path.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Fixes: 292d1398983f ("bridge: add NTF_USE support")
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/bridge/br_fdb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 6f6c95c..eab8862 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -789,9 +789,11 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge_port *p,
 	int err = 0;
 
 	if (ndm->ndm_flags & NTF_USE) {
+		local_bh_disable();
 		rcu_read_lock();
 		br_fdb_update(p->br, p, addr, vid, true);
 		rcu_read_unlock();
+		local_bh_enable();
 	} else {
 		spin_lock_bh(&p->br->hash_lock);
 		err = fdb_add_entry(p, addr, ndm->ndm_state,
-- 
2.1.0


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

* [added to the 3.18 stable tree] crush: ensuring at most num-rep osds are selected
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (26 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] bridge: disable softirqs around br_fdb_update to avoid lockup Sasha Levin
@ 2015-06-16 11:56 ` Sasha Levin
  2015-06-22 13:19 ` [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Luis Henriques
  28 siblings, 0 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-16 11:56 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Ilya Dryomov, Sasha Levin

From: Ilya Dryomov <idryomov@gmail.com>

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

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

[ Upstream commit 45002267e8d2699bf9b022315bee3dd13b044843 ]

Crush temporary buffers are allocated as per replica size configured
by the user.  When there are more final osds (to be selected as per
rule) than the replicas, buffer overlaps and it causes crash.  Now, it
ensures that at most num-rep osds are selected even if more number of
osds are allowed by the rule.

Reflects ceph.git commits 6b4d1aa99718e3b367496326c1e64551330fabc0,
                          234b066ba04976783d15ff2abc3e81b6cc06fb10.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/ceph/crush/mapper.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/net/ceph/crush/mapper.c b/net/ceph/crush/mapper.c
index a1ef53c..b1f2d1f 100644
--- a/net/ceph/crush/mapper.c
+++ b/net/ceph/crush/mapper.c
@@ -290,6 +290,7 @@ static int is_out(const struct crush_map *map,
  * @type: the type of item to choose
  * @out: pointer to output vector
  * @outpos: our position in that vector
+ * @out_size: size of the out vector
  * @tries: number of attempts to make
  * @recurse_tries: number of attempts to have recursive chooseleaf make
  * @local_retries: localized retries
@@ -304,6 +305,7 @@ static int crush_choose_firstn(const struct crush_map *map,
 			       const __u32 *weight, int weight_max,
 			       int x, int numrep, int type,
 			       int *out, int outpos,
+			       int out_size,
 			       unsigned int tries,
 			       unsigned int recurse_tries,
 			       unsigned int local_retries,
@@ -322,6 +324,7 @@ static int crush_choose_firstn(const struct crush_map *map,
 	int item = 0;
 	int itemtype;
 	int collide, reject;
+	int count = out_size;
 
 	dprintk("CHOOSE%s bucket %d x %d outpos %d numrep %d tries %d recurse_tries %d local_retries %d local_fallback_retries %d parent_r %d\n",
 		recurse_to_leaf ? "_LEAF" : "",
@@ -329,7 +332,7 @@ static int crush_choose_firstn(const struct crush_map *map,
 		tries, recurse_tries, local_retries, local_fallback_retries,
 		parent_r);
 
-	for (rep = outpos; rep < numrep; rep++) {
+	for (rep = outpos; rep < numrep && count > 0 ; rep++) {
 		/* keep trying until we get a non-out, non-colliding item */
 		ftotal = 0;
 		skip_rep = 0;
@@ -403,7 +406,7 @@ static int crush_choose_firstn(const struct crush_map *map,
 							 map->buckets[-1-item],
 							 weight, weight_max,
 							 x, outpos+1, 0,
-							 out2, outpos,
+							 out2, outpos, count,
 							 recurse_tries, 0,
 							 local_retries,
 							 local_fallback_retries,
@@ -463,6 +466,7 @@ reject:
 		dprintk("CHOOSE got %d\n", item);
 		out[outpos] = item;
 		outpos++;
+		count--;
 	}
 
 	dprintk("CHOOSE returns %d\n", outpos);
@@ -654,6 +658,7 @@ int crush_do_rule(const struct crush_map *map,
 	__u32 step;
 	int i, j;
 	int numrep;
+	int out_size;
 	/*
 	 * the original choose_total_tries value was off by one (it
 	 * counted "retries" and not "tries").  add one.
@@ -761,6 +766,7 @@ int crush_do_rule(const struct crush_map *map,
 						x, numrep,
 						curstep->arg2,
 						o+osize, j,
+						result_max-osize,
 						choose_tries,
 						recurse_tries,
 						choose_local_retries,
@@ -770,11 +776,13 @@ int crush_do_rule(const struct crush_map *map,
 						c+osize,
 						0);
 				} else {
+					out_size = ((numrep < (result_max-osize)) ?
+                                                    numrep : (result_max-osize));
 					crush_choose_indep(
 						map,
 						map->buckets[-1-w[i]],
 						weight, weight_max,
-						x, numrep, numrep,
+						x, out_size, numrep,
 						curstep->arg2,
 						o+osize, j,
 						choose_tries,
@@ -783,7 +791,7 @@ int crush_do_rule(const struct crush_map *map,
 						recurse_to_leaf,
 						c+osize,
 						0);
-					osize += numrep;
+					osize += out_size;
 				}
 			}
 
-- 
2.1.0


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

* Re: [added to the 3.18 stable tree] ARM: 8221/1: PJ4: allow building in Thumb-2 mode
  2015-06-16 11:56 ` [added to the 3.18 stable tree] ARM: 8221/1: PJ4: allow building in Thumb-2 mode Sasha Levin
@ 2015-06-16 12:31   ` Ard Biesheuvel
  0 siblings, 0 replies; 34+ messages in thread
From: Ard Biesheuvel @ 2015-06-16 12:31 UTC (permalink / raw)
  To: Sasha Levin, Arnd Bergmann
  Cc: stable, stable-commits, Russell King, Kevin Hilman

qOn 16 June 2015 at 13:56, Sasha Levin <sasha.levin@oracle.com> wrote:
> From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
> Two files that get included when building the multi_v7_defconfig target
> fail to build when selecting THUMB2_KERNEL for this configuration.
>

There is a discussion taking place in another thread

http://thread.gmane.org/gmane.linux.kernel.stable/137646

about whether fixing the Thumb-2 build for multi_v7_defconfig is
appropriate for the -stable trees, since it is unclear if this config
ever worked in Thumb2 mode at any point.

Since this patch affects PJ4 CPUs, and MVEBU was included in
multi_v7_defconfig from the beginning, I don't think
multi_v7_defconfig was ever buildable before in Thumb-2 mode
Perhaps Arnd could confirm?

-- 
Ard.




> In both cases, we can just build the file as ARM code, as none of its
> symbols are exported to modules, so there are no interworking concerns.
> In the iwmmxt.S case, add ENDPROC() declarations so the symbols are
> annotated as functions, resulting in the linker to emit the appropriate
> mode switches.
>
> Acked-by: Nicolas Pitre <nico@linaro.org>
> Tested-by: Olof Johansson <olof@lixom.net>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> (cherry picked from commit 13d1b9575ac2c2da143cd2236b6cf0fc314570f8)
> Cc: <stable@vger.kernel.org> # v3.18+
> Signed-off-by: Kevin Hilman <khilman@linaro.org>
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  arch/arm/kernel/Makefile |  1 +
>  arch/arm/kernel/iwmmxt.S | 13 +++++++++++++
>  2 files changed, 14 insertions(+)
>
> diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
> index 03120e6..2ecc7d1 100644
> --- a/arch/arm/kernel/Makefile
> +++ b/arch/arm/kernel/Makefile
> @@ -84,6 +84,7 @@ obj-$(CONFIG_CPU_PJ4B)                += pj4-cp0.o
>  obj-$(CONFIG_IWMMXT)           += iwmmxt.o
>  obj-$(CONFIG_PERF_EVENTS)      += perf_regs.o
>  obj-$(CONFIG_HW_PERF_EVENTS)   += perf_event.o perf_event_cpu.o
> +CFLAGS_pj4-cp0.o               := -marm
>  AFLAGS_iwmmxt.o                        := -Wa,-mcpu=iwmmxt
>  obj-$(CONFIG_ARM_CPU_TOPOLOGY)  += topology.o
>
> diff --git a/arch/arm/kernel/iwmmxt.S b/arch/arm/kernel/iwmmxt.S
> index ad58e56..49fadbd 100644
> --- a/arch/arm/kernel/iwmmxt.S
> +++ b/arch/arm/kernel/iwmmxt.S
> @@ -58,6 +58,7 @@
>  #define MMX_SIZE               (0x98)
>
>         .text
> +       .arm
>
>  /*
>   * Lazy switching of Concan coprocessor context
> @@ -182,6 +183,8 @@ concan_load:
>         tmcr    wCon, r2
>         ret     lr
>
> +ENDPROC(iwmmxt_task_enable)
> +
>  /*
>   * Back up Concan regs to save area and disable access to them
>   * (mainly for gdb or sleep mode usage)
> @@ -232,6 +235,8 @@ ENTRY(iwmmxt_task_disable)
>  1:     msr     cpsr_c, ip                      @ restore interrupt mode
>         ldmfd   sp!, {r4, pc}
>
> +ENDPROC(iwmmxt_task_disable)
> +
>  /*
>   * Copy Concan state to given memory address
>   *
> @@ -268,6 +273,8 @@ ENTRY(iwmmxt_task_copy)
>         msr     cpsr_c, ip                      @ restore interrupt mode
>         ret     r3
>
> +ENDPROC(iwmmxt_task_copy)
> +
>  /*
>   * Restore Concan state from given memory address
>   *
> @@ -304,6 +311,8 @@ ENTRY(iwmmxt_task_restore)
>         msr     cpsr_c, ip                      @ restore interrupt mode
>         ret     r3
>
> +ENDPROC(iwmmxt_task_restore)
> +
>  /*
>   * Concan handling on task switch
>   *
> @@ -335,6 +344,8 @@ ENTRY(iwmmxt_task_switch)
>         mrc     p15, 0, r1, c2, c0, 0
>         sub     pc, lr, r1, lsr #32             @ cpwait and return
>
> +ENDPROC(iwmmxt_task_switch)
> +
>  /*
>   * Remove Concan ownership of given task
>   *
> @@ -353,6 +364,8 @@ ENTRY(iwmmxt_task_release)
>         msr     cpsr_c, r2                      @ restore interrupts
>         ret     lr
>
> +ENDPROC(iwmmxt_task_release)
> +
>         .data
>  concan_owner:
>         .word   0
> --
> 2.1.0
>

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

* Re: [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build"
  2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
                   ` (27 preceding siblings ...)
  2015-06-16 11:56 ` [added to the 3.18 stable tree] crush: ensuring at most num-rep osds are selected Sasha Levin
@ 2015-06-22 13:19 ` Luis Henriques
  2015-06-23 14:13   ` Sasha Levin
  28 siblings, 1 reply; 34+ messages in thread
From: Luis Henriques @ 2015-06-22 13:19 UTC (permalink / raw)
  To: Sasha Levin; +Cc: stable, stable-commits, Kamal Mostafa, Greg Kroah-Hartman

Hi Sasha,

On Tue, Jun 16, 2015 at 07:56:29AM -0400, Sasha Levin wrote:
> This reverts commit a821ac4c66382f9d6387c8311608f13c6749fea9.
> 
> That patch is not suitable for 3.18.
>

Should this be reverted in other stable trees as well?  I see it has
been included at least in 3.14, 3.16-ckt, 3.19-ckt and 4.0.

Cheers,
--
Lu�s


> Reported-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  tools/vm/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/vm/Makefile b/tools/vm/Makefile
> index c604f3e..3d907da 100644
> --- a/tools/vm/Makefile
> +++ b/tools/vm/Makefile
> @@ -3,7 +3,7 @@
>  TARGETS=page-types slabinfo
>  
>  LIB_DIR = ../lib/api
> -LIBS = $(LIB_DIR)/libapi.a
> +LIBS = $(LIB_DIR)/libapikfs.a
>  
>  CC = $(CROSS_COMPILE)gcc
>  CFLAGS = -Wall -Wextra -I../lib/
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe stable" in

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

* Re: [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build"
  2015-06-22 13:19 ` [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Luis Henriques
@ 2015-06-23 14:13   ` Sasha Levin
  2015-06-23 16:08     ` Luis Henriques
  2015-06-23 16:46     ` Kamal Mostafa
  0 siblings, 2 replies; 34+ messages in thread
From: Sasha Levin @ 2015-06-23 14:13 UTC (permalink / raw)
  To: Luis Henriques; +Cc: stable, stable-commits, Kamal Mostafa, Greg Kroah-Hartman

On 06/22/2015 09:19 AM, Luis Henriques wrote:
> Hi Sasha,
> 
> On Tue, Jun 16, 2015 at 07:56:29AM -0400, Sasha Levin wrote:
>> > This reverts commit a821ac4c66382f9d6387c8311608f13c6749fea9.
>> > 
>> > That patch is not suitable for 3.18.
>> >
> Should this be reverted in other stable trees as well?  I see it has
> been included at least in 3.14, 3.16-ckt, 3.19-ckt and 4.0.

I believe so. You can test it by seeing if 'make -C tools/vm' is
failing or not.


Thanks,
Sasha

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

* Re: [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build"
  2015-06-23 14:13   ` Sasha Levin
@ 2015-06-23 16:08     ` Luis Henriques
  2015-06-23 16:46     ` Kamal Mostafa
  1 sibling, 0 replies; 34+ messages in thread
From: Luis Henriques @ 2015-06-23 16:08 UTC (permalink / raw)
  To: Sasha Levin; +Cc: stable, stable-commits, Kamal Mostafa, Greg Kroah-Hartman

On Tue, Jun 23, 2015 at 10:13:29AM -0400, Sasha Levin wrote:
> On 06/22/2015 09:19 AM, Luis Henriques wrote:
> > Hi Sasha,
> > 
> > On Tue, Jun 16, 2015 at 07:56:29AM -0400, Sasha Levin wrote:
> >> > This reverts commit a821ac4c66382f9d6387c8311608f13c6749fea9.
> >> > 
> >> > That patch is not suitable for 3.18.
> >> >
> > Should this be reverted in other stable trees as well?  I see it has
> > been included at least in 3.14, 3.16-ckt, 3.19-ckt and 4.0.
> 
> I believe so. You can test it by seeing if 'make -C tools/vm' is
> failing or not.
>

Right :-)
I'm queuing a revert of this patch too for the 3.16 kernel.
Thanks Sasha.

Cheers,
--
Lu�s

> 
> Thanks,
> Sasha
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build"
  2015-06-23 14:13   ` Sasha Levin
  2015-06-23 16:08     ` Luis Henriques
@ 2015-06-23 16:46     ` Kamal Mostafa
  1 sibling, 0 replies; 34+ messages in thread
From: Kamal Mostafa @ 2015-06-23 16:46 UTC (permalink / raw)
  To: Sasha Levin; +Cc: Luis Henriques, stable, stable-commits, Greg Kroah-Hartman

On Tue, 2015-06-23 at 10:13 -0400, Sasha Levin wrote:
> On 06/22/2015 09:19 AM, Luis Henriques wrote:
> > Hi Sasha,
> > 
> > On Tue, Jun 16, 2015 at 07:56:29AM -0400, Sasha Levin wrote:
> >> > This reverts commit a821ac4c66382f9d6387c8311608f13c6749fea9.
> >> > 
> >> > That patch is not suitable for 3.18.
> >> >
> > Should this be reverted in other stable trees as well?  I see it has
> > been included at least in 3.14, 3.16-ckt, 3.19-ckt and 4.0.
> 
> I believe so. You can test it by seeing if 'make -C tools/vm' is
> failing or not.


Revert queued for 3.19-stable.  Thanks Sasha!

 -Kamal


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

end of thread, other threads:[~2015-06-23 16:46 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-16 11:56 [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] ARM: 8221/1: PJ4: allow building in Thumb-2 mode Sasha Levin
2015-06-16 12:31   ` Ard Biesheuvel
2015-06-16 11:56 ` [added to the 3.18 stable tree] fs/binfmt_elf.c:load_elf_binary(): return -EINVAL on zero-length mappings Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] net: core: Correct an over-stringent device loop detection Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] x86: bpf_jit: fix FROM_BE16 and FROM_LE16/32 instructions Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] x86: bpf_jit: fix compilation of large bpf programs Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] net: phy: Allow EEE for all RGMII variants Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] rtnl/bond: don't send rtnl msg for unregistered iface Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] tcp/ipv6: fix flow label setting in TIME_WAIT state Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] net/ipv6/udp: Fix ipv6 multicast socket filter regression Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] net: sched: fix call_rcu() race on classifier module unloads Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] ipv4: Avoid crashing in ip_error Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] cdc_ncm: Fix tx_bytes statistics Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] bridge: fix parsing of MLDv2 reports Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] net: dp83640: fix broken calibration routine Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] net: dp83640: reinforce locking rules Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] net: dp83640: fix improper double spin locking Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] unix/caif: sk_socket can disappear when state is unlocked Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] xen/netback: Properly initialize credit_bytes Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] net_sched: invoke ->attach() after setting dev->qdisc Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] sctp: Fix mangled IPv4 addresses on a IPv6 listening socket Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] bridge: fix br_multicast_query_expired() bug Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] udp: fix behavior of wrong checksums Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] tcp: fix child sockets to use system default congestion control if not set Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] xen: netback: read hotplug script once at start of day Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] ipv4/udp: Verify multicast group is ours in upd_v4_early_demux() Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] be2net: Replace dma/pci_alloc_coherent() calls with dma_zalloc_coherent() Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] bridge: disable softirqs around br_fdb_update to avoid lockup Sasha Levin
2015-06-16 11:56 ` [added to the 3.18 stable tree] crush: ensuring at most num-rep osds are selected Sasha Levin
2015-06-22 13:19 ` [added to the 3.18 stable tree] Revert "tools/vm: fix page-flags build" Luis Henriques
2015-06-23 14:13   ` Sasha Levin
2015-06-23 16:08     ` Luis Henriques
2015-06-23 16:46     ` Kamal Mostafa

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.