Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659AbeANLp4 (ORCPT + 1 other); Sun, 14 Jan 2018 06:45:56 -0500 Received: from terminus.zytor.com ([65.50.211.136]:50747 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752562AbeANLpz (ORCPT ); Sun, 14 Jan 2018 06:45:55 -0500 Date: Sun, 14 Jan 2018 03:44:46 -0800 From: "tip-bot for Eric W. Biederman" Message-ID: Cc: oleg@redhat.com, hpa@zytor.com, mingo@kernel.org, ebiederm@xmission.com, linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, tglx@linutronix.de, dave.hansen@linux.intel.com Reply-To: hpa@zytor.com, oleg@redhat.com, linux-kernel@vger.kernel.org, ebiederm@xmission.com, mingo@kernel.org, tglx@linutronix.de, viro@zeniv.linux.org.uk, dave.hansen@linux.intel.com In-Reply-To: <20180112203135.4669-2-ebiederm@xmission.com> References: <20180112203135.4669-2-ebiederm@xmission.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/mm/pkeys: Fix fill_sig_info_pkey Git-Commit-ID: beacd6f7ed5e2915959442245b3b2480c2e37490 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Commit-ID: beacd6f7ed5e2915959442245b3b2480c2e37490 Gitweb: https://git.kernel.org/tip/beacd6f7ed5e2915959442245b3b2480c2e37490 Author: Eric W. Biederman AuthorDate: Fri, 12 Jan 2018 14:31:35 -0600 Committer: Thomas Gleixner CommitDate: Sun, 14 Jan 2018 12:14:51 +0100 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. This error was by inspection, and BUS_MCEERR_AR appears to be a real candidate for confusion. So pass in si_signo and check for SIG_SEGV to verify that it is actually a SEGV_PKUERR Fixes: 019132ff3daf ("x86/mm/pkeys: Fill in pkey field in siginfo") Signed-off-by: "Eric W. Biederman" Signed-off-by: Thomas Gleixner Cc: linux-arch@vger.kernel.org Cc: Dave Hansen Cc: Oleg Nesterov Cc: Al Viro cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20180112203135.4669-2-ebiederm@xmission.com --- arch/x86/mm/fault.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 06fe3d5..b3e4077 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) * 6. T1 : reaches here, sees vma_pkey(vma)=5, when we really * 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 */ if (!boot_cpu_has(X86_FEATURE_OSPKE)) return; /* Fault not from Protection Keys: nothing to do */ - if (si_code != SEGV_PKUERR) + if ((si_code != SEGV_PKUERR) || (si_signo != SIGSEGV)) return; /* * 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, lsb = PAGE_SHIFT; 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); }