Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp36996imu; Fri, 14 Dec 2018 13:59:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/VLgnt14qdF+yMY0Fho+248Lvyt9z5iF0Zg1wswEU36bD7OP/i2Rs9WthLV2kpODmUZpyfd X-Received: by 2002:a62:160d:: with SMTP id 13mr4367406pfw.203.1544824757861; Fri, 14 Dec 2018 13:59:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544824757; cv=none; d=google.com; s=arc-20160816; b=Vu+7qST0KC75h1IIDW23FEZEyTrE6y9BKubG/m1HEuyuByQ0NHeHsfpyll+TPU3ocd cBrNnpYe9OkMvs6GBkkVQIjUnatI1wG8wF/kVA6u7na71vRTYZmkS3rDOp22d9yV884a m+5RNf9YGUN8rgMTKpYqtBFC2IWRVwaNO5gkqJEywJ4yRK+emvgov0/rjYotSCp9BzYH 2cg3U/SfHuT/b9k673Mj8W8k2bRJNWHWXRX2EiRjA5ojClQKha/Qhgb3hF5mwZIgULEw Cb2IXwbc3tGSPkKKKhMMNCFijQbLClX6wtnRBy/zTBjutKfsqFXytraQR4L1ROQ6kw4c 0nSQ== 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=gcElNASX1USl600IyZHbjW3IA31mV5+NMWlaOZSraSksmOgc+UMliZUbUrgOfKhkKT DvrFTZQghpXL96gZMPyb7yfYL6km9HibeYBam3p4qUse3EpmGVF0qX3KYfr3z6lCpfIC 2ObyZqWDD+ci5dofJs8jom7tvvGhn8qirRfBkFEBPbtaukCooktqP0Lk94sSU1xaxF2D cXzSLUEMqyzm14bTWtlvAgpV3x6JMIkCmiZjTSBOwi/+SyX6bagjhVXA+Y3Rsaic3O/F 1j/+NZRIGqzxthYvGCFkpmWMGA/pEGsDfYCCievXVn8pc3lBacZ35Oc560/2+dtl7VZH wX8w== 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 e4si4880602pgk.127.2018.12.14.13.59.02; Fri, 14 Dec 2018 13:59:17 -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 S1731355AbeLNV5y (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 S1731256AbeLNV5e (ORCPT ); Fri, 14 Dec 2018 16:57:34 -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="118650673" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.154]) by FMSMGA003.fm.intel.com with ESMTP; 14 Dec 2018 13:57:33 -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 3/5] x86/fault: Attempt to fixup unhandled #PF on ENCLU before signaling Date: Fri, 14 Dec 2018 13:57:27 -0800 Message-Id: <20181214215729.4221-4-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_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