linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3.12 01/76] crypto: gcm - Fix rfc4543 decryption crash
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 02/76] ARM: OMAP2+: hwmod: Fix updating of sysconfig register Jiri Slaby
                   ` (76 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Herbert Xu, Jiri Slaby

From: Herbert Xu <herbert@gondor.apana.org.au>

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

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

This bug has already bee fixed upstream since 4.2.  However, it
was fixed during the AEAD conversion so no fix was backported to
the older kernels.

When we do an RFC 4543 decryption, we will end up writing the
ICV beyond the end of the dst buffer.  This should lead to a
crash but for some reason it was never noticed.

This patch fixes it by only writing back the ICV for encryption.

Fixes: d733ac90f9fe ("crypto: gcm - fix rfc4543 to handle async...")
Reported-by: Patrick Meyer <patrick.meyer@vasgard.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 crypto/gcm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/crypto/gcm.c b/crypto/gcm.c
index 9cea4d0b6904..f0bd00b15f26 100644
--- a/crypto/gcm.c
+++ b/crypto/gcm.c
@@ -1173,6 +1173,9 @@ static struct aead_request *crypto_rfc4543_crypt(struct aead_request *req,
 	aead_request_set_tfm(subreq, ctx->child);
 	aead_request_set_callback(subreq, req->base.flags, crypto_rfc4543_done,
 				  req);
+	if (!enc)
+		aead_request_set_callback(subreq, req->base.flags,
+					  req->base.complete, req->base.data);
 	aead_request_set_crypt(subreq, cipher, cipher, enc ? 0 : authsize, iv);
 	aead_request_set_assoc(subreq, assoc, assoclen);
 
-- 
2.8.2

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

* [PATCH 3.12 02/76] ARM: OMAP2+: hwmod: Fix updating of sysconfig register
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 01/76] crypto: gcm - Fix rfc4543 decryption crash Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 03/76] usb: xhci: fix wild pointers in xhci_mem_cleanup Jiri Slaby
                   ` (75 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Lokesh Vutla, Jon Hunter, Paul Walmsley, Jiri Slaby

From: Lokesh Vutla <lokeshvutla@ti.com>

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

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

commit 3ca4a238106dedc285193ee47f494a6584b6fd2f upstream.

Commit 127500ccb766f ("ARM: OMAP2+: Only write the sysconfig on idle
when necessary") talks about verification of sysconfig cache value before
updating it, only during idle path. But the patch is adding the
verification in the enable path. So, adding the check in a proper place
as per the commit description.

Not keeping this check during enable path as there is a chance of losing
context and it is safe to do on idle as the context of the register will
never be lost while the device is active.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Acked-by: Tero Kristo <t-kristo@ti.com>
Cc: Jon Hunter <jonathanh@nvidia.com>
Fixes: commit 127500ccb766 "ARM: OMAP2+: Only write the sysconfig on idle when necessary"
[paul@pwsan.com: appears to have been caused by my own mismerge of the
 originally posted patch]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/arm/mach-omap2/omap_hwmod.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 68a9bec32c9e..407d2e3791c3 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1435,9 +1435,7 @@ static void _enable_sysc(struct omap_hwmod *oh)
 	    (sf & SYSC_HAS_CLOCKACTIVITY))
 		_set_clockactivity(oh, oh->class->sysc->clockact, &v);
 
-	/* If the cached value is the same as the new value, skip the write */
-	if (oh->_sysc_cache != v)
-		_write_sysconfig(v, oh);
+	_write_sysconfig(v, oh);
 
 	/*
 	 * Set the autoidle bit only after setting the smartidle bit
@@ -1500,7 +1498,9 @@ static void _idle_sysc(struct omap_hwmod *oh)
 		_set_master_standbymode(oh, idlemode, &v);
 	}
 
-	_write_sysconfig(v, oh);
+	/* If the cached value is the same as the new value, skip the write */
+	if (oh->_sysc_cache != v)
+		_write_sysconfig(v, oh);
 }
 
 /**
-- 
2.8.2

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

* [PATCH 3.12 03/76] usb: xhci: fix wild pointers in xhci_mem_cleanup
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 01/76] crypto: gcm - Fix rfc4543 decryption crash Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 02/76] ARM: OMAP2+: hwmod: Fix updating of sysconfig register Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 04/76] usb: hcd: out of bounds access in for_each_companion Jiri Slaby
                   ` (74 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Lu Baolu, Mathias Nyman, Greg Kroah-Hartman, Jiri Slaby

From: Lu Baolu <baolu.lu@linux.intel.com>

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

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

commit 71504062a7c34838c3fccd92c447f399d3cb5797 upstream.

This patch fixes some wild pointers produced by xhci_mem_cleanup.
These wild pointers will cause system crash if xhci_mem_cleanup()
is called twice.

Reported-and-tested-by: Pengcheng Li <lpc.li@hisilicon.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/host/xhci-mem.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 9552d2080d12..bd889c621ba2 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1785,6 +1785,12 @@ no_bw:
 	kfree(xhci->rh_bw);
 	kfree(xhci->ext_caps);
 
+	xhci->usb2_ports = NULL;
+	xhci->usb3_ports = NULL;
+	xhci->port_array = NULL;
+	xhci->rh_bw = NULL;
+	xhci->ext_caps = NULL;
+
 	xhci->page_size = 0;
 	xhci->page_shift = 0;
 	xhci->bus_state[0].bus_suspended = 0;
-- 
2.8.2

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

* [PATCH 3.12 04/76] usb: hcd: out of bounds access in for_each_companion
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (2 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 03/76] usb: xhci: fix wild pointers in xhci_mem_cleanup Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 05/76] lib: lz4: fixed zram with lz4 on big endian machines Jiri Slaby
                   ` (73 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Robert Dobrowolski, Jiri Slaby

From: Robert Dobrowolski <robert.dobrowolski@linux.intel.com>

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

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

commit e86103a75705c7c530768f4ffaba74cf382910f2 upstream.

On BXT platform Host Controller and Device Controller figure as
same PCI device but with different device function. HCD should
not pass data to Device Controller but only to Host Controllers.
Checking if companion device is Host Controller, otherwise skip.

Signed-off-by: Robert Dobrowolski <robert.dobrowolski@linux.intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/core/hcd-pci.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 04b21577e8ed..1778aeeb9e5c 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -74,6 +74,15 @@ static void for_each_companion(struct pci_dev *pdev, struct usb_hcd *hcd,
 		if (companion->bus != pdev->bus ||
 				PCI_SLOT(companion->devfn) != slot)
 			continue;
+
+		/*
+		 * Companion device should be either UHCI,OHCI or EHCI host
+		 * controller, otherwise skip.
+		 */
+		if (companion->class != CL_UHCI && companion->class != CL_OHCI &&
+				companion->class != CL_EHCI)
+			continue;
+
 		companion_hcd = pci_get_drvdata(companion);
 		if (!companion_hcd || !companion_hcd->self.root_hub)
 			continue;
-- 
2.8.2

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

