All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir()
@ 2016-02-24  9:30 Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] cifs: fix erroneous return value Jiri Slaby
                   ` (27 more replies)
  0 siblings, 28 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Vasily Averin, Steve French, Jiri Slaby

From: Vasily Averin <vvs@virtuozzo.com>

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

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

commit 01b9b0b28626db4a47d7f48744d70abca9914ef1 upstream.

In some cases tmp_bug can be not filled in cifs_filldir and stay uninitialized,
therefore its printk with "%s" modifier can leak content of kernelspace memory.
If old content of this buffer does not contain '\0' access bejond end of
allocated object can crash the host.

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Signed-off-by: Steve French <steve.french@primarydata.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/cifs/readdir.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index e327a9207ee1..5454aff19d18 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -849,6 +849,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx)
 		 * if buggy server returns . and .. late do we want to
 		 * check for that here?
 		 */
+		*tmp_buf = 0;
 		rc = cifs_filldir(current_entry, file, ctx,
 				  tmp_buf, max_len);
 		if (rc) {
-- 
2.7.1


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

* [patch added to 3.12-stable] cifs: fix erroneous return value
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] nfs: Fix race in __update_open_stateid() Jiri Slaby
                   ` (26 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Anton Protopopov, Steve French, Jiri Slaby

From: Anton Protopopov <a.s.protopopov@gmail.com>

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

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

commit 4b550af519854421dfec9f7732cdddeb057134b2 upstream.

The setup_ntlmv2_rsp() function may return positive value ENOMEM instead
of -ENOMEM in case of kmalloc failure.

Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/cifs/cifsencrypt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 134ed52f616f..684e1c5ad46d 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -703,7 +703,7 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
 
 	ses->auth_key.response = kmalloc(baselen + tilen, GFP_KERNEL);
 	if (!ses->auth_key.response) {
-		rc = ENOMEM;
+		rc = -ENOMEM;
 		ses->auth_key.len = 0;
 		goto setup_ntlmv2_rsp_ret;
 	}
-- 
2.7.1


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

* [patch added to 3.12-stable] nfs: Fix race in __update_open_stateid()
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] cifs: fix erroneous return value Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] udf: limit the maximum number of indirect extents in a row Jiri Slaby
                   ` (25 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Andrew Elble, Trond Myklebust, Jiri Slaby

From: Andrew Elble <aweits@rit.edu>

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

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

commit 361cad3c89070aeb37560860ea8bfc092d545adc upstream.

We've seen this in a packet capture - I've intermixed what I
think was going on. The fix here is to grab the so_lock sooner.

1964379 -> #1 open (for write) reply seqid=1
1964393 -> #2 open (for read) reply seqid=2

  __nfs4_close(), state->n_wronly--
  nfs4_state_set_mode_locked(), changes state->state = [R]
  state->flags is [RW]
  state->state is [R], state->n_wronly == 0, state->n_rdonly == 1

1964398 -> #3 open (for write) call -> because close is already running
1964399 -> downgrade (to read) call seqid=2 (close of #1)
1964402 -> #3 open (for write) reply seqid=3

 __update_open_stateid()
   nfs_set_open_stateid_locked(), changes state->flags
   state->flags is [RW]
   state->state is [R], state->n_wronly == 0, state->n_rdonly == 1
   new sequence number is exposed now via nfs4_stateid_copy()

   next step would be update_open_stateflags(), pending so_lock

1964403 -> downgrade reply seqid=2, fails with OLD_STATEID (close of #1)

   nfs4_close_prepare() gets so_lock and recalcs flags -> send close

1964405 -> downgrade (to read) call seqid=3 (close of #1 retry)

   __update_open_stateid() gets so_lock
 * update_open_stateflags() updates state->n_wronly.
   nfs4_state_set_mode_locked() updates state->state

   state->flags is [RW]
   state->state is [RW], state->n_wronly == 1, state->n_rdonly == 1

 * should have suppressed the preceding nfs4_close_prepare() from
   sending open_downgrade

1964406 -> write call
1964408 -> downgrade (to read) reply seqid=4 (close of #1 retry)

   nfs_clear_open_stateid_locked()
   state->flags is [R]
   state->state is [RW], state->n_wronly == 1, state->n_rdonly == 1

1964409 -> write reply (fails, openmode)

Signed-off-by: Andrew Elble <aweits@rit.edu>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/nfs/nfs4proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 794af58b388f..aa62c7308a1b 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1165,6 +1165,7 @@ static void __update_open_stateid(struct nfs4_state *state, nfs4_stateid *open_s
 	 * Protect the call to nfs4_state_set_mode_locked and
 	 * serialise the stateid update
 	 */
+	spin_lock(&state->owner->so_lock);
 	write_seqlock(&state->seqlock);
 	if (deleg_stateid != NULL) {
 		nfs4_stateid_copy(&state->stateid, deleg_stateid);
@@ -1173,7 +1174,6 @@ static void __update_open_stateid(struct nfs4_state *state, nfs4_stateid *open_s
 	if (open_stateid != NULL)
 		nfs_set_open_stateid_locked(state, open_stateid, fmode);
 	write_sequnlock(&state->seqlock);
-	spin_lock(&state->owner->so_lock);
 	update_open_stateflags(state, fmode);
 	spin_unlock(&state->owner->so_lock);
 }
-- 
2.7.1


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

* [patch added to 3.12-stable] udf: limit the maximum number of indirect extents in a row
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] cifs: fix erroneous return value Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] nfs: Fix race in __update_open_stateid() Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] udf: Prevent buffer overrun with multi-byte characters Jiri Slaby
                   ` (24 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Vegard Nossum, Jan Kara, Quentin Casasnovas, Andrew Morton,
	Jan Kara, Jiri Slaby

From: Vegard Nossum <vegard.nossum@oracle.com>

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

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

commit b0918d9f476a8434b055e362b83fa4fd1d462c3f upstream.

udf_next_aext() just follows extent pointers while extents are marked as
indirect. This can loop forever for corrupted filesystem. Limit number
the of indirect extents we are willing to follow in a row.

[JK: Updated changelog, limit, style]

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Jan Kara <jack@suse.com>
Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/udf/inode.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index b0774f245199..b6b2958ba758 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -2069,14 +2069,29 @@ void udf_write_aext(struct inode *inode, struct extent_position *epos,
 		epos->offset += adsize;
 }
 
+/*
+ * Only 1 indirect extent in a row really makes sense but allow upto 16 in case
+ * someone does some weird stuff.
+ */
+#define UDF_MAX_INDIR_EXTS 16
+
 int8_t udf_next_aext(struct inode *inode, struct extent_position *epos,
 		     struct kernel_lb_addr *eloc, uint32_t *elen, int inc)
 {
 	int8_t etype;
+	unsigned int indirections = 0;
 
 	while ((etype = udf_current_aext(inode, epos, eloc, elen, inc)) ==
 	       (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) {
 		int block;
+
+		if (++indirections > UDF_MAX_INDIR_EXTS) {
+			udf_err(inode->i_sb,
+				"too many indirect extents in inode %lu\n",
+				inode->i_ino);
+			return -1;
+		}
+
 		epos->block = *eloc;
 		epos->offset = sizeof(struct allocExtDesc);
 		brelse(epos->bh);
-- 
2.7.1


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

* [patch added to 3.12-stable] udf: Prevent buffer overrun with multi-byte characters
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (2 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] udf: limit the maximum number of indirect extents in a row Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] udf: Check output buffer length when converting name to CS0 Jiri Slaby
                   ` (23 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Andrew Gabbasov, Jan Kara, Jiri Slaby

From: Andrew Gabbasov <andrew_gabbasov@mentor.com>

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

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

commit ad402b265ecf6fa22d04043b41444cdfcdf4f52d upstream.

udf_CS0toUTF8 function stops the conversion when the output buffer
length reaches UDF_NAME_LEN-2, which is correct maximum name length,
but, when checking, it leaves the space for a single byte only,
while multi-bytes output characters can take more space, causing
buffer overflow.

Similar error exists in udf_CS0toNLS function, that restricts
the output length to UDF_NAME_LEN, while actual maximum allowed
length is UDF_NAME_LEN-2.

In these cases the output can override not only the current buffer
length field, causing corruption of the name buffer itself, but also
following allocation structures, causing kernel crash.

Adjust the output length checks in both functions to prevent buffer
overruns in case of multi-bytes UTF8 or NLS characters.

Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/udf/unicode.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index d29c06fbf4ce..dd8c24a9fe74 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -133,11 +133,15 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
 		if (c < 0x80U)
 			utf_o->u_name[utf_o->u_len++] = (uint8_t)c;
 		else if (c < 0x800U) {
+			if (utf_o->u_len > (UDF_NAME_LEN - 4))
+				break;
 			utf_o->u_name[utf_o->u_len++] =
 						(uint8_t)(0xc0 | (c >> 6));
 			utf_o->u_name[utf_o->u_len++] =
 						(uint8_t)(0x80 | (c & 0x3f));
 		} else {
+			if (utf_o->u_len > (UDF_NAME_LEN - 5))
+				break;
 			utf_o->u_name[utf_o->u_len++] =
 						(uint8_t)(0xe0 | (c >> 12));
 			utf_o->u_name[utf_o->u_len++] =
@@ -282,7 +286,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
 			c = (c << 8) | ocu[i++];
 
 		len = nls->uni2char(c, &utf_o->u_name[utf_o->u_len],
-				    UDF_NAME_LEN - utf_o->u_len);
+				    UDF_NAME_LEN - 2 - utf_o->u_len);
 		/* Valid character? */
 		if (len >= 0)
 			utf_o->u_len += len;
-- 
2.7.1


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

* [patch added to 3.12-stable] udf: Check output buffer length when converting name to CS0
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (3 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] udf: Prevent buffer overrun with multi-byte characters Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] ARM: dts: Kirkwood: Fix QNAP TS219 power-off Jiri Slaby
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Andrew Gabbasov, Jan Kara, Jiri Slaby

From: Andrew Gabbasov <andrew_gabbasov@mentor.com>

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

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

commit bb00c898ad1ce40c4bb422a8207ae562e9aea7ae upstream.

If a name contains at least some characters with Unicode values
exceeding single byte, the CS0 output should have 2 bytes per character.
And if other input characters have single byte Unicode values, then
the single input byte is converted to 2 output bytes, and the length
of output becomes larger than the length of input. And if the input
name is long enough, the output length may exceed the allocated buffer
length.

All this means that conversion from UTF8 or NLS to CS0 requires
checking of output length in order to stop when it exceeds the given
output buffer size.

[JK: Make code return -ENAMETOOLONG instead of silently truncating the
name]

Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/udf/unicode.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index dd8c24a9fe74..52330cb09daf 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -182,17 +182,22 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
 static int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length)
 {
 	unsigned c, i, max_val, utf_char;
-	int utf_cnt, u_len;
+	int utf_cnt, u_len, u_ch;
 
 	memset(ocu, 0, sizeof(dstring) * length);
 	ocu[0] = 8;
 	max_val = 0xffU;
+	u_ch = 1;
 
 try_again:
 	u_len = 0U;
 	utf_char = 0U;
 	utf_cnt = 0U;
 	for (i = 0U; i < utf->u_len; i++) {
+		/* Name didn't fit? */
+		if (u_len + 1 + u_ch >= length)
+			return 0;
+
 		c = (uint8_t)utf->u_name[i];
 
 		/* Complete a multi-byte UTF-8 character */
@@ -234,6 +239,7 @@ try_again:
 			if (max_val == 0xffU) {
 				max_val = 0xffffU;
 				ocu[0] = (uint8_t)0x10U;
+				u_ch = 2;
 				goto try_again;
 			}
 			goto error_out;
@@ -304,15 +310,19 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni,
 	int len;
 	unsigned i, max_val;
 	uint16_t uni_char;
-	int u_len;
+	int u_len, u_ch;
 
 	memset(ocu, 0, sizeof(dstring) * length);
 	ocu[0] = 8;
 	max_val = 0xffU;
+	u_ch = 1;
 
 try_again:
 	u_len = 0U;
 	for (i = 0U; i < uni->u_len; i++) {
+		/* Name didn't fit? */
+		if (u_len + 1 + u_ch >= length)
+			return 0;
 		len = nls->char2uni(&uni->u_name[i], uni->u_len - i, &uni_char);
 		if (!len)
 			continue;
@@ -325,6 +335,7 @@ try_again:
 		if (uni_char > max_val) {
 			max_val = 0xffffU;
 			ocu[0] = (uint8_t)0x10U;
+			u_ch = 2;
 			goto try_again;
 		}
 
-- 
2.7.1


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

* [patch added to 3.12-stable] ARM: dts: Kirkwood: Fix QNAP TS219 power-off
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (4 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] udf: Check output buffer length when converting name to CS0 Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] ARM: 8471/1: need to save/restore arm register(r11) when it is corrupted Jiri Slaby
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Helmut Klein, Andrew Lunn, Gregory CLEMENT, Jiri Slaby

From: Helmut Klein <hgkr.klein@gmail.com>

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

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

commit 5442f0eadf2885453d5b2ed8c8592f32a3744f8e upstream.

The "reg" entry in the "poweroff" section of "kirkwood-ts219.dtsi"
addressed the wrong uart (0 = console). This patch changes the address
to select uart 1, which is the uart connected to the pic
microcontroller, which can switch the device off.

Signed-off-by: Helmut Klein <hgkr.klein@gmail.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Fixes: 4350a47bbac3 ("ARM: Kirkwood: Make use of the QNAP Power off driver.")
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/arm/boot/dts/kirkwood-ts219.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/kirkwood-ts219.dtsi b/arch/arm/boot/dts/kirkwood-ts219.dtsi
index 39158cf16258..067e1e98e831 100644
--- a/arch/arm/boot/dts/kirkwood-ts219.dtsi
+++ b/arch/arm/boot/dts/kirkwood-ts219.dtsi
@@ -47,7 +47,7 @@
 		};
 		poweroff@12100 {
 			compatible = "qnap,power-off";
-			reg = <0x12000 0x100>;
+			reg = <0x12100 0x100>;
 			clocks = <&gate_clk 7>;
 		};
 		spi@10600 {
-- 
2.7.1


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

* [patch added to 3.12-stable] ARM: 8471/1: need to save/restore arm register(r11) when it is corrupted
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (5 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] ARM: dts: Kirkwood: Fix QNAP TS219 power-off Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] ARM: 8519/1: ICST: try other dividends than 1 Jiri Slaby
                   ` (20 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Anson Huang, Russell King, Jiri Slaby

From: Anson Huang <Anson.Huang@freescale.com>

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

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

commit fa0708b320f6da4c1104fe56e01b7abf66fd16ad upstream.

In cpu_v7_do_suspend routine, r11 is used while it is NOT
saved/restored, different compiler may have different usage
of ARM general registers, so it may cause issues during
calling cpu_v7_do_suspend.

We meet kernel fault occurs when using GCC 4.8.3, r11 contains
valid value before calling into cpu_v7_do_suspend, but when returned
from this routine, r11 is corrupted and lead to kernel fault.
Doing save/restore for those corrupted registers is a must in
assemble code.

Signed-off-by: Anson Huang <Anson.Huang@freescale.com>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/arm/mm/proc-v7.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index 2e381582ffee..8a03e9a31a3f 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -95,7 +95,7 @@ ENDPROC(cpu_v7_dcache_clean_area)
 .equ	cpu_v7_suspend_size, 4 * 8
 #ifdef CONFIG_ARM_CPU_SUSPEND
 ENTRY(cpu_v7_do_suspend)
-	stmfd	sp!, {r4 - r10, lr}
+	stmfd	sp!, {r4 - r11, lr}
 	mrc	p15, 0, r4, c13, c0, 0	@ FCSE/PID
 	mrc	p15, 0, r5, c13, c0, 3	@ User r/o thread ID
 	stmia	r0!, {r4 - r5}
@@ -108,7 +108,7 @@ ENTRY(cpu_v7_do_suspend)
 	mrc	p15, 0, r9, c1, c0, 1	@ Auxiliary control register
 	mrc	p15, 0, r10, c1, c0, 2	@ Co-processor access control
 	stmia	r0, {r6 - r11}
-	ldmfd	sp!, {r4 - r10, pc}
+	ldmfd	sp!, {r4 - r11, pc}
 ENDPROC(cpu_v7_do_suspend)
 
 ENTRY(cpu_v7_do_resume)
-- 
2.7.1


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

* [patch added to 3.12-stable] ARM: 8519/1: ICST: try other dividends than 1
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (6 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] ARM: 8471/1: need to save/restore arm register(r11) when it is corrupted Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] ARM: 8517/1: ICST: avoid arithmetic overflow in icst_hz() Jiri Slaby
                   ` (19 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Linus Walleij, Russell King, Jiri Slaby

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

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

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

commit e972c37459c813190461dabfeaac228e00aae259 upstream.

Since the dawn of time the ICST code has only supported divide
by one or hang in an eternal loop. Luckily we were always dividing
by one because the reference frequency for the systems using
the ICSTs is 24MHz and the [min,max] values for the PLL input
if [10,320] MHz for ICST307 and [6,200] for ICST525, so the loop
will always terminate immediately without assigning any divisor
for the reference frequency.

But for the code to make sense, let's insert the missing i++

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/arm/common/icst.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/common/icst.c b/arch/arm/common/icst.c
index 2dc6da70ae59..3b3e58b7ba74 100644
--- a/arch/arm/common/icst.c
+++ b/arch/arm/common/icst.c
@@ -58,6 +58,7 @@ icst_hz_to_vco(const struct icst_params *p, unsigned long freq)
 
 		if (f > p->vco_min && f <= p->vco_max)
 			break;
+		i++;
 	} while (i < 8);
 
 	if (i >= 8)
-- 
2.7.1


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

* [patch added to 3.12-stable] ARM: 8517/1: ICST: avoid arithmetic overflow in icst_hz()
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (7 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] ARM: 8519/1: ICST: try other dividends than 1 Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] fuse: break infinite loop in fuse_fill_write_pages() Jiri Slaby
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Linus Walleij, linux-clk, Pawel Moll, Russell King, Jiri Slaby

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

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

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

commit 5070fb14a0154f075c8b418e5bc58a620ae85a45 upstream.

When trying to set the ICST 307 clock to 25174000 Hz I ran into
this arithmetic error: the icst_hz_to_vco() correctly figure out
DIVIDE=2, RDW=100 and VDW=99 yielding a frequency of
25174000 Hz out of the VCO. (I replicated the icst_hz() function
in a spreadsheet to verify this.)

However, when I called icst_hz() on these VCO settings it would
instead return 4122709 Hz. This causes an error in the common
clock driver for ICST as the common clock framework will call
.round_rate() on the clock which will utilize icst_hz_to_vco()
followed by icst_hz() suggesting the erroneous frequency, and
then the clock gets set to this.

The error did not manifest in the old clock framework since
this high frequency was only used by the CLCD, which calls
clk_set_rate() without first calling clk_round_rate() and since
the old clock framework would not call clk_round_rate() before
setting the frequency, the correct values propagated into
the VCO.

After some experimenting I figured out that it was due to a simple
arithmetic overflow: the divisor for 24Mhz reference frequency
as reference becomes 24000000*2*(99+8)=0x132212400 and the "1"
in bit 32 overflows and is lost.

But introducing an explicit 64-by-32 bit do_div() and casting
the divisor into (u64) we get the right frequency back, and the
right frequency gets set.

Tested on the ARM Versatile.

Cc: linux-clk@vger.kernel.org
Cc: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/arm/common/icst.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/common/icst.c b/arch/arm/common/icst.c
index 3b3e58b7ba74..d7ed252708c5 100644
--- a/arch/arm/common/icst.c
+++ b/arch/arm/common/icst.c
@@ -16,7 +16,7 @@
  */
 #include <linux/module.h>
 #include <linux/kernel.h>
-
+#include <asm/div64.h>
 #include <asm/hardware/icst.h>
 
 /*
@@ -29,7 +29,11 @@ EXPORT_SYMBOL(icst525_s2div);
 
 unsigned long icst_hz(const struct icst_params *p, struct icst_vco vco)
 {
-	return p->ref * 2 * (vco.v + 8) / ((vco.r + 2) * p->s2div[vco.s]);
+	u64 dividend = p->ref * 2 * (u64)(vco.v + 8);
+	u32 divisor = (vco.r + 2) * p->s2div[vco.s];
+
+	do_div(dividend, divisor);
+	return (unsigned long)dividend;
 }
 
 EXPORT_SYMBOL(icst_hz);
-- 
2.7.1


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

* [patch added to 3.12-stable] fuse: break infinite loop in fuse_fill_write_pages()
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (8 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] ARM: 8517/1: ICST: avoid arithmetic overflow in icst_hz() Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] mm: soft-offline: check return value in second __get_any_page() call Jiri Slaby
                   ` (17 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Roman Gushchin, Andrew Morton, Maxim Patlasov,
	Konstantin Khlebnikov, Miklos Szeredi, Jiri Slaby

From: Roman Gushchin <klamm@yandex-team.ru>

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

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

commit 3ca8138f014a913f98e6ef40e939868e1e9ea876 upstream.

I got a report about unkillable task eating CPU. Further
investigation shows, that the problem is in the fuse_fill_write_pages()
function. If iov's first segment has zero length, we get an infinite
loop, because we never reach iov_iter_advance() call.

Fix this by calling iov_iter_advance() before repeating an attempt to
copy data from userspace.

A similar problem is described in 124d3b7041f ("fix writev regression:
pan hanging unkillable and un-straceable"). If zero-length segmend
is followed by segment with invalid address,
iov_iter_fault_in_readable() checks only first segment (zero-length),
iov_iter_copy_from_user_atomic() skips it, fails at second and
returns zero -> goto again without skipping zero-length segment.

Patch calls iov_iter_advance() before goto again: we'll skip zero-length
segment at second iteraction and iov_iter_fault_in_readable() will detect
invalid address.

Special thanks to Konstantin Khlebnikov, who helped a lot with the commit
description.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Maxim Patlasov <mpatlasov@parallels.com>
Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Roman Gushchin <klamm@yandex-team.ru>
Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Fixes: ea9b9907b82a ("fuse: implement perform_write")
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 fs/fuse/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index d08c108065e1..8ef52e12cd57 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -988,6 +988,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
 		tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes);
 		flush_dcache_page(page);
 
+		iov_iter_advance(ii, tmp);
 		if (!tmp) {
 			unlock_page(page);
 			page_cache_release(page);
@@ -1000,7 +1001,6 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
 		req->page_descs[req->num_pages].length = tmp;
 		req->num_pages++;
 
-		iov_iter_advance(ii, tmp);
 		count += tmp;
 		pos += tmp;
 		offset += tmp;
-- 
2.7.1


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

* [patch added to 3.12-stable] mm: soft-offline: check return value in second __get_any_page() call
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (9 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] fuse: break infinite loop in fuse_fill_write_pages() Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] mm: fix mlock accouting Jiri Slaby
                   ` (16 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Naoya Horiguchi, Sasha Levin, Aneesh Kumar K . V,
	Vlastimil Babka, Jerome Marchand, Andrea Arcangeli, Hugh Dickins,
	Dave Hansen, Mel Gorman, Rik van Riel, Steve Capper,
	Johannes Weiner, Michal Hocko, Christoph Lameter, David Rientjes,
	Andrew Morton, Linus Torvalds, Jiri Slaby

From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>

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

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

commit d96b339f453997f2f08c52da3f41423be48c978f upstream.

I saw the following BUG_ON triggered in a testcase where a process calls
madvise(MADV_SOFT_OFFLINE) on thps, along with a background process that
calls migratepages command repeatedly (doing ping-pong among different
NUMA nodes) for the first process:

   Soft offlining page 0x60000 at 0x700000600000
   __get_any_page: 0x60000 free buddy page
   page:ffffea0001800000 count:0 mapcount:-127 mapping:          (null) index:0x1
   flags: 0x1fffc0000000000()
   page dumped because: VM_BUG_ON_PAGE(atomic_read(&page->_count) == 0)
   ------------[ cut here ]------------
   kernel BUG at /src/linux-dev/include/linux/mm.h:342!
   invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC
   Modules linked in: cfg80211 rfkill crc32c_intel serio_raw virtio_balloon i2c_piix4 virtio_blk virtio_net ata_generic pata_acpi
   CPU: 3 PID: 3035 Comm: test_alloc_gene Tainted: G           O    4.4.0-rc8-v4.4-rc8-160107-1501-00000-rc8+ #74
   Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
   task: ffff88007c63d5c0 ti: ffff88007c210000 task.ti: ffff88007c210000
   RIP: 0010:[<ffffffff8118998c>]  [<ffffffff8118998c>] put_page+0x5c/0x60
   RSP: 0018:ffff88007c213e00  EFLAGS: 00010246
   Call Trace:
     put_hwpoison_page+0x4e/0x80
     soft_offline_page+0x501/0x520
     SyS_madvise+0x6bc/0x6f0
     entry_SYSCALL_64_fastpath+0x12/0x6a
   Code: 8b fc ff ff 5b 5d c3 48 89 df e8 b0 fa ff ff 48 89 df 31 f6 e8 c6 7d ff ff 5b 5d c3 48 c7 c6 08 54 a2 81 48 89 df e8 a4 c5 01 00 <0f> 0b 66 90 66 66 66 66 90 55 48 89 e5 41 55 41 54 53 48 8b 47
   RIP  [<ffffffff8118998c>] put_page+0x5c/0x60
    RSP <ffff88007c213e00>

The root cause resides in get_any_page() which retries to get a refcount
of the page to be soft-offlined.  This function calls
put_hwpoison_page(), expecting that the target page is putback to LRU
list.  But it can be also freed to buddy.  So the second check need to
care about such case.

Fixes: af8fae7c0886 ("mm/memory-failure.c: clean up soft_offline_page()")
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Jerome Marchand <jmarchan@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.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>
---
 mm/memory-failure.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index cb08faa72b77..3db082d82428 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1523,7 +1523,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags)
 		 * Did it turn free?
 		 */
 		ret = __get_any_page(page, pfn, 0);
-		if (!PageLRU(page)) {
+		if (ret == 1 && !PageLRU(page)) {
 			/* Drop page reference which is from __get_any_page() */
 			put_page(page);
 			pr_info("soft_offline: %#lx: unknown non LRU page type %lx\n",
-- 
2.7.1


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

* [patch added to 3.12-stable] mm: fix mlock accouting
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (10 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] mm: soft-offline: check return value in second __get_any_page() call Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] Input: elantech - add Fujitsu Lifebook U745 to force crc_enabled Jiri Slaby
                   ` (15 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Kirill A. Shutemov, Michel Lespinasse, Andrew Morton,
	Linus Torvalds, Jiri Slaby

From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>

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

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

commit 7162a1e87b3e380133dadc7909081bb70d0a7041 upstream.

Tetsuo Handa reported underflow of NR_MLOCK on munlock.

Testcase:

    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/mman.h>

    #define BASE ((void *)0x400000000000)
    #define SIZE (1UL << 21)

    int main(int argc, char *argv[])
    {
        void *addr;

        system("grep Mlocked /proc/meminfo");
        addr = mmap(BASE, SIZE, PROT_READ | PROT_WRITE,
                MAP_ANONYMOUS | MAP_PRIVATE | MAP_LOCKED | MAP_FIXED,
                -1, 0);
        if (addr == MAP_FAILED)
            printf("mmap() failed\n"), exit(1);
        munmap(addr, SIZE);
        system("grep Mlocked /proc/meminfo");
        return 0;
    }

It happens on munlock_vma_page() due to unfortunate choice of nr_pages
data type:

    __mod_zone_page_state(zone, NR_MLOCK, -nr_pages);

For unsigned int nr_pages, implicitly casted to long in
__mod_zone_page_state(), it becomes something around UINT_MAX.

munlock_vma_page() usually called for THP as small pages go though
pagevec.

Let's make nr_pages signed int.

Similar fixes in 6cdb18ad98a4 ("mm/vmstat: fix overflow in
mod_zone_page_state()") used `long' type, but `int' here is OK for a
count of the number of sub-pages in a huge page.

Fixes: ff6a6da60b89 ("mm: accelerate munlock() treatment of THP pages")
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Michel Lespinasse <walken@google.com>
Acked-by: Michal Hocko <mhocko@suse.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>
---
 mm/mlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mlock.c b/mm/mlock.c
index 1b12dfad0794..db92bcd7f2fa 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -152,7 +152,7 @@ static void __munlock_isolation_failed(struct page *page)
  */
 unsigned int munlock_vma_page(struct page *page)
 {
-	unsigned int nr_pages;
+	int nr_pages;
 
 	/* For try_to_munlock() and to serialize with page migration */
 	BUG_ON(!PageLocked(page));
-- 
2.7.1


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

* [patch added to 3.12-stable] Input: elantech - add Fujitsu Lifebook U745 to force crc_enabled
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (11 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] mm: fix mlock accouting Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] Input: elantech - mark protocols v2 and v3 as semi-mt Jiri Slaby
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Takashi Iwai, Dmitry Torokhov, Jiri Slaby

From: Takashi Iwai <tiwai@suse.de>

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

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

commit 60603950f836ef4e88daddf61a273b91e671db2d upstream.

Another Lifebook machine that needs the same quirk as other similar
models to make the driver working.

Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=883192
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/mouse/elantech.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 65945db35377..88289c360a80 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -1419,6 +1419,13 @@ static const struct dmi_system_id no_hw_res_dmi_table[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "U2442"),
 		},
 	},
+	{
+		/* Fujitsu LIFEBOOK U745 does not work with crc_enabled == 0 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U745"),
+		},
+	},
 #endif
 	{ }
 };
-- 
2.7.1


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

* [patch added to 3.12-stable] Input: elantech - mark protocols v2 and v3 as semi-mt
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (12 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] Input: elantech - add Fujitsu Lifebook U745 to force crc_enabled Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] Input: i8042 - add Fujitsu Lifebook U745 to the nomux list Jiri Slaby
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Benjamin Tissoires, Dmitry Torokhov, Jiri Slaby

From: Benjamin Tissoires <benjamin.tissoires@redhat.com>

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

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

commit 6544a1df11c48c8413071aac3316792e4678fbfb upstream.

When using a protocol v2 or v3 hardware, elantech uses the function
elantech_report_semi_mt_data() to report data. This devices are rather
creepy because if num_finger is 3, (x2,y2) is (0,0). Yes, only one valid
touch is reported.

Anyway, userspace (libinput) is now confused by these (0,0) touches,
and detect them as palm, and rejects them.

Commit 3c0213d17a09 ("Input: elantech - fix semi-mt protocol for v3 HW")
was sufficient enough for xf86-input-synaptics and libinput before it has
palm rejection. Now we need to actually tell libinput that this device is
a semi-mt one and it should not rely on the actual values of the 2 touches.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/input/mouse/elantech.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 88289c360a80..cbe20b0099a2 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -1113,7 +1113,7 @@ static int elantech_set_input_params(struct psmouse *psmouse)
 			input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2,
 					     ETP_WMAX_V2, 0, 0);
 		}
-		input_mt_init_slots(dev, 2, 0);
+		input_mt_init_slots(dev, 2, INPUT_MT_SEMI_MT);
 		input_set_abs_params(dev, ABS_MT_POSITION_X, x_min, x_max, 0, 0);
 		input_set_abs_params(dev, ABS_MT_POSITION_Y, y_min, y_max, 0, 0);
 		break;
-- 
2.7.1


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

* [patch added to 3.12-stable] Input: i8042 - add Fujitsu Lifebook U745 to the nomux list
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (13 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] Input: elantech - mark protocols v2 and v3 as semi-mt Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] iommu/vt-d: Fix 64-bit accesses to 32-bit DMAR_GSTS_REG Jiri Slaby
                   ` (12 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Aurélien Francillon, Dmitry Torokhov, Jiri Slaby

From: Aurélien Francillon <aurelien@francillon.net>

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

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

commit dd0d0d4de582a6a61c032332c91f4f4cb2bab569 upstream.

Without i8042.nomux=1 the Elantech touch pad is not working at all on
a Fujitsu Lifebook U745. This patch does not seem necessary for all
U745 (maybe because of different BIOS versions?). However, it was
verified that the patch does not break those (see opensuse bug 883192:
https://bugzilla.opensuse.org/show_bug.cgi?id=883192).

Signed-off-by: Aurélien Francillon <aurelien@francillon.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/input/serio/i8042-x86ia64io.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 0254ed97c16e..d9ab5c5e8e82 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -258,6 +258,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
 		},
 	},
 	{
+		/* Fujitsu Lifebook U745 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U745"),
+		},
+	},
+	{
 		/* Fujitsu T70H */
 		.matches = {
 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
-- 
2.7.1


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

* [patch added to 3.12-stable] iommu/vt-d: Fix 64-bit accesses to 32-bit DMAR_GSTS_REG
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (14 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] Input: i8042 - add Fujitsu Lifebook U745 to the nomux list Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone() Jiri Slaby
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: CQ Tang, David Woodhouse, Jiri Slaby

From: CQ Tang <cq.tang@intel.com>

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

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

commit fda3bec12d0979aae3f02ee645913d66fbc8a26e upstream.

This is a 32-bit register. Apparently harmless on real hardware, but
causing justified warnings in simulation.

Signed-off-by: CQ Tang <cq.tang@intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/iommu/dmar.c                | 2 +-
 drivers/iommu/intel_irq_remapping.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 785675a56a10..ba5d1a37a90d 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -972,7 +972,7 @@ void dmar_disable_qi(struct intel_iommu *iommu)
 
 	raw_spin_lock_irqsave(&iommu->register_lock, flags);
 
-	sts =  dmar_readq(iommu->reg + DMAR_GSTS_REG);
+	sts =  readl(iommu->reg + DMAR_GSTS_REG);
 	if (!(sts & DMA_GSTS_QIES))
 		goto end;
 
diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
index b97d70b1abe0..0ff40be0f3b2 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -495,7 +495,7 @@ static void iommu_disable_irq_remapping(struct intel_iommu *iommu)
 
 	raw_spin_lock_irqsave(&iommu->register_lock, flags);
 
-	sts = dmar_readq(iommu->reg + DMAR_GSTS_REG);
+	sts = readl(iommu->reg + DMAR_GSTS_REG);
 	if (!(sts & DMA_GSTS_IRES))
 		goto end;
 
-- 
2.7.1


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

* [patch added to 3.12-stable] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone()
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (15 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] iommu/vt-d: Fix 64-bit accesses to 32-bit DMAR_GSTS_REG Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] xhci: Fix list corruption in urb dequeue at host removal Jiri Slaby
                   ` (10 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Andrew Banman, Russ Anderson, Alex Thorlton, Yinghai Lu, Greg KH,
	Seth Jennings, Andrew Morton, Linus Torvalds, Jiri Slaby

From: Andrew Banman <abanman@sgi.com>

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

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

commit 5f0f2887f4de9508dcf438deab28f1de8070c271 upstream.

test_pages_in_a_zone() does not account for the possibility of missing
sections in the given pfn range.  pfn_valid_within always returns 1 when
CONFIG_HOLES_IN_ZONE is not set, allowing invalid pfns from missing
sections to pass the test, leading to a kernel oops.

Wrap an additional pfn loop with PAGES_PER_SECTION granularity to check
for missing sections before proceeding into the zone-check code.

This also prevents a crash from offlining memory devices with missing
sections.  Despite this, it may be a good idea to keep the related patch
'[PATCH 3/3] drivers: memory: prohibit offlining of memory blocks with
missing sections' because missing sections in a memory block may lead to
other problems not covered by the scope of this fix.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Alex Thorlton <athorlton@sgi.com>
Cc: Russ Anderson <rja@sgi.com>
Cc: Alex Thorlton <athorlton@sgi.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Greg KH <greg@kroah.com>
Cc: Seth Jennings <sjennings@variantweb.net>
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>
---
 mm/memory_hotplug.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index efeb4871b7e3..723978c6f8ab 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1209,23 +1209,30 @@ int is_mem_section_removable(unsigned long start_pfn, unsigned long nr_pages)
  */
 static int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn)
 {
-	unsigned long pfn;
+	unsigned long pfn, sec_end_pfn;
 	struct zone *zone = NULL;
 	struct page *page;
 	int i;
-	for (pfn = start_pfn;
+	for (pfn = start_pfn, sec_end_pfn = SECTION_ALIGN_UP(start_pfn);
 	     pfn < end_pfn;
-	     pfn += MAX_ORDER_NR_PAGES) {
-		i = 0;
-		/* This is just a CONFIG_HOLES_IN_ZONE check.*/
-		while ((i < MAX_ORDER_NR_PAGES) && !pfn_valid_within(pfn + i))
-			i++;
-		if (i == MAX_ORDER_NR_PAGES)
+	     pfn = sec_end_pfn + 1, sec_end_pfn += PAGES_PER_SECTION) {
+		/* Make sure the memory section is present first */
+		if (!present_section_nr(pfn_to_section_nr(pfn)))
 			continue;
-		page = pfn_to_page(pfn + i);
-		if (zone && page_zone(page) != zone)
-			return 0;
-		zone = page_zone(page);
+		for (; pfn < sec_end_pfn && pfn < end_pfn;
+		     pfn += MAX_ORDER_NR_PAGES) {
+			i = 0;
+			/* This is just a CONFIG_HOLES_IN_ZONE check.*/
+			while ((i < MAX_ORDER_NR_PAGES) &&
+				!pfn_valid_within(pfn + i))
+				i++;
+			if (i == MAX_ORDER_NR_PAGES)
+				continue;
+			page = pfn_to_page(pfn + i);
+			if (zone && page_zone(page) != zone)
+				return 0;
+			zone = page_zone(page);
+		}
 	}
 	return 1;
 }
-- 
2.7.1


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

* [patch added to 3.12-stable] xhci: Fix list corruption in urb dequeue at host removal
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (16 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone() Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] m32r: fix m32104ut_defconfig build fail Jiri Slaby
                   ` (9 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Mathias Nyman, Jiri Slaby

From: Mathias Nyman <mathias.nyman@linux.intel.com>

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

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

commit 5c82171167adb8e4ac77b91a42cd49fb211a81a0 upstream.

xhci driver frees data for all devices, both usb2 and and usb3 the
first time usb_remove_hcd() is called, including td_list and and xhci_ring
structures.

When usb_remove_hcd() is called a second time for the second xhci bus it
will try to dequeue all pending urbs, and touches td_list which is already
freed for that endpoint.

Reported-by: Joe Lawrence <joe.lawrence@stratus.com>
Tested-by: Joe Lawrence <joe.lawrence@stratus.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/host/xhci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index dfcf0a3527b8..806ed2ba1c6e 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1522,7 +1522,9 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 		xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
 				"HW died, freeing TD.");
 		urb_priv = urb->hcpriv;
-		for (i = urb_priv->td_cnt; i < urb_priv->length; i++) {
+		for (i = urb_priv->td_cnt;
+		     i < urb_priv->length && xhci->devs[urb->dev->slot_id];
+		     i++) {
 			td = urb_priv->td[i];
 			if (!list_empty(&td->td_list))
 				list_del_init(&td->td_list);
-- 
2.7.1


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

* [patch added to 3.12-stable] m32r: fix m32104ut_defconfig build fail
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (17 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] xhci: Fix list corruption in urb dequeue at host removal Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] dma-debug: switch check from _text to _stext Jiri Slaby
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Sudip Mukherjee, Sudip Mukherjee, Andrew Morton, Linus Torvalds,
	Jiri Slaby

From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>

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

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

commit 601f1db653217f205ffa5fb33514b4e1711e56d1 upstream.

The build of m32104ut_defconfig for m32r arch was failing for long long
time with the error:

  ERROR: "memory_start" [fs/udf/udf.ko] undefined!
  ERROR: "memory_end" [fs/udf/udf.ko] undefined!
  ERROR: "memory_end" [drivers/scsi/sg.ko] undefined!
  ERROR: "memory_start" [drivers/scsi/sg.ko] undefined!
  ERROR: "memory_end" [drivers/i2c/i2c-dev.ko] undefined!
  ERROR: "memory_start" [drivers/i2c/i2c-dev.ko] undefined!

As done in other architectures export the symbols to fix the error.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.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>
---
 arch/m32r/kernel/setup.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c
index 0392112a5d70..a5ecef7188ba 100644
--- a/arch/m32r/kernel/setup.c
+++ b/arch/m32r/kernel/setup.c
@@ -81,7 +81,10 @@ static struct resource code_resource = {
 };
 
 unsigned long memory_start;
+EXPORT_SYMBOL(memory_start);
+
 unsigned long memory_end;
+EXPORT_SYMBOL(memory_end);
 
 void __init setup_arch(char **);
 int get_cpuinfo(char *);
-- 
2.7.1


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

* [patch added to 3.12-stable] dma-debug: switch check from _text to _stext
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (18 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] m32r: fix m32104ut_defconfig build fail Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] scripts/bloat-o-meter: fix python3 syntax error Jiri Slaby
                   ` (7 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Laura Abbott, Russell King, Arnd Bergmann, Andrew Morton,
	Linus Torvalds, Jiri Slaby

From: Laura Abbott <labbott@fedoraproject.org>

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

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

commit ea535e418c01837d07b6c94e817540f50bfdadb0 upstream.

In include/asm-generic/sections.h:

  /*
   * Usage guidelines:
   * _text, _data: architecture specific, don't use them in
   * arch-independent code
   * [_stext, _etext]: contains .text.* sections, may also contain
   * .rodata.*
   *                   and/or .init.* sections

_text is not guaranteed across architectures.  Architectures such as ARM
may reuse parts which are not actually text and erroneously trigger a bug.
Switch to using _stext which is guaranteed to contain text sections.

Came out of https://lkml.kernel.org/g/<567B1176.4000106@redhat.com>

Signed-off-by: Laura Abbott <labbott@fedoraproject.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
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>
---
 lib/dma-debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index d87a17a819d0..eb43517bf261 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -962,7 +962,7 @@ static inline bool overlap(void *addr, unsigned long len, void *start, void *end
 
 static void check_for_illegal_area(struct device *dev, void *addr, unsigned long len)
 {
-	if (overlap(addr, len, _text, _etext) ||
+	if (overlap(addr, len, _stext, _etext) ||
 	    overlap(addr, len, __start_rodata, __end_rodata))
 		err_printk(dev, NULL, "DMA-API: device driver maps memory from kernel text or rodata [addr=%p] [len=%lu]\n", addr, len);
 }
-- 
2.7.1


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

* [patch added to 3.12-stable] scripts/bloat-o-meter: fix python3 syntax error
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (19 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] dma-debug: switch check from _text to _stext Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] memcg: only free spare array when readers are done Jiri Slaby
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Sergey Senozhatsky, Sergey Senozhatsky, Andrew Morton,
	Linus Torvalds, Jiri Slaby

From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>

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

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

commit 72214a24a7677d4c7501eecc9517ed681b5f2db2 upstream.

In Python3+ print is a function so the old syntax is not correct
anymore:

  $ ./scripts/bloat-o-meter vmlinux.o vmlinux.o.old
    File "./scripts/bloat-o-meter", line 61
      print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
                                                                     ^
  SyntaxError: invalid syntax

Fix by calling print as a function.

Tested on python 2.7.11, 3.5.1

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.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>
---
 scripts/bloat-o-meter | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
index 6129020c41a9..81228a443122 100755
--- a/scripts/bloat-o-meter
+++ b/scripts/bloat-o-meter
@@ -55,8 +55,8 @@ for name in common:
 delta.sort()
 delta.reverse()
 
-print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
-      (add, remove, grow, shrink, up, -down, up-down)
-print "%-40s %7s %7s %+7s" % ("function", "old", "new", "delta")
+print("add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
+      (add, remove, grow, shrink, up, -down, up-down))
+print("%-40s %7s %7s %+7s" % ("function", "old", "new", "delta"))
 for d, n in delta:
-    if d: print "%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)
+    if d: print("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d))
-- 
2.7.1


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

* [patch added to 3.12-stable] memcg: only free spare array when readers are done
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (20 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] scripts/bloat-o-meter: fix python3 syntax error Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] radix-tree: fix race in gang lookup Jiri Slaby
                   ` (5 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Martijn Coenen, Johannes Weiner, Vladimir Davydov, Andrew Morton,
	Linus Torvalds, Jiri Slaby

From: Martijn Coenen <maco@google.com>

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

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

commit 6611d8d76132f86faa501de9451a89bf23fb2371 upstream.

A spare array holding mem cgroup threshold events is kept around to make
sure we can always safely deregister an event and have an array to store
the new set of events in.

In the scenario where we're going from 1 to 0 registered events, the
pointer to the primary array containing 1 event is copied to the spare
slot, and then the spare slot is freed because no events are left.
However, it is freed before calling synchronize_rcu(), which means
readers may still be accessing threshold->primary after it is freed.

Fixed by only freeing after synchronize_rcu().

Signed-off-by: Martijn Coenen <maco@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Vladimir Davydov <vdavydov@virtuozzo.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>
---
 mm/memcontrol.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ff648969e402..5904fc833523 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5830,16 +5830,17 @@ static void mem_cgroup_usage_unregister_event(struct cgroup_subsys_state *css,
 swap_buffers:
 	/* Swap primary and spare array */
 	thresholds->spare = thresholds->primary;
-	/* If all events are unregistered, free the spare array */
-	if (!new) {
-		kfree(thresholds->spare);
-		thresholds->spare = NULL;
-	}
 
 	rcu_assign_pointer(thresholds->primary, new);
 
 	/* To be sure that nobody uses thresholds */
 	synchronize_rcu();
+
+	/* If all events are unregistered, free the spare array */
+	if (!new) {
+		kfree(thresholds->spare);
+		thresholds->spare = NULL;
+	}
 unlock:
 	mutex_unlock(&memcg->thresholds_lock);
 }
-- 
2.7.1


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

* [patch added to 3.12-stable] radix-tree: fix race in gang lookup
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (21 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] memcg: only free spare array when readers are done Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] radix-tree: fix oops after radix_tree_iter_retry Jiri Slaby
                   ` (4 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Matthew Wilcox, Hugh Dickins, Ohad Ben-Cohen,
	Konstantin Khlebnikov, Andrew Morton, Linus Torvalds, Jiri Slaby

From: Matthew Wilcox <willy@linux.intel.com>

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

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

commit 46437f9a554fbe3e110580ca08ab703b59f2f95a upstream.

If the indirect_ptr bit is set on a slot, that indicates we need to redo
the lookup.  Introduce a new function radix_tree_iter_retry() which
forces the loop to retry the lookup by setting 'slot' to NULL and
turning the iterator back to point at the problematic entry.

This is a pretty rare problem to hit at the moment; the lookup has to
race with a grow of the radix tree from a height of 0.  The consequences
of hitting this race are that gang lookup could return a pointer to a
radix_tree_node instead of a pointer to whatever the user had inserted
in the tree.

Fixes: cebbd29e1c2f ("radix-tree: rewrite gang lookup using iterator")
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Konstantin Khlebnikov <khlebnikov@openvz.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>
---
 include/linux/radix-tree.h | 16 ++++++++++++++++
 lib/radix-tree.c           | 12 ++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index e8be53ecfc45..3c2ce3cdd16a 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -320,6 +320,22 @@ void **radix_tree_next_chunk(struct radix_tree_root *root,
 			     struct radix_tree_iter *iter, unsigned flags);
 
 /**
+ * radix_tree_iter_retry - retry this chunk of the iteration
+ * @iter:	iterator state
+ *
+ * If we iterate over a tree protected only by the RCU lock, a race
+ * against deletion or creation may result in seeing a slot for which
+ * radix_tree_deref_retry() returns true.  If so, call this function
+ * and continue the iteration.
+ */
+static inline __must_check
+void **radix_tree_iter_retry(struct radix_tree_iter *iter)
+{
+	iter->next_index = iter->index;
+	return NULL;
+}
+
+/**
  * radix_tree_chunk_size - get current chunk size
  *
  * @iter:	pointer to radix tree iterator
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index e8adb5d8a184..50a9a1c155d3 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -977,9 +977,13 @@ radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
 		return 0;
 
 	radix_tree_for_each_slot(slot, root, &iter, first_index) {
-		results[ret] = indirect_to_ptr(rcu_dereference_raw(*slot));
+		results[ret] = rcu_dereference_raw(*slot);
 		if (!results[ret])
 			continue;
+		if (radix_tree_is_indirect_ptr(results[ret])) {
+			slot = radix_tree_iter_retry(&iter);
+			continue;
+		}
 		if (++ret == max_items)
 			break;
 	}
@@ -1056,9 +1060,13 @@ radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
 		return 0;
 
 	radix_tree_for_each_tagged(slot, root, &iter, first_index, tag) {
-		results[ret] = indirect_to_ptr(rcu_dereference_raw(*slot));
+		results[ret] = rcu_dereference_raw(*slot);
 		if (!results[ret])
 			continue;
+		if (radix_tree_is_indirect_ptr(results[ret])) {
+			slot = radix_tree_iter_retry(&iter);
+			continue;
+		}
 		if (++ret == max_items)
 			break;
 	}
-- 
2.7.1


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

* [patch added to 3.12-stable] radix-tree: fix oops after radix_tree_iter_retry
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (22 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] radix-tree: fix race in gang lookup Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] dump_stack: avoid potential deadlocks Jiri Slaby
                   ` (3 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Konstantin Khlebnikov, Matthew Wilcox, Hugh Dickins,
	Ohad Ben-Cohen, Jeremiah Mahler, Andrew Morton, Linus Torvalds,
	Jiri Slaby

From: Konstantin Khlebnikov <koct9i@gmail.com>

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

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

commit 732042821cfa106b3c20b9780e4c60fee9d68900 upstream.

Helper radix_tree_iter_retry() resets next_index to the current index.
In following radix_tree_next_slot current chunk size becomes zero.  This
isn't checked and it tries to dereference null pointer in slot.

Tagged iterator is fine because retry happens only at slot 0 where tag
bitmask in iter->tags is filled with single bit.

Fixes: 46437f9a554f ("radix-tree: fix race in gang lookup")
Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Matthew Wilcox <willy@linux.intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Jeremiah Mahler <jmmahler@gmail.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/radix-tree.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 3c2ce3cdd16a..16604454e95f 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -341,7 +341,7 @@ void **radix_tree_iter_retry(struct radix_tree_iter *iter)
  * @iter:	pointer to radix tree iterator
  * Returns:	current chunk size
  */
-static __always_inline unsigned
+static __always_inline long
 radix_tree_chunk_size(struct radix_tree_iter *iter)
 {
 	return iter->next_index - iter->index;
@@ -375,9 +375,9 @@ radix_tree_next_slot(void **slot, struct radix_tree_iter *iter, unsigned flags)
 			return slot + offset + 1;
 		}
 	} else {
-		unsigned size = radix_tree_chunk_size(iter) - 1;
+		long size = radix_tree_chunk_size(iter);
 
-		while (size--) {
+		while (--size > 0) {
 			slot++;
 			iter->index++;
 			if (likely(*slot))
-- 
2.7.1


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

* [patch added to 3.12-stable] dump_stack: avoid potential deadlocks
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (23 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] radix-tree: fix oops after radix_tree_iter_retry Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] intel_scu_ipcutil: underflow in scu_reg_access() Jiri Slaby
                   ` (2 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Eric Dumazet, Alex Thorlton, Andrew Morton, Linus Torvalds, Jiri Slaby

From: Eric Dumazet <edumazet@google.com>

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

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

commit d7ce36924344ace0dbdc855b1206cacc46b36d45 upstream.

Some servers experienced fatal deadlocks because of a combination of
bugs, leading to multiple cpus calling dump_stack().

The checksumming bug was fixed in commit 34ae6a1aa054 ("ipv6: update
skb->csum when CE mark is propagated").

The second problem is a faulty locking in dump_stack()

CPU1 runs in process context and calls dump_stack(), grabs dump_lock.

   CPU2 receives a TCP packet under softirq, grabs socket spinlock, and
   call dump_stack() from netdev_rx_csum_fault().

   dump_stack() spins on atomic_cmpxchg(&dump_lock, -1, 2), since
   dump_lock is owned by CPU1

While dumping its stack, CPU1 is interrupted by a softirq, and happens
to process a packet for the TCP socket locked by CPU2.

CPU1 spins forever in spin_lock() : deadlock

Stack trace on CPU1 looked like :

    NMI backtrace for cpu 1
    RIP: _raw_spin_lock+0x25/0x30
    ...
    Call Trace:
      <IRQ>
      tcp_v6_rcv+0x243/0x620
      ip6_input_finish+0x11f/0x330
      ip6_input+0x38/0x40
      ip6_rcv_finish+0x3c/0x90
      ipv6_rcv+0x2a9/0x500
      process_backlog+0x461/0xaa0
      net_rx_action+0x147/0x430
      __do_softirq+0x167/0x2d0
      call_softirq+0x1c/0x30
      do_softirq+0x3f/0x80
      irq_exit+0x6e/0xc0
      smp_call_function_single_interrupt+0x35/0x40
      call_function_single_interrupt+0x6a/0x70
      <EOI>
      printk+0x4d/0x4f
      printk_address+0x31/0x33
      print_trace_address+0x33/0x3c
      print_context_stack+0x7f/0x119
      dump_trace+0x26b/0x28e
      show_trace_log_lvl+0x4f/0x5c
      show_stack_log_lvl+0x104/0x113
      show_stack+0x42/0x44
      dump_stack+0x46/0x58
      netdev_rx_csum_fault+0x38/0x3c
      __skb_checksum_complete_head+0x6e/0x80
      __skb_checksum_complete+0x11/0x20
      tcp_rcv_established+0x2bd5/0x2fd0
      tcp_v6_do_rcv+0x13c/0x620
      sk_backlog_rcv+0x15/0x30
      release_sock+0xd2/0x150
      tcp_recvmsg+0x1c1/0xfc0
      inet_recvmsg+0x7d/0x90
      sock_recvmsg+0xaf/0xe0
      ___sys_recvmsg+0x111/0x3b0
      SyS_recvmsg+0x5c/0xb0
      system_call_fastpath+0x16/0x1b

Fixes: b58d977432c8 ("dump_stack: serialize the output from dump_stack()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Alex Thorlton <athorlton@sgi.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>
---
 lib/dump_stack.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/dump_stack.c b/lib/dump_stack.c
index f23b63f0a1c3..1e21b4682666 100644
--- a/lib/dump_stack.c
+++ b/lib/dump_stack.c
@@ -25,6 +25,7 @@ static atomic_t dump_lock = ATOMIC_INIT(-1);
 
 asmlinkage void dump_stack(void)
 {
+	unsigned long flags;
 	int was_locked;
 	int old;
 	int cpu;
@@ -33,9 +34,8 @@ asmlinkage void dump_stack(void)
 	 * Permit this cpu to perform nested stack dumps while serialising
 	 * against other CPUs
 	 */
-	preempt_disable();
-
 retry:
+	local_irq_save(flags);
 	cpu = smp_processor_id();
 	old = atomic_cmpxchg(&dump_lock, -1, cpu);
 	if (old == -1) {
@@ -43,6 +43,7 @@ retry:
 	} else if (old == cpu) {
 		was_locked = 1;
 	} else {
+		local_irq_restore(flags);
 		cpu_relax();
 		goto retry;
 	}
@@ -52,7 +53,7 @@ retry:
 	if (!was_locked)
 		atomic_set(&dump_lock, -1);
 
-	preempt_enable();
+	local_irq_restore(flags);
 }
 #else
 asmlinkage void dump_stack(void)
-- 
2.7.1


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

* [patch added to 3.12-stable] intel_scu_ipcutil: underflow in scu_reg_access()
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (24 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] dump_stack: avoid potential deadlocks Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] futex: Drop refcount if requeue_pi() acquired the rtmutex Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] module: wrapper for symbol name Jiri Slaby
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Dan Carpenter, Darren Hart, Jiri Slaby

From: Dan Carpenter <dan.carpenter@oracle.com>

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

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

commit b1d353ad3d5835b16724653b33c05124e1b5acf1 upstream.

"count" is controlled by the user and it can be negative.  Let's prevent
that by making it unsigned.  You have to have CAP_SYS_RAWIO to call this
function so the bug is not as serious as it could be.

Fixes: 5369c02d951a ('intel_scu_ipc: Utility driver for intel scu ipc')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/platform/x86/intel_scu_ipcutil.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel_scu_ipcutil.c b/drivers/platform/x86/intel_scu_ipcutil.c
index 02bc5a6343c3..aa454241489c 100644
--- a/drivers/platform/x86/intel_scu_ipcutil.c
+++ b/drivers/platform/x86/intel_scu_ipcutil.c
@@ -49,7 +49,7 @@ struct scu_ipc_data {
 
 static int scu_reg_access(u32 cmd, struct scu_ipc_data  *data)
 {
-	int count = data->count;
+	unsigned int count = data->count;
 
 	if (count == 0 || count == 3 || count > 4)
 		return -EINVAL;
-- 
2.7.1


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

* [patch added to 3.12-stable] futex: Drop refcount if requeue_pi() acquired the rtmutex
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (25 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] intel_scu_ipcutil: underflow in scu_reg_access() Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  2016-02-24  9:30 ` [patch added to 3.12-stable] module: wrapper for symbol name Jiri Slaby
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable
  Cc: Thomas Gleixner, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Bhuvanesh_Surachari, Andy Lowe, Jiri Slaby

From: Thomas Gleixner <tglx@linutronix.de>

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

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

commit fb75a4282d0d9a3c7c44d940582c2d226cf3acfb upstream.

If the proxy lock in the requeue loop acquires the rtmutex for a
waiter then it acquired also refcount on the pi_state related to the
futex, but the waiter side does not drop the reference count.

Add the missing free_pi_state() call.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Darren Hart <darren@dvhart.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Bhuvanesh_Surachari@mentor.com
Cc: Andy Lowe <Andy_Lowe@mentor.com>
Link: http://lkml.kernel.org/r/20151219200607.178132067@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 kernel/futex.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/futex.c b/kernel/futex.c
index 3ee1b3ce78df..509bdd404414 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2497,6 +2497,11 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
 		if (q.pi_state && (q.pi_state->owner != current)) {
 			spin_lock(q.lock_ptr);
 			ret = fixup_pi_state_owner(uaddr2, &q, current);
+			/*
+			 * Drop the reference to the pi state which
+			 * the requeue_pi() code acquired for us.
+			 */
+			free_pi_state(q.pi_state);
 			spin_unlock(q.lock_ptr);
 		}
 	} else {
-- 
2.7.1


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

* [patch added to 3.12-stable] module: wrapper for symbol name.
  2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
                   ` (26 preceding siblings ...)
  2016-02-24  9:30 ` [patch added to 3.12-stable] futex: Drop refcount if requeue_pi() acquired the rtmutex Jiri Slaby
@ 2016-02-24  9:30 ` Jiri Slaby
  27 siblings, 0 replies; 29+ messages in thread
From: Jiri Slaby @ 2016-02-24  9:30 UTC (permalink / raw)
  To: stable; +Cc: Rusty Russell, Jiri Slaby

From: Rusty Russell <rusty@rustcorp.com.au>

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

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

commit 2e7bac536106236104e9e339531ff0fcdb7b8147 upstream.

This trivial wrapper adds clarity and makes the following patch
smaller.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 kernel/module.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 7d1c2ea27898..cb56e581062d 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3425,6 +3425,11 @@ static inline int is_arm_mapping_symbol(const char *str)
 	       && (str[2] == '\0' || str[2] == '.');
 }
 
+static const char *symname(struct module *mod, unsigned int symnum)
+{
+	return mod->strtab + mod->symtab[symnum].st_name;
+}
+
 static const char *get_ksymbol(struct module *mod,
 			       unsigned long addr,
 			       unsigned long *size,
@@ -3447,15 +3452,15 @@ static const char *get_ksymbol(struct module *mod,
 
 		/* We ignore unnamed symbols: they're uninformative
 		 * and inserted at a whim. */
+		if (*symname(mod, i) == '\0'
+		    || is_arm_mapping_symbol(symname(mod, i)))
+			continue;
+
 		if (mod->symtab[i].st_value <= addr
-		    && mod->symtab[i].st_value > mod->symtab[best].st_value
-		    && *(mod->strtab + mod->symtab[i].st_name) != '\0'
-		    && !is_arm_mapping_symbol(mod->strtab + mod->symtab[i].st_name))
+		    && mod->symtab[i].st_value > mod->symtab[best].st_value)
 			best = i;
 		if (mod->symtab[i].st_value > addr
-		    && mod->symtab[i].st_value < nextval
-		    && *(mod->strtab + mod->symtab[i].st_name) != '\0'
-		    && !is_arm_mapping_symbol(mod->strtab + mod->symtab[i].st_name))
+		    && mod->symtab[i].st_value < nextval)
 			nextval = mod->symtab[i].st_value;
 	}
 
@@ -3466,7 +3471,7 @@ static const char *get_ksymbol(struct module *mod,
 		*size = nextval - mod->symtab[best].st_value;
 	if (offset)
 		*offset = addr - mod->symtab[best].st_value;
-	return mod->strtab + mod->symtab[best].st_name;
+	return symname(mod, best);
 }
 
 /* For kallsyms to ask for address resolution.  NULL means not found.  Careful
@@ -3567,8 +3572,7 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
 		if (symnum < mod->num_symtab) {
 			*value = mod->symtab[symnum].st_value;
 			*type = mod->symtab[symnum].st_info;
-			strlcpy(name, mod->strtab + mod->symtab[symnum].st_name,
-				KSYM_NAME_LEN);
+			strlcpy(name, symname(mod, symnum), KSYM_NAME_LEN);
 			strlcpy(module_name, mod->name, MODULE_NAME_LEN);
 			*exported = is_exported(name, *value, mod);
 			preempt_enable();
@@ -3585,7 +3589,7 @@ static unsigned long mod_find_symname(struct module *mod, const char *name)
 	unsigned int i;
 
 	for (i = 0; i < mod->num_symtab; i++)
-		if (strcmp(name, mod->strtab+mod->symtab[i].st_name) == 0 &&
+		if (strcmp(name, symname(mod, i)) == 0 &&
 		    mod->symtab[i].st_info != 'U')
 			return mod->symtab[i].st_value;
 	return 0;
@@ -3627,7 +3631,7 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
 		if (mod->state == MODULE_STATE_UNFORMED)
 			continue;
 		for (i = 0; i < mod->num_symtab; i++) {
-			ret = fn(data, mod->strtab + mod->symtab[i].st_name,
+			ret = fn(data, symname(mod, i),
 				 mod, mod->symtab[i].st_value);
 			if (ret != 0)
 				return ret;
-- 
2.7.1


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

end of thread, other threads:[~2016-02-24  9:31 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-24  9:30 [patch added to 3.12-stable] cifs_dbg() outputs an uninitialized buffer in cifs_readdir() Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] cifs: fix erroneous return value Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] nfs: Fix race in __update_open_stateid() Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] udf: limit the maximum number of indirect extents in a row Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] udf: Prevent buffer overrun with multi-byte characters Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] udf: Check output buffer length when converting name to CS0 Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] ARM: dts: Kirkwood: Fix QNAP TS219 power-off Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] ARM: 8471/1: need to save/restore arm register(r11) when it is corrupted Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] ARM: 8519/1: ICST: try other dividends than 1 Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] ARM: 8517/1: ICST: avoid arithmetic overflow in icst_hz() Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] fuse: break infinite loop in fuse_fill_write_pages() Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] mm: soft-offline: check return value in second __get_any_page() call Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] mm: fix mlock accouting Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] Input: elantech - add Fujitsu Lifebook U745 to force crc_enabled Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] Input: elantech - mark protocols v2 and v3 as semi-mt Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] Input: i8042 - add Fujitsu Lifebook U745 to the nomux list Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] iommu/vt-d: Fix 64-bit accesses to 32-bit DMAR_GSTS_REG Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone() Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] xhci: Fix list corruption in urb dequeue at host removal Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] m32r: fix m32104ut_defconfig build fail Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] dma-debug: switch check from _text to _stext Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] scripts/bloat-o-meter: fix python3 syntax error Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] memcg: only free spare array when readers are done Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] radix-tree: fix race in gang lookup Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] radix-tree: fix oops after radix_tree_iter_retry Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] dump_stack: avoid potential deadlocks Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] intel_scu_ipcutil: underflow in scu_reg_access() Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] futex: Drop refcount if requeue_pi() acquired the rtmutex Jiri Slaby
2016-02-24  9:30 ` [patch added to 3.12-stable] module: wrapper for symbol name Jiri Slaby

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.