linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3.18 00/24] 3.18.69-stable review
@ 2017-08-31 15:43 Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 01/24] scsi: isci: avoid array subscript warning Greg Kroah-Hartman
                   ` (24 more replies)
  0 siblings, 25 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, torvalds, akpm, linux, shuahkh, patches,
	ben.hutchings, stable

This is the start of the stable review cycle for the 3.18.69 release.
There are 24 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 Sat Sep  2 15:40:49 UTC 2017.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:
	kernel.org/pub/linux/kernel/v3.x/stable-review/patch-3.18.69-rc1.gz
or in the git tree and branch at:
  git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-3.18.y
and the diffstat can be found below.

thanks,

greg k-h

-------------
Pseudo-Shortlog of commits:

Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Linux 3.18.69-rc1

Chao Yu <chao2.yu@samsung.com>
    f2fs: do more integrity verification for superblock

Hannes Reinecke <hare@suse.de>
    scsi: sg: reset 'res_in_use' after unlinking reserved array

Hannes Reinecke <hare@suse.de>
    scsi: sg: protect accesses to 'reserved' page array

Krzysztof Kozlowski <k.kozlowski@samsung.com>
    clk: si5351: Constify clock names and struct regmap_config

Markus Trippelsdorf <markus@trippelsdorf.de>
    x86/tools: Fix gcc-7 warning in relocs.c

Jan Beulich <JBeulich@suse.com>
    x86-64: Handle PC-relative relocations on per-CPU data

Dave Martin <Dave.Martin@arm.com>
    arm64: fpsimd: Prevent registers leaking across exec

Ard Biesheuvel <ard.biesheuvel@linaro.org>
    arm64: flush FP/SIMD state correctly after execve()

Arnd Bergmann <arnd@arndb.de>
    x86/io: Add "memory" clobber to insb/insw/insl/outsb/outsw/outsl

Rohit Vaswani <rvaswani@codeaurora.org>
    mm: cma: fix incorrect type conversion for size during dma allocation

Sasha Levin <sasha.levin@oracle.com>
    mm: cma: constify and use correct signness in mm/cma.c

Danesh Petigara <dpetigara@broadcom.com>
    mm: cma: fix CMA aligned offset calculation

George G. Davis <ggdavisiv@gmail.com>
    mm: cma: fix totalcma_pages to include DT defined CMA regions

Pintu Kumar <pintu.k@samsung.com>
    mm: cma: split cma-reserved in dmesg log

Thierry Reding <treding@nvidia.com>
    mm/cma: make kmemleak ignore CMA regions

Gregory Fong <gregory.0xf0@gmail.com>
    mm: cma: align to physical address, not CMA region position

Michal Nazarewicz <mina86@mina86.com>
    lib: bitmap: add alignment offset for bitmap_find_next_zero_area()

Mark Rutland <mark.rutland@arm.com>
    arm64: mm: abort uaccess retries upon fatal signal

Jiri Slaby <jslaby@suse.cz>
    p54: memset(0) whole array

Martin Liska <mliska@suse.cz>
    gcov: support GCC 7.1

Florian Meier <Florian.Meier@informatik.uni-erlangen.de>
    gcov: add support for gcc version >= 6

Lorenzo Stoakes <lstoakes@gmail.com>
    gcov: add support for GCC 5.1

Takashi Iwai <tiwai@suse.de>
    ALSA: au88x0: Fix zero clear of stream->resources

Arnd Bergmann <arnd@arndb.de>
    scsi: isci: avoid array subscript warning


-------------

Diffstat:

 Makefile                                |  4 +-
 arch/arm64/kernel/fpsimd.c              |  3 +
 arch/arm64/mm/fault.c                   |  5 +-
 arch/x86/boot/compressed/misc.c         | 14 ++++-
 arch/x86/include/asm/io.h               |  4 +-
 arch/x86/tools/relocs.c                 | 39 +++++++++----
 drivers/base/dma-contiguous.c           |  2 +-
 drivers/clk/clk-si5351.c                | 10 ++--
 drivers/net/wireless/p54/fwio.c         |  2 +-
 drivers/scsi/isci/remote_node_context.c |  3 +
 drivers/scsi/sg.c                       | 49 ++++++++++-------
 fs/f2fs/super.c                         | 98 +++++++++++++++++++++++++++++++++
 include/linux/bitmap.h                  | 36 ++++++++++--
 include/linux/cma.h                     | 13 +++--
 include/linux/dma-contiguous.h          |  4 +-
 kernel/gcov/base.c                      | 12 ++++
 kernel/gcov/gcc_4_7.c                   |  6 +-
 lib/bitmap.c                            | 24 ++++----
 mm/cma.c                                | 52 ++++++++++++-----
 mm/page_alloc.c                         |  6 +-
 sound/pci/au88x0/au88x0_core.c          | 14 ++---
 21 files changed, 307 insertions(+), 93 deletions(-)

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

* [PATCH 3.18 01/24] scsi: isci: avoid array subscript warning
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 02/24] ALSA: au88x0: Fix zero clear of stream->resources Greg Kroah-Hartman
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Arnd Bergmann, Martin K. Petersen

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

------------------

From: Arnd Bergmann <arnd@arndb.de>

commit 5cfa2a3c7342bd0b50716c8bb32ee491af43c785 upstream.

I'm getting a new warning with gcc-7:

isci/remote_node_context.c: In function 'sci_remote_node_context_destruct':
isci/remote_node_context.c:69:16: error: array subscript is above array bounds [-Werror=array-bounds]

This is odd, since we clearly cover all values for enum
scis_sds_remote_node_context_states here. Anyway, checking for an array
overflow can't harm and it makes the warning go away.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/isci/remote_node_context.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/scsi/isci/remote_node_context.c
+++ b/drivers/scsi/isci/remote_node_context.c
@@ -66,6 +66,9 @@ const char *rnc_state_name(enum scis_sds
 {
 	static const char * const strings[] = RNC_STATES;
 
+	if (state >= ARRAY_SIZE(strings))
+		return "UNKNOWN";
+
 	return strings[state];
 }
 #undef C

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

* [PATCH 3.18 02/24] ALSA: au88x0: Fix zero clear of stream->resources
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 01/24] scsi: isci: avoid array subscript warning Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 03/24] gcov: add support for GCC 5.1 Greg Kroah-Hartman
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, David Binderman, Takashi Iwai

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

------------------

From: Takashi Iwai <tiwai@suse.de>

commit 639db596165746ca87bbcb56559b094fd9042890 upstream.

There are a few calls of memset() to stream->resources, but they all
are called in a wrong size, sizeof(unsigned char) * VORTEX_RESOURCE_LAST,
while this field is a u32 array.  This may leave the memories not
zero-cleared.

Fix it by replacing them with a simpler sizeof(stream->resources)
instead.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/pci/au88x0/au88x0_core.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

--- a/sound/pci/au88x0/au88x0_core.c
+++ b/sound/pci/au88x0/au88x0_core.c
@@ -2146,8 +2146,7 @@ vortex_adb_allocroute(vortex_t *vortex,
 							   stream->resources, en,
 							   VORTEX_RESOURCE_SRC)) < 0) {
 					memset(stream->resources, 0,
-					       sizeof(unsigned char) *
-					       VORTEX_RESOURCE_LAST);
+					       sizeof(stream->resources));
 					return -EBUSY;
 				}
 				if (stream->type != VORTEX_PCM_A3D) {
@@ -2157,7 +2156,7 @@ vortex_adb_allocroute(vortex_t *vortex,
 								   VORTEX_RESOURCE_MIXIN)) < 0) {
 						memset(stream->resources,
 						       0,
-						       sizeof(unsigned char) * VORTEX_RESOURCE_LAST);
+						       sizeof(stream->resources));
 						return -EBUSY;
 					}
 				}
@@ -2170,8 +2169,7 @@ vortex_adb_allocroute(vortex_t *vortex,
 						   stream->resources, en,
 						   VORTEX_RESOURCE_A3D)) < 0) {
 				memset(stream->resources, 0,
-				       sizeof(unsigned char) *
-				       VORTEX_RESOURCE_LAST);
+				       sizeof(stream->resources));
 				pr_err( "vortex: out of A3D sources. Sorry\n");
 				return -EBUSY;
 			}
@@ -2283,8 +2281,7 @@ vortex_adb_allocroute(vortex_t *vortex,
 						   VORTEX_RESOURCE_MIXOUT))
 			    < 0) {
 				memset(stream->resources, 0,
-				       sizeof(unsigned char) *
-				       VORTEX_RESOURCE_LAST);
+				       sizeof(stream->resources));
 				return -EBUSY;
 			}
 			if ((src[i] =
@@ -2292,8 +2289,7 @@ vortex_adb_allocroute(vortex_t *vortex,
 						   stream->resources, en,
 						   VORTEX_RESOURCE_SRC)) < 0) {
 				memset(stream->resources, 0,
-				       sizeof(unsigned char) *
-				       VORTEX_RESOURCE_LAST);
+				       sizeof(stream->resources));
 				return -EBUSY;
 			}
 		}

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

* [PATCH 3.18 03/24] gcov: add support for GCC 5.1
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 01/24] scsi: isci: avoid array subscript warning Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 02/24] ALSA: au88x0: Fix zero clear of stream->resources Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 04/24] gcov: add support for gcc version >= 6 Greg Kroah-Hartman
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Lorenzo Stoakes, Andrey Ryabinin,
	Yuan Pengfei, Peter Oberparleiter, Andrew Morton, Linus Torvalds

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

------------------

From: Lorenzo Stoakes <lstoakes@gmail.com>

commit 3e44c471a2dab210f7e9b1e5f7d4d54d52df59eb upstream.

Fix kernel gcov support for GCC 5.1.  Similar to commit a992bf836f9
("gcov: add support for GCC 4.9"), this patch takes into account the
existence of a new gcov counter (see gcc's gcc/gcov-counter.def.)

Firstly, it increments GCOV_COUNTERS (to 10), which makes the data
structure struct gcov_info compatible with GCC 5.1.

Secondly, a corresponding counter function __gcov_merge_icall_topn (Top N
value tracking for indirect calls) is included in base.c with the other
gcov counters unused for kernel profiling.

Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
Cc: Andrey Ryabinin <a.ryabinin@samsung.com>
Cc: Yuan Pengfei <coolypf@qq.com>
Tested-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/gcov/base.c    |    6 ++++++
 kernel/gcov/gcc_4_7.c |    4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

--- a/kernel/gcov/base.c
+++ b/kernel/gcov/base.c
@@ -91,6 +91,12 @@ void __gcov_merge_time_profile(gcov_type
 }
 EXPORT_SYMBOL(__gcov_merge_time_profile);
 
+void __gcov_merge_icall_topn(gcov_type *counters, unsigned int n_counters)
+{
+	/* Unused. */
+}
+EXPORT_SYMBOL(__gcov_merge_icall_topn);
+
 /**
  * gcov_enable_events - enable event reporting through gcov_event()
  *
--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -18,7 +18,9 @@
 #include <linux/vmalloc.h>
 #include "gcov.h"
 
-#if __GNUC__ == 4 && __GNUC_MINOR__ >= 9
+#if __GNUC__ == 5 && __GNUC_MINOR__ >= 1
+#define GCOV_COUNTERS			10
+#elif __GNUC__ == 4 && __GNUC_MINOR__ >= 9
 #define GCOV_COUNTERS			9
 #else
 #define GCOV_COUNTERS			8

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

* [PATCH 3.18 04/24] gcov: add support for gcc version >= 6
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (2 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 03/24] gcov: add support for GCC 5.1 Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 05/24] gcov: support GCC 7.1 Greg Kroah-Hartman
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Florian Meier, Peter Oberparleiter,
	Andrew Morton, Linus Torvalds

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

------------------

From: Florian Meier <Florian.Meier@informatik.uni-erlangen.de>

commit d02038f972538b93011d78c068f44514fbde0a8c upstream.

Link: http://lkml.kernel.org/r/20160701130914.GA23225@styxhp
Signed-off-by: Florian Meier <Florian.Meier@informatik.uni-erlangen.de>
Reviewed-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Tested-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/gcov/gcc_4_7.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -18,7 +18,7 @@
 #include <linux/vmalloc.h>
 #include "gcov.h"
 
-#if __GNUC__ == 5 && __GNUC_MINOR__ >= 1
+#if (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
 #define GCOV_COUNTERS			10
 #elif __GNUC__ == 4 && __GNUC_MINOR__ >= 9
 #define GCOV_COUNTERS			9

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

* [PATCH 3.18 05/24] gcov: support GCC 7.1
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (3 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 04/24] gcov: add support for gcc version >= 6 Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 06/24] p54: memset(0) whole array Greg Kroah-Hartman
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Martin Liska, Peter Oberparleiter,
	Andrew Morton, Linus Torvalds

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

------------------

From: Martin Liska <mliska@suse.cz>

commit 05384213436ab690c46d9dfec706b80ef8d671ab upstream.

Starting from GCC 7.1, __gcov_exit is a new symbol expected to be
implemented in a profiling runtime.

[akpm@linux-foundation.org: coding-style fixes]
[mliska@suse.cz: v2]
  Link: http://lkml.kernel.org/r/e63a3c59-0149-c97e-4084-20ca8f146b26@suse.cz
Link: http://lkml.kernel.org/r/8c4084fa-3885-29fe-5fc4-0d4ca199c785@suse.cz
Signed-off-by: Martin Liska <mliska@suse.cz>
Acked-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/gcov/base.c    |    6 ++++++
 kernel/gcov/gcc_4_7.c |    4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

--- a/kernel/gcov/base.c
+++ b/kernel/gcov/base.c
@@ -97,6 +97,12 @@ void __gcov_merge_icall_topn(gcov_type *
 }
 EXPORT_SYMBOL(__gcov_merge_icall_topn);
 
+void __gcov_exit(void)
+{
+	/* Unused. */
+}
+EXPORT_SYMBOL(__gcov_exit);
+
 /**
  * gcov_enable_events - enable event reporting through gcov_event()
  *
--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -18,7 +18,9 @@
 #include <linux/vmalloc.h>
 #include "gcov.h"
 
-#if (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
+#if (__GNUC__ >= 7)
+#define GCOV_COUNTERS			9
+#elif (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
 #define GCOV_COUNTERS			10
 #elif __GNUC__ == 4 && __GNUC_MINOR__ >= 9
 #define GCOV_COUNTERS			9

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

* [PATCH 3.18 06/24] p54: memset(0) whole array
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (4 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 05/24] gcov: support GCC 7.1 Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 07/24] arm64: mm: abort uaccess retries upon fatal signal Greg Kroah-Hartman
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Jiri Slaby, Christian Lamparter, Kalle Valo

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

------------------

From: Jiri Slaby <jslaby@suse.cz>

commit 6f17581788206444cbbcdbc107498f85e9765e3d upstream.

gcc 7 complains:
drivers/net/wireless/intersil/p54/fwio.c: In function 'p54_scan':
drivers/net/wireless/intersil/p54/fwio.c:491:4: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]

Fix that by passing the correct size to memset.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Christian Lamparter <chunkeey@googlemail.com>
Cc: Kalle Valo <kvalo@codeaurora.org>
Acked-by: Christian Lamparter <chunkeey@googlemail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/wireless/p54/fwio.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/wireless/p54/fwio.c
+++ b/drivers/net/wireless/p54/fwio.c
@@ -486,7 +486,7 @@ int p54_scan(struct p54_common *priv, u1
 
 			entry += sizeof(__le16);
 			chan->pa_points_per_curve = 8;
-			memset(chan->curve_data, 0, sizeof(*chan->curve_data));
+			memset(chan->curve_data, 0, sizeof(chan->curve_data));
 			memcpy(chan->curve_data, entry,
 			       sizeof(struct p54_pa_curve_data_sample) *
 			       min((u8)8, curve_data->points_per_channel));

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

* [PATCH 3.18 07/24] arm64: mm: abort uaccess retries upon fatal signal
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (5 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 06/24] p54: memset(0) whole array Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 08/24] lib: bitmap: add alignment offset for bitmap_find_next_zero_area() Greg Kroah-Hartman
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Catalin Marinas, Laura Abbott,
	Steve Capper, James Morse, Mark Rutland, Will Deacon

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

------------------

From: Mark Rutland <mark.rutland@arm.com>

commit 289d07a2dc6c6b6f3e4b8a62669320d99dbe6c3d upstream.

When there's a fatal signal pending, arm64's do_page_fault()
implementation returns 0. The intent is that we'll return to the
faulting userspace instruction, delivering the signal on the way.

However, if we take a fatal signal during fixing up a uaccess, this
results in a return to the faulting kernel instruction, which will be
instantly retried, resulting in the same fault being taken forever. As
the task never reaches userspace, the signal is not delivered, and the
task is left unkillable. While the task is stuck in this state, it can
inhibit the forward progress of the system.

To avoid this, we must ensure that when a fatal signal is pending, we
apply any necessary fixup for a faulting kernel instruction. Thus we
will return to an error path, and it is up to that code to make forward
progress towards delivering the fatal signal.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Laura Abbott <labbott@redhat.com>
Reviewed-by: Steve Capper <steve.capper@arm.com>
Tested-by: Steve Capper <steve.capper@arm.com>
Reviewed-by: James Morse <james.morse@arm.com>
Tested-by: James Morse <james.morse@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/mm/fault.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -253,8 +253,11 @@ retry:
 	 * signal first. We do not need to release the mmap_sem because it
 	 * would already be released in __lock_page_or_retry in mm/filemap.c.
 	 */
-	if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
+	if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) {
+		if (!user_mode(regs))
+			goto no_context;
 		return 0;
+	}
 
 	/*
 	 * Major/minor page fault accounting is only done on the initial

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

* [PATCH 3.18 08/24] lib: bitmap: add alignment offset for bitmap_find_next_zero_area()
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (6 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 07/24] arm64: mm: abort uaccess retries upon fatal signal Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 09/24] mm: cma: align to physical address, not CMA region position Greg Kroah-Hartman
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Michal Nazarewicz, Kyungmin Park,
	Marek Szyprowski, Gregory Fong, Joonsoo Kim, Kukjin Kim,
	Laurent Pinchart, Laura Abbott, Andrew Morton, Linus Torvalds

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

------------------

From: Michal Nazarewicz <mina86@mina86.com>

commit 5e19b013f55a884c59a14391b22138899d1cc4cc upstream.

Add a bitmap_find_next_zero_area_off() function which works like
bitmap_find_next_zero_area() function except it allows an offset to be
specified when alignment is checked.  This lets caller request a bit such
that its number plus the offset is aligned according to the mask.

[gregory.0xf0@gmail.com: Retrieved from https://patchwork.linuxtv.org/patch/6254/ and updated documentation]
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Gregory Fong <gregory.0xf0@gmail.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/bitmap.h |   36 +++++++++++++++++++++++++++++++-----
 lib/bitmap.c           |   24 +++++++++++++-----------
 2 files changed, 44 insertions(+), 16 deletions(-)

--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -45,6 +45,7 @@
  * bitmap_set(dst, pos, nbits)			Set specified bit area
  * bitmap_clear(dst, pos, nbits)		Clear specified bit area
  * bitmap_find_next_zero_area(buf, len, pos, n, mask)	Find bit free area
+ * bitmap_find_next_zero_area_off(buf, len, pos, n, mask)	as above
  * bitmap_shift_right(dst, src, n, nbits)	*dst = *src >> n
  * bitmap_shift_left(dst, src, n, nbits)	*dst = *src << n
  * bitmap_remap(dst, src, old, new, nbits)	*dst = map(old, new)(src)
@@ -114,11 +115,36 @@ extern int __bitmap_weight(const unsigne
 
 extern void bitmap_set(unsigned long *map, unsigned int start, int len);
 extern void bitmap_clear(unsigned long *map, unsigned int start, int len);
-extern unsigned long bitmap_find_next_zero_area(unsigned long *map,
-					 unsigned long size,
-					 unsigned long start,
-					 unsigned int nr,
-					 unsigned long align_mask);
+
+extern unsigned long bitmap_find_next_zero_area_off(unsigned long *map,
+						    unsigned long size,
+						    unsigned long start,
+						    unsigned int nr,
+						    unsigned long align_mask,
+						    unsigned long align_offset);
+
+/**
+ * bitmap_find_next_zero_area - find a contiguous aligned zero area
+ * @map: The address to base the search on
+ * @size: The bitmap size in bits
+ * @start: The bitnumber to start searching at
+ * @nr: The number of zeroed bits we're looking for
+ * @align_mask: Alignment mask for zero area
+ *
+ * The @align_mask should be one less than a power of 2; the effect is that
+ * the bit offset of all zero areas this function finds is multiples of that
+ * power of 2. A @align_mask of 0 means no alignment is required.
+ */
+static inline unsigned long
+bitmap_find_next_zero_area(unsigned long *map,
+			   unsigned long size,
+			   unsigned long start,
+			   unsigned int nr,
+			   unsigned long align_mask)
+{
+	return bitmap_find_next_zero_area_off(map, size, start, nr,
+					      align_mask, 0);
+}
 
 extern int bitmap_scnprintf(char *buf, unsigned int len,
 			const unsigned long *src, int nbits);
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -326,30 +326,32 @@ void bitmap_clear(unsigned long *map, un
 }
 EXPORT_SYMBOL(bitmap_clear);
 
-/*
- * bitmap_find_next_zero_area - find a contiguous aligned zero area
+/**
+ * bitmap_find_next_zero_area_off - find a contiguous aligned zero area
  * @map: The address to base the search on
  * @size: The bitmap size in bits
  * @start: The bitnumber to start searching at
  * @nr: The number of zeroed bits we're looking for
  * @align_mask: Alignment mask for zero area
+ * @align_offset: Alignment offset for zero area.
  *
  * The @align_mask should be one less than a power of 2; the effect is that
- * the bit offset of all zero areas this function finds is multiples of that
- * power of 2. A @align_mask of 0 means no alignment is required.
+ * the bit offset of all zero areas this function finds plus @align_offset
+ * is multiple of that power of 2.
  */
-unsigned long bitmap_find_next_zero_area(unsigned long *map,
-					 unsigned long size,
-					 unsigned long start,
-					 unsigned int nr,
-					 unsigned long align_mask)
+unsigned long bitmap_find_next_zero_area_off(unsigned long *map,
+					     unsigned long size,
+					     unsigned long start,
+					     unsigned int nr,
+					     unsigned long align_mask,
+					     unsigned long align_offset)
 {
 	unsigned long index, end, i;
 again:
 	index = find_next_zero_bit(map, size, start);
 
 	/* Align allocation */
-	index = __ALIGN_MASK(index, align_mask);
+	index = __ALIGN_MASK(index + align_offset, align_mask) - align_offset;
 
 	end = index + nr;
 	if (end > size)
@@ -361,7 +363,7 @@ again:
 	}
 	return index;
 }
-EXPORT_SYMBOL(bitmap_find_next_zero_area);
+EXPORT_SYMBOL(bitmap_find_next_zero_area_off);
 
 /*
  * Bitmap printing & parsing functions: first version by Nadia Yvette Chambers,

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

* [PATCH 3.18 09/24] mm: cma: align to physical address, not CMA region position
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (7 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 08/24] lib: bitmap: add alignment offset for bitmap_find_next_zero_area() Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 10/24] mm/cma: make kmemleak ignore CMA regions Greg Kroah-Hartman
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Gregory Fong, Michal Nazarewicz,
	Marek Szyprowski, Joonsoo Kim, Kukjin Kim, Laurent Pinchart,
	Laura Abbott, Andrew Morton, Linus Torvalds

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

------------------

From: Gregory Fong <gregory.0xf0@gmail.com>

commit b5be83e308f70e16c63c4e520ea7bb03ef57c46f upstream.

The alignment in cma_alloc() was done w.r.t. the bitmap.  This is a
problem when, for example:

- a device requires 16M (order 12) alignment
- the CMA region is not 16 M aligned

In such a case, can result with the CMA region starting at, say,
0x2f800000 but any allocation you make from there will be aligned from
there.  Requesting an allocation of 32 M with 16 M alignment will result
in an allocation from 0x2f800000 to 0x31800000, which doesn't work very
well if your strange device requires 16M alignment.

Change to use bitmap_find_next_zero_area_off() to account for the
difference in alignment at reserve-time and alloc-time.

Signed-off-by: Gregory Fong <gregory.0xf0@gmail.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/cma.c |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

--- a/mm/cma.c
+++ b/mm/cma.c
@@ -63,6 +63,17 @@ static unsigned long cma_bitmap_aligned_
 	return (1UL << (align_order - cma->order_per_bit)) - 1;
 }
 
+static unsigned long cma_bitmap_aligned_offset(struct cma *cma, int align_order)
+{
+	unsigned int alignment;
+
+	if (align_order <= cma->order_per_bit)
+		return 0;
+	alignment = 1UL << (align_order - cma->order_per_bit);
+	return ALIGN(cma->base_pfn, alignment) -
+		(cma->base_pfn >> cma->order_per_bit);
+}
+
 static unsigned long cma_bitmap_maxno(struct cma *cma)
 {
 	return cma->count >> cma->order_per_bit;
@@ -341,7 +352,7 @@ err:
  */
 struct page *cma_alloc(struct cma *cma, int count, unsigned int align)
 {
-	unsigned long mask, pfn, start = 0;
+	unsigned long mask, offset, pfn, start = 0;
 	unsigned long bitmap_maxno, bitmap_no, bitmap_count;
 	struct page *page = NULL;
 	int ret;
@@ -356,13 +367,15 @@ struct page *cma_alloc(struct cma *cma,
 		return NULL;
 
 	mask = cma_bitmap_aligned_mask(cma, align);
+	offset = cma_bitmap_aligned_offset(cma, align);
 	bitmap_maxno = cma_bitmap_maxno(cma);
 	bitmap_count = cma_bitmap_pages_to_bits(cma, count);
 
 	for (;;) {
 		mutex_lock(&cma->lock);
-		bitmap_no = bitmap_find_next_zero_area(cma->bitmap,
-				bitmap_maxno, start, bitmap_count, mask);
+		bitmap_no = bitmap_find_next_zero_area_off(cma->bitmap,
+				bitmap_maxno, start, bitmap_count, mask,
+				offset);
 		if (bitmap_no >= bitmap_maxno) {
 			mutex_unlock(&cma->lock);
 			break;

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

* [PATCH 3.18 10/24] mm/cma: make kmemleak ignore CMA regions
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (8 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 09/24] mm: cma: align to physical address, not CMA region position Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 11/24] mm: cma: split cma-reserved in dmesg log Greg Kroah-Hartman
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Thierry Reding, Michal Nazarewicz,
	Marek Szyprowski, Joonsoo Kim, Aneesh Kumar K.V, Catalin Marinas,
	Stephen Rothwell, Andrew Morton, Linus Torvalds

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

------------------

From: Thierry Reding <treding@nvidia.com>

commit 620951e2745750de1482128615adc15b74ee37ed upstream.

kmemleak will add allocations as objects to a pool.  The memory allocated
for each object in this pool is periodically searched for pointers to
other allocated objects.  This only works for memory that is mapped into
the kernel's virtual address space, which happens not to be the case for
most CMA regions.

Furthermore, CMA regions are typically used to store data transferred to
or from a device and therefore don't contain pointers to other objects.

Without this, the kernel crashes on the first execution of the
scan_gray_list() because it tries to access highmem.  Perhaps a more
appropriate fix would be to reject any object that can't map to a kernel
virtual address?

[akpm@linux-foundation.org: add comment]
[akpm@linux-foundation.org: fix comment, per Catalin]
[sfr@canb.auug.org.au: include linux/io.h for phys_to_virt()]
Signed-off-by: Thierry Reding <treding@nvidia.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/cma.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/mm/cma.c
+++ b/mm/cma.c
@@ -33,6 +33,7 @@
 #include <linux/log2.h>
 #include <linux/cma.h>
 #include <linux/highmem.h>
+#include <linux/io.h>
 
 struct cma {
 	unsigned long	base_pfn;
@@ -325,6 +326,11 @@ int __init cma_declare_contiguous(phys_a
 			}
 		}
 
+		/*
+		 * kmemleak scans/reads tracked objects for pointers to other
+		 * objects but this address isn't mapped and accessible
+		 */
+		kmemleak_ignore(phys_to_virt(addr));
 		base = addr;
 	}
 

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

* [PATCH 3.18 11/24] mm: cma: split cma-reserved in dmesg log
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (9 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 10/24] mm/cma: make kmemleak ignore CMA regions Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 12/24] mm: cma: fix totalcma_pages to include DT defined CMA regions Greg Kroah-Hartman
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Pintu Kumar, Vishnu Pratap Singh,
	Michal Nazarewicz, Rafael Aquini, Jerome Marchand,
	Marek Szyprowski, Joonsoo Kim, Andrew Morton, Linus Torvalds

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

------------------

From: Pintu Kumar <pintu.k@samsung.com>

commit e48322abb061d75096fe52d71886b237e7ae7bfb upstream.

When the system boots up, in the dmesg logs we can see the memory
statistics along with total reserved as below.  Memory: 458840k/458840k
available, 65448k reserved, 0K highmem

When CMA is enabled, still the total reserved memory remains the same.
However, the CMA memory is not considered as reserved.  But, when we see
/proc/meminfo, the CMA memory is part of free memory.  This creates
confusion.  This patch corrects the problem by properly subtracting the
CMA reserved memory from the total reserved memory in dmesg logs.

Below is the dmesg snapshot from an arm based device with 512MB RAM and
12MB single CMA region.

Before this change:
  Memory: 458840k/458840k available, 65448k reserved, 0K highmem

After this change:
  Memory: 458840k/458840k available, 53160k reserved, 12288k cma-reserved, 0K highmem

Signed-off-by: Pintu Kumar <pintu.k@samsung.com>
Signed-off-by: Vishnu Pratap Singh <vishnu.ps@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Rafael Aquini <aquini@redhat.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/cma.h |    1 +
 mm/cma.c            |    1 +
 mm/page_alloc.c     |    6 ++++--
 3 files changed, 6 insertions(+), 2 deletions(-)

--- a/include/linux/cma.h
+++ b/include/linux/cma.h
@@ -15,6 +15,7 @@
 
 struct cma;
 
+extern unsigned long totalcma_pages;
 extern phys_addr_t cma_get_base(struct cma *cma);
 extern unsigned long cma_get_size(struct cma *cma);
 
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -338,6 +338,7 @@ int __init cma_declare_contiguous(phys_a
 	if (ret)
 		goto err;
 
+	totalcma_pages += (size / PAGE_SIZE);
 	pr_info("Reserved %ld MiB at %pa\n", (unsigned long)size / SZ_1M,
 		&base);
 	return 0;
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -110,6 +110,7 @@ static DEFINE_SPINLOCK(managed_page_coun
 
 unsigned long totalram_pages __read_mostly;
 unsigned long totalreserve_pages __read_mostly;
+unsigned long totalcma_pages __read_mostly;
 /*
  * When calculating the number of globally allowed dirty pages, there
  * is a certain number of per-zone reserves that should not be
@@ -5522,7 +5523,7 @@ void __init mem_init_print_info(const ch
 
 	printk("Memory: %luK/%luK available "
 	       "(%luK kernel code, %luK rwdata, %luK rodata, "
-	       "%luK init, %luK bss, %luK reserved"
+	       "%luK init, %luK bss, %luK reserved, %luK cma-reserved"
 #ifdef	CONFIG_HIGHMEM
 	       ", %luK highmem"
 #endif
@@ -5530,7 +5531,8 @@ void __init mem_init_print_info(const ch
 	       nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
 	       codesize >> 10, datasize >> 10, rosize >> 10,
 	       (init_data_size + init_code_size) >> 10, bss_size >> 10,
-	       (physpages - totalram_pages) << (PAGE_SHIFT-10),
+	       (physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT-10),
+	       totalcma_pages << (PAGE_SHIFT-10),
 #ifdef	CONFIG_HIGHMEM
 	       totalhigh_pages << (PAGE_SHIFT-10),
 #endif

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

* [PATCH 3.18 12/24] mm: cma: fix totalcma_pages to include DT defined CMA regions
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (10 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 11/24] mm: cma: split cma-reserved in dmesg log Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 13/24] mm: cma: fix CMA aligned offset calculation Greg Kroah-Hartman
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, George G. Davis, Marek Szyprowski,
	Michal Nazarewicz, Joonsoo Kim, Aneesh Kumar K.V,
	Laurent Pinchart, Andrew Morton, Linus Torvalds

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

------------------

From: George G. Davis <ggdavisiv@gmail.com>

commit 94737a85f332aee75255960eaa16e89ddfa4c75a upstream.

The totalcma_pages variable is not updated to account for CMA regions
defined via device tree reserved-memory sub-nodes.  Fix this omission by
moving the calculation of totalcma_pages into cma_init_reserved_mem()
instead of cma_declare_contiguous() such that it will include reserved
memory used by all CMA regions.

Signed-off-by: George G. Davis <george_davis@mentor.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/cma.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/mm/cma.c
+++ b/mm/cma.c
@@ -200,6 +200,7 @@ int __init cma_init_reserved_mem(phys_ad
 	cma->order_per_bit = order_per_bit;
 	*res_cma = cma;
 	cma_area_count++;
+	totalcma_pages += (size / PAGE_SIZE);
 
 	return 0;
 }
@@ -338,7 +339,6 @@ int __init cma_declare_contiguous(phys_a
 	if (ret)
 		goto err;
 
-	totalcma_pages += (size / PAGE_SIZE);
 	pr_info("Reserved %ld MiB at %pa\n", (unsigned long)size / SZ_1M,
 		&base);
 	return 0;

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

* [PATCH 3.18 13/24] mm: cma: fix CMA aligned offset calculation
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (11 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 12/24] mm: cma: fix totalcma_pages to include DT defined CMA regions Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 14/24] mm: cma: constify and use correct signness in mm/cma.c Greg Kroah-Hartman
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Danesh Petigara, Gregory Fong,
	Michal Nazarewicz, Andrew Morton, Linus Torvalds

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

------------------

From: Danesh Petigara <dpetigara@broadcom.com>

commit 850fc430f47aad52092deaaeb32b99f97f0e6aca upstream.

The CMA aligned offset calculation is incorrect for non-zero order_per_bit
values.

For example, if cma->order_per_bit=1, cma->base_pfn= 0x2f800000 and
align_order=12, the function returns a value of 0x17c00 instead of 0x400.

This patch fixes the CMA aligned offset calculation.

The previous calculation was wrong and would return too-large values for
the offset, so that when cma_alloc looks for free pages in the bitmap with
the requested alignment > order_per_bit, it starts too far into the bitmap
and so CMA allocations will fail despite there actually being plenty of
free pages remaining.  It will also probably have the wrong alignment.
With this change, we will get the correct offset into the bitmap.

One affected user is powerpc KVM, which has kvm_cma->order_per_bit set to
KVM_CMA_CHUNK_ORDER - PAGE_SHIFT, or 18 - 12 = 6.

[gregory.0xf0@gmail.com: changelog additions]
Signed-off-by: Danesh Petigara <dpetigara@broadcom.com>
Reviewed-by: Gregory Fong <gregory.0xf0@gmail.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/cma.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

--- a/mm/cma.c
+++ b/mm/cma.c
@@ -64,15 +64,17 @@ static unsigned long cma_bitmap_aligned_
 	return (1UL << (align_order - cma->order_per_bit)) - 1;
 }
 
+/*
+ * Find a PFN aligned to the specified order and return an offset represented in
+ * order_per_bits.
+ */
 static unsigned long cma_bitmap_aligned_offset(struct cma *cma, int align_order)
 {
-	unsigned int alignment;
-
 	if (align_order <= cma->order_per_bit)
 		return 0;
-	alignment = 1UL << (align_order - cma->order_per_bit);
-	return ALIGN(cma->base_pfn, alignment) -
-		(cma->base_pfn >> cma->order_per_bit);
+
+	return (ALIGN(cma->base_pfn, (1UL << align_order))
+		- cma->base_pfn) >> cma->order_per_bit;
 }
 
 static unsigned long cma_bitmap_maxno(struct cma *cma)

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

* [PATCH 3.18 14/24] mm: cma: constify and use correct signness in mm/cma.c
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (12 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 13/24] mm: cma: fix CMA aligned offset calculation Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 15/24] mm: cma: fix incorrect type conversion for size during dma allocation Greg Kroah-Hartman
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Sasha Levin, Michal Nazarewicz,
	Marek Szyprowski, Joonsoo Kim, Laurent Pinchart, Gregory Fong,
	Pintu Kumar, Andrew Morton, Linus Torvalds

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

------------------

From: Sasha Levin <sasha.levin@oracle.com>

commit ac173824959adeb489f9fcf88858774c4535a241 upstream.

Constify function parameters and use correct signness where needed.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Gregory Fong <gregory.0xf0@gmail.com>
Cc: Pintu Kumar <pintu.k@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/cma.h |   12 ++++++------
 mm/cma.c            |   24 ++++++++++++++----------
 2 files changed, 20 insertions(+), 16 deletions(-)

--- a/include/linux/cma.h
+++ b/include/linux/cma.h
@@ -16,16 +16,16 @@
 struct cma;
 
 extern unsigned long totalcma_pages;
-extern phys_addr_t cma_get_base(struct cma *cma);
-extern unsigned long cma_get_size(struct cma *cma);
+extern phys_addr_t cma_get_base(const struct cma *cma);
+extern unsigned long cma_get_size(const struct cma *cma);
 
 extern int __init cma_declare_contiguous(phys_addr_t base,
 			phys_addr_t size, phys_addr_t limit,
 			phys_addr_t alignment, unsigned int order_per_bit,
 			bool fixed, struct cma **res_cma);
-extern int cma_init_reserved_mem(phys_addr_t base,
-					phys_addr_t size, int order_per_bit,
+extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
+					unsigned int order_per_bit,
 					struct cma **res_cma);
-extern struct page *cma_alloc(struct cma *cma, int count, unsigned int align);
-extern bool cma_release(struct cma *cma, struct page *pages, int count);
+extern struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align);
+extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count);
 #endif
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -47,17 +47,18 @@ static struct cma cma_areas[MAX_CMA_AREA
 static unsigned cma_area_count;
 static DEFINE_MUTEX(cma_mutex);
 
-phys_addr_t cma_get_base(struct cma *cma)
+phys_addr_t cma_get_base(const struct cma *cma)
 {
 	return PFN_PHYS(cma->base_pfn);
 }
 
-unsigned long cma_get_size(struct cma *cma)
+unsigned long cma_get_size(const struct cma *cma)
 {
 	return cma->count << PAGE_SHIFT;
 }
 
-static unsigned long cma_bitmap_aligned_mask(struct cma *cma, int align_order)
+static unsigned long cma_bitmap_aligned_mask(const struct cma *cma,
+					     int align_order)
 {
 	if (align_order <= cma->order_per_bit)
 		return 0;
@@ -68,7 +69,8 @@ static unsigned long cma_bitmap_aligned_
  * Find a PFN aligned to the specified order and return an offset represented in
  * order_per_bits.
  */
-static unsigned long cma_bitmap_aligned_offset(struct cma *cma, int align_order)
+static unsigned long cma_bitmap_aligned_offset(const struct cma *cma,
+					       int align_order)
 {
 	if (align_order <= cma->order_per_bit)
 		return 0;
@@ -82,13 +84,14 @@ static unsigned long cma_bitmap_maxno(st
 	return cma->count >> cma->order_per_bit;
 }
 
-static unsigned long cma_bitmap_pages_to_bits(struct cma *cma,
-						unsigned long pages)
+static unsigned long cma_bitmap_pages_to_bits(const struct cma *cma,
+					      unsigned long pages)
 {
 	return ALIGN(pages, 1UL << cma->order_per_bit) >> cma->order_per_bit;
 }
 
-static void cma_clear_bitmap(struct cma *cma, unsigned long pfn, int count)
+static void cma_clear_bitmap(struct cma *cma, unsigned long pfn,
+			     unsigned int count)
 {
 	unsigned long bitmap_no, bitmap_count;
 
@@ -167,7 +170,8 @@ core_initcall(cma_init_reserved_areas);
  * This function creates custom contiguous area from already reserved memory.
  */
 int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
-				 int order_per_bit, struct cma **res_cma)
+				 unsigned int order_per_bit,
+				 struct cma **res_cma)
 {
 	struct cma *cma;
 	phys_addr_t alignment;
@@ -359,7 +363,7 @@ err:
  * This function allocates part of contiguous memory on specific
  * contiguous memory area.
  */
-struct page *cma_alloc(struct cma *cma, int count, unsigned int align)
+struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align)
 {
 	unsigned long mask, offset, pfn, start = 0;
 	unsigned long bitmap_maxno, bitmap_no, bitmap_count;
@@ -430,7 +434,7 @@ struct page *cma_alloc(struct cma *cma,
  * It returns false when provided pages do not belong to contiguous area and
  * true otherwise.
  */
-bool cma_release(struct cma *cma, struct page *pages, int count)
+bool cma_release(struct cma *cma, const struct page *pages, unsigned int count)
 {
 	unsigned long pfn;
 

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

* [PATCH 3.18 15/24] mm: cma: fix incorrect type conversion for size during dma allocation
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (13 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 14/24] mm: cma: constify and use correct signness in mm/cma.c Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 17/24] arm64: flush FP/SIMD state correctly after execve() Greg Kroah-Hartman
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Rohit Vaswani, Marek Szyprowski,
	Andrew Morton, Linus Torvalds, Miles Chen

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

------------------

From: Rohit Vaswani <rvaswani@codeaurora.org>

commit 67a2e213e7e937c41c52ab5bc46bf3f4de469f6e upstream.

This was found during userspace fuzzing test when a large size dma cma
allocation is made by driver(like ion) through userspace.

  show_stack+0x10/0x1c
  dump_stack+0x74/0xc8
  kasan_report_error+0x2b0/0x408
  kasan_report+0x34/0x40
  __asan_storeN+0x15c/0x168
  memset+0x20/0x44
  __dma_alloc_coherent+0x114/0x18c

Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Miles Chen <miles.chen@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/base/dma-contiguous.c  |    2 +-
 include/linux/cma.h            |    2 +-
 include/linux/dma-contiguous.h |    4 ++--
 mm/cma.c                       |    4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -187,7 +187,7 @@ int __init dma_contiguous_reserve_area(p
  * global one. Requires architecture specific dev_get_cma_area() helper
  * function.
  */
-struct page *dma_alloc_from_contiguous(struct device *dev, int count,
+struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
 				       unsigned int align)
 {
 	if (align > CONFIG_CMA_ALIGNMENT)
--- a/include/linux/cma.h
+++ b/include/linux/cma.h
@@ -26,6 +26,6 @@ extern int __init cma_declare_contiguous
 extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
 					unsigned int order_per_bit,
 					struct cma **res_cma);
-extern struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align);
+extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align);
 extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count);
 #endif
--- a/include/linux/dma-contiguous.h
+++ b/include/linux/dma-contiguous.h
@@ -111,7 +111,7 @@ static inline int dma_declare_contiguous
 	return ret;
 }
 
-struct page *dma_alloc_from_contiguous(struct device *dev, int count,
+struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
 				       unsigned int order);
 bool dma_release_from_contiguous(struct device *dev, struct page *pages,
 				 int count);
@@ -144,7 +144,7 @@ int dma_declare_contiguous(struct device
 }
 
 static inline
-struct page *dma_alloc_from_contiguous(struct device *dev, int count,
+struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
 				       unsigned int order)
 {
 	return NULL;
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -363,7 +363,7 @@ err:
  * This function allocates part of contiguous memory on specific
  * contiguous memory area.
  */
-struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align)
+struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align)
 {
 	unsigned long mask, offset, pfn, start = 0;
 	unsigned long bitmap_maxno, bitmap_no, bitmap_count;
@@ -373,7 +373,7 @@ struct page *cma_alloc(struct cma *cma,
 	if (!cma || !cma->count)
 		return NULL;
 
-	pr_debug("%s(cma %p, count %d, align %d)\n", __func__, (void *)cma,
+	pr_debug("%s(cma %p, count %zu, align %d)\n", __func__, (void *)cma,
 		 count, align);
 
 	if (!count)

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

* [PATCH 3.18 17/24] arm64: flush FP/SIMD state correctly after execve()
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (14 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 15/24] mm: cma: fix incorrect type conversion for size during dma allocation Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 18/24] arm64: fpsimd: Prevent registers leaking across exec Greg Kroah-Hartman
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Chunyan Zhang, Janet Liu,
	Ard Biesheuvel, Will Deacon

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

------------------

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

commit 674c242c9323d3c293fc4f9a3a3a619fe3063290 upstream.

When a task calls execve(), its FP/SIMD state is flushed so that
none of the original program state is observeable by the incoming
program.

However, since this flushing consists of setting the in-memory copy
of the FP/SIMD state to all zeroes, the CPU field is set to CPU 0 as
well, which indicates to the lazy FP/SIMD preserve/restore code that
the FP/SIMD state does not need to be reread from memory if the task
is scheduled again on CPU 0 without any other tasks having entered
userland (or used the FP/SIMD in kernel mode) on the same CPU in the
mean time. If this happens, the FP/SIMD state of the old program will
still be present in the registers when the new program starts.

So set the CPU field to the invalid value of NR_CPUS when performing
the flush, by calling fpsimd_flush_task_state().

Reported-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Reported-by: Janet Liu <janet.liu@spreadtrum.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/kernel/fpsimd.c |    1 +
 1 file changed, 1 insertion(+)

--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -157,6 +157,7 @@ void fpsimd_thread_switch(struct task_st
 void fpsimd_flush_thread(void)
 {
 	memset(&current->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
+	fpsimd_flush_task_state(current);
 	set_thread_flag(TIF_FOREIGN_FPSTATE);
 }
 

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

* [PATCH 3.18 18/24] arm64: fpsimd: Prevent registers leaking across exec
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (15 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 17/24] arm64: flush FP/SIMD state correctly after execve() Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 19/24] x86-64: Handle PC-relative relocations on per-CPU data Greg Kroah-Hartman
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Ard Biesheuvel, Dave Martin, Will Deacon

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

------------------

From: Dave Martin <Dave.Martin@arm.com>

commit 096622104e14d8a1db4860bd557717067a0515d2 upstream.

There are some tricky dependencies between the different stages of
flushing the FPSIMD register state during exec, and these can race
with context switch in ways that can cause the old task's regs to
leak across.  In particular, a context switch during the memset() can
cause some of the task's old FPSIMD registers to reappear.

Disabling preemption for this small window would be no big deal for
performance: preemption is already disabled for similar scenarios
like updating the FPSIMD registers in sigreturn.

So, instead of rearranging things in ways that might swap existing
subtle bugs for new ones, this patch just disables preemption
around the FPSIMD state flushing so that races of this type can't
occur here.  This brings fpsimd_flush_thread() into line with other
code paths.

Fixes: 674c242c9323 ("arm64: flush FP/SIMD state correctly after execve()")
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---

For stable only.

3.17.x-4.0.x don't appear active, and this patch isn't sufficient to fix
them (they would need 674c242c9323 also).

 arch/arm64/kernel/fpsimd.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -156,9 +156,11 @@ void fpsimd_thread_switch(struct task_st
 
 void fpsimd_flush_thread(void)
 {
+	preempt_disable();
 	memset(&current->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
 	fpsimd_flush_task_state(current);
 	set_thread_flag(TIF_FOREIGN_FPSTATE);
+	preempt_enable();
 }
 
 /*

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

* [PATCH 3.18 19/24] x86-64: Handle PC-relative relocations on per-CPU data
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (16 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 18/24] arm64: fpsimd: Prevent registers leaking across exec Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 21/24] clk: si5351: Constify clock names and struct regmap_config Greg Kroah-Hartman
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Jan Beulich, Thomas Gleixner

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

------------------

From: Jan Beulich <JBeulich@suse.com>

commit 6d24c5f72dfb26e5fa7f02fa9266dfdbae41adba upstream.

This is in preparation of using RIP-relative addressing in many of the
per-CPU accesses.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Link: http://lkml.kernel.org/r/5458A15A0200007800044A9A@mail.emea.novell.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/boot/compressed/misc.c |   14 +++++++++++++-
 arch/x86/tools/relocs.c         |   38 ++++++++++++++++++++++++++++----------
 2 files changed, 41 insertions(+), 11 deletions(-)

--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -260,7 +260,7 @@ static void handle_relocations(void *out
 
 	/*
 	 * Process relocations: 32 bit relocations first then 64 bit after.
-	 * Two sets of binary relocations are added to the end of the kernel
+	 * Three sets of binary relocations are added to the end of the kernel
 	 * before compression. Each relocation table entry is the kernel
 	 * address of the location which needs to be updated stored as a
 	 * 32-bit value which is sign extended to 64 bits.
@@ -270,6 +270,8 @@ static void handle_relocations(void *out
 	 * kernel bits...
 	 * 0 - zero terminator for 64 bit relocations
 	 * 64 bit relocation repeated
+	 * 0 - zero terminator for inverse 32 bit relocations
+	 * 32 bit inverse relocation repeated
 	 * 0 - zero terminator for 32 bit relocations
 	 * 32 bit relocation repeated
 	 *
@@ -286,6 +288,16 @@ static void handle_relocations(void *out
 		*(uint32_t *)ptr += delta;
 	}
 #ifdef CONFIG_X86_64
+	while (*--reloc) {
+		long extended = *reloc;
+		extended += map;
+
+		ptr = (unsigned long)extended;
+		if (ptr < min_addr || ptr > max_addr)
+			error("inverse 32-bit relocation outside of kernel!\n");
+
+		*(int32_t *)ptr -= delta;
+	}
 	for (reloc--; *reloc; reloc--) {
 		long extended = *reloc;
 		extended += map;
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -20,7 +20,10 @@ struct relocs {
 
 static struct relocs relocs16;
 static struct relocs relocs32;
+#if ELF_BITS == 64
+static struct relocs relocs32neg;
 static struct relocs relocs64;
+#endif
 
 struct section {
 	Elf_Shdr       shdr;
@@ -762,11 +765,16 @@ static int do_reloc64(struct section *se
 
 	switch (r_type) {
 	case R_X86_64_NONE:
+		/* NONE can be ignored. */
+		break;
+
 	case R_X86_64_PC32:
 		/*
-		 * NONE can be ignored and PC relative relocations don't
-		 * need to be adjusted.
+		 * PC relative relocations don't need to be adjusted unless
+		 * referencing a percpu symbol.
 		 */
+		if (is_percpu_sym(sym, symname))
+			add_reloc(&relocs32neg, offset);
 		break;
 
 	case R_X86_64_32:
@@ -986,7 +994,10 @@ static void emit_relocs(int as_text, int
 	/* Order the relocations for more efficient processing */
 	sort_relocs(&relocs16);
 	sort_relocs(&relocs32);
+#if ELF_BITS == 64
+	sort_relocs(&relocs32neg);
 	sort_relocs(&relocs64);
+#endif
 
 	/* Print the relocations */
 	if (as_text) {
@@ -1007,14 +1018,21 @@ static void emit_relocs(int as_text, int
 		for (i = 0; i < relocs32.count; i++)
 			write_reloc(relocs32.offset[i], stdout);
 	} else {
-		if (ELF_BITS == 64) {
-			/* Print a stop */
-			write_reloc(0, stdout);
-
-			/* Now print each relocation */
-			for (i = 0; i < relocs64.count; i++)
-				write_reloc(relocs64.offset[i], stdout);
-		}
+#if ELF_BITS == 64
+		/* Print a stop */
+		write_reloc(0, stdout);
+
+		/* Now print each relocation */
+		for (i = 0; i < relocs64.count; i++)
+			write_reloc(relocs64.offset[i], stdout);
+
+		/* Print a stop */
+		write_reloc(0, stdout);
+
+		/* Now print each inverse 32-bit relocation */
+		for (i = 0; i < relocs32neg.count; i++)
+			write_reloc(relocs32neg.offset[i], stdout);
+#endif
 
 		/* Print a stop */
 		write_reloc(0, stdout);

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

* [PATCH 3.18 21/24] clk: si5351: Constify clock names and struct regmap_config
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (17 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 19/24] x86-64: Handle PC-relative relocations on per-CPU data Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 22/24] scsi: sg: protect accesses to reserved page array Greg Kroah-Hartman
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Krzysztof Kozlowski, Max Filippov,
	Stephen Boyd

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

------------------

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

commit 8234caed27f7bce141c9fb1f7e76c91a2a66d248 upstream.

The regmap_config struct may be const because it is not modified by the
driver and regmap_init() accepts pointer to const.

Replace doubled const in the arrays of clock names with proper const
pointer to const data. This fixes the warnings:

drivers/clk/clk-si5351.c:71:25: warning: duplicate const
drivers/clk/clk-si5351.c:74:25: warning: duplicate const
drivers/clk/clk-si5351.c:77:25: warning: duplicate const
drivers/clk/clk-si5351.c:80:25: warning: duplicate const

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/clk/clk-si5351.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/drivers/clk/clk-si5351.c
+++ b/drivers/clk/clk-si5351.c
@@ -68,16 +68,16 @@ struct si5351_driver_data {
 	struct si5351_hw_data	*clkout;
 };
 
-static const char const *si5351_input_names[] = {
+static const char * const si5351_input_names[] = {
 	"xtal", "clkin"
 };
-static const char const *si5351_pll_names[] = {
+static const char * const si5351_pll_names[] = {
 	"plla", "pllb", "vxco"
 };
-static const char const *si5351_msynth_names[] = {
+static const char * const si5351_msynth_names[] = {
 	"ms0", "ms1", "ms2", "ms3", "ms4", "ms5", "ms6", "ms7"
 };
-static const char const *si5351_clkout_names[] = {
+static const char * const si5351_clkout_names[] = {
 	"clk0", "clk1", "clk2", "clk3", "clk4", "clk5", "clk6", "clk7"
 };
 
@@ -207,7 +207,7 @@ static bool si5351_regmap_is_writeable(s
 	return true;
 }
 
-static struct regmap_config si5351_regmap_config = {
+static const struct regmap_config si5351_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.cache_type = REGCACHE_RBTREE,

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

* [PATCH 3.18 22/24] scsi: sg: protect accesses to reserved page array
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (18 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 21/24] clk: si5351: Constify clock names and struct regmap_config Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:43 ` [PATCH 3.18 23/24] scsi: sg: reset res_in_use after unlinking reserved array Greg Kroah-Hartman
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Hannes Reinecke, Johannes Thumshirn,
	Christoph Hellwig, Martin K. Petersen, Todd Poynor

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

