From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x22798HOVHnBnERMC/oBctH8rWYO/B5IRxo19OYK6VzmFeJUjM1RMaN1T/XN/3l0qVjMpjPtg ARC-Seal: i=1; a=rsa-sha256; t=1516610891; cv=none; d=google.com; s=arc-20160816; b=zI0VlOwAUSSGVry6u4f9kkVy67erxllw8miy8+IW00XU2czKkOdjpkdVp7lE7UxiUx sZZExwhxJdPswzEjh7a27f6XP8dU7JDGLa5ycAqAXOh/yv/qBguCCSVfvpEdv2ARc4Gi xe+HuzxWzj8s3WHmKS68BrNBNgv6Q2cWAwqJRmYLFDGaQnwT9zR9mmOwE33xYcKGzdEJ /r4hexEU/vBkTRuiT2g9Y5ZAiPJ9ArKPA2iHF2bGnCUbvVPjirNr9w4IKdp6Mu4bAkOg XD91UP+HTsLeQWgDktRJ9gMCmxCPSYLMjD45Kp3G7J+TV+yR/isxx3pjafTKLci5rxM5 sY0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=pCCkkXj3rcoGIh0LWqBZWYFGU7RUP9JWoK90FZZHJGQ=; b=fSQg111akCQuKRsE6Nhu6YHqz7zFOYoalJlA32iGH7og/PJCtzypxWS1PlVFaoKp3x wCGon0q1OWKQ9Ly7N3pnerN7XXKn4jWtk+a8AtxAFXeVpOcZzgk/P2d268fg9nd5i90O rAXMjTzn0LYtDNdtjsm6hpQwrNZyDDazM9PPK4DvpsyZJ4A08v+KVYEZ2TD6pZ1noJXj ezxOBxhS8JUR3Dk6NpKYddGf6gp6mpSuLVAbHARQdlZq7PmYzODwuQ0cZT0a14m76btN B+gMWsjpTTLjfjQMbxmVks0r4MFXyjoi7e9i16SfO/gM02X47mOnCDqpl0M883mMy9cz H+fA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Eric W. Biederman" , Thomas Gleixner , linux-arch@vger.kernel.org, Dave Hansen , Oleg Nesterov , Al Viro Subject: [PATCH 4.9 19/47] x86/mm/pkeys: Fix fill_sig_info_pkey Date: Mon, 22 Jan 2018 09:45:30 +0100 Message-Id: <20180122083927.168382996@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083925.568134913@linuxfoundation.org> References: <20180122083925.568134913@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590281782187477691?= X-GMAIL-MSGID: =?utf-8?q?1590281782187477691?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric W. Biederman commit beacd6f7ed5e2915959442245b3b2480c2e37490 upstream. 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 Link: https://lkml.kernel.org/r/20180112203135.4669-2-ebiederm@xmission.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/fault.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -191,14 +191,15 @@ is_prefetch(struct pt_regs *regs, unsign * 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 @@ -237,7 +238,7 @@ force_sig_info_fault(int si_signo, int s 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); }