diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2018-01-03 20:04:34 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2018-01-12 15:23:53 -0500 |
commit | 90bc9fb15942ad08b46cd003d8d1b51f3d43e322 (patch) | |
tree | afdec849db739ddb9cfc401a3acb1290bb845a37 | |
parent | 6ac1dc736b323011a55ecd1fc5897c24c4f77cbd (diff) |
x86/mm/pkeys: Fix fill_sig_info_pkey
SEGV_PKUERR is a signal specific si_code which happens to have the
same numeric value as several others: BUS_MCEERR_AR, ILL_ILLTRP,
FPE_FLTOVF, TRAP_HWBKPT, CLD_TRAPPED, POLL_ERR, SEGV_THREAD_ID,
as such it is not safe to just test the si_code the signal number
must also be tested to prevent a false positive in fill_sig_info_pkey.
I found this error by inspection, and BUS_MCEERR_AR appears to
be a real candidate for confusion. So pass in si_signo and fix it.
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Fixes: 019132ff3daf ("x86/mm/pkeys: Fill in pkey field in siginfo")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
-rw-r--r-- | arch/x86/mm/fault.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 06fe3d51d385..b3e40773dce0 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
@@ -172,14 +172,15 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr) | |||
172 | * 6. T1 : reaches here, sees vma_pkey(vma)=5, when we really | 172 | * 6. T1 : reaches here, sees vma_pkey(vma)=5, when we really |
173 | * faulted on a pte with its pkey=4. | 173 | * faulted on a pte with its pkey=4. |
174 | */ | 174 | */ |
175 | static void fill_sig_info_pkey(int si_code, siginfo_t *info, u32 *pkey) | 175 | static void fill_sig_info_pkey(int si_signo, int si_code, siginfo_t *info, |
176 | u32 *pkey) | ||
176 | { | 177 | { |
177 | /* This is effectively an #ifdef */ | 178 | /* This is effectively an #ifdef */ |
178 | if (!boot_cpu_has(X86_FEATURE_OSPKE)) | 179 | if (!boot_cpu_has(X86_FEATURE_OSPKE)) |
179 | return; | 180 | return; |
180 | 181 | ||
181 | /* Fault not from Protection Keys: nothing to do */ | 182 | /* Fault not from Protection Keys: nothing to do */ |
182 | if (si_code != SEGV_PKUERR) | 183 | if ((si_code != SEGV_PKUERR) || (si_signo != SIGSEGV)) |
183 | return; | 184 | return; |
184 | /* | 185 | /* |
185 | * force_sig_info_fault() is called from a number of | 186 | * force_sig_info_fault() is called from a number of |
@@ -218,7 +219,7 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address, | |||
218 | lsb = PAGE_SHIFT; | 219 | lsb = PAGE_SHIFT; |
219 | info.si_addr_lsb = lsb; | 220 | info.si_addr_lsb = lsb; |
220 | 221 | ||
221 | fill_sig_info_pkey(si_code, &info, pkey); | 222 | fill_sig_info_pkey(si_signo, si_code, &info, pkey); |
222 | 223 | ||
223 | force_sig_info(si_signo, &info, tsk); | 224 | force_sig_info(si_signo, &info, tsk); |
224 | } | 225 | } |