]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Mar 2018 14:37:59 +0000 (16:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Mar 2018 14:37:59 +0000 (16:37 +0200)
added patches:
selftests-x86-protection_keys-fix-syscall-nr-redefinition-warnings.patch
selftests-x86-protection_keys-fix-wrong-offset-in-siginfo.patch
selftests-x86-sysret_ss_attrs-doesn-t-build-on-a-pie-build.patch
signal-testing-don-t-look-for-__si_fault-in-userspace.patch
x86-pkeys-selftests-rename-si_pkey-to-siginfo_pkey.patch

queue-4.9/selftests-x86-protection_keys-fix-syscall-nr-redefinition-warnings.patch [new file with mode: 0644]
queue-4.9/selftests-x86-protection_keys-fix-wrong-offset-in-siginfo.patch [new file with mode: 0644]
queue-4.9/selftests-x86-sysret_ss_attrs-doesn-t-build-on-a-pie-build.patch [new file with mode: 0644]
queue-4.9/series
queue-4.9/signal-testing-don-t-look-for-__si_fault-in-userspace.patch [new file with mode: 0644]
queue-4.9/x86-pkeys-selftests-rename-si_pkey-to-siginfo_pkey.patch [new file with mode: 0644]

diff --git a/queue-4.9/selftests-x86-protection_keys-fix-syscall-nr-redefinition-warnings.patch b/queue-4.9/selftests-x86-protection_keys-fix-syscall-nr-redefinition-warnings.patch
new file mode 100644 (file)
index 0000000..42155b8
--- /dev/null
@@ -0,0 +1,67 @@
+From 693cb5580fdb026922363aa103add64b3ecd572e Mon Sep 17 00:00:00 2001
+From: Andy Lutomirski <luto@kernel.org>
+Date: Sat, 4 Nov 2017 04:19:48 -0700
+Subject: selftests/x86/protection_keys: Fix syscall NR redefinition warnings
+
+From: Andy Lutomirski <luto@kernel.org>
+
+commit 693cb5580fdb026922363aa103add64b3ecd572e upstream.
+
+On new enough glibc, the pkey syscalls numbers are available.  Check
+first before defining them to avoid warnings like:
+
+protection_keys.c:198:0: warning: "SYS_pkey_alloc" redefined
+
+Signed-off-by: Andy Lutomirski <luto@kernel.org>
+Cc: Borislav Petkov <bpetkov@suse.de>
+Cc: Dave Hansen <dave.hansen@intel.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: stable@vger.kernel.org
+Link: http://lkml.kernel.org/r/1fbef53a9e6befb7165ff855fc1a7d4788a191d6.1509794321.git.luto@kernel.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/testing/selftests/x86/protection_keys.c |   24 ++++++++++++++++++------
+ 1 file changed, 18 insertions(+), 6 deletions(-)
+
+--- a/tools/testing/selftests/x86/protection_keys.c
++++ b/tools/testing/selftests/x86/protection_keys.c
+@@ -188,17 +188,29 @@ void lots_o_noops_around_write(int *writ
+ #define u64 uint64_t
+ #ifdef __i386__
+-#define SYS_mprotect_key 380
+-#define SYS_pkey_alloc         381
+-#define SYS_pkey_free  382
++
++#ifndef SYS_mprotect_key
++# define SYS_mprotect_key 380
++#endif
++#ifndef SYS_pkey_alloc
++# define SYS_pkey_alloc        381
++# define SYS_pkey_free         382
++#endif
+ #define REG_IP_IDX REG_EIP
+ #define si_pkey_offset 0x14
++
+ #else
+-#define SYS_mprotect_key 329
+-#define SYS_pkey_alloc         330
+-#define SYS_pkey_free  331
++
++#ifndef SYS_mprotect_key
++# define SYS_mprotect_key 329
++#endif
++#ifndef SYS_pkey_alloc
++# define SYS_pkey_alloc        330
++# define SYS_pkey_free         331
++#endif
+ #define REG_IP_IDX REG_RIP
+ #define si_pkey_offset 0x20
++
+ #endif
+ void dump_mem(void *dumpme, int len_bytes)
diff --git a/queue-4.9/selftests-x86-protection_keys-fix-wrong-offset-in-siginfo.patch b/queue-4.9/selftests-x86-protection_keys-fix-wrong-offset-in-siginfo.patch
new file mode 100644 (file)
index 0000000..7b0d64f
--- /dev/null
@@ -0,0 +1,41 @@
+From 2195bff041486eb7fcceaf058acaedcd057efbdc Mon Sep 17 00:00:00 2001
+From: Dave Hansen <dave.hansen@linux.intel.com>
+Date: Fri, 3 Feb 2017 10:51:35 -0800
+Subject: selftests, x86, protection_keys: fix wrong offset in siginfo
+
+From: Dave Hansen <dave.hansen@linux.intel.com>
+
+commit 2195bff041486eb7fcceaf058acaedcd057efbdc upstream.
+
+The siginfo contains a bunch of information about the fault.
+For protection keys, it tells us which protection key's
+permissions were violated.
+
+The wrong offset in here leads to reading garbage and thus
+failures in the tests.
+
+We should probably eventually move this over to using the
+kernel's headers defining the siginfo instead of a hard-coded
+offset.  But, for now, just do the simplest fix.
+
+Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
+Cc: Ingo Molnar <mingo@kernel.org>
+Cc: Shuah Khan <shuahkh@osg.samsung.com>
+Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/testing/selftests/x86/protection_keys.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/tools/testing/selftests/x86/protection_keys.c
++++ b/tools/testing/selftests/x86/protection_keys.c
+@@ -192,7 +192,7 @@ void lots_o_noops_around_write(int *writ
+ #define SYS_pkey_alloc         381
+ #define SYS_pkey_free  382
+ #define REG_IP_IDX REG_EIP
+-#define si_pkey_offset 0x18
++#define si_pkey_offset 0x14
+ #else
+ #define SYS_mprotect_key 329
+ #define SYS_pkey_alloc         330
diff --git a/queue-4.9/selftests-x86-sysret_ss_attrs-doesn-t-build-on-a-pie-build.patch b/queue-4.9/selftests-x86-sysret_ss_attrs-doesn-t-build-on-a-pie-build.patch
new file mode 100644 (file)
index 0000000..ceecb14
--- /dev/null
@@ -0,0 +1,47 @@
+From 3346a6a4e5ba8c040360f753b26938cec31a4bdc Mon Sep 17 00:00:00 2001
+From: Shuah Khan <shuahkh@osg.samsung.com>
+Date: Mon, 2 Oct 2017 16:16:13 -0600
+Subject: selftests: x86: sysret_ss_attrs doesn't build on a PIE build
+
+From: Shuah Khan <shuahkh@osg.samsung.com>
+
+commit 3346a6a4e5ba8c040360f753b26938cec31a4bdc upstream.
+
+sysret_ss_attrs fails to compile leading x86 test run to fail on systems
+configured to build using PIE by default. Add -no-pie fix it.
+
+Relocation might still fail if relocated above 4G. For now this change
+fixes the build and runs x86 tests.
+
+tools/testing/selftests/x86$ make
+gcc -m64 -o .../tools/testing/selftests/x86/single_step_syscall_64 -O2
+-g -std=gnu99 -pthread -Wall  single_step_syscall.c -lrt -ldl
+gcc -m64 -o .../tools/testing/selftests/x86/sysret_ss_attrs_64 -O2 -g
+-std=gnu99 -pthread -Wall  sysret_ss_attrs.c thunks.S -lrt -ldl
+/usr/bin/ld: /tmp/ccS6pvIh.o: relocation R_X86_64_32S against `.text'
+can not be used when making a shared object; recompile with -fPIC
+/usr/bin/ld: final link failed: Nonrepresentable section on output
+collect2: error: ld returned 1 exit status
+Makefile:49: recipe for target
+'.../tools/testing/selftests/x86/sysret_ss_attrs_64' failed
+make: *** [.../tools/testing/selftests/x86/sysret_ss_attrs_64] Error 1
+
+Suggested-by: Andy Lutomirski <luto@kernel.org>
+Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/testing/selftests/x86/Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/tools/testing/selftests/x86/Makefile
++++ b/tools/testing/selftests/x86/Makefile
+@@ -17,7 +17,7 @@ TARGETS_C_64BIT_ALL := $(TARGETS_C_BOTHB
+ BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32)
+ BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64)
+-CFLAGS := -O2 -g -std=gnu99 -pthread -Wall
++CFLAGS := -O2 -g -std=gnu99 -pthread -Wall -no-pie
+ UNAME_M := $(shell uname -m)
+ CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32)
index 0e95dabb67010bd3a2960dfd1f6d983a3fec0e8e..8108b73ab4b04a77af5235f08e30468a455c1bbd 100644 (file)
@@ -57,3 +57,8 @@ perf-x86-intel-don-t-accidentally-clear-high-bits-in-bdw_limit_period.patch
 perf-x86-intel-uncore-fix-multi-domain-pci-cha-enumeration-bug-on-skylake-servers.patch
 iio-abi-fix-name-of-timestamp-sysfs-file.patch
 staging-lustre-ptlrpc-kfree-used-instead-of-kvfree.patch
+selftests-x86-protection_keys-fix-wrong-offset-in-siginfo.patch
+selftests-x86-protection_keys-fix-syscall-nr-redefinition-warnings.patch
+signal-testing-don-t-look-for-__si_fault-in-userspace.patch
+x86-pkeys-selftests-rename-si_pkey-to-siginfo_pkey.patch
+selftests-x86-sysret_ss_attrs-doesn-t-build-on-a-pie-build.patch
diff --git a/queue-4.9/signal-testing-don-t-look-for-__si_fault-in-userspace.patch b/queue-4.9/signal-testing-don-t-look-for-__si_fault-in-userspace.patch
new file mode 100644 (file)
index 0000000..a737ab9
--- /dev/null
@@ -0,0 +1,68 @@
+From d12fe87e62d773e81e0cb3a123c5a480a10d7d91 Mon Sep 17 00:00:00 2001
+From: "Eric W. Biederman" <ebiederm@xmission.com>
+Date: Mon, 26 Jun 2017 16:36:57 -0500
+Subject: signal/testing: Don't look for __SI_FAULT in userspace
+
+From: Eric W. Biederman <ebiederm@xmission.com>
+
+commit d12fe87e62d773e81e0cb3a123c5a480a10d7d91 upstream.
+
+Fix the debug print statements in these tests where they reference
+si_codes and in particular __SI_FAULT.  __SI_FAULT is a kernel
+internal value and should never be seen by userspace.
+
+While I am in there also fix si_code_str.  si_codes are an enumeration
+there are not a bitmap so == and not & is the apropriate operation to
+test for an si_code.
+
+Cc: Dave Hansen <dave.hansen@linux.intel.com>
+Fixes: 5f23f6d082a9 ("x86/pkeys: Add self-tests")
+Fixes: e754aedc26ef ("x86/mpx, selftests: Add MPX self test")
+Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/testing/selftests/x86/mpx-mini-test.c   |    3 +--
+ tools/testing/selftests/x86/protection_keys.c |   13 ++++++-------
+ 2 files changed, 7 insertions(+), 9 deletions(-)
+
+--- a/tools/testing/selftests/x86/mpx-mini-test.c
++++ b/tools/testing/selftests/x86/mpx-mini-test.c
+@@ -419,8 +419,7 @@ void handler(int signum, siginfo_t *si,
+               br_count++;
+               dprintf1("#BR 0x%jx (total seen: %d)\n", status, br_count);
+-#define __SI_FAULT      (3 << 16)
+-#define SEGV_BNDERR     (__SI_FAULT|3)  /* failed address bound checks */
++#define SEGV_BNDERR     3  /* failed address bound checks */
+               dprintf2("Saw a #BR! status 0x%jx at %016lx br_reason: %jx\n",
+                               status, ip, br_reason);
+--- a/tools/testing/selftests/x86/protection_keys.c
++++ b/tools/testing/selftests/x86/protection_keys.c
+@@ -224,19 +224,18 @@ void dump_mem(void *dumpme, int len_byte
+       }
+ }
+-#define __SI_FAULT      (3 << 16)
+-#define SEGV_BNDERR     (__SI_FAULT|3)  /* failed address bound checks */
+-#define SEGV_PKUERR     (__SI_FAULT|4)
++#define SEGV_BNDERR     3  /* failed address bound checks */
++#define SEGV_PKUERR     4
+ static char *si_code_str(int si_code)
+ {
+-      if (si_code & SEGV_MAPERR)
++      if (si_code == SEGV_MAPERR)
+               return "SEGV_MAPERR";
+-      if (si_code & SEGV_ACCERR)
++      if (si_code == SEGV_ACCERR)
+               return "SEGV_ACCERR";
+-      if (si_code & SEGV_BNDERR)
++      if (si_code == SEGV_BNDERR)
+               return "SEGV_BNDERR";
+-      if (si_code & SEGV_PKUERR)
++      if (si_code == SEGV_PKUERR)
+               return "SEGV_PKUERR";
+       return "UNKNOWN";
+ }
diff --git a/queue-4.9/x86-pkeys-selftests-rename-si_pkey-to-siginfo_pkey.patch b/queue-4.9/x86-pkeys-selftests-rename-si_pkey-to-siginfo_pkey.patch
new file mode 100644 (file)
index 0000000..9fd25d9
--- /dev/null
@@ -0,0 +1,63 @@
+From 91c49c2deb96ffc3c461eaae70219d89224076b7 Mon Sep 17 00:00:00 2001
+From: Dave Hansen <dave.hansen@linux.intel.com>
+Date: Fri, 10 Nov 2017 16:12:31 -0800
+Subject: x86/pkeys/selftests: Rename 'si_pkey' to 'siginfo_pkey'
+
+From: Dave Hansen <dave.hansen@linux.intel.com>
+
+commit 91c49c2deb96ffc3c461eaae70219d89224076b7 upstream.
+
+'si_pkey' is now #defined to be the name of the new siginfo field that
+protection keys uses.  Rename it not to conflict.
+
+Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
+Acked-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: Andy Lutomirski <luto@kernel.org>
+Cc: Borislav Petkov <bp@alien8.de>
+Cc: Brian Gerst <brgerst@gmail.com>
+Cc: Denys Vlasenko <dvlasenk@redhat.com>
+Cc: H. Peter Anvin <hpa@zytor.com>
+Cc: Josh Poimboeuf <jpoimboe@redhat.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Link: http://lkml.kernel.org/r/20171111001231.DFFC8285@viggo.jf.intel.com
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/testing/selftests/x86/protection_keys.c |   10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+--- a/tools/testing/selftests/x86/protection_keys.c
++++ b/tools/testing/selftests/x86/protection_keys.c
+@@ -249,7 +249,7 @@ void signal_handler(int signum, siginfo_
+       unsigned long ip;
+       char *fpregs;
+       u32 *pkru_ptr;
+-      u64 si_pkey;
++      u64 siginfo_pkey;
+       u32 *si_pkey_ptr;
+       int pkru_offset;
+       fpregset_t fpregset;
+@@ -291,9 +291,9 @@ void signal_handler(int signum, siginfo_
+       si_pkey_ptr = (u32 *)(((u8 *)si) + si_pkey_offset);
+       dprintf1("si_pkey_ptr: %p\n", si_pkey_ptr);
+       dump_mem(si_pkey_ptr - 8, 24);
+-      si_pkey = *si_pkey_ptr;
+-      pkey_assert(si_pkey < NR_PKEYS);
+-      last_si_pkey = si_pkey;
++      siginfo_pkey = *si_pkey_ptr;
++      pkey_assert(siginfo_pkey < NR_PKEYS);
++      last_si_pkey = siginfo_pkey;
+       if ((si->si_code == SEGV_MAPERR) ||
+           (si->si_code == SEGV_ACCERR) ||
+@@ -305,7 +305,7 @@ void signal_handler(int signum, siginfo_
+       dprintf1("signal pkru from xsave: %08x\n", *pkru_ptr);
+       /* need __rdpkru() version so we do not do shadow_pkru checking */
+       dprintf1("signal pkru from  pkru: %08x\n", __rdpkru());
+-      dprintf1("si_pkey from siginfo: %jx\n", si_pkey);
++      dprintf1("pkey from siginfo: %jx\n", siginfo_pkey);
+       *(u64 *)pkru_ptr = 0x00000000;
+       dprintf1("WARNING: set PRKU=0 to allow faulting instruction to continue\n");
+       pkru_faults++;