]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Oct 2018 09:47:37 +0000 (11:47 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Oct 2018 09:47:37 +0000 (11:47 +0200)
added patches:
arc-clone-syscall-to-setp-r25-as-thread-pointer.patch
powerpc-fadump-return-error-when-fadump-registration-fails.patch

queue-4.4/arc-clone-syscall-to-setp-r25-as-thread-pointer.patch [new file with mode: 0644]
queue-4.4/powerpc-fadump-return-error-when-fadump-registration-fails.patch [new file with mode: 0644]
queue-4.4/series

diff --git a/queue-4.4/arc-clone-syscall-to-setp-r25-as-thread-pointer.patch b/queue-4.4/arc-clone-syscall-to-setp-r25-as-thread-pointer.patch
new file mode 100644 (file)
index 0000000..1bb01ad
--- /dev/null
@@ -0,0 +1,69 @@
+From c58a584f05e35d1d4342923cd7aac07d9c3d3d16 Mon Sep 17 00:00:00 2001
+From: Vineet Gupta <vgupta@synopsys.com>
+Date: Fri, 5 Oct 2018 12:48:48 -0700
+Subject: ARC: clone syscall to setp r25 as thread pointer
+
+From: Vineet Gupta <vgupta@synopsys.com>
+
+commit c58a584f05e35d1d4342923cd7aac07d9c3d3d16 upstream.
+
+Per ARC TLS ABI, r25 is designated TP (thread pointer register).
+However so far kernel didn't do any special treatment, like setting up
+usermode r25, even for CLONE_SETTLS. We instead relied on libc runtime
+to do this, in say clone libc wrapper [1]. This was deliberate to keep
+kernel ABI agnostic (userspace could potentially change TP, specially
+for different ARC ISA say ARCompact vs. ARCv2 with different spare
+registers etc)
+
+However userspace setting up r25, after clone syscall opens a race, if
+child is not scheduled and gets a signal instead. It starts off in
+userspace not in clone but in a signal handler and anything TP sepcific
+there such as pthread_self() fails which showed up with uClibc
+testsuite nptl/tst-kill6 [2]
+
+Fix this by having kernel populate r25 to TP value. So this locks in
+ABI, but it was not going to change anyways, and fwiw is same for both
+ARCompact (arc700 core) and ARCvs (HS3x cores)
+
+[1] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/arc/clone.S
+[2] https://github.com/wbx-github/uclibc-ng-test/blob/master/test/nptl/tst-kill6.c
+
+Fixes: ARC STAR 9001378481
+Cc: stable@vger.kernel.org
+Reported-by: Nikita Sobolev <sobolev@synopsys.com>
+Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arc/kernel/process.c |   20 ++++++++++++++++++++
+ 1 file changed, 20 insertions(+)
+
+--- a/arch/arc/kernel/process.c
++++ b/arch/arc/kernel/process.c
+@@ -153,6 +153,26 @@ int copy_thread(unsigned long clone_flag
+               task_thread_info(current)->thr_ptr;
+       }
++
++      /*
++       * setup usermode thread pointer #1:
++       * when child is picked by scheduler, __switch_to() uses @c_callee to
++       * populate usermode callee regs: this works (despite being in a kernel
++       * function) since special return path for child @ret_from_fork()
++       * ensures those regs are not clobbered all the way to RTIE to usermode
++       */
++      c_callee->r25 = task_thread_info(p)->thr_ptr;
++
++#ifdef CONFIG_ARC_CURR_IN_REG
++      /*
++       * setup usermode thread pointer #2:
++       * however for this special use of r25 in kernel, __switch_to() sets
++       * r25 for kernel needs and only in the final return path is usermode
++       * r25 setup, from pt_regs->user_r25. So set that up as well
++       */
++      c_regs->user_r25 = c_callee->r25;
++#endif
++
+       return 0;
+ }
diff --git a/queue-4.4/powerpc-fadump-return-error-when-fadump-registration-fails.patch b/queue-4.4/powerpc-fadump-return-error-when-fadump-registration-fails.patch
new file mode 100644 (file)
index 0000000..2ec92f9
--- /dev/null
@@ -0,0 +1,128 @@
+From 98b8cd7f75643e0a442d7a4c1cef2c9d53b7e92b Mon Sep 17 00:00:00 2001
+From: Michal Suchanek <msuchanek@suse.de>
+Date: Sat, 27 May 2017 17:46:15 +0200
+Subject: powerpc/fadump: Return error when fadump registration fails
+
+From: Michal Suchanek <msuchanek@suse.de>
+
+commit 98b8cd7f75643e0a442d7a4c1cef2c9d53b7e92b upstream.
+
+ - log an error message when registration fails and no error code listed
+   in the switch is returned
+ - translate the hv error code to posix error code and return it from
+   fw_register
+ - return the posix error code from fw_register to the process writing
+   to sysfs
+ - return EEXIST on re-registration
+ - return success on deregistration when fadump is not registered
+ - return ENODEV when no memory is reserved for fadump
+
+Signed-off-by: Michal Suchanek <msuchanek@suse.de>
+Tested-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
+[mpe: Use pr_err() to shrink the error print]
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Cc: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/kernel/fadump.c |   23 +++++++++++++++--------
+ 1 file changed, 15 insertions(+), 8 deletions(-)
+
+--- a/arch/powerpc/kernel/fadump.c
++++ b/arch/powerpc/kernel/fadump.c
+@@ -360,9 +360,9 @@ static int __init early_fadump_reserve_m
+ }
+ early_param("fadump_reserve_mem", early_fadump_reserve_mem);
+-static void register_fw_dump(struct fadump_mem_struct *fdm)
++static int register_fw_dump(struct fadump_mem_struct *fdm)
+ {
+-      int rc;
++      int rc, err;
+       unsigned int wait_time;
+       pr_debug("Registering for firmware-assisted kernel dump...\n");
+@@ -379,7 +379,11 @@ static void register_fw_dump(struct fadu
+       } while (wait_time);
++      err = -EIO;
+       switch (rc) {
++      default:
++              pr_err("Failed to register. Unknown Error(%d).\n", rc);
++              break;
+       case -1:
+               printk(KERN_ERR "Failed to register firmware-assisted kernel"
+                       " dump. Hardware Error(%d).\n", rc);
+@@ -387,18 +391,22 @@ static void register_fw_dump(struct fadu
+       case -3:
+               printk(KERN_ERR "Failed to register firmware-assisted kernel"
+                       " dump. Parameter Error(%d).\n", rc);
++              err = -EINVAL;
+               break;
+       case -9:
+               printk(KERN_ERR "firmware-assisted kernel dump is already "
+                       " registered.");
+               fw_dump.dump_registered = 1;
++              err = -EEXIST;
+               break;
+       case 0:
+               printk(KERN_INFO "firmware-assisted kernel dump registration"
+                       " is successful\n");
+               fw_dump.dump_registered = 1;
++              err = 0;
+               break;
+       }
++      return err;
+ }
+ void crash_fadump(struct pt_regs *regs, const char *str)
+@@ -997,7 +1005,7 @@ static unsigned long init_fadump_header(
+       return addr;
+ }
+-static void register_fadump(void)
++static int register_fadump(void)
+ {
+       unsigned long addr;
+       void *vaddr;
+@@ -1008,7 +1016,7 @@ static void register_fadump(void)
+        * assisted dump.
+        */
+       if (!fw_dump.reserve_dump_area_size)
+-              return;
++              return -ENODEV;
+       ret = fadump_setup_crash_memory_ranges();
+       if (ret)
+@@ -1023,7 +1031,7 @@ static void register_fadump(void)
+       fadump_create_elfcore_headers(vaddr);
+       /* register the future kernel dump with firmware. */
+-      register_fw_dump(&fdm);
++      return register_fw_dump(&fdm);
+ }
+ static int fadump_unregister_dump(struct fadump_mem_struct *fdm)
+@@ -1208,7 +1216,6 @@ static ssize_t fadump_register_store(str
+       switch (buf[0]) {
+       case '0':
+               if (fw_dump.dump_registered == 0) {
+-                      ret = -EINVAL;
+                       goto unlock_out;
+               }
+               /* Un-register Firmware-assisted dump */
+@@ -1216,11 +1223,11 @@ static ssize_t fadump_register_store(str
+               break;
+       case '1':
+               if (fw_dump.dump_registered == 1) {
+-                      ret = -EINVAL;
++                      ret = -EEXIST;
+                       goto unlock_out;
+               }
+               /* Register Firmware-assisted dump */
+-              register_fadump();
++              ret = register_fadump();
+               break;
+       default:
+               ret = -EINVAL;
index fe1a3476e3f6e286f466e51aa5caf1835d7d7d6a..af9587e6c628fe09cd4e0c681cd71953c4374f39 100644 (file)
@@ -13,3 +13,5 @@ ext4-add-corruption-check-in-ext4_xattr_set_entry.patch
 ext4-always-verify-the-magic-number-in-xattr-blocks.patch
 cgroup-fix-deadlock-in-cpu-hotplug-path.patch
 ath10k-fix-use-after-free-in-ath10k_wmi_cmd_send_nowait.patch
+powerpc-fadump-return-error-when-fadump-registration-fails.patch
+arc-clone-syscall-to-setp-r25-as-thread-pointer.patch