From patchwork Fri Sep 4 10:44:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 11756615 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 88D4F618 for ; Fri, 4 Sep 2020 10:45:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AD1A2087C for ; Fri, 4 Sep 2020 10:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726171AbgIDKpQ (ORCPT ); Fri, 4 Sep 2020 06:45:16 -0400 Received: from mga02.intel.com ([134.134.136.20]:43131 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730092AbgIDKpI (ORCPT ); Fri, 4 Sep 2020 06:45:08 -0400 IronPort-SDR: 0WuXU2uETVumnqwPhv4JBiuqqB/b2hFUzF5+Bf9lou5uKk7rLlGW4RVPoEH9xUHIkZ19Ua1fY6 lp75Xobw5Ebw== X-IronPort-AV: E=McAfee;i="6000,8403,9733"; a="145455661" X-IronPort-AV: E=Sophos;i="5.76,389,1592895600"; d="scan'208";a="145455661" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2020 03:44:47 -0700 IronPort-SDR: /b4nIQdvgNX3ZDZKt7syS3hp3iONaFCFiObqREXg3zsuAj/+ZRuCQx38e4ZbnfnWR/oolf0wtj 5l5bDlUPT/lw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,389,1592895600"; d="scan'208";a="283026276" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.160]) by fmsmga007.fm.intel.com with ESMTP; 04 Sep 2020 03:44:47 -0700 From: Sean Christopherson To: Jarkko Sakkinen Cc: Nathaniel McCallum , Cedric Xing , Jethro Beekman , Andy Lutomirski , linux-sgx@vger.kernel.org Subject: [PATCH for_v37 1/6] x86/vdso: x86/sgx: Explicitly force 8-byte CMP for detecting user handler Date: Fri, 4 Sep 2020 03:44:32 -0700 Message-Id: <20200904104437.29555-2-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904104437.29555-1-sean.j.christopherson@intel.com> References: <20200904104437.29555-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Sender: linux-sgx-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org Use 'cmpq' to force an 8-byte CMP when checking for a user provided exit handler. The handler is a pointer, which is guaranteed to be an 8-byte value since SGX is 64-bit mode only, and gcc defaults to 'cmpl' given a bare 'cmp', i.e. is only checking the lower 32 bits. This could cause a false negative when detecting a user exit handler. Acked-by: Jarkko Sakkinen Acked-by: Jethro Beekman Signed-off-by: Sean Christopherson --- arch/x86/entry/vdso/vsgx_enter_enclave.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/entry/vdso/vsgx_enter_enclave.S b/arch/x86/entry/vdso/vsgx_enter_enclave.S index be7e467e1efb3..2d88acd408d4e 100644 --- a/arch/x86/entry/vdso/vsgx_enter_enclave.S +++ b/arch/x86/entry/vdso/vsgx_enter_enclave.S @@ -48,7 +48,7 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) /* Invoke userspace's exit handler if one was provided. */ .Lhandle_exit: - cmp $0, 0x20(%rbp) + cmpq $0, 0x20(%rbp) jne .Linvoke_userspace_handler .Lout: