Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp36970imu; Fri, 14 Dec 2018 13:59:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/U3BsMH+45i+MMkziIaMu7mat2l2mk8+EZ0G3tfB2I7v2IK3gSJU659iTlv+dosOuQza/Re X-Received: by 2002:a62:b24a:: with SMTP id x71mr4548109pfe.148.1544824755397; Fri, 14 Dec 2018 13:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544824755; cv=none; d=google.com; s=arc-20160816; b=FcfpNYMWFbW0JJSg3VX5NYAju/tXfbPTuJbsa431LaR1gEAqgQ35V81AJTJ21VsOZX ttk9B5FLnHMLwF4XhUqen+0Zy3/YhCmOImCE4X1EwIrPgKzVdQQwGaudpZAFJfe9058I B2UM7klX+/VCkvJL2PJhNvo3jCv+RWlU5jTM15V0VTAPvnJp0qxosaHoY0VvISn3R58w H6KuPzPNxgZbviSvePIgTJY+770jB2J4PcLY+5tGID0P/dCaXwLjtqg7fiZ5hYyDxKo0 aK3RXsrJJns13rnjYdDrUUdl77yFhJb9xv0hKAB54nU+BGZfi3q+7+9uKeQO44pbzh6P y06w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=6rAcNYTsthJCyBr+AJy2K2rRsrRnX/PYjhDeSrp3FwE=; b=I35UCXDOikIwyBgp5hWAgI4+q8FzhYBcYRNlLXLb30i88ikPy1e6LZbuLekpO2ZgtC m7uAIIm24MYl4lOh960dHIkgCiH4Icjzr59drKQ0LVFJ15OO5RnnGxNE+qA1UhwP80G7 SwzBa0b+XdEoMzcfSoMuj4KPs2qXtXvZx5jv7LckfsM65Iu8U8KgIQzsWfcK62jv2Mw0 0DoHJ1qWNLrp39Bkj9Nigfm/JMkSi69nXpOPOhlqY6kzcK5d4FqxfJYL4SLlBFERvrg6 bQ9AUU2I5UJGKdenxzPMcg5iW0fMzwjs4kFIShzoU0ZbjT3iBx0QnZlyIVFOS37nLF7w i/Vw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r197si5519383pfc.116.2018.12.14.13.59.00; Fri, 14 Dec 2018 13:59:15 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731340AbeLNV5y (ORCPT + 99 others); Fri, 14 Dec 2018 16:57:54 -0500 Received: from mga01.intel.com ([192.55.52.88]:13324 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731270AbeLNV5f (ORCPT ); Fri, 14 Dec 2018 16:57:35 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Dec 2018 13:57:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,354,1539673200"; d="scan'208";a="118650677" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.154]) by FMSMGA003.fm.intel.com with ESMTP; 14 Dec 2018 13:57:34 -0800 From: Sean Christopherson To: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, Dave Hansen , Peter Zijlstra , Jarkko Sakkinen Cc: "H. Peter Anvin" , linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, Andy Lutomirski , Josh Triplett , Haitao Huang , Jethro Beekman , "Dr . Greg Wettstein" Subject: [RFC PATCH v5 4/5] x86/traps: Attempt to fixup exceptions in vDSO before signaling Date: Fri, 14 Dec 2018 13:57:28 -0800 Message-Id: <20181214215729.4221-5-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214215729.4221-1-sean.j.christopherson@intel.com> References: <20181214215729.4221-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call fixup_vdso_exception() in all trap flows that generate signals to userspace immediately prior to generating any such signal. If the exception is fixed, return cleanly and do not generate a signal. The goal of vDSO fixup is not to fixup all faults, nor is it to avoid all signals, but rather to report faults directly to userspace when the fault would otherwise directly result in a signal being sent to the process. Suggested-by: Andy Lutomirski Cc: Andy Lutomirski Cc: Jarkko Sakkinen Cc: Dave Hansen Cc: Josh Triplett Signed-off-by: Sean Christopherson --- arch/x86/kernel/traps.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 9b7c4ca8f0a7..b1ca05efb15e 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -61,6 +61,7 @@ #include #include #include +#include #ifdef CONFIG_X86_64 #include @@ -209,6 +210,9 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str, tsk->thread.error_code = error_code; tsk->thread.trap_nr = trapnr; die(str, regs, error_code); + } else { + if (fixup_vdso_exception(regs, trapnr, error_code, 0)) + return 0; } /* @@ -560,6 +564,9 @@ do_general_protection(struct pt_regs *regs, long error_code) return; } + if (fixup_vdso_exception(regs, X86_TRAP_GP, error_code, 0)) + return; + tsk->thread.error_code = error_code; tsk->thread.trap_nr = X86_TRAP_GP; @@ -774,6 +781,10 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code) SIGTRAP) == NOTIFY_STOP) goto exit; + if (user_mode(regs) && + fixup_vdso_exception(regs, X86_TRAP_DB, error_code, 0)) + goto exit; + /* * Let others (NMI) know that the debug stack is in use * as we may switch to the interrupt stack. @@ -854,6 +865,9 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr) if (!si_code) return; + if (fixup_vdso_exception(regs, trapnr, error_code, 0)) + return; + force_sig_fault(SIGFPE, si_code, (void __user *)uprobe_get_trap_addr(regs), task); } -- 2.19.2