------------------

From: Hannes Reinecke <hare@suse.de>

commit 1bc0eb0446158cc76562176b80623aa119afee5b upstream.

The 'reserved' page array is used as a short-cut for mapping data,
saving us to allocate pages per request. However, the 'reserved' array
is only capable of holding one request, so this patch introduces a mutex
for protect 'sg_fd' against concurrent accesses.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Tested-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

[toddpoynor@google.com: backport to 3.18-4.9,  fixup for bad ioctl
SG_SET_FORCE_LOW_DMA code removed in later versions and not modified by
the original patch.]

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Tested-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/sg.c |   47 ++++++++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 21 deletions(-)

--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -153,6 +153,7 @@ typedef struct sg_fd {		/* holds the sta
 	struct sg_device *parentdp;	/* owning device */
 	wait_queue_head_t read_wait;	/* queue read until command done */
 	rwlock_t rq_list_lock;	/* protect access to list in req_arr */
+	struct mutex f_mutex;	/* protect against changes in this fd */
 	int timeout;		/* defaults to SG_DEFAULT_TIMEOUT      */
 	int timeout_user;	/* defaults to SG_DEFAULT_TIMEOUT_USER */
 	Sg_scatter_hold reserve;	/* buffer held for this file descriptor */
@@ -166,6 +167,7 @@ typedef struct sg_fd {		/* holds the sta
 	unsigned char next_cmd_len; /* 0: automatic, >0: use on next write() */
 	char keep_orphan;	/* 0 -> drop orphan (def), 1 -> keep for read() */
 	char mmap_called;	/* 0 -> mmap() never called on this fd */
+	char res_in_use;	/* 1 -> 'reserve' array in use */
 	struct kref f_ref;
 	struct execute_work ew;
 } Sg_fd;
@@ -209,7 +211,6 @@ static void sg_remove_sfp(struct kref *)
 static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id);
 static Sg_request *sg_add_request(Sg_fd * sfp);
 static int sg_remove_request(Sg_fd * sfp, Sg_request * srp);
