Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1347617imu; Thu, 13 Dec 2018 13:33:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wl1zKgvgF7VLhElc/5Jm37YQ8DlCX07GFigkbEJGYZJECs/RiR0CGqIFWNadWYFgZjwef1 X-Received: by 2002:a17:902:b68d:: with SMTP id c13mr448774pls.102.1544736787230; Thu, 13 Dec 2018 13:33:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544736787; cv=none; d=google.com; s=arc-20160816; b=f9pwPyIMIIbnrW4kg17qwy01MjLSnQF4zu3uiVZTnv+RCA75mOQum9ynchTdLPr8kh j4Nlst9iZBUm0JR/xxRd/he/E8vuTjFMKBgE5+kan0UK96rX72UOVHdt9d14cemZDAJx dTNRcaUchhK4G6LygtfdUW67FlpWpNMFxRzG6qhhoV2MAEUWgLP/use//Rr3KjAZZlPh 6U7Rd1JtL038KfqipW77lurAczdA01QKoLFS371z7oPTeDH67YGTipyqIzvTeeJ6YA8+ u8TtRp1+sD/cIeyG8Fu9n+rzNGwOmQREMV2Rde2lCgB4Ge/HygIrhtjy1XhfXDUeVLH9 lROg== 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=MMQdRkwpLmq+z7O3uUHt+HEqfb0h1JZeWmg9uMtbWweW0j6ThzpLgS/UygBtzjOLd/ a5J0DrQMZPmBUlZM6AoZiJjiC/FLcnB+OLKMKOJvsduPgw4BJAOcxUQzetLMn2xgwbN2 WuEyZ6kRWG8O5/GpXaI12HAG0FltqUiinpPSXDZy0r8GxNv2GmC0bErnW4ApvFSx570H kcZNPJx6dHEsWErUsTCBS3ON8gKpYOuJxzpUzsZh4KPFh3iDIzwQvKAffjTYCj5GxTFY yhtJaeePPnRQMzeWkfBIvz/cjZK6Go1BzF7WzWNBBA5ZJFU7lY7O5j7bj9aFaTI/w9b6 DD6A== 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 v10si2314910plp.183.2018.12.13.13.32.49; Thu, 13 Dec 2018 13:33:07 -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 S1728168AbeLMVbu (ORCPT + 99 others); Thu, 13 Dec 2018 16:31:50 -0500 Received: from mga03.intel.com ([134.134.136.65]:43547 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727586AbeLMVbm (ORCPT ); Thu, 13 Dec 2018 16:31:42 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Dec 2018 13:31:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,349,1539673200"; d="scan'208";a="127709243" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.154]) by fmsmga004.fm.intel.com with ESMTP; 13 Dec 2018 13:31:41 -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 v4 4/5] x86/traps: Attempt to fixup exceptions in vDSO before signaling Date: Thu, 13 Dec 2018 13:31:34 -0800 Message-Id: <20181213213135.12913-5-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181213213135.12913-1-sean.j.christopherson@intel.com> References: <20181213213135.12913-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