* [PATCH 3.12 05/76] lib: lz4: fixed zram with lz4 on big endian machines
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (3 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 04/76] usb: hcd: out of bounds access in for_each_companion Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 06/76] drm/qxl: fix cursor position with non-zero hotspot Jiri Slaby
                   ` (72 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Rui Salvaterra, Jiri Slaby

From: Rui Salvaterra <rsalvaterra@gmail.com>

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

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

commit 3e26a691fe3fe1e02a76e5bab0c143ace4b137b4 upstream.

Based on Sergey's test patch [1], this fixes zram with lz4 compression
on big endian cpus.

Note that the 64-bit preprocessor test is not a cleanup, it's part of
the fix, since those identifiers are bogus (for example, __ppc64__
isn't defined anywhere else in the kernel, which means we'd fall into
the 32-bit definitions on ppc64).

Tested on ppc64 with no regression on x86_64.

[1] http://marc.info/?l=linux-kernel&m=145994470805853&w=4

Suggested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 lib/lz4/lz4defs.h | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
index abcecdc2d0f2..0710a62ad2f6 100644
--- a/lib/lz4/lz4defs.h
+++ b/lib/lz4/lz4defs.h
@@ -11,8 +11,7 @@
 /*
  * Detects 64 bits mode
  */
-#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \
-	|| defined(__ppc64__) || defined(__LP64__))
+#if defined(CONFIG_64BIT)
 #define LZ4_ARCH64 1
 #else
 #define LZ4_ARCH64 0
@@ -35,6 +34,10 @@ typedef struct _U64_S { u64 v; } U64_S;
 
 #define PUT4(s, d) (A32(d) = A32(s))
 #define PUT8(s, d) (A64(d) = A64(s))
+
+#define LZ4_READ_LITTLEENDIAN_16(d, s, p)	\
+	(d = s - A16(p))
+
 #define LZ4_WRITE_LITTLEENDIAN_16(p, v)	\
 	do {	\
 		A16(p) = v; \
@@ -51,10 +54,13 @@ typedef struct _U64_S { u64 v; } U64_S;
 #define PUT8(s, d) \
 	put_unaligned(get_unaligned((const u64 *) s), (u64 *) d)
 
-#define LZ4_WRITE_LITTLEENDIAN_16(p, v)	\
-	do {	\
-		put_unaligned(v, (u16 *)(p)); \
-		p += 2; \
+#define LZ4_READ_LITTLEENDIAN_16(d, s, p)	\
+	(d = s - get_unaligned_le16(p))
+
+#define LZ4_WRITE_LITTLEENDIAN_16(p, v)			\
+	do {						\
+		put_unaligned_le16(v, (u16 *)(p));	\
+		p += 2;					\
 	} while (0)
 #endif
 
@@ -140,9 +146,6 @@ typedef struct _U64_S { u64 v; } U64_S;
 
 #endif
 
-#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
-	(d = s - get_unaligned_le16(p))
-
 #define LZ4_WILDCOPY(s, d, e)		\
 	do {				\
 		LZ4_COPYPACKET(s, d);	\
-- 
2.8.2

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

* [PATCH 3.12 06/76] drm/qxl: fix cursor position with non-zero hotspot
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (4 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 05/76] lib: lz4: fixed zram with lz4 on big endian machines Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 07/76] nl80211: check netlink protocol in socket release notification Jiri Slaby
                   ` (71 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, John Keeping, Jani Nikula, Jiri Slaby

From: John Keeping <john@metanate.com>

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

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

commit d59a1f71ff1aeda4b4630df92d3ad4e3b1dfc885 upstream.

The SPICE protocol considers the position of a cursor to be the location
of its active pixel on the display, so the cursor is drawn with its
top-left corner at "(x - hot_spot_x, y - hot_spot_y)" but the DRM cursor
position gives the location where the top-left corner should be drawn,
with the hotspot being a hint for drivers that need it.

This fixes the location of the window resize cursors when using Fluxbox
with the QXL DRM driver and both the QXL and modesetting X drivers.

Signed-off-by: John Keeping <john@metanate.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1447845445-2116-1-git-send-email-john@metanate.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/gpu/drm/qxl/qxl_display.c | 13 +++++++++----
 drivers/gpu/drm/qxl/qxl_drv.h     |  2 ++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 98976f054597..dc59c2d33fbe 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -287,10 +287,15 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
 
 	qxl_bo_kunmap(user_bo);
 
+	qcrtc->cur_x += qcrtc->hot_spot_x - hot_x;
+	qcrtc->cur_y += qcrtc->hot_spot_y - hot_y;
+	qcrtc->hot_spot_x = hot_x;
+	qcrtc->hot_spot_y = hot_y;
+
 	cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
 	cmd->type = QXL_CURSOR_SET;
-	cmd->u.set.position.x = qcrtc->cur_x;
-	cmd->u.set.position.y = qcrtc->cur_y;
+	cmd->u.set.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
+	cmd->u.set.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
 
 	cmd->u.set.shape = qxl_bo_physical_address(qdev, cursor_bo, 0);
 
@@ -353,8 +358,8 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
 
 	cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
 	cmd->type = QXL_CURSOR_MOVE;
-	cmd->u.position.x = qcrtc->cur_x;
-	cmd->u.position.y = qcrtc->cur_y;
+	cmd->u.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
+	cmd->u.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
 	qxl_release_unmap(qdev, release, &cmd->release_info);
 
 	qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 9cfafd7a1af6..0bc4991e3002 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -139,6 +139,8 @@ struct qxl_crtc {
 	int index;
 	int cur_x;
 	int cur_y;
+	int hot_spot_x;
+	int hot_spot_y;
 };
 
 struct qxl_output {
-- 
2.8.2

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

* [PATCH 3.12 07/76] nl80211: check netlink protocol in socket release notification
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (5 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 06/76] drm/qxl: fix cursor position with non-zero hotspot Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 08/76] Input: gtco - fix crash on detecting device without endpoints Jiri Slaby
                   ` (70 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Dmitry Ivanov, Dmitry Ivanov, Johannes Berg, Jiri Slaby

From: Dmitry Ivanov <dmitrijs.ivanovs@ubnt.com>

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

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

commit 8f815cdde3e550e10c2736990d791f60c2ce43eb upstream.

A non-privileged user can create a netlink socket with the same port_id as
used by an existing open nl80211 netlink socket (e.g. as used by a hostapd
process) with a different protocol number.

Closing this socket will then lead to the notification going to nl80211's
socket release notification handler, and possibly cause an action such as
removing a virtual interface.

Fix this issue by checking that the netlink protocol is NETLINK_GENERIC.
Since generic netlink has no notifier chain of its own, we can't fix the
problem more generically.

Fixes: 026331c4d9b5 ("cfg80211/mac80211: allow registering for and sending action frames")
Signed-off-by: Dmitry Ivanov <dima@ubnt.com>
[rewrite commit message]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/wireless/nl80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 79c3e641581d..cda142009426 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -11156,7 +11156,7 @@ static int nl80211_netlink_notify(struct notifier_block * nb,
 	struct wireless_dev *wdev;
 	struct cfg80211_beacon_registration *reg, *tmp;
 
-	if (state != NETLINK_URELEASE)
+	if (state != NETLINK_URELEASE || notify->protocol != NETLINK_GENERIC)
 		return NOTIFY_DONE;
 
 	rcu_read_lock();
-- 
2.8.2

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

* [PATCH 3.12 08/76] Input: gtco - fix crash on detecting device without endpoints
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (6 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 07/76] nl80211: check netlink protocol in socket release notification Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 09/76] pinctrl: single: Fix pcs_parse_bits_in_pinctrl_entry to use __ffs than ffs Jiri Slaby
                   ` (69 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Vladis Dronov, Dmitry Torokhov, Jiri Slaby

From: Vladis Dronov <vdronov@redhat.com>

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

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

commit 162f98dea487206d9ab79fc12ed64700667a894d upstream.

The gtco driver expects at least one valid endpoint. If given malicious
descriptors that specify 0 for the number of endpoints, it will crash in
the probe function. Ensure there is at least one endpoint on the interface
before using it.

Also let's fix a minor coding style issue.

The full correct report of this issue can be found in the public
Red Hat Bugzilla:

https://bugzilla.redhat.com/show_bug.cgi?id=1283385

Reported-by: Ralf Spenneberg <ralf@spenneberg.net>
Signed-off-by: Vladis Dronov <vdronov@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/input/tablet/gtco.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c
index 29e01ab6859f..a9f8f925ba2b 100644
--- a/drivers/input/tablet/gtco.c
+++ b/drivers/input/tablet/gtco.c
@@ -869,6 +869,14 @@ static int gtco_probe(struct usb_interface *usbinterface,
 		goto err_free_buf;
 	}
 
+	/* Sanity check that a device has an endpoint */
+	if (usbinterface->altsetting[0].desc.bNumEndpoints < 1) {
+		dev_err(&usbinterface->dev,
+			"Invalid number of endpoints\n");
+		error = -EINVAL;
+		goto err_free_urb;
+	}
+
 	/*
 	 * The endpoint is always altsetting 0, we know this since we know
 	 * this device only has one interrupt endpoint
@@ -890,7 +898,7 @@ static int gtco_probe(struct usb_interface *usbinterface,
 	 * HID report descriptor
 	 */
 	if (usb_get_extra_descriptor(usbinterface->cur_altsetting,
-				     HID_DEVICE_TYPE, &hid_desc) != 0){
+				     HID_DEVICE_TYPE, &hid_desc) != 0) {
 		dev_err(&usbinterface->dev,
 			"Can't retrieve exta USB descriptor to get hid report descriptor length\n");
 		error = -EIO;
-- 
2.8.2

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

* [PATCH 3.12 09/76] pinctrl: single: Fix pcs_parse_bits_in_pinctrl_entry to use __ffs than ffs
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (7 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 08/76] Input: gtco - fix crash on detecting device without endpoints Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 10/76] EDAC: i7core, sb_edac: Don't return NOTIFY_BAD from mce_decoder callback Jiri Slaby
                   ` (68 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Keerthy, Linus Walleij, Jiri Slaby

From: Keerthy <j-keerthy@ti.com>

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

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

commit 56b367c0cd67d4c3006738e7dc9dda9273fd2bfe upstream.

pcs_parse_bits_in_pinctrl_entry uses ffs which gives bit indices
ranging from 1 to MAX. This leads to a corner case where we try to request
the pin number = MAX and fails.

bit_pos value is being calculted using ffs. pin_num_from_lsb uses
bit_pos value. pins array is populated with:

pin + pin_num_from_lsb.

The above is 1 more than usual bit indices as bit_pos uses ffs to compute
first set bit. Hence the last of the pins array is populated with the MAX
value and not MAX - 1 which causes error when we call pin_request.

mask_pos is rightly calculated as ((pcs->fmask) << (bit_pos - 1))
Consequently val_pos and submask are correct.

Hence use __ffs which gives (ffs(x) - 1) as the first bit set.

fixes: 4e7e8017a8 ("pinctrl: pinctrl-single: enhance to configure multiple pins of different modules")
Signed-off-by: Keerthy <j-keerthy@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/pinctrl/pinctrl-single.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index a82ace4d9a20..44cbed9540dd 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1263,9 +1263,9 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
 
 		/* Parse pins in each row from LSB */
 		while (mask) {
-			bit_pos = ffs(mask);
+			bit_pos = __ffs(mask);
 			pin_num_from_lsb = bit_pos / pcs->bits_per_pin;
-			mask_pos = ((pcs->fmask) << (bit_pos - 1));
+			mask_pos = ((pcs->fmask) << bit_pos);
 			val_pos = val & mask_pos;
 			submask = mask & mask_pos;
 			mask &= ~mask_pos;
@@ -1549,7 +1549,7 @@ static int pcs_probe(struct platform_device *pdev)
 	ret = of_property_read_u32(np, "pinctrl-single,function-mask",
 				   &pcs->fmask);
 	if (!ret) {
-		pcs->fshift = ffs(pcs->fmask) - 1;
+		pcs->fshift = __ffs(pcs->fmask);
 		pcs->fmax = pcs->fmask >> pcs->fshift;
 	} else {
 		/* If mask property doesn't exist, function mux is invalid. */
-- 
2.8.2

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

* [PATCH 3.12 10/76] EDAC: i7core, sb_edac: Don't return NOTIFY_BAD from mce_decoder callback
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (8 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 09/76] pinctrl: single: Fix pcs_parse_bits_in_pinctrl_entry to use __ffs than ffs Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 11/76] ASoC: s3c24xx: use const snd_soc_component_driver pointer Jiri Slaby
                   ` (67 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Tony Luck, linux-edac, Borislav Petkov, Jiri Slaby

From: Tony Luck <tony.luck@intel.com>

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

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

commit c4fc1956fa31003bfbe4f597e359d751568e2954 upstream.

Both of these drivers can return NOTIFY_BAD, but this terminates
processing other callbacks that were registered later on the chain.
Since the driver did nothing to log the error it seems wrong to prevent
other interested parties from seeing it. E.g. neither of them had even
bothered to check the type of the error to see if it was a memory error
before the return NOTIFY_BAD.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Acked-by: Aristeu Rozanski <aris@redhat.com>
Acked-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/72937355dd92318d2630979666063f8a2853495b.1461864507.git.tony.luck@intel.com
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/edac/i7core_edac.c | 2 +-
 drivers/edac/sb_edac.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index c67fb4d707d3..69c9c4ecaaa9 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -1878,7 +1878,7 @@ static int i7core_mce_check_error(struct notifier_block *nb, unsigned long val,
 
 	i7_dev = get_i7core_dev(mce->socketid);
 	if (!i7_dev)
-		return NOTIFY_BAD;
+		return NOTIFY_DONE;
 
 	mci = i7_dev->mci;
 	pvt = mci->pvt_info;
diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index 3bdefbfb4377..0d40f7f0c379 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -1538,7 +1538,7 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val,
 
 	mci = get_mci_for_node_id(mce->socketid);
 	if (!mci)
-		return NOTIFY_BAD;
+		return NOTIFY_DONE;
 	pvt = mci->pvt_info;
 
 	/*
-- 
2.8.2

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

* [PATCH 3.12 11/76] ASoC: s3c24xx: use const snd_soc_component_driver pointer
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (9 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 10/76] EDAC: i7core, sb_edac: Don't return NOTIFY_BAD from mce_decoder callback Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 12/76] ASoC: rt5640: Correct the digital interface data select Jiri Slaby
                   ` (66 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Arnd Bergmann, Mark Brown, Jiri Slaby

From: Arnd Bergmann <arnd@arndb.de>

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

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

commit ba4bc32eaa39ba7687f0958ae90eec94da613b46 upstream.

An older patch to convert the API in the s3c i2s driver
ended up passing a const pointer into a function that takes
a non-const pointer, so we now get a warning:

sound/soc/samsung/s3c2412-i2s.c: In function 's3c2412_iis_dev_probe':
sound/soc/samsung/s3c2412-i2s.c:172:9: error: passing argument 3 of 's3c_i2sv2_register_component' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]

However, the s3c_i2sv2_register_component() function again
passes the pointer into another function taking a const, so
we just need to change its prototype.

Fixes: eca3b01d0885 ("ASoC: switch over to use snd_soc_register_component() on s3c i2s")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 sound/soc/samsung/s3c-i2s-v2.c | 2 +-
 sound/soc/samsung/s3c-i2s-v2.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/samsung/s3c-i2s-v2.c b/sound/soc/samsung/s3c-i2s-v2.c
index e5e81b111001..a2edb3c904a3 100644
--- a/sound/soc/samsung/s3c-i2s-v2.c
+++ b/sound/soc/samsung/s3c-i2s-v2.c
@@ -730,7 +730,7 @@ static int s3c2412_i2s_resume(struct snd_soc_dai *dai)
 #endif
 
 int s3c_i2sv2_register_component(struct device *dev, int id,
-			   struct snd_soc_component_driver *cmp_drv,
+			   const struct snd_soc_component_driver *cmp_drv,
 			   struct snd_soc_dai_driver *dai_drv)
 {
 	struct snd_soc_dai_ops *ops = drv->ops;
diff --git a/sound/soc/samsung/s3c-i2s-v2.h b/sound/soc/samsung/s3c-i2s-v2.h
index 90abab364b49..d0684145ed1f 100644
--- a/sound/soc/samsung/s3c-i2s-v2.h
+++ b/sound/soc/samsung/s3c-i2s-v2.h
@@ -101,7 +101,7 @@ extern int s3c_i2sv2_probe(struct snd_soc_dai *dai,
  * soc core.
  */
 extern int s3c_i2sv2_register_component(struct device *dev, int id,
-					struct snd_soc_component_driver *cmp_drv,
+					const struct snd_soc_component_driver *cmp_drv,
 					struct snd_soc_dai_driver *dai_drv);
 
 #endif /* __SND_SOC_S3C24XX_S3C_I2SV2_I2S_H */
-- 
2.8.2

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

* [PATCH 3.12 12/76] ASoC: rt5640: Correct the digital interface data select
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (10 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 11/76] ASoC: s3c24xx: use const snd_soc_component_driver pointer Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 13/76] efi: Fix out-of-bounds read in variable_matches() Jiri Slaby
                   ` (65 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Sugar Zhang, Mark Brown, Jiri Slaby

From: Sugar Zhang <sugar.zhang@rock-chips.com>

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

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

commit 653aa4645244042826f105aab1be3d01b3d493ca upstream.

this patch corrects the interface adc/dac control register definition
according to datasheet.

Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 sound/soc/codecs/rt5640.c |  2 +-
 sound/soc/codecs/rt5640.h | 36 ++++++++++++++++++------------------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index aa5253a3548e..5929116fd886 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -358,7 +358,7 @@ static unsigned int bst_tlv[] = {
 
 /* Interface data select */
 static const char * const rt5640_data_select[] = {
-	"Normal", "left copy to right", "right copy to left", "Swap"};
+	"Normal", "Swap", "left copy to right", "right copy to left"};
 
 static const SOC_ENUM_SINGLE_DECL(rt5640_if1_dac_enum, RT5640_DIG_INF_DATA,
 				RT5640_IF1_DAC_SEL_SFT, rt5640_data_select);
diff --git a/sound/soc/codecs/rt5640.h b/sound/soc/codecs/rt5640.h
index 5e8df25a13f3..02e3fe767df6 100644
--- a/sound/soc/codecs/rt5640.h
+++ b/sound/soc/codecs/rt5640.h
@@ -435,39 +435,39 @@
 #define RT5640_IF1_DAC_SEL_MASK			(0x3 << 14)
 #define RT5640_IF1_DAC_SEL_SFT			14
 #define RT5640_IF1_DAC_SEL_NOR			(0x0 << 14)
-#define RT5640_IF1_DAC_SEL_L2R			(0x1 << 14)
-#define RT5640_IF1_DAC_SEL_R2L			(0x2 << 14)
-#define RT5640_IF1_DAC_SEL_SWAP			(0x3 << 14)
+#define RT5640_IF1_DAC_SEL_SWAP			(0x1 << 14)
+#define RT5640_IF1_DAC_SEL_L2R			(0x2 << 14)
+#define RT5640_IF1_DAC_SEL_R2L			(0x3 << 14)
 #define RT5640_IF1_ADC_SEL_MASK			(0x3 << 12)
 #define RT5640_IF1_ADC_SEL_SFT			12
 #define RT5640_IF1_ADC_SEL_NOR			(0x0 << 12)
-#define RT5640_IF1_ADC_SEL_L2R			(0x1 << 12)
-#define RT5640_IF1_ADC_SEL_R2L			(0x2 << 12)
-#define RT5640_IF1_ADC_SEL_SWAP			(0x3 << 12)
+#define RT5640_IF1_ADC_SEL_SWAP			(0x1 << 12)
+#define RT5640_IF1_ADC_SEL_L2R			(0x2 << 12)
+#define RT5640_IF1_ADC_SEL_R2L			(0x3 << 12)
 #define RT5640_IF2_DAC_SEL_MASK			(0x3 << 10)
 #define RT5640_IF2_DAC_SEL_SFT			10
 #define RT5640_IF2_DAC_SEL_NOR			(0x0 << 10)
-#define RT5640_IF2_DAC_SEL_L2R			(0x1 << 10)
-#define RT5640_IF2_DAC_SEL_R2L			(0x2 << 10)
-#define RT5640_IF2_DAC_SEL_SWAP			(0x3 << 10)
+#define RT5640_IF2_DAC_SEL_SWAP			(0x1 << 10)
+#define RT5640_IF2_DAC_SEL_L2R			(0x2 << 10)
+#define RT5640_IF2_DAC_SEL_R2L			(0x3 << 10)
 #define RT5640_IF2_ADC_SEL_MASK			(0x3 << 8)
 #define RT5640_IF2_ADC_SEL_SFT			8
 #define RT5640_IF2_ADC_SEL_NOR			(0x0 << 8)
-#define RT5640_IF2_ADC_SEL_L2R			(0x1 << 8)
-#define RT5640_IF2_ADC_SEL_R2L			(0x2 << 8)
-#define RT5640_IF2_ADC_SEL_SWAP			(0x3 << 8)
+#define RT5640_IF2_ADC_SEL_SWAP			(0x1 << 8)
+#define RT5640_IF2_ADC_SEL_L2R			(0x2 << 8)
+#define RT5640_IF2_ADC_SEL_R2L			(0x3 << 8)
 #define RT5640_IF3_DAC_SEL_MASK			(0x3 << 6)
 #define RT5640_IF3_DAC_SEL_SFT			6
 #define RT5640_IF3_DAC_SEL_NOR			(0x0 << 6)
-#define RT5640_IF3_DAC_SEL_L2R			(0x1 << 6)
-#define RT5640_IF3_DAC_SEL_R2L			(0x2 << 6)
-#define RT5640_IF3_DAC_SEL_SWAP			(0x3 << 6)
+#define RT5640_IF3_DAC_SEL_SWAP			(0x1 << 6)
+#define RT5640_IF3_DAC_SEL_L2R			(0x2 << 6)
+#define RT5640_IF3_DAC_SEL_R2L			(0x3 << 6)
 #define RT5640_IF3_ADC_SEL_MASK			(0x3 << 4)
 #define RT5640_IF3_ADC_SEL_SFT			4
 #define RT5640_IF3_ADC_SEL_NOR			(0x0 << 4)
-#define RT5640_IF3_ADC_SEL_L2R			(0x1 << 4)
-#define RT5640_IF3_ADC_SEL_R2L			(0x2 << 4)
-#define RT5640_IF3_ADC_SEL_SWAP			(0x3 << 4)
+#define RT5640_IF3_ADC_SEL_SWAP			(0x1 << 4)
+#define RT5640_IF3_ADC_SEL_L2R			(0x2 << 4)
+#define RT5640_IF3_ADC_SEL_R2L			(0x3 << 4)
 
 /* REC Left Mixer Control 1 (0x3b) */
 #define RT5640_G_HP_L_RM_L_MASK			(0x7 << 13)
-- 
2.8.2

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

* [PATCH 3.12 13/76] efi: Fix out-of-bounds read in variable_matches()
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (11 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 12/76] ASoC: rt5640: Correct the digital interface data select Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 14/76] workqueue: fix ghost PENDING flag while doing MQ IO Jiri Slaby
                   ` (64 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Laszlo Ersek, Peter Jones, Matthew Garrett,
	Jason Andryuk, Jani Nikula, Matt Fleming, Jiri Slaby

From: Laszlo Ersek <lersek@redhat.com>

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

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

commit 630ba0cc7a6dbafbdee43795617c872b35cde1b4 upstream.

The variable_matches() function can currently read "var_name[len]", for
example when:

 - var_name[0] == 'a',
 - len == 1
 - match_name points to the NUL-terminated string "ab".

This function is supposed to accept "var_name" inputs that are not
NUL-terminated (hence the "len" parameter"). Document the function, and
access "var_name[*match]" only if "*match" is smaller than "len".

Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Cc: Peter Jones <pjones@redhat.com>
Cc: Matthew Garrett <mjg59@coreos.com>
Cc: Jason Andryuk <jandryuk@gmail.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Link: http://thread.gmane.org/gmane.comp.freedesktop.xorg.drivers.intel/86906
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/firmware/efi/vars.c | 37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index 4e2f46938bf0..e7566d4931c6 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -202,29 +202,44 @@ static const struct variable_validate variable_validate[] = {
 	{ NULL_GUID, "", NULL },
 };
 
+/*
+ * Check if @var_name matches the pattern given in @match_name.
+ *
+ * @var_name: an array of @len non-NUL characters.
+ * @match_name: a NUL-terminated pattern string, optionally ending in "*". A
+ *              final "*" character matches any trailing characters @var_name,
+ *              including the case when there are none left in @var_name.
+ * @match: on output, the number of non-wildcard characters in @match_name
+ *         that @var_name matches, regardless of the return value.
+ * @return: whether @var_name fully matches @match_name.
+ */
 static bool
 variable_matches(const char *var_name, size_t len, const char *match_name,
 		 int *match)
 {
 	for (*match = 0; ; (*match)++) {
 		char c = match_name[*match];
-		char u = var_name[*match];
 
-		/* Wildcard in the matching name means we've matched */
-		if (c == '*')
+		switch (c) {
+		case '*':
+			/* Wildcard in @match_name means we've matched. */
 			return true;
 
-		/* Case sensitive match */
-		if (!c && *match == len)
-			return true;
+		case '\0':
+			/* @match_name has ended. Has @var_name too? */
+			return (*match == len);
 
-		if (c != u)
+		default:
+			/*
+			 * We've reached a non-wildcard char in @match_name.
+			 * Continue only if there's an identical character in
+			 * @var_name.
+			 */
+			if (*match < len && c == var_name[*match])
+				continue;
 			return false;
-
-		if (!c)
-			return true;
+		}
 	}
-	return true;
 }
 
 bool
-- 
2.8.2

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

* [PATCH 3.12 14/76] workqueue: fix ghost PENDING flag while doing MQ IO
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (12 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 13/76] efi: Fix out-of-bounds read in variable_matches() Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 15/76] paride: make 'verbose' parameter an 'int' again Jiri Slaby
                   ` (63 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Roman Pen, Gioh Kim, Michael Wang, Tejun Heo,
	Jens Axboe, linux-block, Jiri Slaby

From: Roman Pen <roman.penyaev@profitbricks.com>

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

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

commit 346c09f80459a3ad97df1816d6d606169a51001a upstream.

The bug in a workqueue leads to a stalled IO request in MQ ctx->rq_list
with the following backtrace:

[  601.347452] INFO: task kworker/u129:5:1636 blocked for more than 120 seconds.
[  601.347574]       Tainted: G           O    4.4.5-1-storage+ #6
[  601.347651] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[  601.348142] kworker/u129:5  D ffff880803077988     0  1636      2 0x00000000
[  601.348519] Workqueue: ibnbd_server_fileio_wq ibnbd_dev_file_submit_io_worker [ibnbd_server]
[  601.348999]  ffff880803077988 ffff88080466b900 ffff8808033f9c80 ffff880803078000
[  601.349662]  ffff880807c95000 7fffffffffffffff ffffffff815b0920 ffff880803077ad0
[  601.350333]  ffff8808030779a0 ffffffff815b01d5 0000000000000000 ffff880803077a38
[  601.350965] Call Trace:
[  601.351203]  [<ffffffff815b0920>] ? bit_wait+0x60/0x60
[  601.351444]  [<ffffffff815b01d5>] schedule+0x35/0x80
[  601.351709]  [<ffffffff815b2dd2>] schedule_timeout+0x192/0x230
[  601.351958]  [<ffffffff812d43f7>] ? blk_flush_plug_list+0xc7/0x220
[  601.352208]  [<ffffffff810bd737>] ? ktime_get+0x37/0xa0
[  601.352446]  [<ffffffff815b0920>] ? bit_wait+0x60/0x60
[  601.352688]  [<ffffffff815af784>] io_schedule_timeout+0xa4/0x110
[  601.352951]  [<ffffffff815b3a4e>] ? _raw_spin_unlock_irqrestore+0xe/0x10
[  601.353196]  [<ffffffff815b093b>] bit_wait_io+0x1b/0x70
[  601.353440]  [<ffffffff815b056d>] __wait_on_bit+0x5d/0x90
[  601.353689]  [<ffffffff81127bd0>] wait_on_page_bit+0xc0/0xd0
[  601.353958]  [<ffffffff81096db0>] ? autoremove_wake_function+0x40/0x40
[  601.354200]  [<ffffffff81127cc4>] __filemap_fdatawait_range+0xe4/0x140
[  601.354441]  [<ffffffff81127d34>] filemap_fdatawait_range+0x14/0x30
[  601.354688]  [<ffffffff81129a9f>] filemap_write_and_wait_range+0x3f/0x70
[  601.354932]  [<ffffffff811ced3b>] blkdev_fsync+0x1b/0x50
[  601.355193]  [<ffffffff811c82d9>] vfs_fsync_range+0x49/0xa0
[  601.355432]  [<ffffffff811cf45a>] blkdev_write_iter+0xca/0x100
[  601.355679]  [<ffffffff81197b1a>] __vfs_write+0xaa/0xe0
[  601.355925]  [<ffffffff81198379>] vfs_write+0xa9/0x1a0
[  601.356164]  [<ffffffff811c59d8>] kernel_write+0x38/0x50

The underlying device is a null_blk, with default parameters:

  queue_mode    = MQ
  submit_queues = 1

Verification that nullb0 has something inflight:

root@pserver8:~# cat /sys/block/nullb0/inflight
       0        1
root@pserver8:~# find /sys/block/nullb0/mq/0/cpu* -name rq_list -print -exec cat {} \;
...
/sys/block/nullb0/mq/0/cpu2/rq_list
CTX pending:
        ffff8838038e2400
...

During debug it became clear that stalled request is always inserted in
the rq_list from the following path:

   save_stack_trace_tsk + 34
   blk_mq_insert_requests + 231
   blk_mq_flush_plug_list + 281
   blk_flush_plug_list + 199
   wait_on_page_bit + 192
   __filemap_fdatawait_range + 228
   filemap_fdatawait_range + 20
   filemap_write_and_wait_range + 63
   blkdev_fsync + 27
   vfs_fsync_range + 73
   blkdev_write_iter + 202
   __vfs_write + 170
   vfs_write + 169
   kernel_write + 56

So blk_flush_plug_list() was called with from_schedule == true.

If from_schedule is true, that means that finally blk_mq_insert_requests()
offloads execution of __blk_mq_run_hw_queue() and uses kblockd workqueue,
i.e. it calls kblockd_schedule_delayed_work_on().

That means, that we race with another CPU, which is about to execute
__blk_mq_run_hw_queue() work.

Further debugging shows the following traces from different CPUs:

  CPU#0                                  CPU#1
  ----------------------------------     -------------------------------
  reqeust A inserted
  STORE hctx->ctx_map[0] bit marked
  kblockd_schedule...() returns 1
  <schedule to kblockd workqueue>
                                         request B inserted
                                         STORE hctx->ctx_map[1] bit marked
                                         kblockd_schedule...() returns 0
  *** WORK PENDING bit is cleared ***
  flush_busy_ctxs() is executed, but
  bit 1, set by CPU#1, is not observed

As a result request B pended forever.

This behaviour can be explained by speculative LOAD of hctx->ctx_map on
CPU#0, which is reordered with clear of PENDING bit and executed _before_
actual STORE of bit 1 on CPU#1.

The proper fix is an explicit full barrier <mfence>, which guarantees
that clear of PENDING bit is to be executed before all possible
speculative LOADS or STORES inside actual work function.

Signed-off-by: Roman Pen <roman.penyaev@profitbricks.com>
Cc: Gioh Kim <gi-oh.kim@profitbricks.com>
Cc: Michael Wang <yun.wang@profitbricks.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 kernel/workqueue.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index bb5f920268d7..2bc1257e420f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -622,6 +622,35 @@ static void set_work_pool_and_clear_pending(struct work_struct *work,
 	 */
 	smp_wmb();
 	set_work_data(work, (unsigned long)pool_id << WORK_OFFQ_POOL_SHIFT, 0);
+	/*
+	 * The following mb guarantees that previous clear of a PENDING bit
+	 * will not be reordered with any speculative LOADS or STORES from
+	 * work->current_func, which is executed afterwards.  This possible
+	 * reordering can lead to a missed execution on attempt to qeueue
+	 * the same @work.  E.g. consider this case:
+	 *
+	 *   CPU#0                         CPU#1
+	 *   ----------------------------  --------------------------------
+	 *
+	 * 1  STORE event_indicated
+	 * 2  queue_work_on() {
+	 * 3    test_and_set_bit(PENDING)
+	 * 4 }                             set_..._and_clear_pending() {
+	 * 5                                 set_work_data() # clear bit
+	 * 6                                 smp_mb()
+	 * 7                               work->current_func() {
+	 * 8				      LOAD event_indicated
+	 *				   }
+	 *
+	 * Without an explicit full barrier speculative LOAD on line 8 can
+	 * be executed before CPU#0 does STORE on line 1.  If that happens,
+	 * CPU#0 observes the PENDING bit is still set and new execution of
+	 * a @work is not queued in a hope, that CPU#1 will eventually
+	 * finish the queued @work.  Meanwhile CPU#1 does not see
+	 * event_indicated is set, because speculative LOAD was executed
+	 * before actual STORE.
+	 */
+	smp_mb();
 }
 
 static void clear_work_data(struct work_struct *work)
-- 
2.8.2

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

* [PATCH 3.12 15/76] paride: make 'verbose' parameter an 'int' again
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (13 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 14/76] workqueue: fix ghost PENDING flag while doing MQ IO Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 16/76] fbdev: da8xx-fb: fix videomodes of lcd panels Jiri Slaby
                   ` (62 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Arnd Bergmann, Tim Waugh, Sudip Mukherjee,
	Jens Axboe, Greg Kroah-Hartman, Andrew Morton, Linus Torvalds,
	Jiri Slaby

From: Arnd Bergmann <arnd@arndb.de>

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

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

commit dec63a4dec2d6d01346fd5d96062e67c0636852b upstream.

gcc-6.0 found an ancient bug in the paride driver, which had a
"module_param(verbose, bool, 0);" since before 2.6.12, but actually uses
it to accept '0', '1' or '2' as arguments:

  drivers/block/paride/pd.c: In function 'pd_init_dev_parms':
  drivers/block/paride/pd.c:298:29: warning: comparison of constant '1' with boolean expression is always false [-Wbool-compare]
   #define DBMSG(msg) ((verbose>1)?(msg):NULL)

In 2012, Rusty did a cleanup patch that also changed the type of the
variable to 'bool', which introduced what is now a gcc warning.

This changes the type back to 'int' and adapts the module_param() line
instead, so it should work as documented in case anyone ever cares about
running the ancient driver with debugging.

Fixes: 90ab5ee94171 ("module_param: make bool parameters really bool (drivers & misc)")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Rusty Russell <rusty@rustcorp.com.au>
Cc: Tim Waugh <tim@cyberelk.net>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/block/paride/pd.c | 4 ++--
 drivers/block/paride/pt.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 19ad8f0c83ef..897b6b9e53b1 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -126,7 +126,7 @@
 */
 #include <linux/types.h>
 
-static bool verbose = 0;
+static int verbose = 0;
 static int major = PD_MAJOR;
 static char *name = PD_NAME;
 static int cluster = 64;
@@ -161,7 +161,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_GEO, D_SBY, D_DLY, D_SLV};
 static DEFINE_MUTEX(pd_mutex);
 static DEFINE_SPINLOCK(pd_lock);
 
-module_param(verbose, bool, 0);
+module_param(verbose, int, 0);
 module_param(major, int, 0);
 module_param(name, charp, 0);
 module_param(cluster, int, 0);
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 2596042eb987..ada45058e04d 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -117,7 +117,7 @@
 
 */
 
-static bool verbose = 0;
+static int verbose = 0;
 static int major = PT_MAJOR;
 static char *name = PT_NAME;
 static int disable = 0;
@@ -152,7 +152,7 @@ static int (*drives[4])[6] = {&drive0, &drive1, &drive2, &drive3};
 
 #include <asm/uaccess.h>
 
-module_param(verbose, bool, 0);
+module_param(verbose, int, 0);
 module_param(major, int, 0);
 module_param(name, charp, 0);
 module_param_array(drive0, int, NULL, 0);
-- 
2.8.2

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

* [PATCH 3.12 16/76] fbdev: da8xx-fb: fix videomodes of lcd panels
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (14 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 15/76] paride: make 'verbose' parameter an 'int' again Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 17/76] misc/bmp085: Enable building as a module Jiri Slaby
                   ` (61 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Sushaanth Srirangapathi, Tomi Valkeinen, Jiri Slaby

From: Sushaanth Srirangapathi <sushaanth.s@ti.com>

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

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

commit 713fced8d10fa1c759c8fb6bf9aaa681bae68cad upstream.

Commit 028cd86b794f4a ("video: da8xx-fb: fix the polarities of the
hsync/vsync pulse") fixes polarities of HSYNC/VSYNC pulse but
forgot to update known_lcd_panels[] which had sync values
according to old logic. This breaks LCD at least on DA850 EVM.

This patch fixes this issue and I have tested this for panel
"Sharp_LK043T1DG01" using DA850 EVM board.

Fixes: 028cd86b794f4a ("video: da8xx-fb: fix the polarities of the hsync/vsync pulse")
Signed-off-by: Sushaanth Srirangapathi <sushaanth.s@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/video/da8xx-fb.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index e030e17a83f2..e68b5b229952 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -210,8 +210,7 @@ static struct fb_videomode known_lcd_panels[] = {
 		.lower_margin   = 2,
 		.hsync_len      = 0,
 		.vsync_len      = 0,
-		.sync           = FB_SYNC_CLK_INVERT |
-			FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+		.sync           = FB_SYNC_CLK_INVERT,
 	},
 	/* Sharp LK043T1DG01 */
 	[1] = {
@@ -225,7 +224,7 @@ static struct fb_videomode known_lcd_panels[] = {
 		.lower_margin   = 2,
 		.hsync_len      = 41,
 		.vsync_len      = 10,
-		.sync           = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+		.sync           = 0,
 		.flag           = 0,
 	},
 	[2] = {
@@ -240,7 +239,7 @@ static struct fb_videomode known_lcd_panels[] = {
 		.lower_margin   = 10,
 		.hsync_len      = 10,
 		.vsync_len      = 10,
-		.sync           = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+		.sync           = 0,
 		.flag           = 0,
 	},
 };
-- 
2.8.2

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

* [PATCH 3.12 17/76] misc/bmp085: Enable building as a module
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (15 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 16/76] fbdev: da8xx-fb: fix videomodes of lcd panels Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 18/76] rtc: vr41xx: Wire up alarm_irq_enable Jiri Slaby
                   ` (60 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Ben Hutchings, Eric Andersson, Greg Kroah-Hartman,
	Jiri Slaby

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

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

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

commit 50e6315dba721cbc24ccd6d7b299f1782f210a98 upstream.

Commit 985087dbcb02 'misc: add support for bmp18x chips to the bmp085
driver' changed the BMP085 config symbol to a boolean.  I see no
reason why the shared code cannot be built as a module, so change it
back to tristate.

Fixes: 985087dbcb02 ("misc: add support for bmp18x chips to the bmp085 driver")
Cc: Eric Andersson <eric.andersson@unixphere.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/misc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 8dacd4c9ee87..3eaafbc66974 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -451,7 +451,7 @@ config ARM_CHARLCD
 	  still useful.
 
 config BMP085
-	bool
+	tristate
 	depends on SYSFS
 
 config BMP085_I2C
-- 
2.8.2

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

* [PATCH 3.12 18/76] rtc: vr41xx: Wire up alarm_irq_enable
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (16 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 17/76] misc/bmp085: Enable building as a module Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 19/76] drivers/misc/ad525x_dpot: AD5274 fix RDAC read back errors Jiri Slaby
                   ` (59 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Geert Uytterhoeven, Alexandre Belloni, Jiri Slaby

From: Geert Uytterhoeven <geert@linux-m68k.org>

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

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

commit a25f4a95ec3cded34c1250364eba704c5e4fdac4 upstream.

drivers/rtc/rtc-vr41xx.c:229: warning: ‘vr41xx_rtc_alarm_irq_enable’ defined but not used

Apparently the conversion to alarm_irq_enable forgot to wire up the
callback.

Fixes: 16380c153a69c378 ("RTC: Convert rtc drivers to use the alarm_irq_enable method")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/rtc/rtc-vr41xx.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
index 54e104e197e3..1018a1d6c548 100644
--- a/drivers/rtc/rtc-vr41xx.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -272,12 +272,13 @@ static irqreturn_t rtclong1_interrupt(int irq, void *dev_id)
 }
 
 static const struct rtc_class_ops vr41xx_rtc_ops = {
-	.release	= vr41xx_rtc_release,
-	.ioctl		= vr41xx_rtc_ioctl,
-	.read_time	= vr41xx_rtc_read_time,
-	.set_time	= vr41xx_rtc_set_time,
-	.read_alarm	= vr41xx_rtc_read_alarm,
-	.set_alarm	= vr41xx_rtc_set_alarm,
+	.release		= vr41xx_rtc_release,
+	.ioctl			= vr41xx_rtc_ioctl,
+	.read_time		= vr41xx_rtc_read_time,
+	.set_time		= vr41xx_rtc_set_time,
+	.read_alarm		= vr41xx_rtc_read_alarm,
+	.set_alarm		= vr41xx_rtc_set_alarm,
+	.alarm_irq_enable	= vr41xx_rtc_alarm_irq_enable,
 };
 
 static int rtc_probe(struct platform_device *pdev)
-- 
2.8.2

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

* [PATCH 3.12 19/76] drivers/misc/ad525x_dpot: AD5274 fix RDAC read back errors
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (17 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 18/76] rtc: vr41xx: Wire up alarm_irq_enable Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 20/76] serial: sh-sci: Remove cpufreq notifier to fix crash/deadlock Jiri Slaby
                   ` (58 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Michael Hennerich, Jiri Slaby

From: Michael Hennerich <michael.hennerich@analog.com>

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

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

commit f3df53e4d70b5736368a8fe8aa1bb70c1cb1f577 upstream.

Fix RDAC read back errors caused by a typo. Value must shift by 2.

Fixes: a4bd394956f2 ("drivers/misc/ad525x_dpot.c: new features")
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/misc/ad525x_dpot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
index 0daadcf1ed7a..65fb74402c37 100644
--- a/drivers/misc/ad525x_dpot.c
+++ b/drivers/misc/ad525x_dpot.c
@@ -216,7 +216,7 @@ static s32 dpot_read_i2c(struct dpot_data *dpot, u8 reg)
 			 */
 			value = swab16(value);
 
-			if (dpot->uid == DPOT_UID(AD5271_ID))
+			if (dpot->uid == DPOT_UID(AD5274_ID))
 				value = value >> 2;
 		return value;
 	default:
-- 
2.8.2

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

* [PATCH 3.12 20/76] serial: sh-sci: Remove cpufreq notifier to fix crash/deadlock
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (18 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 19/76] drivers/misc/ad525x_dpot: AD5274 fix RDAC read back errors Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 21/76] include/linux/poison.h: fix LIST_POISON{1,2} offset Jiri Slaby
                   ` (57 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Geert Uytterhoeven, Jiri Slaby

From: Geert Uytterhoeven <geert+renesas@glider.be>

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

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

commit ff1cab374ad98f4b9f408525ca9c08992b4ed784 upstream.

The BSP team noticed that there is spin/mutex lock issue on sh-sci when
CPUFREQ is used.  The issue is that the notifier function may call
mutex_lock() while the spinlock is held, which can lead to a BUG().
This may happen if CPUFREQ is changed while another CPU calls
clk_get_rate().

Taking the spinlock was added to the notifier function in commit
e552de2413edad1a ("sh-sci: add platform device private data"), to
protect the list of serial ports against modification during traversal.
At that time the Common Clock Framework didn't exist yet, and
clk_get_rate() just returned clk->rate without taking a mutex.
Note that since commit d535a2305facf9b4 ("serial: sh-sci: Require a
device per port mapping."), there's no longer a list of serial ports to
traverse, and taking the spinlock became superfluous.

To fix the issue, just remove the cpufreq notifier:
  1. The notifier doesn't work correctly: all it does is update stored
     clock rates; it does not update the divider in the hardware.
     The divider will only be updated when calling sci_set_termios().
     I believe this was broken back in 2004, when the old
     drivers/char/sh-sci.c driver (where the notifier did update the
     divider) was replaced by drivers/serial/sh-sci.c (where the
     notifier just updated port->uartclk).
     Cfr. full-history-linux commits 6f8deaef2e9675d9 ("[PATCH] sh: port
     sh-sci driver to the new API") and 3f73fe878dc9210a ("[PATCH]
     Remove old sh-sci driver").
  2. On modern SoCs, the sh-sci parent clock rate is no longer related
     to the CPU clock rate anyway, so using a cpufreq notifier is
     futile.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/serial/sh-sci.c | 39 ---------------------------------------
 1 file changed, 39 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 537750261aaa..53c24978353c 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -41,7 +41,6 @@
 #include <linux/console.h>
 #include <linux/platform_device.h>
 #include <linux/serial_sci.h>
-#include <linux/notifier.h>
 #include <linux/pm_runtime.h>
 #include <linux/cpufreq.h>
 #include <linux/clk.h>
@@ -97,8 +96,6 @@ struct sci_port {
 	struct timer_list		rx_timer;
 	unsigned int			rx_timeout;
 #endif
-
-	struct notifier_block		freq_transition;
 };
 
 /* Function prototypes */
@@ -1008,30 +1005,6 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr)
 	return ret;
 }
 
-/*
- * Here we define a transition notifier so that we can update all of our
- * ports' baud rate when the peripheral clock changes.
- */
-static int sci_notifier(struct notifier_block *self,
-			unsigned long phase, void *p)
-{
-	struct sci_port *sci_port;
-	unsigned long flags;
-
-	sci_port = container_of(self, struct sci_port, freq_transition);
-
-	if ((phase == CPUFREQ_POSTCHANGE) ||
-	    (phase == CPUFREQ_RESUMECHANGE)) {
-		struct uart_port *port = &sci_port->port;
-
-		spin_lock_irqsave(&port->lock, flags);
-		port->uartclk = clk_get_rate(sci_port->iclk);
-		spin_unlock_irqrestore(&port->lock, flags);
-	}
-
-	return NOTIFY_OK;
-}
-
 static struct sci_irq_desc {
 	const char	*desc;
 	irq_handler_t	handler;
@@ -2427,9 +2400,6 @@ static int sci_remove(struct platform_device *dev)
 {
 	struct sci_port *port = platform_get_drvdata(dev);
 
-	cpufreq_unregister_notifier(&port->freq_transition,
-				    CPUFREQ_TRANSITION_NOTIFIER);
-
 	uart_remove_one_port(&sci_uart_driver, &port->port);
 
 	sci_cleanup_single(port);
@@ -2487,15 +2457,6 @@ static int sci_probe(struct platform_device *dev)
 	if (ret)
 		return ret;
 
-	sp->freq_transition.notifier_call = sci_notifier;
-
-	ret = cpufreq_register_notifier(&sp->freq_transition,
-					CPUFREQ_TRANSITION_NOTIFIER);
-	if (unlikely(ret < 0)) {
-		sci_cleanup_single(sp);
-		return ret;
-	}
-
 #ifdef CONFIG_SH_STANDARD_BIOS
 	sh_bios_gdb_detach();
 #endif
-- 
2.8.2

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

* [PATCH 3.12 21/76] include/linux/poison.h: fix LIST_POISON{1,2} offset
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (19 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 20/76] serial: sh-sci: Remove cpufreq notifier to fix crash/deadlock Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 22/76] Drivers: hv: vmbus: prevent cpu offlining on newer hypervisors Jiri Slaby
                   ` (56 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Vasily Kulikov, Solar Designer, Thomas Gleixner,
	Kirill A. Shutemov, Andrew Morton, Linus Torvalds, Jiri Slaby

From: Vasily Kulikov <segoon@openwall.com>

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

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

commit 8a5e5e02fc83aaf67053ab53b359af08c6c49aaf upstream.

Poison pointer values should be small enough to find a room in
non-mmap'able/hardly-mmap'able space.  E.g.  on x86 "poison pointer space"
is located starting from 0x0.  Given unprivileged users cannot mmap
anything below mmap_min_addr, it should be safe to use poison pointers
lower than mmap_min_addr.

The current poison pointer values of LIST_POISON{1,2} might be too big for
mmap_min_addr values equal or less than 1 MB (common case, e.g.  Ubuntu
uses only 0x10000).  There is little point to use such a big value given
the "poison pointer space" below 1 MB is not yet exhausted.  Changing it
to a smaller value solves the problem for small mmap_min_addr setups.

The values are suggested by Solar Designer:
http://www.openwall.com/lists/oss-security/2015/05/02/6

Signed-off-by: Vasily Kulikov <segoon@openwall.com>
Cc: Solar Designer <solar@openwall.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 include/linux/poison.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/poison.h b/include/linux/poison.h
index 2110a81c5e2a..253c9b4198ef 100644
--- a/include/linux/poison.h
+++ b/include/linux/poison.h
@@ -19,8 +19,8 @@
  * under normal circumstances, used to verify that nobody uses
  * non-initialized list entries.
  */
-#define LIST_POISON1  ((void *) 0x00100100 + POISON_POINTER_DELTA)
-#define LIST_POISON2  ((void *) 0x00200200 + POISON_POINTER_DELTA)
+#define LIST_POISON1  ((void *) 0x100 + POISON_POINTER_DELTA)
+#define LIST_POISON2  ((void *) 0x200 + POISON_POINTER_DELTA)
 
 /********** include/linux/timer.h **********/
 /*
-- 
2.8.2

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

* [PATCH 3.12 22/76] Drivers: hv: vmbus: prevent cpu offlining on newer hypervisors
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (20 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 21/76] include/linux/poison.h: fix LIST_POISON{1,2} offset Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 23/76] perf stat: Document --detailed option Jiri Slaby
                   ` (55 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Vitaly Kuznetsov, K . Y . Srinivasan,
	Chas Williams, Jiri Slaby

From: Vitaly Kuznetsov <vkuznets@redhat.com>

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

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

commit e513229b4c386e6c9f66298c13fde92f73e6e1ac upstream.

When an SMP Hyper-V guest is running on top of 2012R2 Server and secondary
cpus are sent offline (with echo 0 > /sys/devices/system/cpu/cpu$cpu/online)
the system freeze is observed. This happens due to the fact that on newer
hypervisors (Win8, WS2012R2, ...) vmbus channel handlers are distributed
across all cpus (see init_vp_index() function in drivers/hv/channel_mgmt.c)
and on cpu offlining nobody reassigns them to CPU0. Prevent cpu offlining
when vmbus is loaded until the issue is fixed host-side.

This patch also disables hibernation but it is OK as it is also broken (MCE
error is hit on resume). Suspend still works.

Tested with WS2008R2 and WS2012R2.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
[ 3chas3@gmail.com: rebase to 3.14-stable ]
Signed-off-by: Chas Williams <3chas3@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/hv/vmbus_drv.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index f9fe46f52cfa..d13f3dda6769 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -32,6 +32,7 @@
 #include <linux/acpi.h>
 #include <acpi/acpi_bus.h>
 #include <linux/completion.h>
+#include <linux/cpu.h>
 #include <linux/hyperv.h>
 #include <linux/kernel_stat.h>
 #include <asm/hyperv.h>
@@ -517,6 +518,39 @@ static void vmbus_flow_handler(unsigned int irq, struct irq_desc *desc)
 	desc->action->handler(irq, desc->action->dev_id);
 }
 
+#ifdef CONFIG_HOTPLUG_CPU
+static int hyperv_cpu_disable(void)
+{
+	return -ENOSYS;
+}
+
+static void hv_cpu_hotplug_quirk(bool vmbus_loaded)
+{
+	static void *previous_cpu_disable;
+
+	/*
+	 * Offlining a CPU when running on newer hypervisors (WS2012R2, Win8,
+	 * ...) is not supported at this moment as channel interrupts are
+	 * distributed across all of them.
+	 */
+
+	if ((vmbus_proto_version == VERSION_WS2008) ||
+	    (vmbus_proto_version == VERSION_WIN7))
+		return;
+
+	if (vmbus_loaded) {
+		previous_cpu_disable = smp_ops.cpu_disable;
+		smp_ops.cpu_disable = hyperv_cpu_disable;
+		pr_notice("CPU offlining is not supported by hypervisor\n");
+	} else if (previous_cpu_disable)
+		smp_ops.cpu_disable = previous_cpu_disable;
+}
+#else
+static void hv_cpu_hotplug_quirk(bool vmbus_loaded)
+{
+}
+#endif
+
 /*
  * vmbus_bus_init -Main vmbus driver initialization routine.
  *
@@ -575,6 +609,7 @@ static int vmbus_bus_init(int irq)
 	if (ret)
 		goto err_alloc;
 
+	hv_cpu_hotplug_quirk(true);
 	vmbus_request_offers();
 
 	return 0;
@@ -812,6 +847,7 @@ static void __exit vmbus_exit(void)
 	bus_unregister(&hv_bus);
 	hv_cleanup();
 	acpi_bus_unregister_driver(&vmbus_acpi_driver);
+	hv_cpu_hotplug_quirk(false);
 }
 
 
-- 
2.8.2

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

* [PATCH 3.12 23/76] perf stat: Document --detailed option
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (21 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 22/76] Drivers: hv: vmbus: prevent cpu offlining on newer hypervisors Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 24/76] ARM: OMAP3: Add cpuidle parameters table for omap3430 Jiri Slaby
                   ` (54 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Borislav Petkov, Arnaldo Carvalho de Melo,
	Alexander Shishkin, David Ahern, Davidlohr Bueso, Jiri Olsa,
	Mel Gorman, Namhyung Kim, Peter Zijlstra, Peter Zijlstra,
	Steven Rostedt, Thomas Gleixner, Ingo Molnar, Jiri Slaby

From: Borislav Petkov <bp@suse.de>

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

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

commit f594bae08183fb6b57db55387794ece3e1edf6f6 upstream.

I'm surprised this remained undocumented since at least 2011. And it is
actually a very useful switch, as Steve and I came to realize recently.

Add the text from

  2cba3ffb9a9d ("perf stat: Add -d -d and -d -d -d options to show more CPU events")

which added the incrementing aspect to -d.

Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Davidlohr Bueso <dbueso@suse.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mel Gorman <mgorman@suse.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 2cba3ffb9a9d ("perf stat: Add -d -d and -d -d -d options to show more CPU events")
Link: http://lkml.kernel.org/r/1457347294-32546-1-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 tools/perf/Documentation/perf-stat.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 73c9759005a3..0f5e3d75f623 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -50,6 +50,14 @@ OPTIONS
 --scale::
 	scale/normalize counter values
 
+-d::
+--detailed::
+	print more detailed statistics, can be specified up to 3 times
+
+	   -d:          detailed events, L1 and LLC data cache
+        -d -d:     more detailed events, dTLB and iTLB events
+     -d -d -d:     very detailed events, adding prefetch events
+
 -r::
 --repeat=<n>::
 	repeat command and print average + stddev (max: 100). 0 means forever.
-- 
2.8.2

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

* [PATCH 3.12 24/76] ARM: OMAP3: Add cpuidle parameters table for omap3430
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (22 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 23/76] perf stat: Document --detailed option Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 25/76] bus: imx-weim: Take the 'status' property value into account Jiri Slaby
                   ` (53 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Pali Rohár, Tony Lindgren, Jiri Slaby

From: Pali Rohár <pali.rohar@gmail.com>

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

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

commit 98f42221501353067251fbf11e732707dbb68ce3 upstream.

Based on CPU type choose generic omap3 or omap3430 specific cpuidle
parameters. Parameters for omap3430 were measured on Nokia N900 device and
added by commit 5a1b1d3a9efa ("OMAP3: RX-51: Pass cpu idle parameters")
which were later removed by commit 231900afba52 ("ARM: OMAP3: cpuidle -
remove rx51 cpuidle parameters table") due to huge code complexity.

This patch brings cpuidle parameters for omap3430 devices again, but uses
simple condition based on CPU type.

Fixes: 231900afba52 ("ARM: OMAP3: cpuidle - remove rx51 cpuidle
parameters table")
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/arm/mach-omap2/cpuidle34xx.c | 69 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 68 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
index e18709d3b95d..38e1bdcaf015 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -34,6 +34,7 @@
 #include "pm.h"
 #include "control.h"
 #include "common.h"
+#include "soc.h"
 
 /* Mach specific information to be recorded in the C-state driver_data */
 struct omap3_idle_statedata {
@@ -322,6 +323,69 @@ static struct cpuidle_driver omap3_idle_driver = {
 	.safe_state_index = 0,
 };
 
+/*
+ * Numbers based on measurements made in October 2009 for PM optimized kernel
+ * with CPU freq enabled on device Nokia N900. Assumes OPP2 (main idle OPP,
+ * and worst case latencies).
+ */
+static struct cpuidle_driver omap3430_idle_driver = {
+	.name             = "omap3430_idle",
+	.owner            = THIS_MODULE,
+	.states = {
+		{
+			.enter		  = omap3_enter_idle_bm,
+			.exit_latency	  = 110 + 162,
+			.target_residency = 5,
+			.name		  = "C1",
+			.desc		  = "MPU ON + CORE ON",
+		},
+		{
+			.enter		  = omap3_enter_idle_bm,
+			.exit_latency	  = 106 + 180,
+			.target_residency = 309,
+			.name		  = "C2",
+			.desc		  = "MPU ON + CORE ON",
+		},
+		{
+			.enter		  = omap3_enter_idle_bm,
+			.exit_latency	  = 107 + 410,
+			.target_residency = 46057,
+			.name		  = "C3",
+			.desc		  = "MPU RET + CORE ON",
+		},
+		{
+			.enter		  = omap3_enter_idle_bm,
+			.exit_latency	  = 121 + 3374,
+			.target_residency = 46057,
+			.name		  = "C4",
+			.desc		  = "MPU OFF + CORE ON",
+		},
+		{
+			.enter		  = omap3_enter_idle_bm,
+			.exit_latency	  = 855 + 1146,
+			.target_residency = 46057,
+			.name		  = "C5",
+			.desc		  = "MPU RET + CORE RET",
+		},
+		{
+			.enter		  = omap3_enter_idle_bm,
+			.exit_latency	  = 7580 + 4134,
+			.target_residency = 484329,
+			.name		  = "C6",
+			.desc		  = "MPU OFF + CORE RET",
+		},
+		{
+			.enter		  = omap3_enter_idle_bm,
+			.exit_latency	  = 7505 + 15274,
+			.target_residency = 484329,
+			.name		  = "C7",
+			.desc		  = "MPU OFF + CORE OFF",
+		},
+	},
+	.state_count = ARRAY_SIZE(omap3_idle_data),
+	.safe_state_index = 0,
+};
+
 /* Public functions */
 
 /**
@@ -340,5 +404,8 @@ int __init omap3_idle_init(void)
 	if (!mpu_pd || !core_pd || !per_pd || !cam_pd)
 		return -ENODEV;
 
-	return cpuidle_register(&omap3_idle_driver, NULL);
+	if (cpu_is_omap3430())
+		return cpuidle_register(&omap3430_idle_driver, NULL);
+	else
+		return cpuidle_register(&omap3_idle_driver, NULL);
 }
-- 
2.8.2

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

* [PATCH 3.12 25/76] bus: imx-weim: Take the 'status' property value into account
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (23 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 24/76] ARM: OMAP3: Add cpuidle parameters table for omap3430 Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 26/76] sunrpc/cache: drop reference when sunrpc_cache_pipe_upcall() detects a race Jiri Slaby
                   ` (52 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Fabio Estevam, Olof Johansson, Jiri Slaby

From: Fabio Estevam <fabio.estevam@nxp.com>

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

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

commit 33b96d2c9579213cf3f36d7b29841b1e464750c4 upstream.

Currently we have an incorrect behaviour when multiple devices
are present under the weim node. For example:

&weim {
	...
	status = "okay";

	sram@0,0 {
		...
        	status = "okay";
	};

	mram@0,0 {
		...
        	status = "disabled";
    	};
};

In this case only the 'sram' device should be probed and not 'mram'.

However what happens currently is that the status variable is ignored,
causing the 'sram' device to be disabled and 'mram' to be enabled.

Change the weim_parse_dt() function to use
for_each_available_child_of_node()so that the devices marked with
'status = disabled' are not probed.

Suggested-by: Wolfgang Netbal <wolfgang.netbal@sigmatek.at>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/bus/imx-weim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c
index 3ef58c8dbf11..78737f4fd894 100644
--- a/drivers/bus/imx-weim.c
+++ b/drivers/bus/imx-weim.c
@@ -92,7 +92,7 @@ static int __init weim_parse_dt(struct platform_device *pdev,
 	struct device_node *child;
 	int ret;
 
-	for_each_child_of_node(pdev->dev.of_node, child) {
+	for_each_available_child_of_node(pdev->dev.of_node, child) {
 		if (!child->name)
 			continue;
 
-- 
2.8.2

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

* [PATCH 3.12 26/76] sunrpc/cache: drop reference when sunrpc_cache_pipe_upcall() detects a race
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (24 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 25/76] bus: imx-weim: Take the 'status' property value into account Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 27/76] Revert "xfs: add capability check to free eofblocks ioctl" Jiri Slaby
                   ` (51 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, NeilBrown, J . Bruce Fields, Jiri Slaby

From: NeilBrown <neilb@suse.com>

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

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

commit a6ab1e8126d205238defbb55d23661a3a5c6a0d8 upstream.

sunrpc_cache_pipe_upcall() can detect a race if CACHE_PENDING is no longer
set.  In this case it aborts the queuing of the upcall.
However it has already taken a new counted reference on "h" and
doesn't "put" it, even though it frees the data structure holding the reference.

So let's delay the "cache_get" until we know we need it.

Fixes: f9e1aedc6c79 ("sunrpc/cache: remove races with queuing an upcall.")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/sunrpc/cache.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index f3e2b7d8f325..b81e0a33a8be 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1189,14 +1189,14 @@ int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h)
 	}
 
 	crq->q.reader = 0;
-	crq->item = cache_get(h);
 	crq->buf = buf;
 	crq->len = 0;
 	crq->readers = 0;
 	spin_lock(&queue_lock);
-	if (test_bit(CACHE_PENDING, &h->flags))
+	if (test_bit(CACHE_PENDING, &h->flags)) {
+		crq->item = cache_get(h);
 		list_add_tail(&crq->q.list, &detail->queue);
-	else
+	} else
 		/* Lost a race, no longer PENDING, so don't enqueue */
 		ret = -EAGAIN;
 	spin_unlock(&queue_lock);
-- 
2.8.2

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

* [PATCH 3.12 27/76] Revert "xfs: add capability check to free eofblocks ioctl"
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (25 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 26/76] sunrpc/cache: drop reference when sunrpc_cache_pipe_upcall() detects a race Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 28/76] mmc: sdhci: Allow for irq being shared Jiri Slaby
                   ` (50 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Jiri Slaby, Brian Foster, Dave Chinner, Gao feng,
	Dwight Engen, Ben Myers

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

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

This reverts commit eaeeaec383f3228446715e660851f73423501eba, upstream
commit 8c567a7fab6e086a0284eee2db82348521e7120c.

It was (mis)applied twice to stable-3.12.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Brian Foster <bfoster@redhat.com>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Gao feng <gaofeng@cn.fujitsu.com>
Cc: Dwight Engen <dwight.engen@oracle.com>
Cc: Ben Myers <bpm@sgi.com>
---
 fs/xfs/xfs_ioctl.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 52b5375faedc..93a5e91796e9 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1718,12 +1718,6 @@ xfs_file_ioctl(
 		if (mp->m_flags & XFS_MOUNT_RDONLY)
 			return -XFS_ERROR(EROFS);
 
-		if (!capable(CAP_SYS_ADMIN))
-			return -EPERM;
-
-		if (mp->m_flags & XFS_MOUNT_RDONLY)
-			return -XFS_ERROR(EROFS);
-
 		if (copy_from_user(&eofb, arg, sizeof(eofb)))
 			return -XFS_ERROR(EFAULT);
 
-- 
2.8.2

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

* [PATCH 3.12 28/76] mmc: sdhci: Allow for irq being shared
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (26 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 27/76] Revert "xfs: add capability check to free eofblocks ioctl" Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 29/76] scsi: Avoid crashing if device uses DIX but adapter does not support it Jiri Slaby
                   ` (49 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Adrian Hunter, Chris Ball, Jiri Slaby

From: Adrian Hunter <adrian.hunter@intel.com>

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

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

commit 655bca7616bf6076d30b14d1478bca6807d49c45 upstream.

If the SDHCI irq is shared with another device then the interrupt
handler can get called while SDHCI is runtime suspended.  That is
harmless but the warning message is not useful so remove it.  Also
returning IRQ_NONE is more appropriate.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Chris Ball <chris@printf.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/mmc/host/sdhci.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 4aa4d2d18933..4e697ea67ae2 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2417,9 +2417,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
 
 	if (host->runtime_suspended) {
 		spin_unlock(&host->lock);
-		pr_warning("%s: got irq while runtime suspended\n",
-		       mmc_hostname(host->mmc));
-		return IRQ_HANDLED;
+		return IRQ_NONE;
 	}
 
 	intmask = sdhci_readl(host, SDHCI_INT_STATUS);
-- 
2.8.2

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

* [PATCH 3.12 29/76] scsi: Avoid crashing if device uses DIX but adapter does not support it
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (27 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 28/76] mmc: sdhci: Allow for irq being shared Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 30/76] cpuset: Fix potential deadlock w/ set_mems_allowed Jiri Slaby
                   ` (48 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Ewan D. Milne, Christoph Hellwig, Jiri Slaby

From: "Ewan D. Milne" <emilne@redhat.com>

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

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

commit 91724c20613484555ba7e7b3d8549dac1e24f7a8 upstream.

This can happen if a multipathed device uses DIX and another path is
added via an adapter that does not support it.  Multipath should not
allow this path to be added, but we should not depend upon that to avoid
crashing.

Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/scsi/scsi_lib.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 0c6a2660d1d5..2b01c88ad416 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1096,7 +1096,17 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask)
 		struct scsi_data_buffer *prot_sdb = cmd->prot_sdb;
 		int ivecs, count;
 
-		BUG_ON(prot_sdb == NULL);
+		if (prot_sdb == NULL) {
+			/*
+			 * This can happen if someone (e.g. multipath)
+			 * queues a command to a device on an adapter
+			 * that does not support DIX.
+			 */
+			WARN_ON_ONCE(1);
+			error = BLKPREP_KILL;
+			goto err_exit;
+		}
+
 		ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio);
 
 		if (scsi_alloc_sgtable(prot_sdb, ivecs, gfp_mask)) {
-- 
2.8.2

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

* [PATCH 3.12 30/76] cpuset: Fix potential deadlock w/ set_mems_allowed
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (28 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 29/76] scsi: Avoid crashing if device uses DIX but adapter does not support it Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 31/76] compiler-gcc: disable -ftracer for __noclone functions Jiri Slaby
                   ` (47 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, John Stultz, Peter Zijlstra, Mathieu Desnoyers,
	Steven Rostedt, David S. Miller, netdev, Ingo Molnar, Jiri Slaby

From: John Stultz <john.stultz@linaro.org>

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

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

commit db751fe3ea6880ff5ac5abe60cb7b80deb5a4140 upstream.

After adding lockdep support to seqlock/seqcount structures,
I started seeing the following warning:

[    1.070907] ======================================================
[    1.072015] [ INFO: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected ]
[    1.073181] 3.11.0+ #67 Not tainted
[    1.073801] ------------------------------------------------------
[    1.074882] kworker/u4:2/708 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
[    1.076088]  (&p->mems_allowed_seq){+.+...}, at: [<ffffffff81187d7f>] new_slab+0x5f/0x280
[    1.077572]
[    1.077572] and this task is already holding:
[    1.078593]  (&(&q->__queue_lock)->rlock){..-...}, at: [<ffffffff81339f03>] blk_execute_rq_nowait+0x53/0xf0
[    1.080042] which would create a new lock dependency:
[    1.080042]  (&(&q->__queue_lock)->rlock){..-...} -> (&p->mems_allowed_seq){+.+...}
[    1.080042]
[    1.080042] but this new dependency connects a SOFTIRQ-irq-safe lock:
[    1.080042]  (&(&q->__queue_lock)->rlock){..-...}
[    1.080042] ... which became SOFTIRQ-irq-safe at:
[    1.080042]   [<ffffffff810ec179>] __lock_acquire+0x5b9/0x1db0
[    1.080042]   [<ffffffff810edfe5>] lock_acquire+0x95/0x130
[    1.080042]   [<ffffffff818968a1>] _raw_spin_lock+0x41/0x80
[    1.080042]   [<ffffffff81560c9e>] scsi_device_unbusy+0x7e/0xd0
[    1.080042]   [<ffffffff8155a612>] scsi_finish_command+0x32/0xf0
[    1.080042]   [<ffffffff81560e91>] scsi_softirq_done+0xa1/0x130
[    1.080042]   [<ffffffff8133b0f3>] blk_done_softirq+0x73/0x90
[    1.080042]   [<ffffffff81095dc0>] __do_softirq+0x110/0x2f0
[    1.080042]   [<ffffffff81095fcd>] run_ksoftirqd+0x2d/0x60
[    1.080042]   [<ffffffff810bc506>] smpboot_thread_fn+0x156/0x1e0
[    1.080042]   [<ffffffff810b3916>] kthread+0xd6/0xe0
[    1.080042]   [<ffffffff818980ac>] ret_from_fork+0x7c/0xb0
[    1.080042]
[    1.080042] to a SOFTIRQ-irq-unsafe lock:
[    1.080042]  (&p->mems_allowed_seq){+.+...}
[    1.080042] ... which became SOFTIRQ-irq-unsafe at:
[    1.080042] ...  [<ffffffff810ec1d3>] __lock_acquire+0x613/0x1db0
[    1.080042]   [<ffffffff810edfe5>] lock_acquire+0x95/0x130
[    1.080042]   [<ffffffff810b3df2>] kthreadd+0x82/0x180
[    1.080042]   [<ffffffff818980ac>] ret_from_fork+0x7c/0xb0
[    1.080042]
[    1.080042] other info that might help us debug this:
[    1.080042]
[    1.080042]  Possible interrupt unsafe locking scenario:
[    1.080042]
[    1.080042]        CPU0                    CPU1
[    1.080042]        ----                    ----
[    1.080042]   lock(&p->mems_allowed_seq);
[    1.080042]                                local_irq_disable();
[    1.080042]                                lock(&(&q->__queue_lock)->rlock);
[    1.080042]                                lock(&p->mems_allowed_seq);
[    1.080042]   <Interrupt>
[    1.080042]     lock(&(&q->__queue_lock)->rlock);
[    1.080042]
[    1.080042]  *** DEADLOCK ***

The issue stems from the kthreadd() function calling set_mems_allowed
with irqs enabled. While its possibly unlikely for the actual deadlock
to trigger, a fix is fairly simple: disable irqs before taking the
mems_allowed_seq lock.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Link: http://lkml.kernel.org/r/1381186321-4906-4-git-send-email-john.stultz@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 include/linux/cpuset.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index a7ebb89ae9fb..ade2390ffe92 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -132,10 +132,14 @@ static inline bool read_mems_allowed_retry(unsigned int seq)
 
 static inline void set_mems_allowed(nodemask_t nodemask)
 {
+	unsigned long flags;
+
 	task_lock(current);
+	local_irq_save(flags);
 	write_seqcount_begin(&current->mems_allowed_seq);
 	current->mems_allowed = nodemask;
 	write_seqcount_end(&current->mems_allowed_seq);
+	local_irq_restore(flags);
 	task_unlock(current);
 }
 
-- 
2.8.2

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

* [PATCH 3.12 31/76] compiler-gcc: disable -ftracer for __noclone functions
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (29 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 30/76] cpuset: Fix potential deadlock w/ set_mems_allowed Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 32/76] x86: LLVMLinux: Fix "incomplete type const struct x86cpu_device_id" Jiri Slaby
                   ` (46 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Paolo Bonzini, Andrew Morton, Michal Marek, kvm,
	Jiri Slaby

From: Paolo Bonzini <pbonzini@redhat.com>

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

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

commit 95272c29378ee7dc15f43fa2758cb28a5913a06d upstream.

-ftracer can duplicate asm blocks causing compilation to fail in
noclone functions.  For example, KVM declares a global variable
in an asm like

    asm("2: ... \n
         .pushsection data \n
         .global vmx_return \n
         vmx_return: .long 2b");

and -ftracer causes a double declaration.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Marek <mmarek@suse.cz>
Cc: stable@vger.kernel.org
Cc: kvm@vger.kernel.org
Reported-by: Linda Walsh <lkml@tlinx.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 include/linux/compiler-gcc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 65856c3599b4..953cd12175c4 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -177,7 +177,7 @@
 #define unreachable() __builtin_unreachable()
 
 /* Mark a function definition as prohibited from being cloned. */
-#define __noclone	__attribute__((__noclone__))
+#define __noclone	__attribute__((__noclone__, __optimize__("no-tracer")))
 
 #endif /* GCC_VERSION >= 40500 */
 
-- 
2.8.2

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

* [PATCH 3.12 32/76] x86: LLVMLinux: Fix "incomplete type const struct x86cpu_device_id"
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (30 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 31/76] compiler-gcc: disable -ftracer for __noclone functions Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 33/76] ipvs: correct initial offset of Call-ID header search in SIP persistence engine Jiri Slaby
                   ` (45 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Behan Webster, Jan-Simon Möller, Jiri Slaby

From: Behan Webster <behanw@converseincode.com>

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

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

commit c4586256f0c440bc2bdb29d2cbb915f0ca785d26 upstream.

Similar to the fix in 40413dcb7b273bda681dca38e6ff0bbb3728ef11

MODULE_DEVICE_TABLE(x86cpu, ...) expects the struct to be called struct
x86cpu_device_id, and not struct x86_cpu_id which is what is used in the rest
of the kernel code.  Although gcc seems to ignore this error, clang fails
without this define to fix the name.

Code from drivers/thermal/x86_pkg_temp_thermal.c
static const struct x86_cpu_id __initconst pkg_temp_thermal_ids[] = { ... };
MODULE_DEVICE_TABLE(x86cpu, pkg_temp_thermal_ids);

Error from clang:
drivers/thermal/x86_pkg_temp_thermal.c:577:1: error: variable has
      incomplete type 'const struct x86cpu_device_id'
MODULE_DEVICE_TABLE(x86cpu, pkg_temp_thermal_ids);
^
include/linux/module.h:145:3: note: expanded from macro
      'MODULE_DEVICE_TABLE'
  MODULE_GENERIC_TABLE(type##_device, name)
  ^
include/linux/module.h:87:32: note: expanded from macro
      'MODULE_GENERIC_TABLE'
extern const struct gtype##_id __mod_##gtype##_table            \
                               ^
<scratch space>:143:1: note: expanded from here
__mod_x86cpu_device_table
^
drivers/thermal/x86_pkg_temp_thermal.c:577:1: note: forward declaration of
      'struct x86cpu_device_id'
include/linux/module.h:145:3: note: expanded from macro
      'MODULE_DEVICE_TABLE'
  MODULE_GENERIC_TABLE(type##_device, name)
  ^
include/linux/module.h:87:21: note: expanded from macro
      'MODULE_GENERIC_TABLE'
extern const struct gtype##_id __mod_##gtype##_table            \
                    ^
<scratch space>:141:1: note: expanded from here
x86cpu_device_id
^
1 error generated.

Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[added vmbus, mei, and rapdio #defines, needed for 3.14 - gregkh]
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 include/linux/mod_devicetable.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 45e921401b06..740c6df3b3a7 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -398,6 +398,7 @@ struct virtio_device_id {
 /*
  * For Hyper-V devices we use the device guid as the id.
  */
+#define vmbus_device_id hv_vmbus_device_id
 struct hv_vmbus_device_id {
 	__u8 guid[16];
 	kernel_ulong_t driver_data;	/* Data private to the driver */
@@ -548,6 +549,11 @@ struct amba_id {
  * See documentation of "x86_match_cpu" for details.
  */
 
+/*
+ * MODULE_DEVICE_TABLE expects this struct to be called x86cpu_device_id.
+ * Although gcc seems to ignore this error, clang fails without this define.
+ */
+#define x86cpu_device_id x86_cpu_id
 struct x86_cpu_id {
 	__u16 vendor;
 	__u16 family;
@@ -575,6 +581,7 @@ struct ipack_device_id {
 #define MEI_CL_MODULE_PREFIX "mei:"
 #define MEI_CL_NAME_SIZE 32
 
+#define mei_device_id mei_cl_device_id
 struct mei_cl_device_id {
 	char name[MEI_CL_NAME_SIZE];
 	kernel_ulong_t driver_info;
@@ -594,6 +601,7 @@ struct mei_cl_device_id {
  * Identifies a RapidIO device based on both the device/vendor IDs and
  * the assembly device/vendor IDs.
  */
+#define rapidio_device_id rio_device_id
 struct rio_device_id {
 	__u16 did, vid;
 	__u16 asm_did, asm_vid;
-- 
2.8.2

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

* [PATCH 3.12 33/76] ipvs: correct initial offset of Call-ID header search in SIP persistence engine
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (31 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 32/76] x86: LLVMLinux: Fix "incomplete type const struct x86cpu_device_id" Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 34/76] nbd: ratelimit error msgs after socket close Jiri Slaby
                   ` (44 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Marco Angaroni, Simon Horman, Jiri Slaby

From: Marco Angaroni <marcoangaroni@gmail.com>

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

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

commit 7617a24f83b5d67f4dab1844956be1cebc44aec8 upstream.

The IPVS SIP persistence engine is not able to parse the SIP header
"Call-ID" when such header is inserted in the first positions of
the SIP message.

When IPVS is configured with "--pe sip" option, like for example:
ipvsadm -A -u 1.2.3.4:5060 -s rr --pe sip -p 120 -o
some particular messages (see below for details) do not create entries
in the connection template table, which can be listed with:
ipvsadm -Lcn --persistent-conn

Problematic SIP messages are SIP responses having "Call-ID" header
positioned just after message first line:
SIP/2.0 200 OK
[Call-ID header here]
[rest of the headers]

When "Call-ID" header is positioned down (after a few other headers)
it is correctly recognized.

This is due to the data offset used in get_callid function call inside
ip_vs_pe_sip.c file: since dptr already points to the start of the
SIP message, the value of dataoff should be initially 0.
Otherwise the header is searched starting from some bytes after the
first character of the SIP message.

Fixes: 758ff0338722 ("IPVS: sip persistence engine")
Signed-off-by: Marco Angaroni <marcoangaroni@gmail.com>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/netfilter/ipvs/ip_vs_pe_sip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/ipvs/ip_vs_pe_sip.c b/net/netfilter/ipvs/ip_vs_pe_sip.c
index bed5f7042529..bb318e4623a3 100644
--- a/net/netfilter/ipvs/ip_vs_pe_sip.c
+++ b/net/netfilter/ipvs/ip_vs_pe_sip.c
@@ -88,7 +88,7 @@ ip_vs_sip_fill_param(struct ip_vs_conn_param *p, struct sk_buff *skb)
 	dptr = skb->data + dataoff;
 	datalen = skb->len - dataoff;
 
-	if (get_callid(dptr, dataoff, datalen, &matchoff, &matchlen))
+	if (get_callid(dptr, 0, datalen, &matchoff, &matchlen))
 		return -EINVAL;
 
 	/* N.B: pe_data is only set on success,
-- 
2.8.2

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

* [PATCH 3.12 34/76] nbd: ratelimit error msgs after socket close
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (32 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 33/76] ipvs: correct initial offset of Call-ID header search in SIP persistence engine Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 35/76] clk: versatile: sp810: support reentrance Jiri Slaby
                   ` (43 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Dan Streetman, Markus Pargmann, Jiri Slaby

From: Dan Streetman <dan.streetman@canonical.com>

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

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

commit da6ccaaa79caca4f38b540b651238f87215217a2 upstream.

Make the "Attempted send on closed socket" error messages generated in
nbd_request_handler() ratelimited.

When the nbd socket is shutdown, the nbd_request_handler() function emits
an error message for every request remaining in its queue.  If the queue
is large, this will spam a large amount of messages to the log.  There's
no need for a separate error message for each request, so this patch
ratelimits it.

In the specific case this was found, the system was virtual and the error
messages were logged to the serial port, which overwhelmed it.

Fixes: 4d48a542b427 ("nbd: fix I/O hang on disconnected nbds")
Signed-off-by: Dan Streetman <dan.streetman@canonical.com>
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/block/nbd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index b71f4397bcfb..708b40cecfcf 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -581,8 +581,8 @@ static void do_nbd_request(struct request_queue *q)
 		BUG_ON(nbd->magic != NBD_MAGIC);
 
 		if (unlikely(!nbd->sock)) {
-			dev_err(disk_to_dev(nbd->disk),
-				"Attempted send on closed socket\n");
+			dev_err_ratelimited(disk_to_dev(nbd->disk),
+					    "Attempted send on closed socket\n");
 			req->errors++;
 			nbd_end_request(req);
 			spin_lock_irq(q->queue_lock);
-- 
2.8.2

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

* [PATCH 3.12 35/76] clk: versatile: sp810: support reentrance
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (33 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 34/76] nbd: ratelimit error msgs after socket close Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 36/76] lpfc: fix misleading indentation Jiri Slaby
                   ` (42 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Linus Walleij, Michael Turquette, Pawel Moll,
	Stephen Boyd, Jiri Slaby

From: Linus Walleij <linus.walleij@linaro.org>

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

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

commit ec7957a6aa0aaf981fb8356dc47a2cdd01cde03c upstream.

Despite care take to allocate clocks state containers the
SP810 driver actually just supports creating one instance:
all clocks registered for every instance will end up with the
exact same name and __clk_init() will fail.

Rename the timclken<0> .. timclken<n> to sp810_<instance>_<n>
so every clock on every instance gets a unique name.

This is necessary for the RealView PBA8 which has two SP810
blocks: the second block will not register its clocks unless
every clock on every instance is unique and results in boot
logs like this:

------------[ cut here ]------------
WARNING: CPU: 0 PID: 0 at ../drivers/clk/versatile/clk-sp810.c:137
  clk_sp810_of_setup+0x110/0x154()
Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted
4.5.0-rc2-00030-g352718fc39f6-dirty #225
Hardware name: ARM RealView Machine (Device Tree Support)
[<c00167f8>] (unwind_backtrace) from [<c0013204>]
             (show_stack+0x10/0x14)
[<c0013204>] (show_stack) from [<c01a049c>]
             (dump_stack+0x84/0x9c)
[<c01a049c>] (dump_stack) from [<c0024990>]
             (warn_slowpath_common+0x74/0xb0)
[<c0024990>] (warn_slowpath_common) from [<c0024a68>]
             (warn_slowpath_null+0x1c/0x24)
[<c0024a68>] (warn_slowpath_null) from [<c051eb44>]
             (clk_sp810_of_setup+0x110/0x154)
[<c051eb44>] (clk_sp810_of_setup) from [<c051e3a4>]
             (of_clk_init+0x12c/0x1c8)
[<c051e3a4>] (of_clk_init) from [<c0504714>]
             (time_init+0x20/0x2c)
[<c0504714>] (time_init) from [<c0501b18>]
             (start_kernel+0x244/0x3c4)
[<c0501b18>] (start_kernel) from [<7000807c>] (0x7000807c)
---[ end trace cb88537fdc8fa200 ]---

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Pawel Moll <pawel.moll@arm.com>
Fixes: 6e973d2c4385 "clk: vexpress: Add separate SP810 driver"
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/clk/versatile/clk-sp810.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/versatile/clk-sp810.c b/drivers/clk/versatile/clk-sp810.c
index b9e05bde0c06..a21e2fa66a2a 100644
--- a/drivers/clk/versatile/clk-sp810.c
+++ b/drivers/clk/versatile/clk-sp810.c
@@ -141,6 +141,7 @@ void __init clk_sp810_of_setup(struct device_node *node)
 	const char *parent_names[2];
 	char name[12];
 	struct clk_init_data init;
+	static int instance;
 	int i;
 
 	if (!sp810) {
@@ -172,7 +173,7 @@ void __init clk_sp810_of_setup(struct device_node *node)
 	init.num_parents = ARRAY_SIZE(parent_names);
 
 	for (i = 0; i < ARRAY_SIZE(sp810->timerclken); i++) {
-		snprintf(name, ARRAY_SIZE(name), "timerclken%d", i);
+		snprintf(name, sizeof(name), "sp810_%d_%d", instance, i);
 
 		sp810->timerclken[i].sp810 = sp810;
 		sp810->timerclken[i].channel = i;
@@ -184,5 +185,6 @@ void __init clk_sp810_of_setup(struct device_node *node)
 	}
 
 	of_clk_add_provider(node, clk_sp810_timerclken_of_get, sp810);
+	instance++;
 }
 CLK_OF_DECLARE(sp810, "arm,sp810", clk_sp810_of_setup);
-- 
2.8.2

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

* [PATCH 3.12 36/76] lpfc: fix misleading indentation
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (34 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 35/76] clk: versatile: sp810: support reentrance Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 37/76] ARM: SoCFPGA: Fix secondary CPU startup in thumb2 kernel Jiri Slaby
                   ` (41 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Arnd Bergmann, Martin K . Petersen, Jiri Slaby

From: Arnd Bergmann <arnd@arndb.de>

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

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

commit aeb6641f8ebdd61939f462a8255b316f9bfab707 upstream.

gcc-6 complains about the indentation of the lpfc_destroy_vport_work_array()
call in lpfc_online(), which clearly doesn't look right:

drivers/scsi/lpfc/lpfc_init.c: In function 'lpfc_online':
drivers/scsi/lpfc/lpfc_init.c:2880:3: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation]
   lpfc_destroy_vport_work_array(phba, vports);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/lpfc/lpfc_init.c:2863:2: note: ...this 'if' clause, but it is not
  if (vports != NULL)
  ^~

Looking at the patch that introduced this code, it's clear that the
behavior is correct and the indentation is wrong.

This fixes the indentation and adds curly braces around the previous
if() block for clarity, as that is most likely what caused the code
to be misindented in the first place.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 549e55cd2a1b ("[SCSI] lpfc 8.2.2 : Fix locking around HBA's port_list")
Reviewed-by: Sebastian Herbszt <herbszt@gmx.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/scsi/lpfc/lpfc_init.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 153de0cbfbc3..3b73eea72946 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -2697,7 +2697,7 @@ lpfc_online(struct lpfc_hba *phba)
 	}
 
 	vports = lpfc_create_vport_work_array(phba);
-	if (vports != NULL)
+	if (vports != NULL) {
 		for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
 			struct Scsi_Host *shost;
 			shost = lpfc_shost_from_vport(vports[i]);
@@ -2714,7 +2714,8 @@ lpfc_online(struct lpfc_hba *phba)
 			}
 			spin_unlock_irq(shost->host_lock);
 		}
-		lpfc_destroy_vport_work_array(phba, vports);
+	}
+	lpfc_destroy_vport_work_array(phba, vports);
 
 	lpfc_unblock_mgmt_io(phba);
 	return 0;
-- 
2.8.2

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

* [PATCH 3.12 37/76] ARM: SoCFPGA: Fix secondary CPU startup in thumb2 kernel
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (35 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 36/76] lpfc: fix misleading indentation Jiri Slaby
@ 2016-05-19  9:07 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 38/76] proc: prevent accessing /proc/<PID>/environ until it's ready Jiri Slaby
                   ` (40 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:07 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Sascha Hauer, Dinh Nguyen, Kevin Hilman, Jiri Slaby

From: Sascha Hauer <s.hauer@pengutronix.de>

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

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

commit 5616f36713ea77f57ae908bf2fef641364403c9f upstream.

The secondary CPU starts up in ARM mode. When the kernel is compiled in
thumb2 mode we have to explicitly compile the secondary startup
trampoline in ARM mode, otherwise the CPU will go to Nirvana.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/arm/mach-socfpga/headsmp.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-socfpga/headsmp.S b/arch/arm/mach-socfpga/headsmp.S
index 95c115d8b5ee..b143f946bb79 100644
--- a/arch/arm/mach-socfpga/headsmp.S
+++ b/arch/arm/mach-socfpga/headsmp.S
@@ -11,6 +11,7 @@
 #include <linux/init.h>
 
 	.arch	armv7-a
+	.arm
 
 ENTRY(secondary_trampoline)
 	movw	r2, #:lower16:cpu1start_addr
-- 
2.8.2

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

* [PATCH 3.12 38/76] proc: prevent accessing /proc/<PID>/environ until it's ready
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (36 preceding siblings ...)
  2016-05-19  9:07 ` [PATCH 3.12 37/76] ARM: SoCFPGA: Fix secondary CPU startup in thumb2 kernel Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 39/76] batman-adv: Check skb size before using encapsulated ETH+VLAN header Jiri Slaby
                   ` (39 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Mathias Krause, Emese Revfy, Pax Team, Al Viro,
	Mateusz Guzik, Alexey Dobriyan, Cyrill Gorcunov, Jarod Wilson,
	Andrew Morton, Linus Torvalds, Jiri Slaby

From: Mathias Krause <minipli@googlemail.com>

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

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

commit 8148a73c9901a8794a50f950083c00ccf97d43b3 upstream.

If /proc/<PID>/environ gets read before the envp[] array is fully set up
in create_{aout,elf,elf_fdpic,flat}_tables(), we might end up trying to
read more bytes than are actually written, as env_start will already be
set but env_end will still be zero, making the range calculation
underflow, allowing to read beyond the end of what has been written.

Fix this as it is done for /proc/<PID>/cmdline by testing env_end for
zero.  It is, apparently, intentionally set last in create_*_tables().

This bug was found by the PaX size_overflow plugin that detected the
arithmetic underflow of 'this_len = env_end - (env_start + src)' when
env_end is still zero.

The expected consequence is that userland trying to access
/proc/<PID>/environ of a not yet fully set up process may get
inconsistent data as we're in the middle of copying in the environment
variables.

Fixes: https://forums.grsecurity.net/viewtopic.php?f=3&t=4363
Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=116461
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Emese Revfy <re.emese@gmail.com>
Cc: Pax Team <pageexec@freemail.hu>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Mateusz Guzik <mguzik@redhat.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/proc/base.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 293c987a5dab..582d34aaa56e 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -844,7 +844,8 @@ static ssize_t environ_read(struct file *file, char __user *buf,
 	int ret = 0;
 	struct mm_struct *mm = file->private_data;
 
-	if (!mm)
+	/* Ensure the process spawned far enough to have an environment. */
+	if (!mm || !mm->env_end)
 		return 0;
 
 	page = (char *)__get_free_page(GFP_TEMPORARY);
-- 
2.8.2

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

* [PATCH 3.12 39/76] batman-adv: Check skb size before using encapsulated ETH+VLAN header
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (37 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 38/76] proc: prevent accessing /proc/<PID>/environ until it's ready Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 40/76] batman-adv: Fix broadcast/ogm queue limit on a removed interface Jiri Slaby
                   ` (38 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Sven Eckelmann, Marek Lindner, Antonio Quartulli,
	Jiri Slaby

From: Sven Eckelmann <sven@narfation.org>

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

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

commit c78296665c3d81f040117432ab9e1cb125521b0c upstream.

The encapsulated ethernet and VLAN header may be outside the received
ethernet frame. Thus the skb buffer size has to be checked before it can be
parsed to find out if it encapsulates another batman-adv packet.

Fixes: 420193573f11 ("batman-adv: softif bridge loop avoidance")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/batman-adv/soft-interface.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 813db4e64602..40ac803135c6 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -326,10 +326,16 @@ void batadv_interface_rx(struct net_device *soft_iface,
 	skb_pull_rcsum(skb, hdr_size);
 	skb_reset_mac_header(skb);
 
+	if (unlikely(!pskb_may_pull(skb, ETH_HLEN)))
+		goto dropped;
+
 	ethhdr = eth_hdr(skb);
 
 	switch (ntohs(ethhdr->h_proto)) {
 	case ETH_P_8021Q:
+		if (!pskb_may_pull(skb, VLAN_ETH_HLEN))
+			goto dropped;
+
 		vhdr = (struct vlan_ethhdr *)skb->data;
 		vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
 		vid |= BATADV_VLAN_HAS_TAG;
@@ -343,8 +349,6 @@ void batadv_interface_rx(struct net_device *soft_iface,
 	}
 
 	/* skb->dev & skb->pkt_type are set here */
-	if (unlikely(!pskb_may_pull(skb, ETH_HLEN)))
-		goto dropped;
 	skb->protocol = eth_type_trans(skb, soft_iface);
 
 	/* should not be necessary anymore as we use skb_pull_rcsum()
-- 
2.8.2

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

* [PATCH 3.12 40/76] batman-adv: Fix broadcast/ogm queue limit on a removed interface
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (38 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 39/76] batman-adv: Check skb size before using encapsulated ETH+VLAN header Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 41/76] batman-adv: Reduce refcnt of removed router when updating route Jiri Slaby
                   ` (37 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Linus Lüssing, Sven Eckelmann, Marek Lindner,
	Antonio Quartulli, Jiri Slaby

From: Linus Lüssing <linus.luessing@c0d3.blue>

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

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

commit c4fdb6cff2aa0ae740c5f19b6f745cbbe786d42f upstream.

When removing a single interface while a broadcast or ogm packet is
still pending then we will free the forward packet without releasing the
queue slots again.

This patch is supposed to fix this issue.

Fixes: 6d5808d4ae1b ("batman-adv: Add missing hardif_free_ref in forw_packet_free")
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
[sven@narfation.org: fix conflicts with current version]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/batman-adv/send.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 0266edd0fa7f..3e002d3d8765 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -364,6 +364,9 @@ batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
 
 		if (pending) {
 			hlist_del(&forw_packet->list);
+			if (!forw_packet->own)
+				atomic_inc(&bat_priv->batman_queue_left);
+
 			batadv_forw_packet_free(forw_packet);
 		}
 	}
@@ -390,6 +393,9 @@ batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
 
 		if (pending) {
 			hlist_del(&forw_packet->list);
+			if (!forw_packet->own)
+				atomic_inc(&bat_priv->bcast_queue_left);
+
 			batadv_forw_packet_free(forw_packet);
 		}
 	}
-- 
2.8.2

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

* [PATCH 3.12 41/76] batman-adv: Reduce refcnt of removed router when updating route
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (39 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 40/76] batman-adv: Fix broadcast/ogm queue limit on a removed interface Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 42/76] MAINTAINERS: Remove asterisk from EFI directory names Jiri Slaby
                   ` (36 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Sven Eckelmann, Marek Lindner, Antonio Quartulli,
	Jiri Slaby

From: Sven Eckelmann <sven@narfation.org>

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

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

commit d1a65f1741bfd9c69f9e4e2ad447a89b6810427d upstream.

_batadv_update_route rcu_derefences orig_ifinfo->router outside of a
spinlock protected region to print some information messages to the debug
log. But this pointer is not checked again when the new pointer is assigned
in the spinlock protected region. Thus is can happen that the value of
orig_ifinfo->router changed in the meantime and thus the reference counter
of the wrong router gets reduced after the spinlock protected region.

Just rcu_dereferencing the value of orig_ifinfo->router inside the spinlock
protected region (which also set the new pointer) is enough to get the
correct old router object.

Fixes: e1a5382f978b ("batman-adv: Make orig_node->router an rcu protected pointer")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/batman-adv/routing.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 0439395d7ba5..cf91099c4eca 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -70,6 +70,15 @@ static void _batadv_update_route(struct batadv_priv *bat_priv,
 		neigh_node = NULL;
 
 	spin_lock_bh(&orig_node->neigh_list_lock);
+	/* curr_router used earlier may not be the current orig_node->router
+	 * anymore because it was dereferenced outside of the neigh_list_lock
+	 * protected region. After the new best neighbor has replace the current
+	 * best neighbor the reference counter needs to decrease. Consequently,
+	 * the code needs to ensure the curr_router variable contains a pointer
+	 * to the replaced best neighbor.
+	 */
+	curr_router = rcu_dereference_protected(orig_node->router, true);
+
 	rcu_assign_pointer(orig_node->router, neigh_node);
 	spin_unlock_bh(&orig_node->neigh_list_lock);
 
-- 
2.8.2

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

* [PATCH 3.12 42/76] MAINTAINERS: Remove asterisk from EFI directory names
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (40 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 41/76] batman-adv: Reduce refcnt of removed router when updating route Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 43/76] x86/sysfb_efi: Fix valid BAR address range check Jiri Slaby
                   ` (35 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Matt Fleming, Ard Biesheuvel, Catalin Marinas,
	Linus Torvalds, Peter Zijlstra, Thomas Gleixner, linux-efi,
	Ingo Molnar, Jiri Slaby

From: Matt Fleming <matt@codeblueprint.co.uk>

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

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

commit e8dfe6d8f6762d515fcd4f30577f7bfcf7659887 upstream.

Mark reported that having asterisks on the end of directory names
confuses get_maintainer.pl when it encounters subdirectories, and that
my name does not appear when run on drivers/firmware/efi/libstub.

Reported-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/1462303781-8686-2-git-send-email-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 44881abcfb06..b3233331dc0d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3165,8 +3165,8 @@ F:	Documentation/x86/efi-stub.txt
 F:	arch/ia64/kernel/efi.c
 F:	arch/x86/boot/compressed/eboot.[ch]
 F:	arch/x86/include/asm/efi.h
-F:	arch/x86/platform/efi/*
-F:	drivers/firmware/efi/*
+F:	arch/x86/platform/efi/
+F:	drivers/firmware/efi/
 F:	include/linux/efi*.h
 
 EFI VARIABLE FILESYSTEM
-- 
2.8.2

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

* [PATCH 3.12 43/76] x86/sysfb_efi: Fix valid BAR address range check
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (41 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 42/76] MAINTAINERS: Remove asterisk from EFI directory names Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 44/76] ACPICA: Dispatcher: Update thread ID for recursive method calls Jiri Slaby
                   ` (34 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Wang YanQing, Matt Fleming, Ard Biesheuvel,
	David Herrmann, Linus Torvalds, Peter Zijlstra, Thomas Gleixner,
	Tomi Valkeinen, linux-efi, Ingo Molnar, Jiri Slaby

From: Wang YanQing <udknight@gmail.com>

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

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

commit c10fcb14c7afd6688c7b197a814358fecf244222 upstream.

The code for checking whether a BAR address range is valid will break
out of the loop when a start address of 0x0 is encountered.

This behaviour is wrong since by breaking out of the loop we may miss
the BAR that describes the EFI frame buffer in a later iteration.

Because of this bug I can't use video=efifb: boot parameter to get
efifb on my new ThinkPad E550 for my old linux system hard disk with
3.10 kernel. In 3.10, efifb is the only choice due to DRM/I915 not
supporting the GPU.

This patch also add a trivial optimization to break out after we find
the frame buffer address range without testing later BARs.

Signed-off-by: Wang YanQing <udknight@gmail.com>
[ Rewrote changelog. ]
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Reviewed-by: Peter Jones <pjones@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/1462454061-21561-2-git-send-email-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/x86/kernel/sysfb_efi.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/sysfb_efi.c b/arch/x86/kernel/sysfb_efi.c
index b285d4e8c68e..5da924bbf0a0 100644
--- a/arch/x86/kernel/sysfb_efi.c
+++ b/arch/x86/kernel/sysfb_efi.c
@@ -106,14 +106,24 @@ static int __init efifb_set_system(const struct dmi_system_id *id)
 					continue;
 				for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
 					resource_size_t start, end;
+					unsigned long flags;
+
+					flags = pci_resource_flags(dev, i);
+					if (!(flags & IORESOURCE_MEM))
+						continue;
+
+					if (flags & IORESOURCE_UNSET)
+						continue;
+
+					if (pci_resource_len(dev, i) == 0)
+						continue;
 
 					start = pci_resource_start(dev, i);
-					if (start == 0)
-						break;
 					end = pci_resource_end(dev, i);
 					if (screen_info.lfb_base >= start &&
 					    screen_info.lfb_base < end) {
 						found_bar = 1;
+						break;
 					}
 				}
 			}
-- 
2.8.2

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

* [PATCH 3.12 44/76] ACPICA: Dispatcher: Update thread ID for recursive method calls
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (42 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 43/76] x86/sysfb_efi: Fix valid BAR address range check Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 45/76] USB: serial: cp210x: add ID for Link ECU Jiri Slaby
                   ` (33 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Prarit Bhargava, Bob Moore, Lv Zheng,
	Rafael J . Wysocki, Jiri Slaby

From: Prarit Bhargava <prarit@redhat.com>

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

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

commit 93d68841a23a5779cef6fb9aa0ef32e7c5bd00da upstream.

ACPICA commit 7a3bd2d962f221809f25ddb826c9e551b916eb25

Set the mutex owner thread ID.
Original patch from: Prarit Bhargava <prarit@redhat.com>

Link: https://bugzilla.kernel.org/show_bug.cgi?id=115121
Link: https://github.com/acpica/acpica/commit/7a3bd2d9
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Tested-by: Andy Lutomirski <luto@kernel.org> # On a Dell XPS 13 9350
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/acpi/acpica/dsmethod.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index a9ffd44c18fe..2184259c386b 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -267,6 +267,9 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
 				obj_desc->method.mutex->mutex.
 				    original_sync_level =
 				    obj_desc->method.mutex->mutex.sync_level;
+
+				obj_desc->method.mutex->mutex.thread_id =
+				    acpi_os_get_thread_id();
 			}
 		}
 
-- 
2.8.2

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

* [PATCH 3.12 45/76] USB: serial: cp210x: add ID for Link ECU
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (43 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 44/76] ACPICA: Dispatcher: Update thread ID for recursive method calls Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 46/76] USB: serial: cp210x: add Straizona Focusers device ids Jiri Slaby
                   ` (32 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Mike Manning, Johan Hovold, Jiri Slaby

From: Mike Manning <michael@bsch.com.au>

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

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

commit 1d377f4d690637a0121eac8701f84a0aa1e69a69 upstream.

The Link ECU is an aftermarket ECU computer for vehicles that provides
full tuning abilities as well as datalogging and displaying capabilities
via the USB to Serial adapter built into the device.

Signed-off-by: Mike Manning <michael@bsch.com.au>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/serial/cp210x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index bab76bc1e525..1c352e79de20 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -140,6 +140,8 @@ static const struct usb_device_id id_table[] = {
 	{ USB_DEVICE(0x10C4, 0xF004) }, /* Elan Digital Systems USBcount50 */
 	{ USB_DEVICE(0x10C5, 0xEA61) }, /* Silicon Labs MobiData GPRS USB Modem */
 	{ USB_DEVICE(0x10CE, 0xEA6A) }, /* Silicon Labs MobiData GPRS USB Modem 100EU */
+	{ USB_DEVICE(0x12B8, 0xEC60) }, /* Link G4 ECU */
+	{ USB_DEVICE(0x12B8, 0xEC62) }, /* Link G4+ ECU */
 	{ USB_DEVICE(0x13AD, 0x9999) }, /* Baltech card reader */
 	{ USB_DEVICE(0x1555, 0x0004) }, /* Owen AC4 USB-RS485 Converter */
 	{ USB_DEVICE(0x166A, 0x0201) }, /* Clipsal 5500PACA C-Bus Pascal Automation Controller */
-- 
2.8.2

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

* [PATCH 3.12 46/76] USB: serial: cp210x: add Straizona Focusers device ids
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (44 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 45/76] USB: serial: cp210x: add ID for Link ECU Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 47/76] iio: ak8975: Fix NULL pointer exception on early interrupt Jiri Slaby
                   ` (31 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Jasem Mutlaq, Johan Hovold, Jiri Slaby

From: Jasem Mutlaq <mutlaqja@ikarustech.com>

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

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

commit 613ac23a46e10d4d4339febdd534fafadd68e059 upstream.

Adding VID:PID for Straizona Focusers to cp210x driver.

Signed-off-by: Jasem Mutlaq <mutlaqja@ikarustech.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/serial/cp210x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 1c352e79de20..4063099f429a 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -108,6 +108,7 @@ static const struct usb_device_id id_table[] = {
 	{ USB_DEVICE(0x10C4, 0x826B) }, /* Cygnal Integrated Products, Inc., Fasttrax GPS demonstration module */
 	{ USB_DEVICE(0x10C4, 0x8281) }, /* Nanotec Plug & Drive */
 	{ USB_DEVICE(0x10C4, 0x8293) }, /* Telegesis ETRX2USB */
+	{ USB_DEVICE(0x10C4, 0x82F4) }, /* Starizona MicroTouch */
 	{ USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */
 	{ USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
 	{ USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */
@@ -117,6 +118,7 @@ static const struct usb_device_id id_table[] = {
 	{ USB_DEVICE(0x10C4, 0x8418) }, /* IRZ Automation Teleport SG-10 GSM/GPRS Modem */
 	{ USB_DEVICE(0x10C4, 0x846E) }, /* BEI USB Sensor Interface (VCP) */
 	{ USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */
+	{ USB_DEVICE(0x10C4, 0x84B6) }, /* Starizona Hyperion */
 	{ USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */
 	{ USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */
 	{ USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */
-- 
2.8.2

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

* [PATCH 3.12 47/76] iio: ak8975: Fix NULL pointer exception on early interrupt
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (45 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 46/76] USB: serial: cp210x: add Straizona Focusers device ids Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 48/76] Input: ads7846 - correct the value got from SPI Jiri Slaby
                   ` (30 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Krzysztof Kozlowski, Jonathan Cameron, Jiri Slaby

From: Krzysztof Kozlowski <k.kozlowski@samsung.com>

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

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

commit 07d2390e36ee5b3265e9cc8305f2a106c8721e16 upstream.

In certain probe conditions the interrupt came right after registering
the handler causing a NULL pointer exception because of uninitialized
waitqueue:

$ udevadm trigger
i2c-gpio i2c-gpio-1: using pins 143 (SDA) and 144 (SCL)
i2c-gpio i2c-gpio-3: using pins 53 (SDA) and 52 (SCL)
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = e8b38000
[00000000] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
Modules linked in: snd_soc_i2s(+) i2c_gpio(+) snd_soc_idma snd_soc_s3c_dma snd_soc_core snd_pcm_dmaengine snd_pcm snd_timer snd soundcore ac97_bus spi_s3c64xx pwm_samsung dwc2 exynos_adc phy_exynos_usb2 exynosdrm exynos_rng rng_core rtc_s3c
CPU: 0 PID: 717 Comm: data-provider-m Not tainted 4.6.0-rc1-next-20160401-00011-g1b8d87473b9e-dirty #101
Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
(...)
(__wake_up_common) from [<c0379624>] (__wake_up+0x38/0x4c)
(__wake_up) from [<c0a41d30>] (ak8975_irq_handler+0x28/0x30)
(ak8975_irq_handler) from [<c0386720>] (handle_irq_event_percpu+0x88/0x140)
(handle_irq_event_percpu) from [<c038681c>] (handle_irq_event+0x44/0x68)
(handle_irq_event) from [<c0389c40>] (handle_edge_irq+0xf0/0x19c)
(handle_edge_irq) from [<c0385e04>] (generic_handle_irq+0x24/0x34)
(generic_handle_irq) from [<c05ee360>] (exynos_eint_gpio_irq+0x50/0x68)
(exynos_eint_gpio_irq) from [<c0386720>] (handle_irq_event_percpu+0x88/0x140)
(handle_irq_event_percpu) from [<c038681c>] (handle_irq_event+0x44/0x68)
(handle_irq_event) from [<c0389a70>] (handle_fasteoi_irq+0xb4/0x194)
(handle_fasteoi_irq) from [<c0385e04>] (generic_handle_irq+0x24/0x34)
(generic_handle_irq) from [<c03860b4>] (__handle_domain_irq+0x5c/0xb4)
(__handle_domain_irq) from [<c0301774>] (gic_handle_irq+0x54/0x94)
(gic_handle_irq) from [<c030c910>] (__irq_usr+0x50/0x80)

The bug was reproduced on exynos4412-trats2 (with a max77693 device also
using i2c-gpio) after building max77693 as a module.

Fixes: 94a6d5cf7caa ("iio:ak8975 Implement data ready interrupt handling")
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Tested-by: Gregor Boirie <gregor.boirie@parrot.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/iio/magnetometer/ak8975.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index aeba3bbdadb0..3a26a1171e3b 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -151,6 +151,8 @@ static int ak8975_setup_irq(struct ak8975_data *data)
 	int rc;
 	int irq;
 
+	init_waitqueue_head(&data->data_ready_queue);
+	clear_bit(0, &data->flags);
 	if (client->irq)
 		irq = client->irq;
 	else
@@ -166,8 +168,6 @@ static int ak8975_setup_irq(struct ak8975_data *data)
 		return rc;
 	}
 
-	init_waitqueue_head(&data->data_ready_queue);
-	clear_bit(0, &data->flags);
 	data->eoc_irq = irq;
 
 	return rc;
-- 
2.8.2

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

* [PATCH 3.12 48/76] Input: ads7846 - correct the value got from SPI
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (46 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 47/76] iio: ak8975: Fix NULL pointer exception on early interrupt Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 49/76] powerpc: scan_features() updates incorrect bits for REAL_LE Jiri Slaby
                   ` (29 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Andrey Gelman, Haibo Chen, Igor Grinberg,
	Dmitry Torokhov, Jiri Slaby

From: Andrey Gelman <andrey.gelman@compulab.co.il>

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

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

commit 879f2fea8a5a748bcbf98d2cdce9139c045505d3 upstream.

According to the touch controller spec, SPI return a 16 bit value, only 12
bits are valid, they are bit[14-3].

The value of MISO and MOSI can be configured when SPI is in idle mode.
Currently this touch driver assumes the SPI bus sets the MOSI and MISO in
low level when SPI bus is in idle mode. So the bit[15] of the value got
from SPI bus is always 0. But when SPI bus congfigures the MOSI and MISO in
high level during the SPI idle mode, the bit[15] of the value get from SPI
is always 1. If bit[15] is not masked, we may get the wrong value.

Mask the invalid bit to make sure the correct value gets returned.
Regardless of the SPI bus idle configuration.

Signed-off-by: Andrey Gelman <andrey.gelman@compulab.co.il>
Signed-off-by: Haibo Chen <haibo.chen@freescale.com>
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/input/touchscreen/ads7846.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index ea195360747e..6ad648151a89 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -700,18 +700,22 @@ static int ads7846_no_filter(void *ads, int data_idx, int *val)
 
 static int ads7846_get_value(struct ads7846 *ts, struct spi_message *m)
 {
+	int value;
 	struct spi_transfer *t =
 		list_entry(m->transfers.prev, struct spi_transfer, transfer_list);
 
 	if (ts->model == 7845) {
-		return be16_to_cpup((__be16 *)&(((char*)t->rx_buf)[1])) >> 3;
+		value = be16_to_cpup((__be16 *)&(((char *)t->rx_buf)[1]));
 	} else {
 		/*
 		 * adjust:  on-wire is a must-ignore bit, a BE12 value, then
 		 * padding; built from two 8 bit values written msb-first.
 		 */
-		return be16_to_cpup((__be16 *)t->rx_buf) >> 3;
+		value = be16_to_cpup((__be16 *)t->rx_buf);
 	}
+
+	/* enforce ADC output is 12 bits width */
+	return (value >> 3) & 0xfff;
 }
 
 static void ads7846_update_value(struct spi_message *m, int val)
-- 
2.8.2

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

* [PATCH 3.12 49/76] powerpc: scan_features() updates incorrect bits for REAL_LE
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (47 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 48/76] Input: ads7846 - correct the value got from SPI Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 50/76] Input: i8042 - lower log level for "no controller" message Jiri Slaby
                   ` (28 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Anton Blanchard, Michael Ellerman, Jiri Slaby

From: Anton Blanchard <anton@samba.org>

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

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

commit 6997e57d693b07289694239e52a10d2f02c3a46f upstream.

The REAL_LE feature entry in the ibm_pa_feature struct is missing an MMU
feature value, meaning all the remaining elements initialise the wrong
values.

This means instead of checking for byte 5, bit 0, we check for byte 0,
bit 0, and then we incorrectly set the CPU feature bit as well as MMU
feature bit 1 and CPU user feature bits 0 and 2 (5).

Checking byte 0 bit 0 (IBM numbering), means we're looking at the
"Memory Management Unit (MMU)" feature - ie. does the CPU have an MMU.
In practice that bit is set on all platforms which have the property.

This means we set CPU_FTR_REAL_LE always. In practice that seems not to
matter because all the modern cpus which have this property also
implement REAL_LE, and we've never needed to disable it.

We're also incorrectly setting MMU feature bit 1, which is:

  #define MMU_FTR_TYPE_8xx		0x00000002

Luckily the only place that looks for MMU_FTR_TYPE_8xx is in Book3E
code, which can't run on the same cpus as scan_features(). So this also
doesn't matter in practice.

Finally in the CPU user feature mask, we're setting bits 0 and 2. Bit 2
is not currently used, and bit 0 is:

  #define PPC_FEATURE_PPC_LE		0x00000001

Which says the CPU supports the old style "PPC Little Endian" mode.
Again this should be harmless in practice as no 64-bit CPUs implement
that mode.

Fix the code by adding the missing initialisation of the MMU feature.

Also add a comment marking CPU user feature bit 2 (0x4) as reserved. It
would be unsafe to start using it as old kernels incorrectly set it.

Fixes: 44ae3ab3358e ("powerpc: Free up some CPU feature bits by moving out MMU-related features")
Signed-off-by: Anton Blanchard <anton@samba.org>
[mpe: Flesh out changelog, add comment reserving 0x4]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/powerpc/include/uapi/asm/cputable.h | 1 +
 arch/powerpc/kernel/prom.c               | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/uapi/asm/cputable.h b/arch/powerpc/include/uapi/asm/cputable.h
index de2c0e4ee1aa..67de80a8e178 100644
--- a/arch/powerpc/include/uapi/asm/cputable.h
+++ b/arch/powerpc/include/uapi/asm/cputable.h
@@ -31,6 +31,7 @@
 #define PPC_FEATURE_PSERIES_PERFMON_COMPAT \
 					0x00000040
 
+/* Reserved - do not use		0x00000004 */
 #define PPC_FEATURE_TRUE_LE		0x00000002
 #define PPC_FEATURE_PPC_LE		0x00000001
 
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index b7634ce41dbc..70433feb54b8 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -159,7 +159,7 @@ static struct ibm_pa_feature {
 	{CPU_FTR_NOEXECUTE, 0, 0,	0, 6, 0},
 	{CPU_FTR_NODSISRALIGN, 0, 0,	1, 1, 1},
 	{0, MMU_FTR_CI_LARGE_PAGE, 0,	1, 2, 0},
-	{CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0},
+	{CPU_FTR_REAL_LE, 0, PPC_FEATURE_TRUE_LE, 5, 0, 0},
 };
 
 static void __init scan_features(unsigned long node, unsigned char *ftrs,
-- 
2.8.2

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

* [PATCH 3.12 50/76] Input: i8042 - lower log level for "no controller" message
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (48 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 49/76] powerpc: scan_features() updates incorrect bits for REAL_LE Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 51/76] mm/balloon_compaction: redesign ballooned pages management Jiri Slaby
                   ` (27 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Takashi Iwai, Dmitry Torokhov, Jiri Slaby

From: Takashi Iwai <tiwai@suse.de>

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

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

commit f5d75341fac6033f6afac900da110cc78e06d40d upstream.

Nowadays the machines without i8042 controller is popular, and no need
to print "No controller found" message in the error log level, which
annoys at booting in quiet mode.  Let's lower it info level.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/input/serio/i8042.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index e38024cf0227..42825216e83d 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -871,7 +871,7 @@ static int __init i8042_check_aux(void)
 static int i8042_controller_check(void)
 {
 	if (i8042_flush()) {
-		pr_err("No controller found\n");
+		pr_info("No controller found\n");
 		return -ENODEV;
 	}
 
-- 
2.8.2

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

* [PATCH 3.12 51/76] mm/balloon_compaction: redesign ballooned pages management
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (49 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 50/76] Input: i8042 - lower log level for "no controller" message Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 52/76] mm/balloon_compaction: fix deflation when compaction is disabled Jiri Slaby
                   ` (26 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Konstantin Khlebnikov, Rafael Aquini,
	Andrey Ryabinin, Andrew Morton, Linus Torvalds, Gavin Guo,
	Jiri Slaby

From: Konstantin Khlebnikov <k.khlebnikov@samsung.com>

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

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

commit d6d86c0a7f8ddc5b38cf089222cb1d9540762dc2 upstream.

Sasha Levin reported KASAN splash inside isolate_migratepages_range().
Problem is in the function __is_movable_balloon_page() which tests
AS_BALLOON_MAP in page->mapping->flags.  This function has no protection
against anonymous pages.  As result it tried to check address space flags
inside struct anon_vma.

Further investigation shows more problems in current implementation:

* Special branch in __unmap_and_move() never works:
  balloon_page_movable() checks page flags and page_count.  In
  __unmap_and_move() page is locked, reference counter is elevated, thus
  balloon_page_movable() always fails.  As a result execution goes to the
  normal migration path.  virtballoon_migratepage() returns
  MIGRATEPAGE_BALLOON_SUCCESS instead of MIGRATEPAGE_SUCCESS,
  move_to_new_page() thinks this is an error code and assigns
  newpage->mapping to NULL.  Newly migrated page lose connectivity with
  balloon an all ability for further migration.

* lru_lock erroneously required in isolate_migratepages_range() for
  isolation ballooned page.  This function releases lru_lock periodically,
  this makes migration mostly impossible for some pages.

* balloon_page_dequeue have a tight race with balloon_page_isolate:
  balloon_page_isolate could be executed in parallel with dequeue between
  picking page from list and locking page_lock.  Race is rare because they
  use trylock_page() for locking.

This patch fixes all of them.

Instead of fake mapping with special flag this patch uses special state of
page->_mapcount: PAGE_BALLOON_MAPCOUNT_VALUE = -256.  Buddy allocator uses
PAGE_BUDDY_MAPCOUNT_VALUE = -128 for similar purpose.  Storing mark
directly in struct page makes everything safer and easier.

PagePrivate is used to mark pages present in page list (i.e.  not
isolated, like PageLRU for normal pages).  It replaces special rules for
reference counter and makes balloon migration similar to migration of
normal pages.  This flag is protected by page_lock together with link to
the balloon device.

[js] backport to 3.12. MIGRATEPAGE_BALLOON_SUCCESS had to be removed
     from one more place. VM_BUG_ON_PAGE does not exist in 3.12 yet,
     use plain VM_BUG_ON.

Signed-off-by: Konstantin Khlebnikov <k.khlebnikov@samsung.com>
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Link: http://lkml.kernel.org/p/53E6CEAA.9020105@oracle.com
Cc: Rafael Aquini <aquini@redhat.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Gavin Guo <gavin.guo@canonical.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/virtio/virtio_balloon.c    | 15 +++---
 include/linux/balloon_compaction.h | 97 ++++++++++----------------------------
 include/linux/migrate.h            | 11 +----
 include/linux/mm.h                 | 19 ++++++++
 mm/balloon_compaction.c            | 26 +++++-----
 mm/compaction.c                    |  2 +-
 mm/migrate.c                       | 20 ++------
 7 files changed, 69 insertions(+), 121 deletions(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index cfda0a6c07a7..55e284935f10 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -164,8 +164,8 @@ static void release_pages_by_pfn(const u32 pfns[], unsigned int num)
 	/* Find pfns pointing at start of each page, get pages and free them. */
 	for (i = 0; i < num; i += VIRTIO_BALLOON_PAGES_PER_PAGE) {
 		struct page *page = balloon_pfn_to_page(pfns[i]);
-		balloon_page_free(page);
 		adjust_managed_page_count(page, 1);
+		put_page(page); /* balloon reference */
 	}
 }
 
@@ -399,6 +399,8 @@ int virtballoon_migratepage(struct address_space *mapping,
 	if (!mutex_trylock(&vb->balloon_lock))
 		return -EAGAIN;
 
+	get_page(newpage); /* balloon reference */
+
 	/* balloon's page migration 1st step  -- inflate "newpage" */
 	spin_lock_irqsave(&vb_dev_info->pages_lock, flags);
 	balloon_page_insert(newpage, mapping, &vb_dev_info->pages);
@@ -408,12 +410,7 @@ int virtballoon_migratepage(struct address_space *mapping,
 	set_page_pfns(vb->pfns, newpage);
 	tell_host(vb, vb->inflate_vq);
 
-	/*
-	 * balloon's page migration 2nd step -- deflate "page"
-	 *
-	 * It's safe to delete page->lru here because this page is at
-	 * an isolated migration list, and this step is expected to happen here
-	 */
+	/* balloon's page migration 2nd step -- deflate "page" */
 	balloon_page_delete(page);
 	vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE;
 	set_page_pfns(vb->pfns, page);
@@ -421,7 +418,9 @@ int virtballoon_migratepage(struct address_space *mapping,
 
 	mutex_unlock(&vb->balloon_lock);
 
-	return MIGRATEPAGE_BALLOON_SUCCESS;
+	put_page(page); /* balloon reference */
+
+	return MIGRATEPAGE_SUCCESS;
 }
 
 /* define the balloon_mapping->a_ops callback to allow balloon page migration */
diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_compaction.h
index 089743ade734..38aa07d5b81c 100644
--- a/include/linux/balloon_compaction.h
+++ b/include/linux/balloon_compaction.h
@@ -27,10 +27,13 @@
  *      counter raised only while it is under our special handling;
  *
  * iii. after the lockless scan step have selected a potential balloon page for
- *      isolation, re-test the page->mapping flags and the page ref counter
+ *      isolation, re-test the PageBalloon mark and the PagePrivate flag
  *      under the proper page lock, to ensure isolating a valid balloon page
  *      (not yet isolated, nor under release procedure)
  *
+ *  iv. isolation or dequeueing procedure must clear PagePrivate flag under
+ *      page lock together with removing page from balloon device page list.
+ *
  * The functions provided by this interface are placed to help on coping with
  * the aforementioned balloon page corner case, as well as to ensure the simple
  * set of exposed rules are satisfied while we are dealing with balloon pages
@@ -71,28 +74,6 @@ static inline void balloon_devinfo_free(struct balloon_dev_info *b_dev_info)
 	kfree(b_dev_info);
 }
 
-/*
- * balloon_page_free - release a balloon page back to the page free lists
- * @page: ballooned page to be set free
- *
- * This function must be used to properly set free an isolated/dequeued balloon
- * page at the end of a sucessful page migration, or at the balloon driver's
- * page release procedure.
- */
-static inline void balloon_page_free(struct page *page)
-{
-	/*
-	 * Balloon pages always get an extra refcount before being isolated
-	 * and before being dequeued to help on sorting out fortuite colisions
-	 * between a thread attempting to isolate and another thread attempting
-	 * to release the very same balloon page.
-	 *
-	 * Before we handle the page back to Buddy, lets drop its extra refcnt.
-	 */
-	put_page(page);
-	__free_page(page);
-}
-
 #ifdef CONFIG_BALLOON_COMPACTION
 extern bool balloon_page_isolate(struct page *page);
 extern void balloon_page_putback(struct page *page);
@@ -108,74 +89,33 @@ static inline void balloon_mapping_free(struct address_space *balloon_mapping)
 }
 
 /*
- * page_flags_cleared - helper to perform balloon @page ->flags tests.
- *
- * As balloon pages are obtained from buddy and we do not play with page->flags
- * at driver level (exception made when we get the page lock for compaction),
- * we can safely identify a ballooned page by checking if the
- * PAGE_FLAGS_CHECK_AT_PREP page->flags are all cleared.  This approach also
- * helps us skip ballooned pages that are locked for compaction or release, thus
- * mitigating their racy check at balloon_page_movable()
- */
-static inline bool page_flags_cleared(struct page *page)
-{
-	return !(page->flags & PAGE_FLAGS_CHECK_AT_PREP);
-}
-
-/*
- * __is_movable_balloon_page - helper to perform @page mapping->flags tests
+ * __is_movable_balloon_page - helper to perform @page PageBalloon tests
  */
 static inline bool __is_movable_balloon_page(struct page *page)
 {
-	struct address_space *mapping = page->mapping;
-	return mapping_balloon(mapping);
+	return PageBalloon(page);
 }
 
 /*
- * balloon_page_movable - test page->mapping->flags to identify balloon pages
- *			  that can be moved by compaction/migration.
- *
- * This function is used at core compaction's page isolation scheme, therefore
- * most pages exposed to it are not enlisted as balloon pages and so, to avoid
- * undesired side effects like racing against __free_pages(), we cannot afford
- * holding the page locked while testing page->mapping->flags here.
+ * balloon_page_movable - test PageBalloon to identify balloon pages
+ *			  and PagePrivate to check that the page is not
+ *			  isolated and can be moved by compaction/migration.
  *
  * As we might return false positives in the case of a balloon page being just
- * released under us, the page->mapping->flags need to be re-tested later,
- * under the proper page lock, at the functions that will be coping with the
- * balloon page case.
+ * released under us, this need to be re-tested later, under the page lock.
  */
 static inline bool balloon_page_movable(struct page *page)
 {
-	/*
-	 * Before dereferencing and testing mapping->flags, let's make sure
-	 * this is not a page that uses ->mapping in a different way
-	 */
-	if (page_flags_cleared(page) && !page_mapped(page) &&
-	    page_count(page) == 1)
-		return __is_movable_balloon_page(page);
-
-	return false;
+	return PageBalloon(page) && PagePrivate(page);
 }
 
 /*
  * isolated_balloon_page - identify an isolated balloon page on private
  *			   compaction/migration page lists.
- *
- * After a compaction thread isolates a balloon page for migration, it raises
- * the page refcount to prevent concurrent compaction threads from re-isolating
- * the same page. For that reason putback_movable_pages(), or other routines
- * that need to identify isolated balloon pages on private pagelists, cannot
- * rely on balloon_page_movable() to accomplish the task.
  */
 static inline bool isolated_balloon_page(struct page *page)
 {
-	/* Already isolated balloon pages, by default, have a raised refcount */
-	if (page_flags_cleared(page) && !page_mapped(page) &&
-	    page_count(page) >= 2)
-		return __is_movable_balloon_page(page);
-
-	return false;
+	return PageBalloon(page);
 }
 
 /*
@@ -192,6 +132,8 @@ static inline void balloon_page_insert(struct page *page,
 				       struct address_space *mapping,
 				       struct list_head *head)
 {
+	__SetPageBalloon(page);
+	SetPagePrivate(page);
 	page->mapping = mapping;
 	list_add(&page->lru, head);
 }
@@ -206,8 +148,12 @@ static inline void balloon_page_insert(struct page *page,
  */
 static inline void balloon_page_delete(struct page *page)
 {
+	__ClearPageBalloon(page);
 	page->mapping = NULL;
-	list_del(&page->lru);
+	if (PagePrivate(page)) {
+		ClearPagePrivate(page);
+		list_del(&page->lru);
+	}
 }
 
 /*
@@ -258,6 +204,11 @@ static inline void balloon_page_delete(struct page *page)
 	list_del(&page->lru);
 }
 
+static inline bool __is_movable_balloon_page(struct page *page)
+{
+	return false;
+}
+
 static inline bool balloon_page_movable(struct page *page)
 {
 	return false;
diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 449905ebcab3..ebee4fe4c948 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -13,18 +13,9 @@ typedef void free_page_t(struct page *page, unsigned long private);
  * Return values from addresss_space_operations.migratepage():
  * - negative errno on page migration failure;
  * - zero on page migration success;
- *
- * The balloon page migration introduces this special case where a 'distinct'
- * return code is used to flag a successful page migration to unmap_and_move().
- * This approach is necessary because page migration can race against balloon
- * deflation procedure, and for such case we could introduce a nasty page leak
- * if a successfully migrated balloon page gets released concurrently with
- * migration's unmap_and_move() wrap-up steps.
  */
 #define MIGRATEPAGE_SUCCESS		0
-#define MIGRATEPAGE_BALLOON_SUCCESS	1 /* special ret code for balloon page
-					   * sucessful migration case.
-					   */
+
 enum migrate_reason {
 	MR_COMPACTION,
 	MR_MEMORY_FAILURE,
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 3f4bb8eb12a4..79aa518c16a3 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -477,6 +477,25 @@ static inline void __ClearPageBuddy(struct page *page)
 	atomic_set(&page->_mapcount, -1);
 }
 
+#define PAGE_BALLOON_MAPCOUNT_VALUE (-256)
+
+static inline int PageBalloon(struct page *page)
+{
+	return atomic_read(&page->_mapcount) == PAGE_BALLOON_MAPCOUNT_VALUE;
+}
+
+static inline void __SetPageBalloon(struct page *page)
+{
+	VM_BUG_ON(atomic_read(&page->_mapcount) != -1);
+	atomic_set(&page->_mapcount, PAGE_BALLOON_MAPCOUNT_VALUE);
+}
+
+static inline void __ClearPageBalloon(struct page *page)
+{
+	VM_BUG_ON(!PageBalloon(page));
+	atomic_set(&page->_mapcount, -1);
+}
+
 void put_page(struct page *page);
 void put_pages_list(struct list_head *pages);
 
diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
index 07dbc8ec46cf..d7aae638b585 100644
--- a/mm/balloon_compaction.c
+++ b/mm/balloon_compaction.c
@@ -93,17 +93,12 @@ struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info)
 		 * to be released by the balloon driver.
 		 */
 		if (trylock_page(page)) {
+			if (!PagePrivate(page)) {
+				/* raced with isolation */
+				unlock_page(page);
+				continue;
+			}
 			spin_lock_irqsave(&b_dev_info->pages_lock, flags);
-			/*
-			 * Raise the page refcount here to prevent any wrong
-			 * attempt to isolate this page, in case of coliding
-			 * with balloon_page_isolate() just after we release
-			 * the page lock.
-			 *
-			 * balloon_page_free() will take care of dropping
-			 * this extra refcount later.
-			 */
-			get_page(page);
 			balloon_page_delete(page);
 			spin_unlock_irqrestore(&b_dev_info->pages_lock, flags);
 			unlock_page(page);
@@ -187,7 +182,9 @@ static inline void __isolate_balloon_page(struct page *page)
 {
 	struct balloon_dev_info *b_dev_info = page->mapping->private_data;
 	unsigned long flags;
+
 	spin_lock_irqsave(&b_dev_info->pages_lock, flags);
+	ClearPagePrivate(page);
 	list_del(&page->lru);
 	b_dev_info->isolated_pages++;
 	spin_unlock_irqrestore(&b_dev_info->pages_lock, flags);
@@ -197,7 +194,9 @@ static inline void __putback_balloon_page(struct page *page)
 {
 	struct balloon_dev_info *b_dev_info = page->mapping->private_data;
 	unsigned long flags;
+
 	spin_lock_irqsave(&b_dev_info->pages_lock, flags);
+	SetPagePrivate(page);
 	list_add(&page->lru, &b_dev_info->pages);
 	b_dev_info->isolated_pages--;
 	spin_unlock_irqrestore(&b_dev_info->pages_lock, flags);
@@ -235,12 +234,11 @@ bool balloon_page_isolate(struct page *page)
 		 */
 		if (likely(trylock_page(page))) {
 			/*
-			 * A ballooned page, by default, has just one refcount.
+			 * A ballooned page, by default, has PagePrivate set.
 			 * Prevent concurrent compaction threads from isolating
-			 * an already isolated balloon page by refcount check.
+			 * an already isolated balloon page by clearing it.
 			 */
-			if (__is_movable_balloon_page(page) &&
-			    page_count(page) == 2) {
+			if (balloon_page_movable(page)) {
 				__isolate_balloon_page(page);
 				unlock_page(page);
 				return true;
diff --git a/mm/compaction.c b/mm/compaction.c
index ddcdbe0e42d9..6590b57db751 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -595,7 +595,7 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
 		 */
 		if (!PageLRU(page)) {
 			if (unlikely(balloon_page_movable(page))) {
-				if (locked && balloon_page_isolate(page)) {
+				if (balloon_page_isolate(page)) {
 					/* Successfully isolated */
 					goto isolate_success;
 				}
diff --git a/mm/migrate.c b/mm/migrate.c
index 05502f10c842..0c14c0e1bdd6 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -856,7 +856,7 @@ static int __unmap_and_move(struct page *page, struct page *newpage,
 		}
 	}
 
-	if (unlikely(balloon_page_movable(page))) {
+	if (unlikely(isolated_balloon_page(page))) {
 		/*
 		 * A ballooned page does not need any special attention from
 		 * physical to virtual reverse mapping procedures.
@@ -904,9 +904,7 @@ skip_unmap:
 		put_anon_vma(anon_vma);
 
 uncharge:
-	mem_cgroup_end_migration(mem, page, newpage,
-				 (rc == MIGRATEPAGE_SUCCESS ||
-				  rc == MIGRATEPAGE_BALLOON_SUCCESS));
+	mem_cgroup_end_migration(mem, page, newpage, rc == MIGRATEPAGE_SUCCESS);
 	unlock_page(page);
 out:
 	return rc;
@@ -938,17 +936,6 @@ static int unmap_and_move(new_page_t get_new_page, free_page_t put_new_page,
 
 	rc = __unmap_and_move(page, newpage, force, mode);
 
-	if (unlikely(rc == MIGRATEPAGE_BALLOON_SUCCESS)) {
-		/*
-		 * A ballooned page has been migrated already.
-		 * Now, it's the time to wrap-up counters,
-		 * handle the page back to Buddy and return.
-		 */
-		dec_zone_page_state(page, NR_ISOLATED_ANON +
-				    page_is_file_cache(page));
-		balloon_page_free(page);
-		return MIGRATEPAGE_SUCCESS;
-	}
 out:
 	if (rc != -EAGAIN) {
 		/*
@@ -971,6 +958,9 @@ out:
 	if (rc != MIGRATEPAGE_SUCCESS && put_new_page) {
 		ClearPageSwapBacked(newpage);
 		put_new_page(newpage, private);
+	} else if (unlikely(__is_movable_balloon_page(newpage))) {
+		/* drop our reference, page already in the balloon */
+		put_page(newpage);
 	} else
 		putback_lru_page(newpage);
 
-- 
2.8.2

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

* [PATCH 3.12 52/76] mm/balloon_compaction: fix deflation when compaction is disabled
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (50 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 51/76] mm/balloon_compaction: redesign ballooned pages management Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 53/76] crypto: hash - Fix page length clamping in hash walk Jiri Slaby
                   ` (25 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Konstantin Khlebnikov, Andrew Morton,
	Linus Torvalds, Gavin Guo, Jiri Slaby

From: Konstantin Khlebnikov <k.khlebnikov@samsung.com>

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

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

commit 4d88e6f7d5ffc84e6094a47925870f4a130555c2 upstream.

If CONFIG_BALLOON_COMPACTION=n balloon_page_insert() does not link pages
with balloon and doesn't set PagePrivate flag, as a result
balloon_page_dequeue() cannot get any pages because it thinks that all
of them are isolated.  Without balloon compaction nobody can isolate
ballooned pages.  It's safe to remove this check.

Fixes: d6d86c0a7f8d ("mm/balloon_compaction: redesign ballooned pages management").
Signed-off-by: Konstantin Khlebnikov <k.khlebnikov@samsung.com>
Reported-by: Matt Mullins <mmullins@mmlx.us>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Gavin Guo <gavin.guo@canonical.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 mm/balloon_compaction.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
index d7aae638b585..2ad56effb962 100644
--- a/mm/balloon_compaction.c
+++ b/mm/balloon_compaction.c
@@ -93,11 +93,13 @@ struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info)
 		 * to be released by the balloon driver.
 		 */
 		if (trylock_page(page)) {
+#ifdef CONFIG_BALLOON_COMPACTION
 			if (!PagePrivate(page)) {
 				/* raced with isolation */
 				unlock_page(page);
 				continue;
 			}
+#endif
 			spin_lock_irqsave(&b_dev_info->pages_lock, flags);
 			balloon_page_delete(page);
 			spin_unlock_irqrestore(&b_dev_info->pages_lock, flags);
-- 
2.8.2

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

* [PATCH 3.12 53/76] crypto: hash - Fix page length clamping in hash walk
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (51 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 52/76] mm/balloon_compaction: fix deflation when compaction is disabled Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 54/76] get_rock_ridge_filename(): handle malformed NM entries Jiri Slaby
                   ` (24 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Herbert Xu, Jiri Slaby

From: Herbert Xu <herbert@gondor.apana.org.au>

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

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

commit 13f4bb78cf6a312bbdec367ba3da044b09bf0e29 upstream.

The crypto hash walk code is broken when supplied with an offset
greater than or equal to PAGE_SIZE.  This patch fixes it by adjusting
walk->pg and walk->offset when this happens.

Reported-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 crypto/ahash.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/crypto/ahash.c b/crypto/ahash.c
index b246858ca032..781a8a73a7ff 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -64,8 +64,9 @@ static int hash_walk_new_entry(struct crypto_hash_walk *walk)
 	struct scatterlist *sg;
 
 	sg = walk->sg;
-	walk->pg = sg_page(sg);
 	walk->offset = sg->offset;
+	walk->pg = sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT);
+	walk->offset = offset_in_page(walk->offset);
 	walk->entrylen = sg->length;
 
 	if (walk->entrylen > walk->total)
-- 
2.8.2

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

* [PATCH 3.12 54/76] get_rock_ridge_filename(): handle malformed NM entries
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (52 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 53/76] crypto: hash - Fix page length clamping in hash walk Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 55/76] Input: max8997-haptic - fix NULL pointer dereference Jiri Slaby
                   ` (23 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Al Viro, Jiri Slaby

From: Al Viro <viro@zeniv.linux.org.uk>

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

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

commit 99d825822eade8d827a1817357cbf3f889a552d6 upstream.

Payloads of NM entries are not supposed to contain NUL.  When we run
into such, only the part prior to the first NUL goes into the
concatenation (i.e. the directory entry name being encoded by a bunch
of NM entries).  We do stop when the amount collected so far + the
claimed amount in the current NM entry exceed 254.  So far, so good,
but what we return as the total length is the sum of *claimed*
sizes, not the actual amount collected.  And that can grow pretty
large - not unlimited, since you'd need to put CE entries in
between to be able to get more than the maximum that could be
contained in one isofs directory entry / continuation chunk and
we are stop once we'd encountered 32 CEs, but you can get about 8Kb
easily.  And that's what will be passed to readdir callback as the
name length.  8Kb __copy_to_user() from a buffer allocated by
__get_free_page()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/isofs/rock.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index 735d7522a3a9..204659a5f6db 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -203,6 +203,8 @@ int get_rock_ridge_filename(struct iso_directory_record *de,
 	int retnamlen = 0;
 	int truncate = 0;
 	int ret = 0;
+	char *p;
+	int len;
 
 	if (!ISOFS_SB(inode->i_sb)->s_rock)
 		return 0;
@@ -267,12 +269,17 @@ repeat:
 					rr->u.NM.flags);
 				break;
 			}
-			if ((strlen(retname) + rr->len - 5) >= 254) {
+			len = rr->len - 5;
+			if (retnamlen + len >= 254) {
 				truncate = 1;
 				break;
 			}
-			strncat(retname, rr->u.NM.name, rr->len - 5);
-			retnamlen += rr->len - 5;
+			p = memchr(rr->u.NM.name, '\0', len);
+			if (unlikely(p))
+				len = p - rr->u.NM.name;
+			memcpy(retname + retnamlen, rr->u.NM.name, len);
+			retnamlen += len;
+			retname[retnamlen] = '\0';
 			break;
 		case SIG('R', 'E'):
 			kfree(rs.buffer);
-- 
2.8.2

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

* [PATCH 3.12 55/76] Input: max8997-haptic - fix NULL pointer dereference
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (53 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 54/76] get_rock_ridge_filename(): handle malformed NM entries Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 56/76] asmlinkage, pnp: Make variables used from assembler code visible Jiri Slaby
                   ` (22 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Marek Szyprowski, Krzysztof Kozlowski,
	Dmitry Torokhov, Jiri Slaby

From: Marek Szyprowski <m.szyprowski@samsung.com>

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

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

commit 6ae645d5fa385f3787bf1723639cd907fe5865e7 upstream.

NULL pointer derefence happens when booting with DTB because the
platform data for haptic device is not set in supplied data from parent
MFD device.

The MFD device creates only platform data (from Device Tree) for itself,
not for haptic child.

Unable to handle kernel NULL pointer dereference at virtual address 0000009c
pgd = c0004000
	[0000009c] *pgd=00000000
	Internal error: Oops: 5 [#1] PREEMPT SMP ARM
	(max8997_haptic_probe) from [<c03f9cec>] (platform_drv_probe+0x4c/0xb0)
	(platform_drv_probe) from [<c03f8440>] (driver_probe_device+0x214/0x2c0)
	(driver_probe_device) from [<c03f8598>] (__driver_attach+0xac/0xb0)
	(__driver_attach) from [<c03f67ac>] (bus_for_each_dev+0x68/0x9c)
	(bus_for_each_dev) from [<c03f7a38>] (bus_add_driver+0x1a0/0x218)
	(bus_add_driver) from [<c03f8db0>] (driver_register+0x78/0xf8)
	(driver_register) from [<c0101774>] (do_one_initcall+0x90/0x1d8)
	(do_one_initcall) from [<c0a00dbc>] (kernel_init_freeable+0x15c/0x1fc)
	(kernel_init_freeable) from [<c06bb5b4>] (kernel_init+0x8/0x114)
	(kernel_init) from [<c0107938>] (ret_from_fork+0x14/0x3c)

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Fixes: 104594b01ce7 ("Input: add driver support for MAX8997-haptic")
[k.kozlowski: Write commit message, add CC-stable]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/input/misc/max8997_haptic.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/input/misc/max8997_haptic.c b/drivers/input/misc/max8997_haptic.c
index e973133212a5..a8c91226cd22 100644
--- a/drivers/input/misc/max8997_haptic.c
+++ b/drivers/input/misc/max8997_haptic.c
@@ -246,12 +246,14 @@ static int max8997_haptic_probe(struct platform_device *pdev)
 	struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
 	const struct max8997_platform_data *pdata =
 					dev_get_platdata(iodev->dev);
-	const struct max8997_haptic_platform_data *haptic_pdata =
-					pdata->haptic_pdata;
+	const struct max8997_haptic_platform_data *haptic_pdata = NULL;
 	struct max8997_haptic *chip;
 	struct input_dev *input_dev;
 	int error;
 
+	if (pdata)
+		haptic_pdata = pdata->haptic_pdata;
+
 	if (!haptic_pdata) {
 		dev_err(&pdev->dev, "no haptic platform data\n");
 		return -EINVAL;
-- 
2.8.2

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

* [PATCH 3.12 56/76] asmlinkage, pnp: Make variables used from assembler code visible
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (54 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 55/76] Input: max8997-haptic - fix NULL pointer dereference Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 57/76] drm/radeon: fix PLL sharing on DCE6.1 (v2) Jiri Slaby
                   ` (21 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Andi Kleen, Jaroslav Kysela, H . Peter Anvin,
	Christoph Biedl, Jiri Slaby

From: Andi Kleen <ak@linux.intel.com>

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

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

commit a99aa42d0253f033cbb85096d3f2bd82201321e6 upstream.

Mark variables referenced from assembler files visible.

This fixes compile problems with LTO.

Cc: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1391845930-28580-4-git-send-email-ak@linux.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Christoph Biedl <linux-kernel.bfrz@manchmal.in-ulm.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/pnp/pnpbios/bioscalls.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
index 769d265b221b..deb7f4bcdb7b 100644
--- a/drivers/pnp/pnpbios/bioscalls.c
+++ b/drivers/pnp/pnpbios/bioscalls.c
@@ -21,7 +21,7 @@
 
 #include "pnpbios.h"
 
-static struct {
+__visible struct {
 	u16 offset;
 	u16 segment;
 } pnp_bios_callpoint;
@@ -41,6 +41,7 @@ asmlinkage void pnp_bios_callfunc(void);
 
 __asm__(".text			\n"
 	__ALIGN_STR "\n"
+	".globl pnp_bios_callfunc\n"
 	"pnp_bios_callfunc:\n"
 	"	pushl %edx	\n"
 	"	pushl %ecx	\n"
@@ -66,9 +67,9 @@ static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
  * after PnP BIOS oopses.
  */
 
-u32 pnp_bios_fault_esp;
-u32 pnp_bios_fault_eip;
-u32 pnp_bios_is_utter_crap = 0;
+__visible u32 pnp_bios_fault_esp;
+__visible u32 pnp_bios_fault_eip;
+__visible u32 pnp_bios_is_utter_crap = 0;
 
 static spinlock_t pnp_bios_lock;
 
-- 
2.8.2

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

* [PATCH 3.12 00/76] 3.12.60-stable review
@ 2016-05-19  9:08 Jiri Slaby
  2016-05-19  9:07 ` [PATCH 3.12 01/76] crypto: gcm - Fix rfc4543 decryption crash Jiri Slaby
                   ` (77 more replies)
  0 siblings, 78 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux, shuah.kh, linux-kernel, Jiri Slaby

This is the start of the stable review cycle for the 3.12.60 release.
There are 76 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Mon May 23 11:07:53 CEST 2016.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:
	http://kernel.org/pub/linux/kernel/people/jirislaby/stable-review/patch-3.12.60-rc1.xz
and the diffstat can be found below.

thanks,
js

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


Adrian Hunter (1):
  mmc: sdhci: Allow for irq being shared

Al Viro (1):
  get_rock_ridge_filename(): handle malformed NM entries

Andi Kleen (1):
  asmlinkage, pnp: Make variables used from assembler code visible

Andrey Gelman (1):
  Input: ads7846 - correct the value got from SPI

Anton Blanchard (1):
  powerpc: scan_features() updates incorrect bits for REAL_LE

Antonio Alecrim Jr (1):
  X.509: remove possible code fragility: enumeration values not handled

Arnd Bergmann (3):
  ASoC: s3c24xx: use const snd_soc_component_driver pointer
  paride: make 'verbose' parameter an 'int' again
  lpfc: fix misleading indentation

Behan Webster (1):
  x86: LLVMLinux: Fix "incomplete type const struct x86cpu_device_id"

Ben Hutchings (2):
  misc/bmp085: Enable building as a module
  atl2: Disable unimplemented scatter/gather feature

Borislav Petkov (1):
  perf stat: Document --detailed option

Chris Friesen (1):
  route: do not cache fib route info on local routes with oif

Dan Streetman (1):
  nbd: ratelimit error msgs after socket close

Daniel Vetter (1):
  drm/i915: Bail out of pipe config compute loop on LPT

David Howells (2):
  ASN.1: Fix non-match detection failure on data overrun
  KEYS: Fix ASN.1 indefinite length object parsing

David S. Miller (1):
  decnet: Do not build routes to devices without decnet private data.

Dmitry Ivanov (1):
  nl80211: check netlink protocol in socket release notification

Eric Dumazet (1):
  net/mlx4_en: fix spurious timestamping callbacks

Ewan D. Milne (1):
  scsi: Avoid crashing if device uses DIX but adapter does not support
    it

Fabio Estevam (1):
  bus: imx-weim: Take the 'status' property value into account

Geert Uytterhoeven (2):
  rtc: vr41xx: Wire up alarm_irq_enable
  serial: sh-sci: Remove cpufreq notifier to fix crash/deadlock

Herbert Xu (2):
  crypto: gcm - Fix rfc4543 decryption crash
  crypto: hash - Fix page length clamping in hash walk

Ian Campbell (1):
  VSOCK: do not disconnect socket when peer has shutdown SEND only

Jasem Mutlaq (1):
  USB: serial: cp210x: add Straizona Focusers device ids

Jiri Slaby (1):
  Revert "xfs: add capability check to free eofblocks ioctl"

John Keeping (1):
  drm/qxl: fix cursor position with non-zero hotspot

John Stultz (1):
  cpuset: Fix potential deadlock w/ set_mems_allowed

Kangjie Lu (3):
  net: fix infoleak in llc
  net: fix infoleak in rtnetlink
  net: fix a kernel infoleak in x25 module

Keerthy (1):
  pinctrl: single: Fix pcs_parse_bits_in_pinctrl_entry to use __ffs than
    ffs

Kirill Tkhai (1):
  sched: Remove lockdep check in sched_move_task()

Konstantin Khlebnikov (2):
  mm/balloon_compaction: redesign ballooned pages management
  mm/balloon_compaction: fix deflation when compaction is disabled

Krzysztof Kozlowski (1):
  iio: ak8975: Fix NULL pointer exception on early interrupt

Laszlo Ersek (1):
  efi: Fix out-of-bounds read in variable_matches()

Linus Lüssing (1):
  batman-adv: Fix broadcast/ogm queue limit on a removed interface

Linus Walleij (1):
  clk: versatile: sp810: support reentrance

Lokesh Vutla (1):
  ARM: OMAP2+: hwmod: Fix updating of sysconfig register

Lu Baolu (1):
  usb: xhci: fix wild pointers in xhci_mem_cleanup

Lucas Stach (1):
  drm/radeon: fix PLL sharing on DCE6.1 (v2)

Marco Angaroni (1):
  ipvs: correct initial offset of Call-ID header search in SIP
    persistence engine

Marek Szyprowski (1):
  Input: max8997-haptic - fix NULL pointer dereference

Mathias Krause (2):
  proc: prevent accessing /proc/<PID>/environ until it's ready
  packet: fix heap info leak in PACKET_DIAG_MCLIST sock_diag interface

Matt Fleming (1):
  MAINTAINERS: Remove asterisk from EFI directory names

Michael Hennerich (1):
  drivers/misc/ad525x_dpot: AD5274 fix RDAC read back errors

Mike Manning (1):
  USB: serial: cp210x: add ID for Link ECU

Neil Horman (1):
  netem: Segment GSO packets on enqueue

NeilBrown (1):
  sunrpc/cache: drop reference when sunrpc_cache_pipe_upcall() detects a
    race

Nikolay Aleksandrov (1):
  net: bridge: fix old ioctl unlocked net device walk

Pali Rohár (1):
  ARM: OMAP3: Add cpuidle parameters table for omap3430

Paolo Abeni (2):
  net/route: enforce hoplimit max value
  ipv4/fib: don't warn when primary address is missing if in_dev is dead

Paolo Bonzini (1):
  compiler-gcc: disable -ftracer for __noclone functions

Prarit Bhargava (1):
  ACPICA: Dispatcher: Update thread ID for recursive method calls

Robert Dobrowolski (1):
  usb: hcd: out of bounds access in for_each_companion

Roman Pen (1):
  workqueue: fix ghost PENDING flag while doing MQ IO

Rui Salvaterra (1):
  lib: lz4: fixed zram with lz4 on big endian machines

Sascha Hauer (1):
  ARM: SoCFPGA: Fix secondary CPU startup in thumb2 kernel

Sugar Zhang (1):
  ASoC: rt5640: Correct the digital interface data select

Sushaanth Srirangapathi (1):
  fbdev: da8xx-fb: fix videomodes of lcd panels

Sven Eckelmann (2):
  batman-adv: Check skb size before using encapsulated ETH+VLAN header
  batman-adv: Reduce refcnt of removed router when updating route

Takashi Iwai (1):
  Input: i8042 - lower log level for "no controller" message

Tony Lindgren (1):
  ARM: OMAP3: Fix booting with thumb2 kernel

Tony Luck (1):
  EDAC: i7core, sb_edac: Don't return NOTIFY_BAD from mce_decoder
    callback

Vasily Kulikov (1):
  include/linux/poison.h: fix LIST_POISON{1,2} offset

Vitaly Kuznetsov (1):
  Drivers: hv: vmbus: prevent cpu offlining on newer hypervisors

Vladis Dronov (1):
  Input: gtco - fix crash on detecting device without endpoints

Wang YanQing (1):
  x86/sysfb_efi: Fix valid BAR address range check

 MAINTAINERS                                |  4 +-
 arch/arm/mach-omap2/cpuidle34xx.c          | 69 ++++++++++++++++++++-
 arch/arm/mach-omap2/omap_hwmod.c           |  8 +--
 arch/arm/mach-omap2/sleep34xx.S            | 22 +------
 arch/arm/mach-socfpga/headsmp.S            |  1 +
 arch/powerpc/include/uapi/asm/cputable.h   |  1 +
 arch/powerpc/kernel/prom.c                 |  2 +-
 arch/x86/kernel/sysfb_efi.c                | 14 ++++-
 crypto/ahash.c                             |  3 +-
 crypto/gcm.c                               |  3 +
 drivers/acpi/acpica/dsmethod.c             |  3 +
 drivers/block/nbd.c                        |  4 +-
 drivers/block/paride/pd.c                  |  4 +-
 drivers/block/paride/pt.c                  |  4 +-
 drivers/bus/imx-weim.c                     |  2 +-
 drivers/clk/versatile/clk-sp810.c          |  4 +-
 drivers/edac/i7core_edac.c                 |  2 +-
 drivers/edac/sb_edac.c                     |  2 +-
 drivers/firmware/efi/vars.c                | 37 ++++++++----
 drivers/gpu/drm/i915/intel_crt.c           |  8 ++-
 drivers/gpu/drm/qxl/qxl_display.c          | 13 ++--
 drivers/gpu/drm/qxl/qxl_drv.h              |  2 +
 drivers/gpu/drm/radeon/atombios_crtc.c     | 10 +++
 drivers/hv/vmbus_drv.c                     | 36 +++++++++++
 drivers/iio/magnetometer/ak8975.c          |  4 +-
 drivers/input/misc/max8997_haptic.c        |  6 +-
 drivers/input/serio/i8042.c                |  2 +-
 drivers/input/tablet/gtco.c                | 10 ++-
 drivers/input/touchscreen/ads7846.c        |  8 ++-
 drivers/misc/Kconfig                       |  2 +-
 drivers/misc/ad525x_dpot.c                 |  2 +-
 drivers/mmc/host/sdhci.c                   |  4 +-
 drivers/net/ethernet/atheros/atlx/atl2.c   |  2 +-
 drivers/net/ethernet/mellanox/mlx4/en_tx.c |  6 +-
 drivers/pinctrl/pinctrl-single.c           |  6 +-
 drivers/pnp/pnpbios/bioscalls.c            |  9 +--
 drivers/rtc/rtc-vr41xx.c                   | 13 ++--
 drivers/scsi/lpfc/lpfc_init.c              |  5 +-
 drivers/scsi/scsi_lib.c                    | 12 +++-
 drivers/tty/serial/sh-sci.c                | 39 ------------
 drivers/usb/core/hcd-pci.c                 |  9 +++
 drivers/usb/host/xhci-mem.c                |  6 ++
 drivers/usb/serial/cp210x.c                |  4 ++
 drivers/video/da8xx-fb.c                   |  7 +--
 drivers/virtio/virtio_balloon.c            | 15 +++--
 fs/isofs/rock.c                            | 13 +++-
 fs/proc/base.c                             |  3 +-
 fs/xfs/xfs_ioctl.c                         |  6 --
 include/linux/balloon_compaction.h         | 97 ++++++++----------------------
 include/linux/compiler-gcc.h               |  2 +-
 include/linux/cpuset.h                     |  4 ++
 include/linux/migrate.h                    | 11 +---
 include/linux/mm.h                         | 19 ++++++
 include/linux/mod_devicetable.h            |  8 +++
 include/linux/poison.h                     |  4 +-
 kernel/sched/core.c                        |  8 ++-
 kernel/workqueue.c                         | 29 +++++++++
 lib/asn1_decoder.c                         | 21 ++++---
 lib/lz4/lz4defs.h                          | 21 ++++---
 mm/balloon_compaction.c                    | 28 ++++-----
 mm/compaction.c                            |  2 +-
 mm/migrate.c                               | 20 ++----
 net/batman-adv/routing.c                   |  9 +++
 net/batman-adv/send.c                      |  6 ++
 net/batman-adv/soft-interface.c            |  8 ++-
 net/bridge/br_ioctl.c                      |  5 +-
 net/core/rtnetlink.c                       | 18 +++---
 net/decnet/dn_route.c                      |  9 ++-
 net/ipv4/fib_frontend.c                    |  6 +-
 net/ipv4/fib_semantics.c                   |  2 +
 net/ipv4/route.c                           | 12 ++++
 net/ipv6/route.c                           |  6 +-
 net/llc/af_llc.c                           |  1 +
 net/netfilter/ipvs/ip_vs_pe_sip.c          |  2 +-
 net/packet/af_packet.c                     |  1 +
 net/sched/sch_netem.c                      | 61 ++++++++++++++++++-
 net/sunrpc/cache.c                         |  6 +-
 net/vmw_vsock/af_vsock.c                   | 21 +------
 net/wireless/nl80211.c                     |  2 +-
 net/x25/x25_facilities.c                   |  1 +
 scripts/asn1_compiler.c                    |  2 +
 sound/soc/codecs/rt5640.c                  |  2 +-
 sound/soc/codecs/rt5640.h                  | 36 +++++------
 sound/soc/samsung/s3c-i2s-v2.c             |  2 +-
 sound/soc/samsung/s3c-i2s-v2.h             |  2 +-
 tools/perf/Documentation/perf-stat.txt     |  8 +++
 86 files changed, 603 insertions(+), 350 deletions(-)

-- 
2.8.2

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

* [PATCH 3.12 57/76] drm/radeon: fix PLL sharing on DCE6.1 (v2)
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (55 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 56/76] asmlinkage, pnp: Make variables used from assembler code visible Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 58/76] drm/i915: Bail out of pipe config compute loop on LPT Jiri Slaby
                   ` (20 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Lucas Stach, Alex Deucher, Jiri Slaby

From: Lucas Stach <dev@lynxeye.de>

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

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

commit e3c00d87845ab375f90fa6e10a5e72a3a5778cd3 upstream.

On DCE6.1 PPLL2 is exclusively available to UNIPHYA, so it should not
be taken into consideration when looking for an already enabled PLL
to be shared with other outputs.

This fixes the broken VGA port (TRAVIS DP->VGA bridge) on my Richland
based laptop, where the internal display is connected to UNIPHYA through
a TRAVIS DP->LVDS bridge.

Bug:
https://bugs.freedesktop.org/show_bug.cgi?id=78987

v2: agd: add check in radeon_get_shared_nondp_ppll as well, drop
    extra parameter.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/gpu/drm/radeon/atombios_crtc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index ecd4a3dd51bb..d988fff65ee5 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -1572,6 +1572,7 @@ static u32 radeon_get_pll_use_mask(struct drm_crtc *crtc)
 static int radeon_get_shared_dp_ppll(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
+	struct radeon_device *rdev = dev->dev_private;
 	struct drm_crtc *test_crtc;
 	struct radeon_crtc *test_radeon_crtc;
 
@@ -1581,6 +1582,10 @@ static int radeon_get_shared_dp_ppll(struct drm_crtc *crtc)
 		test_radeon_crtc = to_radeon_crtc(test_crtc);
 		if (test_radeon_crtc->encoder &&
 		    ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_radeon_crtc->encoder))) {
+			/* PPLL2 is exclusive to UNIPHYA on DCE61 */
+			if (ASIC_IS_DCE61(rdev) && !ASIC_IS_DCE8(rdev) &&
+			    test_radeon_crtc->pll_id == ATOM_PPLL2)
+				continue;
 			/* for DP use the same PLL for all */
 			if (test_radeon_crtc->pll_id != ATOM_PPLL_INVALID)
 				return test_radeon_crtc->pll_id;
@@ -1602,6 +1607,7 @@ static int radeon_get_shared_nondp_ppll(struct drm_crtc *crtc)
 {
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
 	struct drm_device *dev = crtc->dev;
+	struct radeon_device *rdev = dev->dev_private;
 	struct drm_crtc *test_crtc;
 	struct radeon_crtc *test_radeon_crtc;
 	u32 adjusted_clock, test_adjusted_clock;
@@ -1617,6 +1623,10 @@ static int radeon_get_shared_nondp_ppll(struct drm_crtc *crtc)
 		test_radeon_crtc = to_radeon_crtc(test_crtc);
 		if (test_radeon_crtc->encoder &&
 		    !ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_radeon_crtc->encoder))) {
+			/* PPLL2 is exclusive to UNIPHYA on DCE61 */
+			if (ASIC_IS_DCE61(rdev) && !ASIC_IS_DCE8(rdev) &&
+			    test_radeon_crtc->pll_id == ATOM_PPLL2)
+				continue;
 			/* check if we are already driving this connector with another crtc */
 			if (test_radeon_crtc->connector == radeon_crtc->connector) {
 				/* if we are, return that pll */
-- 
2.8.2

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

* [PATCH 3.12 58/76] drm/i915: Bail out of pipe config compute loop on LPT
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (56 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 57/76] drm/radeon: fix PLL sharing on DCE6.1 (v2) Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 59/76] ARM: OMAP3: Fix booting with thumb2 kernel Jiri Slaby
                   ` (19 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Daniel Vetter, Chris Wilson, Maarten Lankhorst,
	Daniel Vetter, Jani Nikula, Jiri Slaby

From: Daniel Vetter <daniel.vetter@ffwll.ch>

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

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

commit 2700818ac9f935d8590715eecd7e8cadbca552b6 upstream.

LPT is pch, so might run into the fdi bandwidth constraint (especially
since it has only 2 lanes). But right now we just force pipe_bpp back
to 24, resulting in a nice loop (which we bail out with a loud
WARN_ON). Fix this.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
References: https://bugs.freedesktop.org/show_bug.cgi?id=93477
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1462264381-7573-1-git-send-email-daniel.vetter@ffwll.ch
(cherry picked from commit f58a1acc7e4a1f37d26124ce4c875c647fbcc61f)
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/gpu/drm/i915/intel_crt.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 3c25af46ba07..74ef54a4645f 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -248,8 +248,14 @@ static bool intel_crt_compute_config(struct intel_encoder *encoder,
 		pipe_config->has_pch_encoder = true;
 
 	/* LPT FDI RX only supports 8bpc. */
-	if (HAS_PCH_LPT(dev))
+	if (HAS_PCH_LPT(dev)) {
+		if (pipe_config->bw_constrained && pipe_config->pipe_bpp < 24) {
+			DRM_DEBUG_KMS("LPT only supports 24bpp\n");
+			return false;
+		}
+
 		pipe_config->pipe_bpp = 24;
+	}
 
 	return true;
 }
-- 
2.8.2

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

* [PATCH 3.12 59/76] ARM: OMAP3: Fix booting with thumb2 kernel
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (57 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 58/76] drm/i915: Bail out of pipe config compute loop on LPT Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 60/76] net/route: enforce hoplimit max value Jiri Slaby
                   ` (18 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Tony Lindgren, Jiri Slaby

From: Tony Lindgren <tony@atomide.com>

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

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

commit d8a50941c91a68da202aaa96a3dacd471ea9c693 upstream.

We get a NULL pointer dereference on omap3 for thumb2 compiled kernels:

Internal error: Oops: 80000005 [#1] SMP THUMB2
...
[<c046497b>] (_raw_spin_unlock_irqrestore) from [<c0024375>]
(omap3_enter_idle_bm+0xc5/0x178)
[<c0024375>] (omap3_enter_idle_bm) from [<c0374e63>]
(cpuidle_enter_state+0x77/0x27c)
[<c0374e63>] (cpuidle_enter_state) from [<c00627f1>]
(cpu_startup_entry+0x155/0x23c)
[<c00627f1>] (cpu_startup_entry) from [<c06b9a47>]
(start_kernel+0x32f/0x338)
[<c06b9a47>] (start_kernel) from [<8000807f>] (0x8000807f)

The power management related assembly on omaps needs to interact with
ARM mode bootrom code, so we need to keep most of the related assembly
in ARM mode.

Turns out this error is because of missing ENDPROC for assembly code
as suggested by Stephen Boyd <sboyd@codeaurora.org>. Let's fix the
problem by adding ENDPROC in two places to sleep34xx.S.

Let's also remove the now duplicate custom code for mode switching.
This has been unnecessary since commit 6ebbf2ce437b ("ARM: convert
all "mov.* pc, reg" to "bx reg" for ARMv6+").

And let's also remove the comments about local variables, they are
now just confusing after the ENDPROC.

The reason why ENDPROC makes a difference is it sets .type and then
the compiler knows what to do with the thumb bit as explained at:

https://wiki.ubuntu.com/ARM/Thumb2PortingHowto

Reported-by: Kevin Hilman <khilman@kernel.org>
Tested-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/arm/mach-omap2/sleep34xx.S | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index d1dedc8195ed..eafd120b53f1 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -203,23 +203,8 @@ save_context_wfi:
 	 */
 	ldr	r1, kernel_flush
 	blx	r1
-	/*
-	 * The kernel doesn't interwork: v7_flush_dcache_all in particluar will
-	 * always return in Thumb state when CONFIG_THUMB2_KERNEL is enabled.
-	 * This sequence switches back to ARM.  Note that .align may insert a
-	 * nop: bx pc needs to be word-aligned in order to work.
-	 */
- THUMB(	.thumb		)
- THUMB(	.align		)
- THUMB(	bx	pc	)
- THUMB(	nop		)
-	.arm
-
 	b	omap3_do_wfi
-
-/*
- * Local variables
- */
+ENDPROC(omap34xx_cpu_suspend)
 omap3_do_wfi_sram_addr:
 	.word omap3_do_wfi_sram
 kernel_flush:
@@ -364,10 +349,7 @@ exit_nonoff_modes:
  * ===================================
  */
 	ldmfd	sp!, {r4 - r11, pc}	@ restore regs and return
-
-/*
- * Local variables
- */
+ENDPROC(omap3_do_wfi)
 sdrc_power:
 	.word	SDRC_POWER_V
 cm_idlest1_core:
-- 
2.8.2

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

* [PATCH 3.12 60/76] net/route: enforce hoplimit max value
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (58 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 59/76] ARM: OMAP3: Fix booting with thumb2 kernel Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 61/76] decnet: Do not build routes to devices without decnet private data Jiri Slaby
                   ` (17 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Paolo Abeni, David S . Miller, Jiri Slaby

From: Paolo Abeni <pabeni@redhat.com>

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

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

[ Upstream commit 626abd59e51d4d8c6367e03aae252a8aa759ac78 ]

Currently, when creating or updating a route, no check is performed
in both ipv4 and ipv6 code to the hoplimit value.

The caller can i.e. set hoplimit to 256, and when such route will
 be used, packets will be sent with hoplimit/ttl equal to 0.

This commit adds checks for the RTAX_HOPLIMIT value, in both ipv4
ipv6 route code, substituting any value greater than 255 with 255.

This is consistent with what is currently done for ADVMSS and MTU
in the ipv4 code.

[js] backport to 3.12: no ip6_convert_metrics yet, fix applied to
     ip6_route_add directly.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/ipv4/fib_semantics.c | 2 ++
 net/ipv6/route.c         | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index ec12b169931b..82c28244ad96 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -860,6 +860,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
 					val = 65535 - 40;
 				if (type == RTAX_MTU && val > 65535 - 15)
 					val = 65535 - 15;
+				if (type == RTAX_HOPLIMIT && val > 255)
+					val = 255;
 				fi->fib_metrics[type - 1] = val;
 			}
 		}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 0464f9a9d2dc..f862c7688c99 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1670,7 +1670,11 @@ install_route:
 					goto out;
 				}
 
-				dst_metric_set(&rt->dst, type, nla_get_u32(nla));
+				if (type == RTAX_HOPLIMIT && nla_get_u32(nla) > 255)
+					dst_metric_set(&rt->dst, type, 255);
+				else
+					dst_metric_set(&rt->dst, type,
+						nla_get_u32(nla));
 			}
 		}
 	}
-- 
2.8.2

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

* [PATCH 3.12 61/76] decnet: Do not build routes to devices without decnet private data.
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (59 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 60/76] net/route: enforce hoplimit max value Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 62/76] route: do not cache fib route info on local routes with oif Jiri Slaby
                   ` (16 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, David S. Miller, Jiri Slaby

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

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

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

[ Upstream commit a36a0d4008488fa545c74445d69eaf56377d5d4e ]

In particular, make sure we check for decnet private presence
for loopback devices.

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/decnet/dn_route.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index fe32388ea24f..b9610051f3b2 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -1030,10 +1030,13 @@ source_ok:
 	if (!fld.daddr) {
 		fld.daddr = fld.saddr;
 
-		err = -EADDRNOTAVAIL;
 		if (dev_out)
 			dev_put(dev_out);
+		err = -EINVAL;
 		dev_out = init_net.loopback_dev;
+		if (!dev_out->dn_ptr)
+			goto out;
+		err = -EADDRNOTAVAIL;
 		dev_hold(dev_out);
 		if (!fld.daddr) {
 			fld.daddr =
@@ -1106,6 +1109,8 @@ source_ok:
 		if (dev_out == NULL)
 			goto out;
 		dn_db = rcu_dereference_raw(dev_out->dn_ptr);
+		if (!dn_db)
+			goto e_inval;
 		/* Possible improvement - check all devices for local addr */
 		if (dn_dev_islocal(dev_out, fld.daddr)) {
 			dev_put(dev_out);
@@ -1147,6 +1152,8 @@ select_source:
 			dev_put(dev_out);
 		dev_out = init_net.loopback_dev;
 		dev_hold(dev_out);
+		if (!dev_out->dn_ptr)
+			goto e_inval;
 		fld.flowidn_oif = dev_out->ifindex;
 		if (res.fi)
 			dn_fib_info_put(res.fi);
-- 
2.8.2

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

* [PATCH 3.12 62/76] route: do not cache fib route info on local routes with oif
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (60 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 61/76] decnet: Do not build routes to devices without decnet private data Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 63/76] packet: fix heap info leak in PACKET_DIAG_MCLIST sock_diag interface Jiri Slaby
                   ` (15 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Chris Friesen, Allain Legacy, David S . Miller, Jiri Slaby

From: Chris Friesen <chris.friesen@windriver.com>

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

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

[ Upstream commit d6d5e999e5df67f8ec20b6be45e2229455ee3699 ]

For local routes that require a particular output interface we do not want
to cache the result.  Caching the result causes incorrect behaviour when
there are multiple source addresses on the interface.  The end result
being that if the intended recipient is waiting on that interface for the
packet he won't receive it because it will be delivered on the loopback
interface and the IP_PKTINFO ipi_ifindex will be set to the loopback
interface as well.

This can be tested by running a program such as "dhcp_release" which
attempts to inject a packet on a particular interface so that it is
received by another program on the same board.  The receiving process
should see an IP_PKTINFO ipi_ifndex value of the source interface
(e.g., eth1) instead of the loopback interface (e.g., lo).  The packet
will still appear on the loopback interface in tcpdump but the important
aspect is that the CMSG info is correct.

Sample dhcp_release command line:

   dhcp_release eth1 192.168.204.222 02:11:33:22:44:66

Signed-off-by: Allain Legacy <allain.legacy@windriver.com>
Signed off-by: Chris Friesen <chris.friesen@windriver.com>
Reviewed-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/ipv4/route.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index ae001e8e81b9..1454176792b3 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1968,6 +1968,18 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
 		 */
 		if (fi && res->prefixlen < 4)
 			fi = NULL;
+	} else if ((type == RTN_LOCAL) && (orig_oif != 0) &&
+		   (orig_oif != dev_out->ifindex)) {
+		/* For local routes that require a particular output interface
+		 * we do not want to cache the result.  Caching the result
+		 * causes incorrect behaviour when there are multiple source
+		 * addresses on the interface, the end result being that if the
+		 * intended recipient is waiting on that interface for the
+		 * packet he won't receive it because it will be delivered on
+		 * the loopback interface and the IP_PKTINFO ipi_ifindex will
+		 * be set to the loopback interface as well.
+		 */
+		fi = NULL;
 	}
 
 	fnhe = NULL;
-- 
2.8.2

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

* [PATCH 3.12 63/76] packet: fix heap info leak in PACKET_DIAG_MCLIST sock_diag interface
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (61 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 62/76] route: do not cache fib route info on local routes with oif Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 64/76] atl2: Disable unimplemented scatter/gather feature Jiri Slaby
                   ` (14 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Mathias Krause, Eric W . Biederman,
	Pavel Emelyanov, David S . Miller, Jiri Slaby

From: Mathias Krause <minipli@googlemail.com>

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

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

[ Upstream commit 309cf37fe2a781279b7675d4bb7173198e532867 ]

Because we miss to wipe the remainder of i->addr[] in packet_mc_add(),
pdiag_put_mclist() leaks uninitialized heap bytes via the
PACKET_DIAG_MCLIST netlink attribute.

Fix this by explicitly memset(0)ing the remaining bytes in i->addr[].

Fixes: eea68e2f1a00 ("packet: Report socket mclist info via diag module")
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/packet/af_packet.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 370ee2b9713d..63d0f92f45d0 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2977,6 +2977,7 @@ static int packet_mc_add(struct sock *sk, struct packet_mreq_max *mreq)
 	i->ifindex = mreq->mr_ifindex;
 	i->alen = mreq->mr_alen;
 	memcpy(i->addr, mreq->mr_address, i->alen);
+	memset(i->addr + i->alen, 0, sizeof(i->addr) - i->alen);
 	i->count = 1;
 	i->next = po->mclist;
 	po->mclist = i;
-- 
2.8.2

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

* [PATCH 3.12 64/76] atl2: Disable unimplemented scatter/gather feature
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (62 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 63/76] packet: fix heap info leak in PACKET_DIAG_MCLIST sock_diag interface Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 65/76] ipv4/fib: don't warn when primary address is missing if in_dev is dead Jiri Slaby
                   ` (13 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Ben Hutchings, David S . Miller, Jiri Slaby

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

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

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

[ Upstream commit f43bfaeddc79effbf3d0fcb53ca477cca66f3db8 ]

atl2 includes NETIF_F_SG in hw_features even though it has no support
for non-linear skbs.  This bug was originally harmless since the
driver does not claim to implement checksum offload and that used to
be a requirement for SG.

Now that SG and checksum offload are independent features, if you
explicitly enable SG *and* use one of the rare protocols that can use
SG without checkusm offload, this potentially leaks sensitive
information (before you notice that it just isn't working).  Therefore
this obscure bug has been designated CVE-2016-2117.

Reported-by: Justin Yackoski <jyackoski@crypto-nite.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Fixes: ec5f06156423 ("net: Kill link between CSUM and SG features.")
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/net/ethernet/atheros/atlx/atl2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c
index 265ce1b752ed..96fe542b4acb 100644
--- a/drivers/net/ethernet/atheros/atlx/atl2.c
+++ b/drivers/net/ethernet/atheros/atlx/atl2.c
@@ -1413,7 +1413,7 @@ static int atl2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	err = -EIO;
 
-	netdev->hw_features = NETIF_F_SG | NETIF_F_HW_VLAN_CTAG_RX;
+	netdev->hw_features = NETIF_F_HW_VLAN_CTAG_RX;
 	netdev->features |= (NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX);
 
 	/* Init PHY as early as possible due to power saving issue  */
-- 
2.8.2

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

* [PATCH 3.12 65/76] ipv4/fib: don't warn when primary address is missing if in_dev is dead
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (63 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 64/76] atl2: Disable unimplemented scatter/gather feature Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 66/76] net/mlx4_en: fix spurious timestamping callbacks Jiri Slaby
                   ` (12 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Paolo Abeni, David S . Miller, Jiri Slaby

From: Paolo Abeni <pabeni@redhat.com>

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

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

[ Upstream commit 391a20333b8393ef2e13014e6e59d192c5594471 ]

After commit fbd40ea0180a ("ipv4: Don't do expensive useless work
during inetdev destroy.") when deleting an interface,
fib_del_ifaddr() can be executed without any primary address
present on the dead interface.

The above is safe, but triggers some "bug: prim == NULL" warnings.

This commit avoids warning if the in_dev is dead

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/ipv4/fib_frontend.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 25a0946f7074..3d3966bf3df6 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -797,7 +797,11 @@ void fib_del_ifaddr(struct in_ifaddr *ifa, struct in_ifaddr *iprim)
 	if (ifa->ifa_flags & IFA_F_SECONDARY) {
 		prim = inet_ifa_byprefix(in_dev, any, ifa->ifa_mask);
 		if (prim == NULL) {
-			pr_warn("%s: bug: prim == NULL\n", __func__);
+			/* if the device has been deleted, we don't perform
+			 * address promotion
+			 */
+			if (!in_dev->dead)
+				pr_warn("%s: bug: prim == NULL\n", __func__);
 			return;
 		}
 		if (iprim && iprim != prim) {
-- 
2.8.2

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

* [PATCH 3.12 66/76] net/mlx4_en: fix spurious timestamping callbacks
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (64 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 65/76] ipv4/fib: don't warn when primary address is missing if in_dev is dead Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 67/76] netem: Segment GSO packets on enqueue Jiri Slaby
                   ` (11 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Eric Dumazet, Willem de Bruijn, David S . Miller,
	Jiri Slaby

From: Eric Dumazet <edumazet@google.com>

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

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

[ Upstream commit fc96256c906362e845d848d0f6a6354450059e81 ]

When multiple skb are TX-completed in a row, we might incorrectly keep
a timestamp of a prior skb and cause extra work.

Fixes: ec693d47010e8 ("net/mlx4_en: Add HW timestamping (TS) support")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/net/ethernet/mellanox/mlx4/en_tx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 0698c82d6ff1..3d3cd0f1adf8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -343,7 +343,6 @@ static void mlx4_en_process_tx_cq(struct net_device *dev, struct mlx4_en_cq *cq)
 	u32 packets = 0;
 	u32 bytes = 0;
 	int factor = priv->cqe_factor;
-	u64 timestamp = 0;
 
 	if (!priv->port_up)
 		return;
@@ -375,9 +374,12 @@ static void mlx4_en_process_tx_cq(struct net_device *dev, struct mlx4_en_cq *cq)
 		new_index = be16_to_cpu(cqe->wqe_index) & size_mask;
 
 		do {
+			u64 timestamp = 0;
+
 			txbbs_skipped += ring->last_nr_txbb;
 			ring_index = (ring_index + ring->last_nr_txbb) & size_mask;
-			if (ring->tx_info[ring_index].ts_requested)
+
+			if (unlikely(ring->tx_info[ring_index].ts_requested))
 				timestamp = mlx4_en_get_cqe_ts(cqe);
 
 			/* free next descriptor */
-- 
2.8.2

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

* [PATCH 3.12 67/76] netem: Segment GSO packets on enqueue
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (65 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 66/76] net/mlx4_en: fix spurious timestamping callbacks Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 68/76] net: fix infoleak in llc Jiri Slaby
                   ` (10 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Neil Horman, Jamal Hadi Salim, David S. Miller,
	netem, eric.dumazet, stephen, Jiri Slaby

From: Neil Horman <nhorman@tuxdriver.com>

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

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

[ Upstream commit 6071bd1aa13ed9e41824bafad845b7b7f4df5cfd ]

This was recently reported to me, and reproduced on the latest net kernel,
when attempting to run netperf from a host that had a netem qdisc attached
to the egress interface:

[  788.073771] ---------------------[ cut here ]---------------------------
[  788.096716] WARNING: at net/core/dev.c:2253 skb_warn_bad_offload+0xcd/0xda()
[  788.129521] bnx2: caps=(0x00000001801949b3, 0x0000000000000000) len=2962
data_len=0 gso_size=1448 gso_type=1 ip_summed=3
[  788.182150] Modules linked in: sch_netem kvm_amd kvm crc32_pclmul ipmi_ssif
ghash_clmulni_intel sp5100_tco amd64_edac_mod aesni_intel lrw gf128mul
glue_helper ablk_helper edac_mce_amd cryptd pcspkr sg edac_core hpilo ipmi_si
i2c_piix4 k10temp fam15h_power hpwdt ipmi_msghandler shpchp acpi_power_meter
pcc_cpufreq nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c
sd_mod crc_t10dif crct10dif_generic mgag200 syscopyarea sysfillrect sysimgblt
i2c_algo_bit drm_kms_helper ahci ata_generic pata_acpi ttm libahci
crct10dif_pclmul pata_atiixp tg3 libata crct10dif_common drm crc32c_intel ptp
serio_raw bnx2 r8169 hpsa pps_core i2c_core mii dm_mirror dm_region_hash dm_log
dm_mod
[  788.465294] CPU: 16 PID: 0 Comm: swapper/16 Tainted: G        W
------------   3.10.0-327.el7.x86_64 #1
[  788.511521] Hardware name: HP ProLiant DL385p Gen8, BIOS A28 12/17/2012
[  788.542260]  ffff880437c036b8 f7afc56532a53db9 ffff880437c03670
ffffffff816351f1
[  788.576332]  ffff880437c036a8 ffffffff8107b200 ffff880633e74200
ffff880231674000
[  788.611943]  0000000000000001 0000000000000003 0000000000000000
ffff880437c03710
[  788.647241] Call Trace:
[  788.658817]  <IRQ>  [<ffffffff816351f1>] dump_stack+0x19/0x1b
[  788.686193]  [<ffffffff8107b200>] warn_slowpath_common+0x70/0xb0
[  788.713803]  [<ffffffff8107b29c>] warn_slowpath_fmt+0x5c/0x80
[  788.741314]  [<ffffffff812f92f3>] ? ___ratelimit+0x93/0x100
[  788.767018]  [<ffffffff81637f49>] skb_warn_bad_offload+0xcd/0xda
[  788.796117]  [<ffffffff8152950c>] skb_checksum_help+0x17c/0x190
[  788.823392]  [<ffffffffa01463a1>] netem_enqueue+0x741/0x7c0 [sch_netem]
[  788.854487]  [<ffffffff8152cb58>] dev_queue_xmit+0x2a8/0x570
[  788.880870]  [<ffffffff8156ae1d>] ip_finish_output+0x53d/0x7d0
...

The problem occurs because netem is not prepared to handle GSO packets (as it
uses skb_checksum_help in its enqueue path, which cannot manipulate these
frames).

The solution I think is to simply segment the skb in a simmilar fashion to the
way we do in __dev_queue_xmit (via validate_xmit_skb), with some minor changes.
When we decide to corrupt an skb, if the frame is GSO, we segment it, corrupt
the first segment, and enqueue the remaining ones.

tested successfully by myself on the latest net kernel, to which this applies

[js] backport to 3.12: no qdisc_qstats_drop yet, update directly. Also use
     qdisc_tree_decrease_qlen instead of qdisc_tree_reduce_backlog.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Jamal Hadi Salim <jhs@mojatatu.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: netem@lists.linux-foundation.org
CC: eric.dumazet@gmail.com
CC: stephen@networkplumber.org
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/sched/sch_netem.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 59 insertions(+), 2 deletions(-)

diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index b87e83d07478..14ac1a1e1bbf 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -394,6 +394,25 @@ static void tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch)
 	sch->q.qlen++;
 }
 
+/* netem can't properly corrupt a megapacket (like we get from GSO), so instead
+ * when we statistically choose to corrupt one, we instead segment it, returning
+ * the first packet to be corrupted, and re-enqueue the remaining frames
+ */
+static struct sk_buff *netem_segment(struct sk_buff *skb, struct Qdisc *sch)
+{
+	struct sk_buff *segs;
+	netdev_features_t features = netif_skb_features(skb);
+
+	segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
+
+	if (IS_ERR_OR_NULL(segs)) {
+		qdisc_reshape_fail(skb, sch);
+		return NULL;
+	}
+	consume_skb(skb);
+	return segs;
+}
+
 /*
  * Insert one skb into qdisc.
  * Note: parent depends on return value to account for queue length.
@@ -406,7 +425,11 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 	/* We don't fill cb now as skb_unshare() may invalidate it */
 	struct netem_skb_cb *cb;
 	struct sk_buff *skb2;
+	struct sk_buff *segs = NULL;
+	unsigned int len = 0, last_len;
+	int nb = 0;
 	int count = 1;
+	int rc = NET_XMIT_SUCCESS;
 
 	/* Random duplication */
 	if (q->duplicate && q->duplicate >= get_crandom(&q->dup_cor))
@@ -452,10 +475,23 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 	 * do it now in software before we mangle it.
 	 */
 	if (q->corrupt && q->corrupt >= get_crandom(&q->corrupt_cor)) {
+		if (skb_is_gso(skb)) {
+			segs = netem_segment(skb, sch);
+			if (!segs)
+				return NET_XMIT_DROP;
+		} else {
+			segs = skb;
+		}
+
+		skb = segs;
+		segs = segs->next;
+
 		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
 		    (skb->ip_summed == CHECKSUM_PARTIAL &&
-		     skb_checksum_help(skb)))
-			return qdisc_drop(skb, sch);
+		     skb_checksum_help(skb))) {
+			rc = qdisc_drop(skb, sch);
+			goto finish_segs;
+		}
 
 		skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8);
 	}
@@ -514,6 +550,27 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 		sch->qstats.requeues++;
 	}
 
+finish_segs:
+	if (segs) {
+		while (segs) {
+			skb2 = segs->next;
+			segs->next = NULL;
+			qdisc_skb_cb(segs)->pkt_len = segs->len;
+			last_len = segs->len;
+			rc = qdisc_enqueue(segs, sch);
+			if (rc != NET_XMIT_SUCCESS) {
+				if (net_xmit_drop_count(rc))
+					sch->qstats.drops++;
+			} else {
+				nb++;
+				len += last_len;
+			}
+			segs = skb2;
+		}
+		sch->q.qlen += nb;
+		if (nb > 1)
+			qdisc_tree_decrease_qlen(sch, 1 - nb);
+	}
 	return NET_XMIT_SUCCESS;
 }
 
-- 
2.8.2

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

* [PATCH 3.12 68/76] net: fix infoleak in llc
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (66 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 67/76] netem: Segment GSO packets on enqueue Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 69/76] net: fix infoleak in rtnetlink Jiri Slaby
                   ` (9 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Kangjie Lu, Kangjie Lu, David S . Miller, Jiri Slaby

From: Kangjie Lu <kangjielu@gmail.com>

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

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

[ Upstream commit b8670c09f37bdf2847cc44f36511a53afc6161fd ]

The stack object “info” has a total size of 12 bytes. Its last byte
is padding which is not initialized and leaked via “put_cmsg”.

Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/llc/af_llc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index c71b699eb555..a6c281ddd8b4 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -626,6 +626,7 @@ static void llc_cmsg_rcv(struct msghdr *msg, struct sk_buff *skb)
 	if (llc->cmsg_flags & LLC_CMSG_PKTINFO) {
 		struct llc_pktinfo info;
 
+		memset(&info, 0, sizeof(info));
 		info.lpi_ifindex = llc_sk(skb->sk)->dev->ifindex;
 		llc_pdu_decode_dsap(skb, &info.lpi_sap);
 		llc_pdu_decode_da(skb, info.lpi_mac);
-- 
2.8.2

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

* [PATCH 3.12 69/76] net: fix infoleak in rtnetlink
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (67 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 68/76] net: fix infoleak in llc Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-20 12:04   ` Vegard Nossum
  2016-05-19  9:08 ` [PATCH 3.12 70/76] VSOCK: do not disconnect socket when peer has shutdown SEND only Jiri Slaby
                   ` (8 subsequent siblings)
  77 siblings, 1 reply; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Kangjie Lu, Kangjie Lu, David S . Miller, Jiri Slaby

From: Kangjie Lu <kangjielu@gmail.com>

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

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

[ Upstream commit 5f8e44741f9f216e33736ea4ec65ca9ac03036e6 ]

The stack object “map” has a total size of 32 bytes. Its last 4
bytes are padding generated by compiler. These padding bytes are
not initialized and sent out via “nla_put”.

Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/core/rtnetlink.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index fd3a16e45dd9..5093f42d7afc 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -950,14 +950,16 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
 		goto nla_put_failure;
 
 	if (1) {
-		struct rtnl_link_ifmap map = {
-			.mem_start   = dev->mem_start,
-			.mem_end     = dev->mem_end,
-			.base_addr   = dev->base_addr,
-			.irq         = dev->irq,
-			.dma         = dev->dma,
-			.port        = dev->if_port,
-		};
+		struct rtnl_link_ifmap map;
+
+		memset(&map, 0, sizeof(map));
+		map.mem_start   = dev->mem_start;
+		map.mem_end     = dev->mem_end;
+		map.base_addr   = dev->base_addr;
+		map.irq         = dev->irq;
+		map.dma         = dev->dma;
+		map.port        = dev->if_port;
+
 		if (nla_put(skb, IFLA_MAP, sizeof(map), &map))
 			goto nla_put_failure;
 	}
-- 
2.8.2

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

* [PATCH 3.12 70/76] VSOCK: do not disconnect socket when peer has shutdown SEND only
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (68 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 69/76] net: fix infoleak in rtnetlink Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 71/76] net: bridge: fix old ioctl unlocked net device walk Jiri Slaby
                   ` (7 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Ian Campbell, David S. Miller, Stefan Hajnoczi,
	Claudio Imbrenda, Andy King, Dmitry Torokhov, Jorgen Hansen,
	Adit Ranadive, netdev, Jiri Slaby

From: Ian Campbell <ian.campbell@docker.com>

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

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

[ Upstream commit dedc58e067d8c379a15a8a183c5db318201295bb ]

The peer may be expecting a reply having sent a request and then done a
shutdown(SHUT_WR), so tearing down the whole socket at this point seems
wrong and breaks for me with a client which does a SHUT_WR.

Looking at other socket family's stream_recvmsg callbacks doing a shutdown
here does not seem to be the norm and removing it does not seem to have
had any adverse effects that I can see.

I'm using Stefan's RFC virtio transport patches, I'm unsure of the impact
on the vmci transport.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
Cc: Andy King <acking@vmware.com>
Cc: Dmitry Torokhov <dtor@vmware.com>
Cc: Jorgen Hansen <jhansen@vmware.com>
Cc: Adit Ranadive <aditr@vmware.com>
Cc: netdev@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/vmw_vsock/af_vsock.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 85d232bed87d..e8d3313ea2c9 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1796,27 +1796,8 @@ vsock_stream_recvmsg(struct kiocb *kiocb,
 	else if (sk->sk_shutdown & RCV_SHUTDOWN)
 		err = 0;
 
-	if (copied > 0) {
-		/* We only do these additional bookkeeping/notification steps
-		 * if we actually copied something out of the queue pair
-		 * instead of just peeking ahead.
-		 */
-
-		if (!(flags & MSG_PEEK)) {
-			/* If the other side has shutdown for sending and there
-			 * is nothing more to read, then modify the socket
-			 * state.
-			 */
-			if (vsk->peer_shutdown & SEND_SHUTDOWN) {
-				if (vsock_stream_has_data(vsk) <= 0) {
-					sk->sk_state = SS_UNCONNECTED;
-					sock_set_flag(sk, SOCK_DONE);
-					sk->sk_state_change(sk);
-				}
-			}
-		}
+	if (copied > 0)
 		err = copied;
-	}
 
 out_wait:
 	finish_wait(sk_sleep(sk), &wait);
-- 
2.8.2

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

* [PATCH 3.12 71/76] net: bridge: fix old ioctl unlocked net device walk
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (69 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 70/76] VSOCK: do not disconnect socket when peer has shutdown SEND only Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 72/76] net: fix a kernel infoleak in x25 module Jiri Slaby
                   ` (6 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Nikolay Aleksandrov, David S . Miller, Jiri Slaby

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

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

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

[ Upstream commit 31ca0458a61a502adb7ed192bf9716c6d05791a5 ]

get_bridge_ifindices() is used from the old "deviceless" bridge ioctl
calls which aren't called with rtnl held. The comment above says that it is
called with rtnl but that is not really the case.
Here's a sample output from a test ASSERT_RTNL() which I put in
get_bridge_ifindices and executed "brctl show":
[  957.422726] RTNL: assertion failed at net/bridge//br_ioctl.c (30)
[  957.422925] CPU: 0 PID: 1862 Comm: brctl Tainted: G        W  O
4.6.0-rc4+ #157
[  957.423009] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
BIOS 1.8.1-20150318_183358- 04/01/2014
[  957.423009]  0000000000000000 ffff880058adfdf0 ffffffff8138dec5
0000000000000400
[  957.423009]  ffffffff81ce8380 ffff880058adfe58 ffffffffa05ead32
0000000000000001
[  957.423009]  00007ffec1a444b0 0000000000000400 ffff880053c19130
0000000000008940
[  957.423009] Call Trace:
[  957.423009]  [<ffffffff8138dec5>] dump_stack+0x85/0xc0
[  957.423009]  [<ffffffffa05ead32>]
br_ioctl_deviceless_stub+0x212/0x2e0 [bridge]
[  957.423009]  [<ffffffff81515beb>] sock_ioctl+0x22b/0x290
[  957.423009]  [<ffffffff8126ba75>] do_vfs_ioctl+0x95/0x700
[  957.423009]  [<ffffffff8126c159>] SyS_ioctl+0x79/0x90
[  957.423009]  [<ffffffff8163a4c0>] entry_SYSCALL_64_fastpath+0x23/0xc1

Since it only reads bridge ifindices, we can use rcu to safely walk the net
device list. Also remove the wrong rtnl comment above.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/bridge/br_ioctl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index b73eaba85667..a882db499d33 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -21,18 +21,19 @@
 #include <asm/uaccess.h>
 #include "br_private.h"
 
-/* called with RTNL */
 static int get_bridge_ifindices(struct net *net, int *indices, int num)
 {
 	struct net_device *dev;
 	int i = 0;
 
-	for_each_netdev(net, dev) {
+	rcu_read_lock();
+	for_each_netdev_rcu(net, dev) {
 		if (i >= num)
 			break;
 		if (dev->priv_flags & IFF_EBRIDGE)
 			indices[i++] = dev->ifindex;
 	}
+	rcu_read_unlock();
 
 	return i;
 }
-- 
2.8.2

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

* [PATCH 3.12 72/76] net: fix a kernel infoleak in x25 module
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (70 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 71/76] net: bridge: fix old ioctl unlocked net device walk Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 73/76] ASN.1: Fix non-match detection failure on data overrun Jiri Slaby
                   ` (5 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Kangjie Lu, Kangjie Lu, David S . Miller, Jiri Slaby

From: Kangjie Lu <kangjielu@gmail.com>

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

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

[ Upstream commit 79e48650320e6fba48369fccf13fd045315b19b8 ]

Stack object "dte_facilities" is allocated in x25_rx_call_request(),
which is supposed to be initialized in x25_negotiate_facilities.
However, 5 fields (8 bytes in total) are not initialized. This
object is then copied to userland via copy_to_user, thus infoleak
occurs.

Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/x25/x25_facilities.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/x25/x25_facilities.c b/net/x25/x25_facilities.c
index b8253250d723..c42bf2b8ec4f 100644
--- a/net/x25/x25_facilities.c
+++ b/net/x25/x25_facilities.c
@@ -275,6 +275,7 @@ int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk,
 
 	memset(&theirs, 0, sizeof(theirs));
 	memcpy(new, ours, sizeof(*new));
+	memset(dte, 0, sizeof(*dte));
 
 	len = x25_parse_facilities(skb, &theirs, dte, &x25->vc_facil_mask);
 	if (len < 0)
-- 
2.8.2

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

* [PATCH 3.12 73/76] ASN.1: Fix non-match detection failure on data overrun
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (71 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 72/76] net: fix a kernel infoleak in x25 module Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 74/76] KEYS: Fix ASN.1 indefinite length object parsing Jiri Slaby
                   ` (4 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, David Howells, Jiri Slaby

From: David Howells <dhowells@redhat.com>

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

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

commit 0d62e9dd6da45bbf0f33a8617afc5fe774c8f45f upstream.

If the ASN.1 decoder is asked to parse a sequence of objects, non-optional
matches get skipped if there's no more data to be had rather than a
data-overrun error being reported.

This is due to the code segment that decides whether to skip optional
matches (ie. matches that could get ignored because an element is marked
OPTIONAL in the grammar) due to a lack of data also skips non-optional
elements if the data pointer has reached the end of the buffer.

This can be tested with the data decoder for the new RSA akcipher algorithm
that takes three non-optional integers.  Currently, it skips the last
integer if there is insufficient data.

Without the fix, #defining DEBUG in asn1_decoder.c will show something
like:

	next_op: pc=0/13 dp=0/270 C=0 J=0
	- match? 30 30 00
	- TAG: 30 266 CONS
	next_op: pc=2/13 dp=4/270 C=1 J=0
	- match? 02 02 00
	- TAG: 02 257
	- LEAF: 257
	next_op: pc=5/13 dp=265/270 C=1 J=0
	- match? 02 02 00
	- TAG: 02 3
	- LEAF: 3
	next_op: pc=8/13 dp=270/270 C=1 J=0
	next_op: pc=11/13 dp=270/270 C=1 J=0
	- end cons t=4 dp=270 l=270/270

The next_op line for pc=8/13 should be followed by a match line.

This is not exploitable for X.509 certificates by means of shortening the
message and fixing up the ASN.1 CONS tags because:

 (1) The relevant records being built up are cleared before use.

 (2) If the message is shortened sufficiently to remove the public key, the
     ASN.1 parse of the RSA key will fail quickly due to a lack of data.

 (3) Extracted signature data is either turned into MPIs (which cope with a
     0 length) or is simpler integers specifying algoritms and suchlike
     (which can validly be 0); and

 (4) The AKID and SKID extensions are optional and their removal is handled
     without risking passing a NULL to asymmetric_key_generate_id().

 (5) If the certificate is truncated sufficiently to remove the subject,
     issuer or serialNumber then the ASN.1 decoder will fail with a 'Cons
     stack underflow' return.

This is not exploitable for PKCS#7 messages by means of removal of elements
from such a message from the tail end of a sequence:

 (1) Any shortened X.509 certs embedded in the PKCS#7 message are survivable
     as detailed above.

 (2) The message digest content isn't used if it shows a NULL pointer,
     similarly, the authattrs aren't used if that shows a NULL pointer.

 (3) A missing signature results in a NULL MPI - which the MPI routines deal
     with.

 (4) If data is NULL, it is expected that the message has detached content and
     that is handled appropriately.

 (5) If the serialNumber is excised, the unconditional action associated
     with it will pick up the containing SEQUENCE instead, so no NULL
     pointer will be seen here.

     If both the issuer and the serialNumber are excised, the ASN.1 decode
     will fail with an 'Unexpected tag' return.

     In either case, there's no way to get to asymmetric_key_generate_id()
     with a NULL pointer.

 (6) Other fields are decoded to simple integers.  Shortening the message
     to omit an algorithm ID field will cause checks on this to fail early
     in the verification process.

This can also be tested by snipping objects off of the end of the ASN.1 stream
such that mandatory tags are removed - or even from the end of internal
SEQUENCEs.  If any mandatory tag is missing, the error EBADMSG *should* be
produced.  Without this patch ERANGE or ENOPKG might be produced or the parse
may apparently succeed, perhaps with ENOKEY or EKEYREJECTED being produced
later, depending on what gets snipped.

Just snipping off the final BIT_STRING or OCTET_STRING from either sample
should be a start since both are mandatory and neither will cause an EBADMSG
without the patches

Reported-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 lib/asn1_decoder.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/asn1_decoder.c b/lib/asn1_decoder.c
index 11b9b01fda6b..3787d02e2c49 100644
--- a/lib/asn1_decoder.c
+++ b/lib/asn1_decoder.c
@@ -208,9 +208,8 @@ next_op:
 		unsigned char tmp;
 
 		/* Skip conditional matches if possible */
-		if ((op & ASN1_OP_MATCH__COND &&
-		     flags & FLAG_MATCHED) ||
-		    dp == datalen) {
+		if ((op & ASN1_OP_MATCH__COND && flags & FLAG_MATCHED) ||
+		    (op & ASN1_OP_MATCH__SKIP && dp == datalen)) {
 			pc += asn1_op_lengths[op];
 			goto next_op;
 		}
-- 
2.8.2

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

* [PATCH 3.12 74/76] KEYS: Fix ASN.1 indefinite length object parsing
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (72 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 73/76] ASN.1: Fix non-match detection failure on data overrun Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 75/76] sched: Remove lockdep check in sched_move_task() Jiri Slaby
                   ` (3 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, David Howells, Jiri Slaby

From: David Howells <dhowells@redhat.com>

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

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

commit 23c8a812dc3c621009e4f0e5342aa4e2ede1ceaa upstream.

This fixes CVE-2016-0758.

In the ASN.1 decoder, when the length field of an ASN.1 value is extracted,
it isn't validated against the remaining amount of data before being added
to the cursor.  With a sufficiently large size indicated, the check:

	datalen - dp < 2

may then fail due to integer overflow.

Fix this by checking the length indicated against the amount of remaining
data in both places a definite length is determined.

Whilst we're at it, make the following changes:

 (1) Check the maximum size of extended length does not exceed the capacity
     of the variable it's being stored in (len) rather than the type that
     variable is assumed to be (size_t).

 (2) Compare the EOC tag to the symbolic constant ASN1_EOC rather than the
     integer 0.

 (3) To reduce confusion, move the initialisation of len outside of:

	for (len = 0; n > 0; n--) {

     since it doesn't have anything to do with the loop counter n.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Acked-by: David Woodhouse <David.Woodhouse@intel.com>
Acked-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 lib/asn1_decoder.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/asn1_decoder.c b/lib/asn1_decoder.c
index 3787d02e2c49..b1c885297113 100644
--- a/lib/asn1_decoder.c
+++ b/lib/asn1_decoder.c
@@ -69,7 +69,7 @@ next_tag:
 
 	/* Extract a tag from the data */
 	tag = data[dp++];
-	if (tag == 0) {
+	if (tag == ASN1_EOC) {
 		/* It appears to be an EOC. */
 		if (data[dp++] != 0)
 			goto invalid_eoc;
@@ -91,10 +91,8 @@ next_tag:
 
 	/* Extract the length */
 	len = data[dp++];
-	if (len <= 0x7f) {
-		dp += len;
-		goto next_tag;
-	}
+	if (len <= 0x7f)
+		goto check_length;
 
 	if (unlikely(len == ASN1_INDEFINITE_LENGTH)) {
 		/* Indefinite length */
@@ -105,14 +103,18 @@ next_tag:
 	}
 
 	n = len - 0x80;
-	if (unlikely(n > sizeof(size_t) - 1))
+	if (unlikely(n > sizeof(len) - 1))
 		goto length_too_long;
 	if (unlikely(n > datalen - dp))
 		goto data_overrun_error;
-	for (len = 0; n > 0; n--) {
+	len = 0;
+	for (; n > 0; n--) {
 		len <<= 8;
 		len |= data[dp++];
 	}
+check_length:
+	if (len > datalen - dp)
+		goto data_overrun_error;
 	dp += len;
 	goto next_tag;
 
-- 
2.8.2

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

* [PATCH 3.12 75/76] sched: Remove lockdep check in sched_move_task()
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (73 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 74/76] KEYS: Fix ASN.1 indefinite length object parsing Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19  9:08 ` [PATCH 3.12 76/76] X.509: remove possible code fragility: enumeration values not handled Jiri Slaby
                   ` (2 subsequent siblings)
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable
  Cc: linux-kernel, Kirill Tkhai, Peter Zijlstra, Linus Torvalds,
	Ingo Molnar, Jiri Slaby

From: Kirill Tkhai <ktkhai@parallels.com>

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

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

commit f7b8a47da17c9ee4998f2ca2018fcc424e953c0e upstream.

sched_move_task() is the only interface to change sched_task_group:
cpu_cgrp_subsys methods and autogroup_move_group() use it.

Everything is synchronized by task_rq_lock(), so cpu_cgroup_attach()
is ordered with other users of sched_move_task(). This means we do no
need RCU here: if we've dereferenced a tg here, the .attach method
hasn't been called for it yet.

Thus, we should pass "true" to task_css_check() to silence lockdep
warnings.

Fixes: eeb61e53ea19 ("sched: Fix race between task_group and sched_task_group")
Reported-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Kirill Tkhai <ktkhai@parallels.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/1414473874.8574.2.camel@tkhai
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 kernel/sched/core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index dd794a9b6850..e382c14652d0 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6865,8 +6865,12 @@ void sched_move_task(struct task_struct *tsk)
 	if (unlikely(running))
 		tsk->sched_class->put_prev_task(rq, tsk);
 
-	tg = container_of(task_css_check(tsk, cpu_cgroup_subsys_id,
-				lockdep_is_held(&tsk->sighand->siglock)),
+	/*
+	 * All callers are synchronized by task_rq_lock(); we do not use RCU
+	 * which is pointless here. Thus, we pass "true" to task_css_check()
+	 * to prevent lockdep warnings.
+	 */
+	tg = container_of(task_css_check(tsk, cpu_cgroup_subsys_id, true),
 			  struct task_group, css);
 	tg = autogroup_task_group(tsk, tg);
 	tsk->sched_task_group = tg;
-- 
2.8.2

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

* [PATCH 3.12 76/76] X.509: remove possible code fragility: enumeration values not handled
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (74 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 75/76] sched: Remove lockdep check in sched_move_task() Jiri Slaby
@ 2016-05-19  9:08 ` Jiri Slaby
  2016-05-19 13:52 ` [PATCH 3.12 00/76] 3.12.60-stable review Guenter Roeck
  2016-05-24 12:58 ` Shuah Khan
  77 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-19  9:08 UTC (permalink / raw)
  To: stable; +Cc: linux-kernel, Antonio Alecrim Jr, David Howells, Jiri Slaby

From: Antonio Alecrim Jr <antonio.alecrim@gmail.com>

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

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

commit eb8948a03704f3dbbfc7e83090e20e93c6c476d2 upstream.

Signed-off-by: Antonio Alecrim Jr <antonio.alecrim@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 scripts/asn1_compiler.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c
index db0e5cd34c70..91c4117637ae 100644
--- a/scripts/asn1_compiler.c
+++ b/scripts/asn1_compiler.c
@@ -1353,6 +1353,8 @@ static void render_out_of_line_list(FILE *out)
 			render_opcode(out, "ASN1_OP_END_SET_OF%s,\n", act);
 			render_opcode(out, "_jump_target(%u),\n", entry);
 			break;
+		default:
+			break;
 		}
 		if (e->action)
 			render_opcode(out, "_action(ACT_%s),\n",
-- 
2.8.2

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

* Re: [PATCH 3.12 00/76] 3.12.60-stable review
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (75 preceding siblings ...)
  2016-05-19  9:08 ` [PATCH 3.12 76/76] X.509: remove possible code fragility: enumeration values not handled Jiri Slaby
@ 2016-05-19 13:52 ` Guenter Roeck
  2016-05-23  9:49   ` Jiri Slaby
  2016-05-24 12:58 ` Shuah Khan
  77 siblings, 1 reply; 86+ messages in thread
From: Guenter Roeck @ 2016-05-19 13:52 UTC (permalink / raw)
  To: Jiri Slaby, stable; +Cc: shuah.kh, linux-kernel

On 05/19/2016 02:08 AM, Jiri Slaby wrote:
> This is the start of the stable review cycle for the 3.12.60 release.
> There are 76 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>
> Responses should be made by Mon May 23 11:07:53 CEST 2016.
> Anything received after that time might be too late.
>

Build results:
	total: 127 pass: 127 fail: 0
Qemu test results:
	total: 85 pass: 85 fail: 0

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

Guenter

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

* Re: [PATCH 3.12 69/76] net: fix infoleak in rtnetlink
  2016-05-19  9:08 ` [PATCH 3.12 69/76] net: fix infoleak in rtnetlink Jiri Slaby
@ 2016-05-20 12:04   ` Vegard Nossum
       [not found]     ` <CABEk9YxT4eRBrEhkrCNHwM9yuFKRW4bBcrAfjgW0iyS0q3v65A@mail.gmail.com>
  2016-05-20 16:45     ` David Miller
  0 siblings, 2 replies; 86+ messages in thread
From: Vegard Nossum @ 2016-05-20 12:04 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: stable, LKML, Kangjie Lu, Kangjie Lu, David S . Miller

On 19 May 2016 at 11:08, Jiri Slaby <jslaby@suse.cz> wrote:
> From: Kangjie Lu <kangjielu@gmail.com>
>
> 3.12-stable review patch.  If anyone has any objections, please let me know.
>
> ===============
>
> [ Upstream commit 5f8e44741f9f216e33736ea4ec65ca9ac03036e6 ]
>
> The stack object “map” has a total size of 32 bytes. Its last 4
> bytes are padding generated by compiler. These padding bytes are
> not initialized and sent out via “nla_put”.
>
> Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> ---
>  net/core/rtnetlink.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index fd3a16e45dd9..5093f42d7afc 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -950,14 +950,16 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
>                 goto nla_put_failure;
>
>         if (1) {
> -               struct rtnl_link_ifmap map = {
> -                       .mem_start   = dev->mem_start,
> -                       .mem_end     = dev->mem_end,
> -                       .base_addr   = dev->base_addr,
> -                       .irq         = dev->irq,
> -                       .dma         = dev->dma,
> -                       .port        = dev->if_port,
> -               };
> +               struct rtnl_link_ifmap map;
> +
> +               memset(&map, 0, sizeof(map));
> +               map.mem_start   = dev->mem_start;
> +               map.mem_end     = dev->mem_end;
> +               map.base_addr   = dev->base_addr;
> +               map.irq         = dev->irq;
> +               map.dma         = dev->dma;
> +               map.port        = dev->if_port;
> +
>                 if (nla_put(skb, IFLA_MAP, sizeof(map), &map))
>                         goto nla_put_failure;
>         }
> --
> 2.8.2
>

Just out of curiosity, was this observed in practice? I could be
wrong, but I was under the impression that using designated
initializers would zero the rest of the struct, including padding.
This seems to back that up:

http://stackoverflow.com/a/3374468/1697183

If this is indeed a real info leak, then I would assume we have much
bigger problems around the kernel.


Vegard

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

* Re: [PATCH 3.12 69/76] net: fix infoleak in rtnetlink
       [not found]     ` <CABEk9YxT4eRBrEhkrCNHwM9yuFKRW4bBcrAfjgW0iyS0q3v65A@mail.gmail.com>
@ 2016-05-20 14:25       ` Vegard Nossum
  0 siblings, 0 replies; 86+ messages in thread
From: Vegard Nossum @ 2016-05-20 14:25 UTC (permalink / raw)
  To: Kangjie Lu; +Cc: Jiri Slaby, stable, LKML, Kangjie Lu, David S . Miller

On 20 May 2016 at 15:43, Kangjie Lu <kangjielu@gmail.com> wrote:
>
>
> On Friday, May 20, 2016, Vegard Nossum <vegard.nossum@gmail.com> wrote:
>>
>> On 19 May 2016 at 11:08, Jiri Slaby <jslaby@suse.cz> wrote:
>> > From: Kangjie Lu <kangjielu@gmail.com>
>> >
>> > 3.12-stable review patch.  If anyone has any objections, please let me
>> > know.
>> >
>> > ===============
>> >
>> > [ Upstream commit 5f8e44741f9f216e33736ea4ec65ca9ac03036e6 ]
>> >
>> > The stack object “map” has a total size of 32 bytes. Its last 4
>> > bytes are padding generated by compiler. These padding bytes are
>> > not initialized and sent out via “nla_put”.
>> >
>> > Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
>> > Signed-off-by: David S. Miller <davem@davemloft.net>
>> > Signed-off-by: Jiri Slaby <jslaby@suse.cz>
>> > ---
>> >  net/core/rtnetlink.c | 18 ++++++++++--------
>> >  1 file changed, 10 insertions(+), 8 deletions(-)
>> >
>> > diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
>> > index fd3a16e45dd9..5093f42d7afc 100644
>> > --- a/net/core/rtnetlink.c
>> > +++ b/net/core/rtnetlink.c
>> > @@ -950,14 +950,16 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
>> > struct net_device *dev,
>> >                 goto nla_put_failure;
>> >
>> >         if (1) {
>> > -               struct rtnl_link_ifmap map = {
>> > -                       .mem_start   = dev->mem_start,
>> > -                       .mem_end     = dev->mem_end,
>> > -                       .base_addr   = dev->base_addr,
>> > -                       .irq         = dev->irq,
>> > -                       .dma         = dev->dma,
>> > -                       .port        = dev->if_port,
>> > -               };
>> > +               struct rtnl_link_ifmap map;
>> > +
>> > +               memset(&map, 0, sizeof(map));
>> > +               map.mem_start   = dev->mem_start;
>> > +               map.mem_end     = dev->mem_end;
>> > +               map.base_addr   = dev->base_addr;
>> > +               map.irq         = dev->irq;
>> > +               map.dma         = dev->dma;
>> > +               map.port        = dev->if_port;
>> > +
>> >                 if (nla_put(skb, IFLA_MAP, sizeof(map), &map))
>> >                         goto nla_put_failure;
>> >         }
>> > --
>> > 2.8.2
>> >
>>
>> Just out of curiosity, was this observed in practice? I could be
>> wrong, but I was under the impression that using designated
>> initializers would zero the rest of the struct, including padding.
>
>
> Yes or no.  According to my experiences, it depends on how
> it is initialized:
> if there are no variables but all constants in the bracket,
> a global initializer will be generated, which will zero the remaining bytes
> including padding; otherwise, no global initializer
> will be used, hence the remaining bytes are not initialized.
> In this case, dev is not a constant, so no global initializer
> will be used to initialize the padding bytes

I did some experiements with gcc and my observations are:

1. it doesn't depend on whether the initializer is constant or variable, but...

2. whether or not padding gets initialized depends on *which fields*
you're initializing (I assume this has to do with what instructions it
ends up using, as it might be faster to do a 32-bit mov on x86 instead
of an 8-bit one if you're initializing an 8-bit field which is
followed by 24 bits of padding, for example).

>> This seems to back that up:
>>
>> http://stackoverflow.com/a/3374468/1697183
>>
>> If this is indeed a real info leak, then I would assume we have much
>> bigger problems around the kernel.
>
>
> Could be.  We've found many such bugs.

That is pretty sad. Anyway, thanks for fixing them.


Vegard

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

* Re: [PATCH 3.12 69/76] net: fix infoleak in rtnetlink
  2016-05-20 12:04   ` Vegard Nossum
       [not found]     ` <CABEk9YxT4eRBrEhkrCNHwM9yuFKRW4bBcrAfjgW0iyS0q3v65A@mail.gmail.com>
@ 2016-05-20 16:45     ` David Miller
  2016-05-21  0:43       ` Hannes Frederic Sowa
  1 sibling, 1 reply; 86+ messages in thread
From: David Miller @ 2016-05-20 16:45 UTC (permalink / raw)
  To: vegard.nossum; +Cc: jslaby, stable, linux-kernel, kangjielu, kjlu

From: Vegard Nossum <vegard.nossum@gmail.com>
Date: Fri, 20 May 2016 14:04:54 +0200

> Just out of curiosity, was this observed in practice? I could be
> wrong, but I was under the impression that using designated
> initializers would zero the rest of the struct, including padding.

I compiled testcases and found that the compiler does not zero out
padding when using designated initializers.

You can do the same.

For example, on sparc 32-bit, this code:

struct foo {
	int a;
	short b;
	int c;
};

extern void foo(struct foo *);

void bar(void)
{
	struct foo f = { .a = 1, .b = 2, .c = 3 };

	foo(&f);
}

gives:

	mov	1, %g1
	st	%g1, [%fp-12]
	mov	2, %g1
	sth	%g1, [%fp-8]
	mov	3, %g1
	st	%g1, [%fp-4]

It does not initialize the padding between 'b' and 'c'.

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

* Re: [PATCH 3.12 69/76] net: fix infoleak in rtnetlink
  2016-05-20 16:45     ` David Miller
@ 2016-05-21  0:43       ` Hannes Frederic Sowa
  0 siblings, 0 replies; 86+ messages in thread
From: Hannes Frederic Sowa @ 2016-05-21  0:43 UTC (permalink / raw)
  To: David Miller, vegard.nossum
  Cc: jslaby, stable, linux-kernel, kangjielu, kjlu, Sabrina Dubroca

On 20.05.2016 18:45, David Miller wrote:
> From: Vegard Nossum <vegard.nossum@gmail.com>
> Date: Fri, 20 May 2016 14:04:54 +0200
> 
>> Just out of curiosity, was this observed in practice? I could be
>> wrong, but I was under the impression that using designated
>> initializers would zero the rest of the struct, including padding.
> 
> I compiled testcases and found that the compiler does not zero out
> padding when using designated initializers.
> 
> You can do the same.
> 
> For example, on sparc 32-bit, this code:
> 
> struct foo {
> 	int a;
> 	short b;
> 	int c;
> };
> 
> extern void foo(struct foo *);
> 
> void bar(void)
> {
> 	struct foo f = { .a = 1, .b = 2, .c = 3 };
> 
> 	foo(&f);
> }
> 
> gives:
> 
> 	mov	1, %g1
> 	st	%g1, [%fp-12]
> 	mov	2, %g1
> 	sth	%g1, [%fp-8]
> 	mov	3, %g1
> 	st	%g1, [%fp-4]
> 
> It does not initialize the padding between 'b' and 'c'.

Interesting side note here is question 1 of the survey "What is C in
practice?", here:

<https://www.cl.cam.ac.uk/~pes20/cerberus/notes50-survey-discussion.html>

It seems safe right now from my understanding but we need to be careful
with future compiler optimizations, e.g. for memset, as Joseph Myers
commented on the question for future possible optimizations.

This report is also going to be presented in the C2X standard meetings,
hopefully they come up with something sensible for that.

Bye,
Hannes

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

* Re: [PATCH 3.12 00/76] 3.12.60-stable review
  2016-05-19 13:52 ` [PATCH 3.12 00/76] 3.12.60-stable review Guenter Roeck
@ 2016-05-23  9:49   ` Jiri Slaby
  0 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-23  9:49 UTC (permalink / raw)
  To: Guenter Roeck, stable; +Cc: shuah.kh, linux-kernel

On 05/19/2016, 03:52 PM, Guenter Roeck wrote:
> On 05/19/2016 02:08 AM, Jiri Slaby wrote:
>> This is the start of the stable review cycle for the 3.12.60 release.
>> There are 76 patches in this series, all will be posted as a response
>> to this one.  If anyone has any issues with these being applied, please
>> let me know.
>>
>> Responses should be made by Mon May 23 11:07:53 CEST 2016.
>> Anything received after that time might be too late.
>>
> 
> Build results:
>     total: 127 pass: 127 fail: 0
> Qemu test results:
>     total: 85 pass: 85 fail: 0
> 
> Details are available at http://kerneltests.org/builders.

Thanks!

-- 
js
suse labs

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

* Re: [PATCH 3.12 00/76] 3.12.60-stable review
  2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
                   ` (76 preceding siblings ...)
  2016-05-19 13:52 ` [PATCH 3.12 00/76] 3.12.60-stable review Guenter Roeck
@ 2016-05-24 12:58 ` Shuah Khan
  2016-05-24 13:55   ` Jiri Slaby
  77 siblings, 1 reply; 86+ messages in thread
From: Shuah Khan @ 2016-05-24 12:58 UTC (permalink / raw)
  To: Jiri Slaby, stable; +Cc: linux, shuah.kh, linux-kernel

On 05/19/2016 03:08 AM, Jiri Slaby wrote:
> This is the start of the stable review cycle for the 3.12.60 release.
> There are 76 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Mon May 23 11:07:53 CEST 2016.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
> 	http://kernel.org/pub/linux/kernel/people/jirislaby/stable-review/patch-3.12.60-rc1.xz
> and the diffstat can be found below.
> 

Sorry I tested this release and forgot to send results. Might be
late now. Compiled and booted on my test system and no dmesg
regressions.

thanks,
-- Shuah

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

* Re: [PATCH 3.12 00/76] 3.12.60-stable review
  2016-05-24 12:58 ` Shuah Khan
@ 2016-05-24 13:55   ` Jiri Slaby
  0 siblings, 0 replies; 86+ messages in thread
From: Jiri Slaby @ 2016-05-24 13:55 UTC (permalink / raw)
  To: Shuah Khan, stable; +Cc: linux, shuah.kh, linux-kernel

On 05/24/2016, 02:58 PM, Shuah Khan wrote:
> On 05/19/2016 03:08 AM, Jiri Slaby wrote:
>> This is the start of the stable review cycle for the 3.12.60 release.
>> There are 76 patches in this series, all will be posted as a response
>> to this one.  If anyone has any issues with these being applied, please
>> let me know.
>>
>> Responses should be made by Mon May 23 11:07:53 CEST 2016.
>> Anything received after that time might be too late.
>>
>> The whole patch series can be found in one patch at:
>> 	http://kernel.org/pub/linux/kernel/people/jirislaby/stable-review/patch-3.12.60-rc1.xz
>> and the diffstat can be found below.
>>
> 
> Sorry I tested this release and forgot to send results. Might be
> late now. Compiled and booted on my test system and no dmesg
> regressions.

It's never late when the results are positive :). Thanks!


-- 
js
suse labs

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

* Re: [PATCH 3.12 69/76] net: fix infoleak in rtnetlink
       [not found] <CABEk9YwJSjE6gKVw-E1_3drG==hg39ZOQ=bYKObzH7D6odm9PQ@mail.gmail.com>
@ 2016-05-20 14:49 ` Vegard Nossum
  0 siblings, 0 replies; 86+ messages in thread
From: Vegard Nossum @ 2016-05-20 14:49 UTC (permalink / raw)
  To: Kangjie Lu; +Cc: Jiri Slaby, stable, LKML, Kangjie Lu, David S . Miller

On 20 May 2016 at 16:35, Kangjie Lu <kangjielu@gmail.com> wrote:
>> > Yes or no.  According to my experiences, it depends on how
>> > it is initialized:
>> > if there are no variables but all constants in the bracket,
>> > a global initializer will be generated, which will zero the remaining
>> > bytes
>> > including padding; otherwise, no global initializer
>> > will be used, hence the remaining bytes are not initialized.
>> > In this case, dev is not a constant, so no global initializer
>> > will be used to initialize the padding bytes
>>
>> I did some experiements with gcc and my observations are:
>>
>> 1. it doesn't depend on whether the initializer is constant or variable,
>> but...
>
>
> My observation is based on LLVM. Could you also double check the LLVM case?

With clang-3.5 from Ubuntu and -O2 I'm seeing the same as you: with
only constants it zeroes the padding, with variables it doesn't.

>>
>> 2. whether or not padding gets initialized depends on *which fields*
>> you're initializing (I assume this has to do with what instructions it
>> ends up using, as it might be faster to do a 32-bit mov on x86 instead
>> of an 8-bit one if you're initializing an 8-bit field which is
>> followed by 24 bits of padding, for example).

Vegard

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

end of thread, other threads:[~2016-05-24 13:55 UTC | newest]

Thread overview: 86+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-19  9:08 [PATCH 3.12 00/76] 3.12.60-stable review Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 01/76] crypto: gcm - Fix rfc4543 decryption crash Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 02/76] ARM: OMAP2+: hwmod: Fix updating of sysconfig register Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 03/76] usb: xhci: fix wild pointers in xhci_mem_cleanup Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 04/76] usb: hcd: out of bounds access in for_each_companion Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 05/76] lib: lz4: fixed zram with lz4 on big endian machines Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 06/76] drm/qxl: fix cursor position with non-zero hotspot Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 07/76] nl80211: check netlink protocol in socket release notification Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 08/76] Input: gtco - fix crash on detecting device without endpoints Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 09/76] pinctrl: single: Fix pcs_parse_bits_in_pinctrl_entry to use __ffs than ffs Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 10/76] EDAC: i7core, sb_edac: Don't return NOTIFY_BAD from mce_decoder callback Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 11/76] ASoC: s3c24xx: use const snd_soc_component_driver pointer Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 12/76] ASoC: rt5640: Correct the digital interface data select Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 13/76] efi: Fix out-of-bounds read in variable_matches() Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 14/76] workqueue: fix ghost PENDING flag while doing MQ IO Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 15/76] paride: make 'verbose' parameter an 'int' again Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 16/76] fbdev: da8xx-fb: fix videomodes of lcd panels Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 17/76] misc/bmp085: Enable building as a module Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 18/76] rtc: vr41xx: Wire up alarm_irq_enable Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 19/76] drivers/misc/ad525x_dpot: AD5274 fix RDAC read back errors Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 20/76] serial: sh-sci: Remove cpufreq notifier to fix crash/deadlock Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 21/76] include/linux/poison.h: fix LIST_POISON{1,2} offset Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 22/76] Drivers: hv: vmbus: prevent cpu offlining on newer hypervisors Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 23/76] perf stat: Document --detailed option Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 24/76] ARM: OMAP3: Add cpuidle parameters table for omap3430 Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 25/76] bus: imx-weim: Take the 'status' property value into account Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 26/76] sunrpc/cache: drop reference when sunrpc_cache_pipe_upcall() detects a race Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 27/76] Revert "xfs: add capability check to free eofblocks ioctl" Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 28/76] mmc: sdhci: Allow for irq being shared Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 29/76] scsi: Avoid crashing if device uses DIX but adapter does not support it Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 30/76] cpuset: Fix potential deadlock w/ set_mems_allowed Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 31/76] compiler-gcc: disable -ftracer for __noclone functions Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 32/76] x86: LLVMLinux: Fix "incomplete type const struct x86cpu_device_id" Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 33/76] ipvs: correct initial offset of Call-ID header search in SIP persistence engine Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 34/76] nbd: ratelimit error msgs after socket close Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 35/76] clk: versatile: sp810: support reentrance Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 36/76] lpfc: fix misleading indentation Jiri Slaby
2016-05-19  9:07 ` [PATCH 3.12 37/76] ARM: SoCFPGA: Fix secondary CPU startup in thumb2 kernel Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 38/76] proc: prevent accessing /proc/<PID>/environ until it's ready Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 39/76] batman-adv: Check skb size before using encapsulated ETH+VLAN header Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 40/76] batman-adv: Fix broadcast/ogm queue limit on a removed interface Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 41/76] batman-adv: Reduce refcnt of removed router when updating route Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 42/76] MAINTAINERS: Remove asterisk from EFI directory names Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 43/76] x86/sysfb_efi: Fix valid BAR address range check Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 44/76] ACPICA: Dispatcher: Update thread ID for recursive method calls Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 45/76] USB: serial: cp210x: add ID for Link ECU Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 46/76] USB: serial: cp210x: add Straizona Focusers device ids Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 47/76] iio: ak8975: Fix NULL pointer exception on early interrupt Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 48/76] Input: ads7846 - correct the value got from SPI Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 49/76] powerpc: scan_features() updates incorrect bits for REAL_LE Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 50/76] Input: i8042 - lower log level for "no controller" message Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 51/76] mm/balloon_compaction: redesign ballooned pages management Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 52/76] mm/balloon_compaction: fix deflation when compaction is disabled Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 53/76] crypto: hash - Fix page length clamping in hash walk Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 54/76] get_rock_ridge_filename(): handle malformed NM entries Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 55/76] Input: max8997-haptic - fix NULL pointer dereference Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 56/76] asmlinkage, pnp: Make variables used from assembler code visible Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 57/76] drm/radeon: fix PLL sharing on DCE6.1 (v2) Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 58/76] drm/i915: Bail out of pipe config compute loop on LPT Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 59/76] ARM: OMAP3: Fix booting with thumb2 kernel Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 60/76] net/route: enforce hoplimit max value Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 61/76] decnet: Do not build routes to devices without decnet private data Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 62/76] route: do not cache fib route info on local routes with oif Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 63/76] packet: fix heap info leak in PACKET_DIAG_MCLIST sock_diag interface Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 64/76] atl2: Disable unimplemented scatter/gather feature Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 65/76] ipv4/fib: don't warn when primary address is missing if in_dev is dead Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 66/76] net/mlx4_en: fix spurious timestamping callbacks Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 67/76] netem: Segment GSO packets on enqueue Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 68/76] net: fix infoleak in llc Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 69/76] net: fix infoleak in rtnetlink Jiri Slaby
2016-05-20 12:04   ` Vegard Nossum
     [not found]     ` <CABEk9YxT4eRBrEhkrCNHwM9yuFKRW4bBcrAfjgW0iyS0q3v65A@mail.gmail.com>
2016-05-20 14:25       ` Vegard Nossum
2016-05-20 16:45     ` David Miller
2016-05-21  0:43       ` Hannes Frederic Sowa
2016-05-19  9:08 ` [PATCH 3.12 70/76] VSOCK: do not disconnect socket when peer has shutdown SEND only Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 71/76] net: bridge: fix old ioctl unlocked net device walk Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 72/76] net: fix a kernel infoleak in x25 module Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 73/76] ASN.1: Fix non-match detection failure on data overrun Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 74/76] KEYS: Fix ASN.1 indefinite length object parsing Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 75/76] sched: Remove lockdep check in sched_move_task() Jiri Slaby
2016-05-19  9:08 ` [PATCH 3.12 76/76] X.509: remove possible code fragility: enumeration values not handled Jiri Slaby
2016-05-19 13:52 ` [PATCH 3.12 00/76] 3.12.60-stable review Guenter Roeck
2016-05-23  9:49   ` Jiri Slaby
2016-05-24 12:58 ` Shuah Khan
2016-05-24 13:55   ` Jiri Slaby
     [not found] <CABEk9YwJSjE6gKVw-E1_3drG==hg39ZOQ=bYKObzH7D6odm9PQ@mail.gmail.com>
2016-05-20 14:49 ` [PATCH 3.12 69/76] net: fix infoleak in rtnetlink Vegard Nossum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).