-static int sg_res_in_use(Sg_fd * sfp);
 static Sg_device *sg_get_dev(int dev);
 static void sg_device_destroy(struct kref *kref);
 
@@ -625,6 +626,7 @@ sg_write(struct file *filp, const char _
 	}
 	buf += SZ_SG_HEADER;
 	__get_user(opcode, buf);
+	mutex_lock(&sfp->f_mutex);
 	if (sfp->next_cmd_len > 0) {
 		cmd_size = sfp->next_cmd_len;
 		sfp->next_cmd_len = 0;	/* reset so only this write() effected */
@@ -633,6 +635,7 @@ sg_write(struct file *filp, const char _
 		if ((opcode >= 0xc0) && old_hdr.twelve_byte)
 			cmd_size = 12;
 	}
+	mutex_unlock(&sfp->f_mutex);
 	SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
 		"sg_write:   scsi opcode=0x%02x, cmd_size=%d\n", (int) opcode, cmd_size));
 /* Determine buffer size.  */
@@ -732,7 +735,7 @@ sg_new_write(Sg_fd *sfp, struct file *fi
 			sg_remove_request(sfp, srp);
 			return -EINVAL;	/* either MMAP_IO or DIRECT_IO (not both) */
 		}
-		if (sg_res_in_use(sfp)) {
+		if (sfp->res_in_use) {
 			sg_remove_request(sfp, srp);
 			return -EBUSY;	/* reserve buffer already being used */
 		}
@@ -917,7 +920,7 @@ sg_ioctl(struct file *filp, unsigned int
 			return result;
 		if (val) {
 			sfp->low_dma = 1;
-			if ((0 == sfp->low_dma) && (0 == sg_res_in_use(sfp))) {
+			if ((0 == sfp->low_dma) && !sfp->res_in_use) {
 				val = (int) sfp->reserve.bufflen;
 				sg_remove_scat(sfp, &sfp->reserve);
 				sg_build_reserve(sfp, val);
@@ -992,12 +995,18 @@ sg_ioctl(struct file *filp, unsigned int
                         return -EINVAL;
 		val = min_t(int, val,
 			    max_sectors_bytes(sdp->device->request_queue));
+		mutex_lock(&sfp->f_mutex);
 		if (val != sfp->reserve.bufflen) {
-			if (sg_res_in_use(sfp) || sfp->mmap_called)
+			if (sfp->mmap_called ||
+			    sfp->res_in_use) {
+				mutex_unlock(&sfp->f_mutex);
 				return -EBUSY;
+			}
+
 			sg_remove_scat(sfp, &sfp->reserve);
 			sg_build_reserve(sfp, val);
 		}
+		mutex_unlock(&sfp->f_mutex);
 		return 0;
 	case SG_GET_RESERVED_SIZE:
 		val = min_t(int, sfp->reserve.bufflen,
@@ -1778,13 +1787,22 @@ sg_start_req(Sg_request *srp, unsigned c
 		md = &map_data;
 
 	if (md) {
-		if (!sg_res_in_use(sfp) && dxfer_len <= rsv_schp->bufflen)
+		mutex_lock(&sfp->f_mutex);
+		if (dxfer_len <= rsv_schp->bufflen &&
+		    !sfp->res_in_use) {
+			sfp->res_in_use = 1;
 			sg_link_reserve(sfp, srp, dxfer_len);
-		else {
+		} else if ((hp->flags & SG_FLAG_MMAP_IO) && sfp->res_in_use) {
+			mutex_unlock(&sfp->f_mutex);
+			return -EBUSY;
+		} else {
 			res = sg_build_indirect(req_schp, sfp, dxfer_len);
-			if (res)
+			if (res) {
+				mutex_unlock(&sfp->f_mutex);
 				return res;
+			}
 		}
+		mutex_unlock(&sfp->f_mutex);
 
 		md->pages = req_schp->pages;
 		md->page_order = req_schp->page_order;
@@ -2191,6 +2209,7 @@ sg_add_sfp(Sg_device * sdp)
 	rwlock_init(&sfp->rq_list_lock);
 
 	kref_init(&sfp->f_ref);
+	mutex_init(&sfp->f_mutex);
 	sfp->timeout = SG_DEFAULT_TIMEOUT;
 	sfp->timeout_user = SG_DEFAULT_TIMEOUT_USER;
 	sfp->force_packid = SG_DEF_FORCE_PACK_ID;
@@ -2266,20 +2285,6 @@ sg_remove_sfp(struct kref *kref)
 	schedule_work(&sfp->ew.work);
 }
 
-static int
-sg_res_in_use(Sg_fd * sfp)
-{
-	const Sg_request *srp;
-	unsigned long iflags;
-
-	read_lock_irqsave(&sfp->rq_list_lock, iflags);
-	for (srp = sfp->headrp; srp; srp = srp->nextrp)
-		if (srp->res_used)
-			break;
-	read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
-	return srp ? 1 : 0;
-}
-
 #ifdef CONFIG_SCSI_PROC_FS
 static int
 sg_idr_max_id(int id, void *p, void *data)

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

* [PATCH 3.18 23/24] scsi: sg: reset res_in_use after unlinking reserved array
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (19 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 22/24] scsi: sg: protect accesses to reserved page array Greg Kroah-Hartman
@ 2017-08-31 15:43 ` Greg Kroah-Hartman
  2017-08-31 15:44 ` [PATCH 3.18 24/24] f2fs: do more integrity verification for superblock Greg Kroah-Hartman
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Hannes Reinecke, Johannes Thumshirn,
	Christoph Hellwig, Martin K. Petersen, Todd Poynor

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

------------------

From: Hannes Reinecke <hare@suse.de>

commit e791ce27c3f6a1d3c746fd6a8f8e36c9540ec6f9 upstream.

Once the reserved page array is unused we can reset the 'res_in_use'
state; here we can do a lazy update without holding the mutex as we only
need to check against concurrent access, not concurrent release.

[mkp: checkpatch]

Fixes: 1bc0eb044615 ("scsi: sg: protect accesses to 'reserved' page array")
Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/sg.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -2098,6 +2098,8 @@ sg_unlink_reserve(Sg_fd * sfp, Sg_reques
 	req_schp->sglist_len = 0;
 	sfp->save_scat_len = 0;
 	srp->res_used = 0;
+	/* Called without mutex lock to avoid deadlock */
+	sfp->res_in_use = 0;
 }
 
 static Sg_request *

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

* [PATCH 3.18 24/24] f2fs: do more integrity verification for superblock
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (20 preceding siblings ...)
  2017-08-31 15:43 ` [PATCH 3.18 23/24] scsi: sg: reset res_in_use after unlinking reserved array Greg Kroah-Hartman
@ 2017-08-31 15:44 ` Greg Kroah-Hartman
  2017-08-31 16:33   ` Greg Kroah-Hartman
  2017-08-31 19:06 ` [PATCH 3.18 00/24] 3.18.69-stable review Shuah Khan
                   ` (2 subsequent siblings)
  24 siblings, 1 reply; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Chao Yu, Jaegeuk Kim

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

------------------

From: Chao Yu <chao2.yu@samsung.com>

commit 9a59b62fd88196844cee5fff851bee2cfd7afb6e upstream.

Do more sanity check for superblock during ->mount.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/f2fs/super.c |   98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)

--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -845,6 +845,79 @@ static inline bool sanity_check_area_bou
 	return false;
 }
 
+static inline bool sanity_check_area_boundary(struct super_block *sb,
+					struct f2fs_super_block *raw_super)
+{
+	u32 segment0_blkaddr = le32_to_cpu(raw_super->segment0_blkaddr);
+	u32 cp_blkaddr = le32_to_cpu(raw_super->cp_blkaddr);
+	u32 sit_blkaddr = le32_to_cpu(raw_super->sit_blkaddr);
+	u32 nat_blkaddr = le32_to_cpu(raw_super->nat_blkaddr);
+	u32 ssa_blkaddr = le32_to_cpu(raw_super->ssa_blkaddr);
+	u32 main_blkaddr = le32_to_cpu(raw_super->main_blkaddr);
+	u32 segment_count_ckpt = le32_to_cpu(raw_super->segment_count_ckpt);
+	u32 segment_count_sit = le32_to_cpu(raw_super->segment_count_sit);
+	u32 segment_count_nat = le32_to_cpu(raw_super->segment_count_nat);
+	u32 segment_count_ssa = le32_to_cpu(raw_super->segment_count_ssa);
+	u32 segment_count_main = le32_to_cpu(raw_super->segment_count_main);
+	u32 segment_count = le32_to_cpu(raw_super->segment_count);
+	u32 log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
+
+	if (segment0_blkaddr != cp_blkaddr) {
+		f2fs_msg(sb, KERN_INFO,
+			"Mismatch start address, segment0(%u) cp_blkaddr(%u)",
+			segment0_blkaddr, cp_blkaddr);
+		return true;
+	}
+
+	if (cp_blkaddr + (segment_count_ckpt << log_blocks_per_seg) !=
+							sit_blkaddr) {
+		f2fs_msg(sb, KERN_INFO,
+			"Wrong CP boundary, start(%u) end(%u) blocks(%u)",
+			cp_blkaddr, sit_blkaddr,
+			segment_count_ckpt << log_blocks_per_seg);
+		return true;
+	}
+
+	if (sit_blkaddr + (segment_count_sit << log_blocks_per_seg) !=
+							nat_blkaddr) {
+		f2fs_msg(sb, KERN_INFO,
+			"Wrong SIT boundary, start(%u) end(%u) blocks(%u)",
+			sit_blkaddr, nat_blkaddr,
+			segment_count_sit << log_blocks_per_seg);
+		return true;
+	}
+
+	if (nat_blkaddr + (segment_count_nat << log_blocks_per_seg) !=
+							ssa_blkaddr) {
+		f2fs_msg(sb, KERN_INFO,
+			"Wrong NAT boundary, start(%u) end(%u) blocks(%u)",
+			nat_blkaddr, ssa_blkaddr,
+			segment_count_nat << log_blocks_per_seg);
+		return true;
+	}
+
+	if (ssa_blkaddr + (segment_count_ssa << log_blocks_per_seg) !=
+							main_blkaddr) {
+		f2fs_msg(sb, KERN_INFO,
+			"Wrong SSA boundary, start(%u) end(%u) blocks(%u)",
+			ssa_blkaddr, main_blkaddr,
+			segment_count_ssa << log_blocks_per_seg);
+		return true;
+	}
+
+	if (main_blkaddr + (segment_count_main << log_blocks_per_seg) !=
+		segment0_blkaddr + (segment_count << log_blocks_per_seg)) {
+		f2fs_msg(sb, KERN_INFO,
+			"Wrong MAIN_AREA boundary, start(%u) end(%u) blocks(%u)",
+			main_blkaddr,
+			segment0_blkaddr + (segment_count << log_blocks_per_seg),
+			segment_count_main << log_blocks_per_seg);
+		return true;
+	}
+
+	return false;
+}
+
 static int sanity_check_raw_super(struct super_block *sb,
 			struct f2fs_super_block *raw_super)
 {
@@ -882,6 +955,14 @@ static int sanity_check_raw_super(struct
 		return 1;
 	}
 
+	/* check log blocks per segment */
+	if (le32_to_cpu(raw_super->log_blocks_per_seg) != 9) {
+		f2fs_msg(sb, KERN_INFO,
+			"Invalid log blocks per segment (%u)\n",
+			le32_to_cpu(raw_super->log_blocks_per_seg));
+		return 1;
+	}
+
 	/* Currently, support 512/1024/2048/4096 bytes sector size */
 	if (le32_to_cpu(raw_super->log_sectorsize) >
 				F2FS_MAX_LOG_SECTOR_SIZE ||
@@ -963,6 +1044,23 @@ static int sanity_check_ckpt(struct f2fs
 		f2fs_msg(sbi->sb, KERN_ERR, "A bug case: need to run fsck");
 		return 1;
 	}
+
+	/* check reserved ino info */
+	if (le32_to_cpu(raw_super->node_ino) != 1 ||
+		le32_to_cpu(raw_super->meta_ino) != 2 ||
+		le32_to_cpu(raw_super->root_ino) != 3) {
+		f2fs_msg(sb, KERN_INFO,
+			"Invalid Fs Meta Ino: node(%u) meta(%u) root(%u)",
+			le32_to_cpu(raw_super->node_ino),
+			le32_to_cpu(raw_super->meta_ino),
+			le32_to_cpu(raw_super->root_ino));
+		return 1;
+	}
+
+	/* check CP/SIT/NAT/SSA/MAIN_AREA area boundary */
+	if (sanity_check_area_boundary(sb, raw_super))
+		return 1;
+
 	return 0;
 }
 

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

* Re: [PATCH 3.18 24/24] f2fs: do more integrity verification for superblock
  2017-08-31 15:44 ` [PATCH 3.18 24/24] f2fs: do more integrity verification for superblock Greg Kroah-Hartman
@ 2017-08-31 16:33   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-31 16:33 UTC (permalink / raw)
  To: linux-kernel; +Cc: stable, Chao Yu, Jaegeuk Kim

On Thu, Aug 31, 2017 at 05:44:00PM +0200, Greg Kroah-Hartman wrote:
> 3.18-stable review patch.  If anyone has any objections, please let me know.

Same here, this breaks the build, now dropped.

greg k-h

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

* Re: [PATCH 3.18 00/24] 3.18.69-stable review
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (21 preceding siblings ...)
  2017-08-31 15:44 ` [PATCH 3.18 24/24] f2fs: do more integrity verification for superblock Greg Kroah-Hartman
@ 2017-08-31 19:06 ` Shuah Khan
  2017-08-31 19:37 ` Guenter Roeck
  2017-09-01  2:30 ` Guenter Roeck
  24 siblings, 0 replies; 28+ messages in thread
From: Shuah Khan @ 2017-08-31 19:06 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: torvalds, akpm, linux, patches, ben.hutchings, stable, Shuah Khan

On 08/31/2017 09:43 AM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 3.18.69 release.
> There are 24 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 Sat Sep  2 15:40:49 UTC 2017.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
> 	kernel.org/pub/linux/kernel/v3.x/stable-review/patch-3.18.69-rc1.gz
> or in the git tree and branch at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-3.18.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled and booted on my test system. No dmesg regressions.

thanks,
-- Shuah

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

* Re: [PATCH 3.18 00/24] 3.18.69-stable review
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (22 preceding siblings ...)
  2017-08-31 19:06 ` [PATCH 3.18 00/24] 3.18.69-stable review Shuah Khan
@ 2017-08-31 19:37 ` Guenter Roeck
  2017-09-01  2:30 ` Guenter Roeck
  24 siblings, 0 replies; 28+ messages in thread
From: Guenter Roeck @ 2017-08-31 19:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, torvalds, akpm, shuahkh, patches, ben.hutchings, stable

On Thu, Aug 31, 2017 at 05:43:36PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 3.18.69 release.
> There are 24 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 Sat Sep  2 15:40:49 UTC 2017.
> Anything received after that time might be too late.
> 

Preliminary report. The problem affects both 3.18.y and 4.4.y,
and various builds in both.

Error log:
fs/f2fs/super.c:848:20: error: redefinition of 'sanity_check_area_boundary'
 static inline bool sanity_check_area_boundary(struct super_block *sb,
                    ^
fs/f2fs/super.c:775:20: note: previous definition of 'sanity_check_area_boundary' was here
 static inline bool sanity_check_area_boundary(struct super_block *sb,
                    ^
fs/f2fs/super.c: In function 'sanity_check_ckpt':
fs/f2fs/super.c:1052:12: error: 'sb' undeclared

Guenter

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

* Re: [PATCH 3.18 00/24] 3.18.69-stable review
  2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
                   ` (23 preceding siblings ...)
  2017-08-31 19:37 ` Guenter Roeck
@ 2017-09-01  2:30 ` Guenter Roeck
  2017-09-01  5:02   ` Greg Kroah-Hartman
  24 siblings, 1 reply; 28+ messages in thread
From: Guenter Roeck @ 2017-09-01  2:30 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, torvalds, akpm, shuahkh, patches, ben.hutchings, stable

On Thu, Aug 31, 2017 at 05:43:36PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 3.18.69 release.
> There are 24 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 Sat Sep  2 15:40:49 UTC 2017.
> Anything received after that time might be too late.
> 

Test results are for v3.18.68-24-gf3691a3.

Build results:
	total: 136 pass: 136 fail: 0
Qemu test results:
	total: 111 pass: 111 fail: 0

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

Guenter

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

* Re: [PATCH 3.18 00/24] 3.18.69-stable review
  2017-09-01  2:30 ` Guenter Roeck
@ 2017-09-01  5:02   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 28+ messages in thread
From: Greg Kroah-Hartman @ 2017-09-01  5:02 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-kernel, torvalds, akpm, shuahkh, patches, ben.hutchings, stable

On Thu, Aug 31, 2017 at 07:30:37PM -0700, Guenter Roeck wrote:
> On Thu, Aug 31, 2017 at 05:43:36PM +0200, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 3.18.69 release.
> > There are 24 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 Sat Sep  2 15:40:49 UTC 2017.
> > Anything received after that time might be too late.
> > 
> 
> Test results are for v3.18.68-24-gf3691a3.
> 
> Build results:
> 	total: 136 pass: 136 fail: 0
> Qemu test results:
> 	total: 111 pass: 111 fail: 0
> 
> Details are available at http://kerneltests.org/builders.

Thanks, yeah, I messed up and pushed the trees out with a broken f2fs
patch that I hadn't even committed locally :(

All should be good now, as your reports show, thanks for testing them
all and letting me know.

greg k-h

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

end of thread, other threads:[~2017-09-01  5:02 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-31 15:43 [PATCH 3.18 00/24] 3.18.69-stable review Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 01/24] scsi: isci: avoid array subscript warning Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 02/24] ALSA: au88x0: Fix zero clear of stream->resources Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 03/24] gcov: add support for GCC 5.1 Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 04/24] gcov: add support for gcc version >= 6 Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 05/24] gcov: support GCC 7.1 Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 06/24] p54: memset(0) whole array Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 07/24] arm64: mm: abort uaccess retries upon fatal signal Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 08/24] lib: bitmap: add alignment offset for bitmap_find_next_zero_area() Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 09/24] mm: cma: align to physical address, not CMA region position Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 10/24] mm/cma: make kmemleak ignore CMA regions Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 11/24] mm: cma: split cma-reserved in dmesg log Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 12/24] mm: cma: fix totalcma_pages to include DT defined CMA regions Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 13/24] mm: cma: fix CMA aligned offset calculation Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 14/24] mm: cma: constify and use correct signness in mm/cma.c Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 15/24] mm: cma: fix incorrect type conversion for size during dma allocation Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 17/24] arm64: flush FP/SIMD state correctly after execve() Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 18/24] arm64: fpsimd: Prevent registers leaking across exec Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 19/24] x86-64: Handle PC-relative relocations on per-CPU data Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 21/24] clk: si5351: Constify clock names and struct regmap_config Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 22/24] scsi: sg: protect accesses to reserved page array Greg Kroah-Hartman
2017-08-31 15:43 ` [PATCH 3.18 23/24] scsi: sg: reset res_in_use after unlinking reserved array Greg Kroah-Hartman
2017-08-31 15:44 ` [PATCH 3.18 24/24] f2fs: do more integrity verification for superblock Greg Kroah-Hartman
2017-08-31 16:33   ` Greg Kroah-Hartman
2017-08-31 19:06 ` [PATCH 3.18 00/24] 3.18.69-stable review Shuah Khan
2017-08-31 19:37 ` Guenter Roeck
2017-09-01  2:30 ` Guenter Roeck
2017-09-01  5:02   ` Greg Kroah-Hartman

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).