Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp947315imu; Fri, 7 Dec 2018 11:26:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/VA1Zte9t0SZ+tvoVT+BMUOeEfxdD5dObnLGRcZYGiVC+EFKQSzpK3Aur1jz4dIohgT5TBi X-Received: by 2002:a62:509b:: with SMTP id g27mr3516389pfj.48.1544210761206; Fri, 07 Dec 2018 11:26:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544210761; cv=none; d=google.com; s=arc-20160816; b=BDS7KTLWPT6VzJwdpF7sWk6QcCaHCd8vXr6hIiTeFoCtCNxJRpHnDnnUaKna41RPJX qnU4ubt5YBtoYPAZHzj1ZcVfvijE2N/5XSEDLrPBmoIZTTJF7eT9TqEygzw81YY5KsRO W+yn9Hu73Xkalt8ixUsM78yZWy4QWUrE8wyJBHy04hETz7fga4qtP+HPilxSjiARsMDJ 1JaRQFyvbRCNsNjdwrdBPrOdOQCLdBlgV722spoW6cf0KFqCuBlXyIkmhGpExqgS8cPI kS+bNLKpop2MpSK1NLJNSLho9aNpLu6kD3C70U8JSOp4iZa+mgUoU8k+qKCgmx08DjSh gMrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=tpMgLz8022es6nTdDC6vCIIc+GNybJRH05E0J5Oj2VU=; b=PAvH9rxyk3EeSlUWUl292ExTgzu7dSFVh6K5GxQxVZ/5VYOFo+mzstVquuCFgjzHPk 5qRDIpWLfcy7YjSXARWW9OZFr+ealX4UrhF6epEQ+NgBLZkPPCkaMrzTV/0LplAr8XEh sG9fZiL3kGtzzjIhKxumVQUB1pwLH8XTgqozKCfbXnbUQZLZMilmmCZlqQfZzVQ/p7f/ 2jLo4IO6r07Xrz8x1wCxdgb4R9/qiBszP+v4U42LDH6oQEAldFeFe9INOBlThLdZNP2j LpBN2a/iJ9VvFuAjs29v4dJqhv6F0NDwK+cyfimyCJ7eJBapz5cM0u6gJWNUlKFRaq/F ATUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=WObCZGoL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si3661622pld.92.2018.12.07.11.25.46; Fri, 07 Dec 2018 11:26:01 -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; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=WObCZGoL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726223AbeLGTXO (ORCPT + 99 others); Fri, 7 Dec 2018 14:23:14 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:38244 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726069AbeLGTXO (ORCPT ); Fri, 7 Dec 2018 14:23:14 -0500 Received: by mail-pl1-f194.google.com with SMTP id e5so2254055plb.5 for ; Fri, 07 Dec 2018 11:23:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=tpMgLz8022es6nTdDC6vCIIc+GNybJRH05E0J5Oj2VU=; b=WObCZGoLaYqDPSDDilAbJevIjVQAGoAq0HCrkKmpUqL+bMw3yop0+HR0MELHqr/Q16 ka3Ilw5f+EtP1Bn4SB0X6PfClstVxywWLavqinXG+wKpnfU/HtqBQotTW0R3eA99lrjv S4p0UcjNkgACVR16VIVaCuin9dyOGjGDRJYZ2LBcjR7HnHEqquX1yQf+dq1jCwapUQ5H 06nct7T1hQdvS0c2yc70Cr8+HVVrjwybUjX+IwTIlW34QX5rJY6dyQEP1vlvyGGLqXdF LGmlXGRL74+0E+D3DtWb8HXy1rdOeLlww7g54L3lxVJZaiCXwoQ8k02yCK4f1PeAP5bh HPwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=tpMgLz8022es6nTdDC6vCIIc+GNybJRH05E0J5Oj2VU=; b=mLNtRSHsRHW7IPkCPp0wRi1FXR31Bp377JzLWCVEd0gVO9qVKr1/6sJRpX1Up8RJKH 80M+pHloKqsU1vMPvqUPGK2963bDgHA6abZQumYzSlxetAfSfk71wJjXDRO7HXVSgsCO 9WEfc+E61/8lJhy62bxYm4qtXK28dx8uMkEUp5yUZDwSIe2DQqLPjC57Ra6H0HvT1VpX /RNr9PUpi2vNywdqMiVITWJ0ncu+hdM47lxiTrHzOb9DD2AImVgVzFMGIAKhZKr9sg4f UXGYUDQfNeBIFPXCj+KvqAzjTKLSi80MOkX+buVslXKmDT4++2oOKJOIhwhmPMv5kHyS GcDg== X-Gm-Message-State: AA+aEWartmv7dsNOeBn8cPshLJJONUpFIG5LJ7vaNhln3tQRBuAoJGht YHm1fTGPhO5py2hLJxAC7mmIQA== X-Received: by 2002:a17:902:8c91:: with SMTP id t17mr3173993plo.119.1544210593296; Fri, 07 Dec 2018 11:23:13 -0800 (PST) Received: from ?IPv6:2600:1010:b02e:9276:b497:ca3d:93db:f61e? ([2600:1010:b02e:9276:b497:ca3d:93db:f61e]) by smtp.gmail.com with ESMTPSA id p7sm6260039pfa.22.2018.12.07.11.23.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Dec 2018 11:23:12 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: [RFC PATCH v2 4/4] x86/vdso: Add __vdso_sgx_enter_enclave() to wrap SGX enclave transitions From: Andy Lutomirski X-Mailer: iPhone Mail (16B92) In-Reply-To: <20181207190257.GC10404@linux.intel.com> Date: Fri, 7 Dec 2018 11:23:10 -0800 Cc: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , Dave Hansen , Peter Zijlstra , "H. Peter Anvin" , LKML , Jarkko Sakkinen , Josh Triplett , linux-sgx@vger.kernel.org, haitao.huang@linux.intel.com, Jethro Beekman , "Dr. Greg Wettstein" Content-Transfer-Encoding: quoted-printable Message-Id: References: <20181206221922.31012-1-sean.j.christopherson@intel.com> <20181206221922.31012-5-sean.j.christopherson@intel.com> <20181207165145.GB10404@linux.intel.com> <20181207190257.GC10404@linux.intel.com> To: Sean Christopherson Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Dec 7, 2018, at 11:02 AM, Sean Christopherson wrote: >=20 >> On Fri, Dec 07, 2018 at 09:56:09AM -0800, Andy Lutomirski wrote: >> On Fri, Dec 7, 2018 at 8:51 AM Sean Christopherson >> wrote: >>> I like that the exit handler allows userspace to trap/panic with the ful= l >>> call stack in place, and in a dedicated path, i.e. outside of the basic >>> enter/exit code. An exit handler probably doesn't fundamentally change >>> what userspace can do with respect to debugging/reporting, but I think >>> it would actually simplify some userspace implementations, e.g. I'd use >>> it in my tests like so: >>>=20 >>> long fault_handler(struct sgx_enclave_exit_info *exit_info, void *tcs, v= oid *priv) >>> { >>> if (exit_info->leaf =3D=3D SGX_EEXIT) >>> return 0; >>>=20 >>> >>> } >>>=20 >>=20 >> Hmm. That't not totally silly, although you could accomplish almost >> the same thing by wrapping the vDSO helper in another function. >=20 > True, but I think there's value in having the option to intercept an > exception at the exact(ish) point of failure, without having to return > up the stack. >=20 > The enclave has full access to the process' memory space, including the > untrsuted stack. It's not too far fetched to envision a scenario where > the enclave corrupts the stack even if the enclave isn't intentionally > using the stack, e.g. the host passes in variable that a points at the > stack instead of whatever memory is supposed to be shared between the > enclave and host. It'd be nice to have the ability to triage something > like that without having to e.g. configure breakpoints on the stack. Ah, I see. You=E2=80=99re saying that, if the non-enclave stare is corrupted= such that RIP is okay and RSP still points somewhere reasonable but the re= turn address is garbage, then we can at least get to the fault handler and p= rint something? This only works if the fault handler pointer itself is okay= , though, which somewhat limits the usefulness, given that its pointer is qu= ite likely to be on the stack very close to the return address. I really wish the ENCLU instruction had seen fit to preserve some registers.=