Commit 90bc9fb1 authored by Eric W. Biederman's avatar Eric W. Biederman

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: 019132ff ("x86/mm/pkeys: Fill in pkey field in siginfo")
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent 6ac1dc73
...@@ -172,14 +172,15 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr) ...@@ -172,14 +172,15 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
* 6. T1 : reaches here, sees vma_pkey(vma)=5, when we really * 6. T1 : reaches here, sees vma_pkey(vma)=5, when we really
* faulted on a pte with its pkey=4. * faulted on a pte with its pkey=4.
*/ */
static void fill_sig_info_pkey(int si_code, siginfo_t *info, u32 *pkey) static void fill_sig_info_pkey(int si_signo, int si_code, siginfo_t *info,
u32 *pkey)
{ {
/* This is effectively an #ifdef */ /* This is effectively an #ifdef */
if (!boot_cpu_has(X86_FEATURE_OSPKE)) if (!boot_cpu_has(X86_FEATURE_OSPKE))
return; return;
/* Fault not from Protection Keys: nothing to do */ /* Fault not from Protection Keys: nothing to do */
if (si_code != SEGV_PKUERR) if ((si_code != SEGV_PKUERR) || (si_signo != SIGSEGV))
return; return;
/* /*
* force_sig_info_fault() is called from a number of * 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,7 +219,7 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
lsb = PAGE_SHIFT; lsb = PAGE_SHIFT;
info.si_addr_lsb = lsb; info.si_addr_lsb = lsb;
fill_sig_info_pkey(si_code, &info, pkey); fill_sig_info_pkey(si_signo, si_code, &info, pkey);
force_sig_info(si_signo, &info, tsk); force_sig_info(si_signo, &info, tsk);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment