Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11258603imu; Thu, 6 Dec 2018 14:20:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/UWz4rsrnqX/QfbkiqugHe/X8bWpAKxfj9okxIjgzS32esKfBmFOfQiLNlL7Ppff5suZg0A X-Received: by 2002:a17:902:8687:: with SMTP id g7mr29603815plo.96.1544134836973; Thu, 06 Dec 2018 14:20:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544134836; cv=none; d=google.com; s=arc-20160816; b=yHx+opYYFhpFIjj8klG51pRsCvEQR2RRAJWkdFjPWaH0+weFLkQJdxzF10ai2ML5/j ZXZFcpWFjarcUVExeDkMc+FvTBGUufCJOu38fhcytJzEgs095MIHcsIleFoglXHsLsuX jXSAETL4Zh988Kr1Bns/WjI7xQh7c4uIQSdrf/h29nItQESOfhhUy34+cD0Ta3hLflTF XK6GK4FVbKBmXMA4C2BDqN772hyJj1p+CPPPCdSj4zkvRNos/S6YjkBUtaLP+x7khPEk fY4i2RgkL1aLZX7r7E7hAoHIZPYLuVxOkBN7Bf0gBshcuiWAwbl7i8hjinRC/ct3rlRj XLEw== 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=/ilhwvIFDvlgGaFOJcUpXN5Zxdn6SZXbCntGqEABCMg=; b=z6CwD275tL311pCHW+AxMDA7BhcZOauQBnwRIMzoLMe039Nz2Crs/61wF9yMl4oMnl sMyZn1TrUm772Thi940GujEW2hykRGISfk4gDhQ2R2O6js6wziqR29XJs/lxiPRItZuE 1zAmI4P03DR8wufh+iXeCdndibjZPK4WUM1O5PF3CqmnOiEnfj7Wzyiw7LQKYvddm/Zd xnznts17d/jbMoD9kLQbsfRIf79mVyXC1YC/EW1NnOiR/TfZiyQWXms9TfBjr8cgJcxH aSe1YHVrJk/whDe8e+Ta+qo6f7gQlbqnEsTkqP2QYHncD6lc8cLF16+3f3cRvSJONvsS r1sg== 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 97si1298338plb.3.2018.12.06.14.20.22; Thu, 06 Dec 2018 14:20:36 -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 S1726224AbeLFWTi (ORCPT + 99 others); Thu, 6 Dec 2018 17:19:38 -0500 Received: from mga06.intel.com ([134.134.136.31]:39985 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbeLFWTb (ORCPT ); Thu, 6 Dec 2018 17:19:31 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Dec 2018 14:19:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,324,1539673200"; d="scan'208";a="99313300" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.154]) by orsmga008.jf.intel.com with ESMTP; 06 Dec 2018 14:19:28 -0800 From: Sean Christopherson To: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, Dave Hansen , Peter Zijlstra Cc: "H. Peter Anvin" , linux-kernel@vger.kernel.org, Andy Lutomirski , Jarkko Sakkinen , Josh Triplett Subject: [RFC PATCH v2 3/4] x86/traps: Attempt to fixup exceptions in vDSO before signaling Date: Thu, 6 Dec 2018 14:19:21 -0800 Message-Id: <20181206221922.31012-4-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206221922.31012-1-sean.j.christopherson@intel.com> References: <20181206221922.31012-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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 9b7c4ca8f0a7..f813481a85ff 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 @@ -223,6 +224,10 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str, tsk->thread.error_code = error_code; tsk->thread.trap_nr = trapnr; + if (user_mode(regs) && + fixup_vdso_exception(regs, trapnr, error_code, 0)) + return 0; + return -1; } @@ -563,6 +568,9 @@ do_general_protection(struct pt_regs *regs, long error_code) tsk->thread.error_code = error_code; tsk->thread.trap_nr = X86_TRAP_GP; + if (fixup_vdso_exception(regs, X86_TRAP_GP, error_code, 0)) + return; + show_signal(tsk, SIGSEGV, "", desc, regs, error_code); force_sig(SIGSEGV, tsk); @@ -791,6 +799,10 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code) goto exit; } + if (user_mode(regs) && + fixup_vdso_exception(regs, X86_TRAP_DB, error_code, 0)) + goto exit; + if (WARN_ON_ONCE((dr6 & DR_STEP) && !user_mode(regs))) { /* * Historical junk that used to handle SYSENTER single-stepping. @@ -854,6 +866,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