From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227DIyQq+8S0LztuWUJFKIZ1TSBKoZ7PdapPTe2l/zm+HkFJAeSpfqyg05gOePQhYTtXt0re ARC-Seal: i=1; a=rsa-sha256; t=1516611109; cv=none; d=google.com; s=arc-20160816; b=N0XEC2Q8y6BakbCSZz3/449EsQrDZzxQkSNY587G0q+l2ovIlSAZIU7K9b2M52VjKk Ln/nDKs8K6rPZHslIS2lbIgf6HUxGahrw84UulQYd93WDoxn3IAJrMAYP8WzI1S5b7Al C6sFrwT29c7xwikZRk0Jgv31OPEGfC0c5/KsyJQDo3ECbDtQylACrVAb5xYtPSA5lseQ uNklY65Ye9K397wMMkg8Fskfk8tgTtj+o9MkYHWgPDVZGYU8vC68pe9M03WtQ5jiYbYV GOh3qjc9S0/OWo1Bi8lmZCGN0WLDX3B4yu1Na5gtu0IyyOxvPM2l0+kICNXhzRXVey3A CsOA== 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=AaspbC3BbOOyJjBWb+cU8KgJa0hccnhb0dq8mH9PcgM=; b=qqZ6sbjtj9mokIwX5RP5dNtn6n2xCdslj/I5Wt3Z+wE2GhAUbPIDhF6dqYXroUQWqJ uuC4lRwaTP15wl7WYkkT9wr9EwJWHj6DU8LUje4RLKQRkBg6eVijKspeYfp2I93B4ITJ rKhOeMwAFpUDE3atOZhLZNl5K+UwTAVM7p/5YDcXZUMAo9JKgEcgaIGn0nD0wChYTI6V QRXTbJ1NJP16ZDfSNGvrvx9CIF6EiQV7qmZdaoNgxAHZQC0Gp2oNsB0J/z2+PIt9xxO2 /jXzDPPQ4TWPt+REorG7ROdMO2wG3GnQxp5IQFtCBt6cqEf3IYXhjj+mYPbs0mPnh+jv AxIw== 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.14 38/89] x86/mm/pkeys: Fix fill_sig_info_pkey Date: Mon, 22 Jan 2018 09:45:18 +0100 Message-Id: <20180122083958.454399528@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083954.683903493@linuxfoundation.org> References: <20180122083954.683903493@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?1590282010598051903?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.14-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 @@ -173,14 +173,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 @@ -219,7 +220,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); }