diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-01-27 15:02:00 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-01-27 15:02:00 -0500 |
| commit | 8a5f06056a25ac7dbca2b0505cc0fe8ffb6947c1 (patch) | |
| tree | d864baa3498f141ab7433c878390b50d7febcb98 /tools | |
| parent | 351e1aa6cb4b136e3f772605071d7a8db3c5b4e0 (diff) | |
| parent | 625210cfa6c0c26ea422f655bf68288176f174e6 (diff) | |
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Thomas Gleixner:
"A set of fixes for x86:
- Fix the swapped outb() parameters in the KASLR code
- Fix the PKEY handling at fork which missed to preserve the pkey
state for the child. Comes with a test case to validate that.
- Fix the entry stack handling for XEN PV to respect that XEN PV
systems enter the function already on the current thread stack and
not on the trampoline.
- Fix kexec load failure caused by using a stale value when the
kexec_buf structure is reused for subsequent allocations.
- Fix a bogus sizeof() in the memory encryption code
- Enforce PCI dependency for the Intel Low Power Subsystem
- Enforce PCI_LOCKLESS_CONFIG when PCI is enabled"
* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/Kconfig: Select PCI_LOCKLESS_CONFIG if PCI is enabled
x86/entry/64/compat: Fix stack switching for XEN PV
x86/kexec: Fix a kexec_file_load() failure
x86/mm/mem_encrypt: Fix erroneous sizeof()
x86/selftests/pkeys: Fork() to check for state being preserved
x86/pkeys: Properly copy pkey state at fork()
x86/kaslr: Fix incorrect i8254 outb() parameters
x86/intel/lpss: Make PCI dependency explicit
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/testing/selftests/x86/protection_keys.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c index 460b4bdf4c1e..5d546dcdbc80 100644 --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c | |||
| @@ -1133,6 +1133,21 @@ void test_pkey_syscalls_bad_args(int *ptr, u16 pkey) | |||
| 1133 | pkey_assert(err); | 1133 | pkey_assert(err); |
| 1134 | } | 1134 | } |
| 1135 | 1135 | ||
| 1136 | void become_child(void) | ||
| 1137 | { | ||
| 1138 | pid_t forkret; | ||
| 1139 | |||
| 1140 | forkret = fork(); | ||
| 1141 | pkey_assert(forkret >= 0); | ||
| 1142 | dprintf3("[%d] fork() ret: %d\n", getpid(), forkret); | ||
| 1143 | |||
| 1144 | if (!forkret) { | ||
| 1145 | /* in the child */ | ||
| 1146 | return; | ||
| 1147 | } | ||
| 1148 | exit(0); | ||
| 1149 | } | ||
| 1150 | |||
| 1136 | /* Assumes that all pkeys other than 'pkey' are unallocated */ | 1151 | /* Assumes that all pkeys other than 'pkey' are unallocated */ |
| 1137 | void test_pkey_alloc_exhaust(int *ptr, u16 pkey) | 1152 | void test_pkey_alloc_exhaust(int *ptr, u16 pkey) |
| 1138 | { | 1153 | { |
| @@ -1141,7 +1156,7 @@ void test_pkey_alloc_exhaust(int *ptr, u16 pkey) | |||
| 1141 | int nr_allocated_pkeys = 0; | 1156 | int nr_allocated_pkeys = 0; |
| 1142 | int i; | 1157 | int i; |
| 1143 | 1158 | ||
| 1144 | for (i = 0; i < NR_PKEYS*2; i++) { | 1159 | for (i = 0; i < NR_PKEYS*3; i++) { |
| 1145 | int new_pkey; | 1160 | int new_pkey; |
| 1146 | dprintf1("%s() alloc loop: %d\n", __func__, i); | 1161 | dprintf1("%s() alloc loop: %d\n", __func__, i); |
| 1147 | new_pkey = alloc_pkey(); | 1162 | new_pkey = alloc_pkey(); |
| @@ -1152,21 +1167,27 @@ void test_pkey_alloc_exhaust(int *ptr, u16 pkey) | |||
| 1152 | if ((new_pkey == -1) && (errno == ENOSPC)) { | 1167 | if ((new_pkey == -1) && (errno == ENOSPC)) { |
| 1153 | dprintf2("%s() failed to allocate pkey after %d tries\n", | 1168 | dprintf2("%s() failed to allocate pkey after %d tries\n", |
| 1154 | __func__, nr_allocated_pkeys); | 1169 | __func__, nr_allocated_pkeys); |
| 1155 | break; | 1170 | } else { |
| 1171 | /* | ||
| 1172 | * Ensure the number of successes never | ||
| 1173 | * exceeds the number of keys supported | ||
| 1174 | * in the hardware. | ||
| 1175 | */ | ||
| 1176 | pkey_assert(nr_allocated_pkeys < NR_PKEYS); | ||
| 1177 | allocated_pkeys[nr_allocated_pkeys++] = new_pkey; | ||
| 1156 | } | 1178 | } |
| 1157 | pkey_assert(nr_allocated_pkeys < NR_PKEYS); | 1179 | |
| 1158 | allocated_pkeys[nr_allocated_pkeys++] = new_pkey; | 1180 | /* |
| 1181 | * Make sure that allocation state is properly | ||
| 1182 | * preserved across fork(). | ||
| 1183 | */ | ||
| 1184 | if (i == NR_PKEYS*2) | ||
| 1185 | become_child(); | ||
| 1159 | } | 1186 | } |
| 1160 | 1187 | ||
| 1161 | dprintf3("%s()::%d\n", __func__, __LINE__); | 1188 | dprintf3("%s()::%d\n", __func__, __LINE__); |
| 1162 | 1189 | ||
| 1163 | /* | 1190 | /* |
| 1164 | * ensure it did not reach the end of the loop without | ||
| 1165 | * failure: | ||
| 1166 | */ | ||
| 1167 | pkey_assert(i < NR_PKEYS*2); | ||
| 1168 | |||
| 1169 | /* | ||
| 1170 | * There are 16 pkeys supported in hardware. Three are | 1191 | * There are 16 pkeys supported in hardware. Three are |
| 1171 | * allocated by the time we get here: | 1192 | * allocated by the time we get here: |
| 1172 | * 1. The default key (0) | 1193 | * 1. The default key (0) |
