Received: by 10.223.176.46 with SMTP id f43csp2689394wra; Mon, 22 Jan 2018 01:39:02 -0800 (PST) X-Google-Smtp-Source: AH8x224ssNqChF/0mLRAJEb8gBKKOQHsVuyID2v8XNeKRLicwUEJsZpa/my0yrIhTEZsJH5pZzq2 X-Received: by 2002:a17:902:6e01:: with SMTP id u1-v6mr3126387plk.12.1516613942764; Mon, 22 Jan 2018 01:39:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516613942; cv=none; d=google.com; s=arc-20160816; b=qSktQKBP08NcYZhN2e1F6kJTgTGBK8SaW9TErxFaTuUAD6HlygodyJu4liwuzu7VTI fBVgf8aASMAfPsT0V7R2u/qcr3Gjgzf+1SOX0wu8tPWPuSNcrjeYHOdAi/63u3/XVODC 2b1fqv0q0gXRdK7M4/CVSI1nY7iF/v6jVrlOCnL7qKW74/v+A4EIQOFQI+CFb0gjUlcu ZiTdZuKmIFebHY2EXZ9zZRB2j7Hf5wpRDCqMX4pLrSLId/e/MYfvP3np0/xjuFFqPei9 wdJNSMt/902iyg30Lw8zRLaR/V+oftrcd51MNKhCqPu7pPk9HTyIV8GrgsKbIPUJbvkG X/gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=pCCkkXj3rcoGIh0LWqBZWYFGU7RUP9JWoK90FZZHJGQ=; b=QN6pgMm7IjdQ/6SY/UjLOrc7HqslLFRMhhArKEjgx00Ui2NvvgY7KHNCjZym25+OWU k5cwHNg+5A/ik6ebw9x/D20mU/D1Eo4e3qkNpBZKXowAayLkPNGrkKeY6zywmRKoQSQ9 yp+tkbnaXctlsBL1QKfkKW2/SLZV3Cmk6cExwqfgj12JwPtb932iqmogusqFqIGwSeKX AocwOK8Nuadn5OifcMljtT4bFxrJcBLoLHVLTCAKws1GfY7waJ651khJibfHzT/qjT4c ZfhscRQx81eX5N2Mjc4CdcXWGMvPOH2Q9HDPCN4iifsiEFj2nkwU4vAN1U3hv0LDdSQi mfNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y190si13657463pgb.728.2018.01.22.01.38.48; Mon, 22 Jan 2018 01:39:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751900AbeAVIsP (ORCPT + 99 others); Mon, 22 Jan 2018 03:48:15 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:60302 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752171AbeAVIsK (ORCPT ); Mon, 22 Jan 2018 03:48:10 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D93ECE08; Mon, 22 Jan 2018 08:48:09 +0000 (UTC) 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); }