Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1347763imu; Thu, 13 Dec 2018 13:33:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/UITDRdG0XwVmViW18ph37jdR8esjqpKhI946UxWh15OvPiUycFGIKGVTEE7ZzxWWpVpmT6 X-Received: by 2002:a63:9f19:: with SMTP id g25mr368880pge.327.1544736796272; Thu, 13 Dec 2018 13:33:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544736796; cv=none; d=google.com; s=arc-20160816; b=zpvyHHK1QLr56YOBzHeP+CrFkRa7ahtm4zlEqJZTPRbHQqVUk3mWdp0yFBbF2+nbW6 rPhRh3aqhXO+wqE5trKgP6w/uD7Kvt+lFWVSwb7PGx3WAHFg8rb/Sr0plTspp8Tccxmq /7frvF7QwTGuxmRCfaUm9EV6N785v/DUmAVSJV4RfoSo6HvCQ9gv3m3t3nyNMtxmaO7k 6voPP1xXzqfCUmXgSzuPVxcKGnEJAFgBlYyoDSR6Nuoe9ayKqC4xq30zZ236jTZBTqGN P1mq9jQIaMcqRnQcCZ4lPgSKqISVd4LkUI7Mwszv0fnl8YfkW5SCMM27sLmH55hgHHT/ 1cKw== 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=AvJAcJbO9VHNnl7cjcragewOKk7OyFZy+kVETJQq2Zc=; b=zhB+dnr77J79OKfVE2iVhZoAQxcam2dmdxgxVR3znjYOXANYdV74KKqQW1IpCcw1TX h4tDX7Vi30IwusmLyZE2kY+WpU+jom82h+MR9TadkX6Se9Em0IjSB87awRmYVQJPXUA5 b5vuAdH4vnSp00W7eC/G4pxDuS2W7HSbs+1tOMio3q7T+uemsrhIftmayzlGYYX8rTk3 gRH92joX+xwxWVmIr7PylyDQLJwX83YBVl77ib1OF2GE/SCcmbGAE2Z0CFdTSr6tKosz JooYRU+WhFfSyDLV3+dgbUr+pM/lmxlKOZj0Js5k3lWJDxHHMYsC1f3Hsaju1JGSqKJy fi9w== 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 39si2308928plc.153.2018.12.13.13.32.58; Thu, 13 Dec 2018 13:33:16 -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 S1727928AbeLMVbq (ORCPT + 99 others); Thu, 13 Dec 2018 16:31:46 -0500 Received: from mga03.intel.com ([134.134.136.65]:43548 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727476AbeLMVbo (ORCPT ); Thu, 13 Dec 2018 16:31:44 -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:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,349,1539673200"; d="scan'208";a="127709240" 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 3/5] x86/fault: Attempt to fixup unhandled #PF on ENCLU before signaling Date: Thu, 13 Dec 2018 13:31:33 -0800 Message-Id: <20181213213135.12913-4-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_sgx_enclu_exception() in the SIGSEGV and SIGBUS paths of the page fault handler immediately prior to signaling. If the fault is fixed, return cleanly and do not generate a signal. In the SIGSEGV flow, make sure the error code passed to userspace has been sanitized. Suggested-by: Andy Lutomirski Cc: Andy Lutomirski Cc: Jarkko Sakkinen Cc: Dave Hansen Cc: Josh Triplett Signed-off-by: Sean Christopherson --- arch/x86/mm/fault.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index fefeb745d21d..c6f5f77ffabd 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -28,6 +28,7 @@ #include /* vma_pkey() */ #include /* efi_recover_from_page_fault()*/ #include /* store_idt(), ... */ +#include /* fixup_vdso_exception() */ #define CREATE_TRACE_POINTS #include @@ -928,6 +929,9 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, sanitize_error_code(address, &error_code); + if (fixup_vdso_exception(regs, X86_TRAP_PF, error_code, address)) + return; + if (likely(show_unhandled_signals)) show_signal_msg(regs, error_code, address, tsk); @@ -1047,6 +1051,9 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address, sanitize_error_code(address, &error_code); + if (fixup_vdso_exception(regs, X86_TRAP_PF, error_code, address)) + return; + set_signal_archinfo(address, error_code); #ifdef CONFIG_MEMORY_FAILURE -- 2.19.2