--- /dev/null
+From deb507f91f1adbf64317ad24ac46c56eeccfb754 Mon Sep 17 00:00:00 2001
+From: Oliver Hartkopp <socketcan@hartkopp.net>
+Date: Mon, 24 Oct 2016 21:11:26 +0200
+Subject: can: bcm: fix warning in bcm_connect/proc_register
+
+From: Oliver Hartkopp <socketcan@hartkopp.net>
+
+commit deb507f91f1adbf64317ad24ac46c56eeccfb754 upstream.
+
+Andrey Konovalov reported an issue with proc_register in bcm.c.
+As suggested by Cong Wang this patch adds a lock_sock() protection and
+a check for unsuccessful proc_create_data() in bcm_connect().
+
+Reference: http://marc.info/?l=linux-netdev&m=147732648731237
+
+Reported-by: Andrey Konovalov <andreyknvl@google.com>
+Suggested-by: Cong Wang <xiyou.wangcong@gmail.com>
+Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
+Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
+Tested-by: Andrey Konovalov <andreyknvl@google.com>
+Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/can/bcm.c | 32 +++++++++++++++++++++++---------
+ 1 file changed, 23 insertions(+), 9 deletions(-)
+
+--- a/net/can/bcm.c
++++ b/net/can/bcm.c
+@@ -1500,24 +1500,31 @@ static int bcm_connect(struct socket *so
+ struct sockaddr_can *addr = (struct sockaddr_can *)uaddr;
+ struct sock *sk = sock->sk;
+ struct bcm_sock *bo = bcm_sk(sk);
++ int ret = 0;
+
+ if (len < sizeof(*addr))
+ return -EINVAL;
+
+- if (bo->bound)
+- return -EISCONN;
++ lock_sock(sk);
++
++ if (bo->bound) {
++ ret = -EISCONN;
++ goto fail;
++ }
+
+ /* bind a device to this socket */
+ if (addr->can_ifindex) {
+ struct net_device *dev;
+
+ dev = dev_get_by_index(&init_net, addr->can_ifindex);
+- if (!dev)
+- return -ENODEV;
+-
++ if (!dev) {
++ ret = -ENODEV;
++ goto fail;
++ }
+ if (dev->type != ARPHRD_CAN) {
+ dev_put(dev);
+- return -ENODEV;
++ ret = -ENODEV;
++ goto fail;
+ }
+
+ bo->ifindex = dev->ifindex;
+@@ -1528,17 +1535,24 @@ static int bcm_connect(struct socket *so
+ bo->ifindex = 0;
+ }
+
+- bo->bound = 1;
+-
+ if (proc_dir) {
+ /* unique socket address as filename */
+ sprintf(bo->procname, "%lu", sock_i_ino(sk));
+ bo->bcm_proc_read = proc_create_data(bo->procname, 0644,
+ proc_dir,
+ &bcm_proc_fops, sk);
++ if (!bo->bcm_proc_read) {
++ ret = -ENOMEM;
++ goto fail;
++ }
+ }
+
+- return 0;
++ bo->bound = 1;
++
++fail:
++ release_sock(sk);
++
++ return ret;
+ }
+
+ static int bcm_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
--- /dev/null
+From 8cdf3372fe8368f56315e66bea9f35053c418093 Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso@mit.edu>
+Date: Fri, 18 Nov 2016 13:00:24 -0500
+Subject: ext4: sanity check the block and cluster size at mount time
+
+From: Theodore Ts'o <tytso@mit.edu>
+
+commit 8cdf3372fe8368f56315e66bea9f35053c418093 upstream.
+
+If the block size or cluster size is insane, reject the mount. This
+is important for security reasons (although we shouldn't be just
+depending on this check).
+
+Ref: http://www.securityfocus.com/archive/1/539661
+Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1332506
+Reported-by: Borislav Petkov <bp@alien8.de>
+Reported-by: Nikolay Borisov <kernel@kyup.com>
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ext4/ext4.h | 1 +
+ fs/ext4/super.c | 17 ++++++++++++++++-
+ 2 files changed, 17 insertions(+), 1 deletion(-)
+
+--- a/fs/ext4/ext4.h
++++ b/fs/ext4/ext4.h
+@@ -221,6 +221,7 @@ struct ext4_io_submit {
+ #define EXT4_MAX_BLOCK_SIZE 65536
+ #define EXT4_MIN_BLOCK_LOG_SIZE 10
+ #define EXT4_MAX_BLOCK_LOG_SIZE 16
++#define EXT4_MAX_CLUSTER_LOG_SIZE 30
+ #ifdef __KERNEL__
+ # define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize)
+ #else
+--- a/fs/ext4/super.c
++++ b/fs/ext4/super.c
+@@ -3394,7 +3394,15 @@ static int ext4_fill_super(struct super_
+ if (blocksize < EXT4_MIN_BLOCK_SIZE ||
+ blocksize > EXT4_MAX_BLOCK_SIZE) {
+ ext4_msg(sb, KERN_ERR,
+- "Unsupported filesystem blocksize %d", blocksize);
++ "Unsupported filesystem blocksize %d (%d log_block_size)",
++ blocksize, le32_to_cpu(es->s_log_block_size));
++ goto failed_mount;
++ }
++ if (le32_to_cpu(es->s_log_block_size) >
++ (EXT4_MAX_BLOCK_LOG_SIZE - EXT4_MIN_BLOCK_LOG_SIZE)) {
++ ext4_msg(sb, KERN_ERR,
++ "Invalid log block size: %u",
++ le32_to_cpu(es->s_log_block_size));
+ goto failed_mount;
+ }
+
+@@ -3533,6 +3541,13 @@ static int ext4_fill_super(struct super_
+ "block size (%d)", clustersize, blocksize);
+ goto failed_mount;
+ }
++ if (le32_to_cpu(es->s_log_cluster_size) >
++ (EXT4_MAX_CLUSTER_LOG_SIZE - EXT4_MIN_BLOCK_LOG_SIZE)) {
++ ext4_msg(sb, KERN_ERR,
++ "Invalid log cluster size: %u",
++ le32_to_cpu(es->s_log_cluster_size));
++ goto failed_mount;
++ }
+ sbi->s_cluster_bits = le32_to_cpu(es->s_log_cluster_size) -
+ le32_to_cpu(es->s_log_block_size);
+ sbi->s_clusters_per_group =
--- /dev/null
+From 59c3b76cc61d1d676f965c192cc7969aa5cb2744 Mon Sep 17 00:00:00 2001
+From: Miklos Szeredi <mszeredi@redhat.com>
+Date: Thu, 18 Aug 2016 09:10:44 +0200
+Subject: fuse: fix fuse_write_end() if zero bytes were copied
+
+From: Miklos Szeredi <mszeredi@redhat.com>
+
+commit 59c3b76cc61d1d676f965c192cc7969aa5cb2744 upstream.
+
+If pos is at the beginning of a page and copied is zero then page is not
+zeroed but is marked uptodate.
+
+Fix by skipping everything except unlock/put of page if zero bytes were
+copied.
+
+Reported-by: Al Viro <viro@zeniv.linux.org.uk>
+Fixes: 6b12c1b37e55 ("fuse: Implement write_begin/write_end callbacks")
+Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/fuse/file.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/fs/fuse/file.c
++++ b/fs/fuse/file.c
+@@ -1997,6 +1997,10 @@ static int fuse_write_end(struct file *f
+ {
+ struct inode *inode = page->mapping->host;
+
++ /* Haven't copied anything? Skip zeroing, size extending, dirtying. */
++ if (!copied)
++ goto unlock;
++
+ if (!PageUptodate(page)) {
+ /* Zero any unwritten bytes at the end of the page */
+ size_t endoff = (pos + copied) & ~PAGE_CACHE_MASK;
+@@ -2007,6 +2011,8 @@ static int fuse_write_end(struct file *f
+
+ fuse_write_update_size(inode, pos + copied);
+ set_page_dirty(page);
++
++unlock:
+ unlock_page(page);
+ page_cache_release(page);
+
--- /dev/null
+From 93d710a65ef02fb7fd48ae207e78f460bd7a6089 Mon Sep 17 00:00:00 2001
+From: Linus Walleij <linus.walleij@linaro.org>
+Date: Mon, 14 Nov 2016 15:34:17 +0100
+Subject: i2c: mux: fix up dependencies
+
+From: Linus Walleij <linus.walleij@linaro.org>
+
+commit 93d710a65ef02fb7fd48ae207e78f460bd7a6089 upstream.
+
+We get the following build error from UM Linux after adding
+an entry to drivers/iio/gyro/Kconfig that issues "select I2C_MUX":
+
+ERROR: "devm_ioremap_resource"
+ [drivers/i2c/muxes/i2c-mux-reg.ko] undefined!
+ERROR: "of_address_to_resource"
+ [drivers/i2c/muxes/i2c-mux-reg.ko] undefined!
+
+It appears that the I2C mux core code depends on HAS_IOMEM
+for historical reasons, while CONFIG_I2C_MUX_REG does *not*
+have a direct dependency on HAS_IOMEM.
+
+This creates a situation where a allyesconfig or allmodconfig
+for UM Linux will select I2C_MUX, and will implicitly enable
+I2C_MUX_REG as well, and the compilation will fail for the
+register driver.
+
+Fix this up by making I2C_MUX_REG depend on HAS_IOMEM and
+removing the dependency from I2C_MUX.
+
+Reported-by: kbuild test robot <fengguang.wu@intel.com>
+Reported-by: Jonathan Cameron <jic23@jic23.retrosnub.co.uk>
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Acked-by: Jonathan Cameron <jic23@kernel.org>
+Acked-by: Peter Rosin <peda@axentia.se>
+Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/i2c/Kconfig | 1 -
+ drivers/i2c/muxes/Kconfig | 1 +
+ 2 files changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/i2c/Kconfig
++++ b/drivers/i2c/Kconfig
+@@ -59,7 +59,6 @@ config I2C_CHARDEV
+
+ config I2C_MUX
+ tristate "I2C bus multiplexing support"
+- depends on HAS_IOMEM
+ help
+ Say Y here if you want the I2C core to support the ability to
+ handle multiplexed I2C bus topologies, by presenting each
+--- a/drivers/i2c/muxes/Kconfig
++++ b/drivers/i2c/muxes/Kconfig
+@@ -63,6 +63,7 @@ config I2C_MUX_PINCTRL
+
+ config I2C_MUX_REG
+ tristate "Register-based I2C multiplexer"
++ depends on HAS_IOMEM
+ help
+ If you say yes to this option, support will be included for a
+ register based I2C multiplexer. This driver provides access to
--- /dev/null
+From 8ae94224c9d72fc4d9aaac93b2d7833cf46d7141 Mon Sep 17 00:00:00 2001
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 4 Nov 2016 19:39:38 +0100
+Subject: kbuild: add -fno-PIE
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+
+commit 8ae94224c9d72fc4d9aaac93b2d7833cf46d7141 upstream.
+
+Debian started to build the gcc with -fPIE by default so the kernel
+build ends before it starts properly with:
+|kernel/bounds.c:1:0: error: code model kernel does not support PIC mode
+
+Also add to KBUILD_AFLAGS due to:
+
+|gcc -Wp,-MD,arch/x86/entry/vdso/vdso32/.note.o.d … -mfentry -DCC_USING_FENTRY … vdso/vdso32/note.S
+|arch/x86/entry/vdso/vdso32/note.S:1:0: sorry, unimplemented: -mfentry isn’t supported for 32-bit in combination with -fpic
+
+Tagging it stable so it is possible to compile recent stable kernels as
+well.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Signed-off-by: Michal Marek <mmarek@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ Makefile | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/Makefile
++++ b/Makefile
+@@ -618,6 +618,8 @@ include arch/$(SRCARCH)/Makefile
+ KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
+ KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
+ KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
++KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
++KBUILD_AFLAGS += $(call cc-option,-fno-PIE)
+
+ ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
+ KBUILD_CFLAGS += -Os
--- /dev/null
+From c6a385539175ebc603da53aafb7753d39089f32e Mon Sep 17 00:00:00 2001
+From: Borislav Petkov <bp@suse.de>
+Date: Mon, 14 Nov 2016 19:41:31 +0100
+Subject: kbuild: Steal gcc's pie from the very beginning
+
+From: Borislav Petkov <bp@suse.de>
+
+commit c6a385539175ebc603da53aafb7753d39089f32e upstream.
+
+So Sebastian turned off the PIE for kernel builds but that was too late
+- Kbuild.include already uses KBUILD_CFLAGS and trying to disable gcc
+options with, say cc-disable-warning, fails:
+
+ gcc -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
+ ...
+ -Wno-sign-compare -fno-asynchronous-unwind-tables -Wframe-address -c -x c /dev/null -o .31392.tmp
+ /dev/null:1:0: error: code model kernel does not support PIC mode
+
+because that returns an error and we can't disable the warning. For
+example in this case:
+
+KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
+
+which leads to gcc issuing all those warnings again.
+
+So let's turn off PIE/PIC at the earliest possible moment, when we
+declare KBUILD_CFLAGS so that cc-disable-warning picks it up too.
+
+Also, we need the $(call cc-option ...) because -fno-PIE is supported
+since gcc v3.4 and our lowest supported gcc version is 3.2 right now.
+
+Signed-off-by: Borislav Petkov <bp@suse.de>
+Cc: Ben Hutchings <ben@decadent.org.uk>
+Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Signed-off-by: Michal Marek <mmarek@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ Makefile | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -395,11 +395,12 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstric
+ -fno-strict-aliasing -fno-common \
+ -Werror-implicit-function-declaration \
+ -Wno-format-security \
+- -std=gnu89
++ -std=gnu89 $(call cc-option,-fno-PIE)
++
+
+ KBUILD_AFLAGS_KERNEL :=
+ KBUILD_CFLAGS_KERNEL :=
+-KBUILD_AFLAGS := -D__ASSEMBLY__
++KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE)
+ KBUILD_AFLAGS_MODULE := -DMODULE
+ KBUILD_CFLAGS_MODULE := -DMODULE
+ KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
+@@ -618,8 +619,6 @@ include arch/$(SRCARCH)/Makefile
+ KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
+ KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
+ KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
+-KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
+-KBUILD_AFLAGS += $(call cc-option,-fno-PIE)
+
+ ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
+ KBUILD_CFLAGS += -Os
--- /dev/null
+From 274e43edcda6f709aa67e436b3123e45a6270923 Mon Sep 17 00:00:00 2001
+From: Azhar Shaikh <azhar.shaikh@intel.com>
+Date: Wed, 12 Oct 2016 10:12:20 -0700
+Subject: mfd: intel-lpss: Do not put device in reset state on suspend
+
+From: Azhar Shaikh <azhar.shaikh@intel.com>
+
+commit 274e43edcda6f709aa67e436b3123e45a6270923 upstream.
+
+Commit 41a3da2b8e163 ("mfd: intel-lpss: Save register context on
+suspend") saved the register context while going to suspend and
+also put the device in reset state.
+
+Due to the resetting of device, system cannot enter S3/S0ix
+states when no_console_suspend flag is enabled. The system
+and serial console both hang. The resetting of device is not
+needed while going to suspend. Hence remove this code.
+
+Fixes: 41a3da2b8e163 ("mfd: intel-lpss: Save register context on suspend")
+Signed-off-by: Azhar Shaikh <azhar.shaikh@intel.com>
+Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Signed-off-by: Lee Jones <lee.jones@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mfd/intel-lpss.c | 3 ---
+ 1 file changed, 3 deletions(-)
+
+--- a/drivers/mfd/intel-lpss.c
++++ b/drivers/mfd/intel-lpss.c
+@@ -494,9 +494,6 @@ int intel_lpss_suspend(struct device *de
+ for (i = 0; i < LPSS_PRIV_REG_COUNT; i++)
+ lpss->priv_ctx[i] = readl(lpss->priv + i * 4);
+
+- /* Put the device into reset state */
+- writel(0, lpss->priv + LPSS_PRIV_RESETS);
+-
+ return 0;
+ }
+ EXPORT_SYMBOL_GPL(intel_lpss_suspend);
--- /dev/null
+From 82031ea29e454b574bc6f49a33683a693ca5d907 Mon Sep 17 00:00:00 2001
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 4 Nov 2016 19:39:39 +0100
+Subject: scripts/has-stack-protector: add -fno-PIE
+
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+
+commit 82031ea29e454b574bc6f49a33683a693ca5d907 upstream.
+
+Adding -no-PIE to the fstack protector check. -no-PIE was introduced
+before -fstack-protector so there is no need for a runtime check.
+
+Without it the build stops:
+|Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong available but compiler is broken
+
+due to -mcmodel=kernel + -fPIE if -fPIE is enabled by default.
+
+Tagging it stable so it is possible to compile recent stable kernels as
+well.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Signed-off-by: Michal Marek <mmarek@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ scripts/gcc-x86_64-has-stack-protector.sh | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/scripts/gcc-x86_64-has-stack-protector.sh
++++ b/scripts/gcc-x86_64-has-stack-protector.sh
+@@ -1,6 +1,6 @@
+ #!/bin/sh
+
+-echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
++echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
+ if [ "$?" -eq "0" ] ; then
+ echo y
+ else
x86-cpu-amd-fix-cpu_llc_id-for-amd-fam17h-systems.patch
kvm-x86-fix-missed-srcu-usage-in-kvm_lapic_set_vapic_addr.patch
kvm-disable-irq-while-unregistering-user-notifier.patch
+fuse-fix-fuse_write_end-if-zero-bytes-were-copied.patch
+mfd-intel-lpss-do-not-put-device-in-reset-state-on-suspend.patch
+can-bcm-fix-warning-in-bcm_connect-proc_register.patch
+i2c-mux-fix-up-dependencies.patch
+kbuild-add-fno-pie.patch
+scripts-has-stack-protector-add-fno-pie.patch
+x86-kexec-add-fno-pie.patch
+kbuild-steal-gcc-s-pie-from-the-very-beginning.patch
+ext4-sanity-check-the-block-and-cluster-size-at-mount-time.patch
--- /dev/null
+From 90944e40ba1838de4b2a9290cf273f9d76bd3bdd Mon Sep 17 00:00:00 2001
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 4 Nov 2016 19:39:40 +0100
+Subject: x86/kexec: add -fno-PIE
+
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+
+commit 90944e40ba1838de4b2a9290cf273f9d76bd3bdd upstream.
+
+If the gcc is configured to do -fPIE by default then the build aborts
+later with:
+| Unsupported relocation type: unknown type rel type name (29)
+
+Tagging it stable so it is possible to compile recent stable kernels as
+well.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Signed-off-by: Michal Marek <mmarek@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/purgatory/Makefile | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/x86/purgatory/Makefile
++++ b/arch/x86/purgatory/Makefile
+@@ -12,6 +12,7 @@ targets += purgatory.ro
+
+ KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes -fno-zero-initialized-in-bss -fno-builtin -ffreestanding -c -MD -Os -mcmodel=large
+ KBUILD_CFLAGS += -m$(BITS)
++KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
+
+ $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
+ $(call if_changed,ld)