From patchwork Thu Jul 11 21:47:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 11040801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B16C61395 for ; Thu, 11 Jul 2019 21:47:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 973DD28ADA for ; Thu, 11 Jul 2019 21:47:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8733728AF2; Thu, 11 Jul 2019 21:47:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2318F28ADA for ; Thu, 11 Jul 2019 21:47:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726446AbfGKVry (ORCPT ); Thu, 11 Jul 2019 17:47:54 -0400 Received: from mga01.intel.com ([192.55.52.88]:34651 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726207AbfGKVrx (ORCPT ); Thu, 11 Jul 2019 17:47:53 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2019 14:47:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,480,1557212400"; d="scan'208";a="317807647" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.165]) by orsmga004.jf.intel.com with ESMTP; 11 Jul 2019 14:47:53 -0700 From: Sean Christopherson To: Jarkko Sakkinen Cc: linux-sgx@vger.kernel.org Subject: [PATCH for_v21] x86/vdso: Do not attempt to fixup #DB or #BP exceptions Date: Thu, 11 Jul 2019 14:47:51 -0700 Message-Id: <20190711214751.16725-1-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Sender: linux-sgx-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Do not fixup #DB or #BP exceptions that are reported on the SGX vDSO's ENCLU, as it's impossible to determine whether or not the exception originated from within an enclave, e.g. a #DB in an enclave will look identical to a #DB on the ENCLU itself. Even if hardware provided a magic flag to identify enclave exceptions, #DB still has scenarios where the intended recipient is ambiguous, e.g. a data breakpoint encountered in the enclave but on an address outside of the enclave, a breakpoint encountered in the enclave and a simultaneouls code breakpoint on ENCLU, and so on and so forth. An alternative solution would be to simply not call the vDSO fixup routine for #DB or #BP. Rejecting fixup from within vDSO explicitly documents that #DB/#BP are intentionally skipped and provides a single location for determining what exceptions are indeed handled by vDSO fixup. Signed-off-by: Sean Christopherson Acked-by: Jarkko Sakkinen --- arch/x86/entry/vdso/extable.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/entry/vdso/extable.c b/arch/x86/entry/vdso/extable.c index 49284d560d36..afcf5b65beef 100644 --- a/arch/x86/entry/vdso/extable.c +++ b/arch/x86/entry/vdso/extable.c @@ -2,6 +2,7 @@ #include #include #include +#include #include struct vdso_exception_table_entry { @@ -16,6 +17,14 @@ bool fixup_vdso_exception(struct pt_regs *regs, int trapnr, unsigned int nr_entries, i; unsigned long base; + /* + * Do not attempt to fixup #DB or #BP. It's impossible to identify + * whether or not a #DB/#BP originated from within an SGX enclave and + * SGX enclaves are currently the only use case for vDSO fixup. + */ + if (trapnr == X86_TRAP_DB || trapnr == X86_TRAP_BP) + return false; + if (!current->mm->context.vdso) return false;