Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4283imd; Fri, 2 Nov 2018 16:28:58 -0700 (PDT) X-Google-Smtp-Source: AJdET5cM10WzdoW1Tbz4H2w8WrI7uIbUGgvidW5Q3WhFxfnZ1RH6ZhUjCrpg77Ey9qwbHXbSk9rw X-Received: by 2002:a63:5442:: with SMTP id e2-v6mr12703537pgm.316.1541201338883; Fri, 02 Nov 2018 16:28:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541201338; cv=none; d=google.com; s=arc-20160816; b=wz+Q83Oa+RTeUzzKLRN2sGJyEGFZCmAD4mgkvNKy+TzuGXeoGrVD7RrNObugoMZV55 tmTkfvxbO+amrR6FcIlB8DmTsyszQGm5pZM5ZLgyvhih/8iTTbuB6gk6+qomZTy4X966 8zYkVZ/9CUbKnRqcuJsiPMGNp8h7L38ZQf786IHQ3zWynxDtEefjQBmw7PX/W5S69oG9 qAWlZl6KxEg4wKMgdW1HL5KuTVdge/eMHQsO0bKvnxKrSmcl+KYzRCEAaxKK9+FezRGv NrZXCM0a4m2jsKiQ24QNqCfgm1w81G9FzH4HNiusnIt+Ljwm5/8FuOP1OZtt2toBnocB DDAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=x1/cnYGOjjvtrAiM/pd5pG9QuDs8Ifd6xBYEVFwVp+4=; b=J7iYSJWZ+edPXG6lesEuiPNbccJB/iFgyeCCf2lhOoHmlApwuM/72+vuAL+cBCMk8f nOczJL+WsGSMOOdTDfMgnSmZEpyN6eAhwzayefCyIhpcyJVnXq/7/mEeiiggsP6RptDh 5IvYHZhUUGYr/aJP/WcNGFSqI1Mt/I7FyK1NjkH9ZOnJTZmz2BQaoX13NI7IQuv5Nx0u DVH0PcJdwjxvDVRVsukcmo4ASoBNUBUmUs9Cp1PN+GRyfpMjmUcvnj8XsU0heDCUo42T p8qzyKvPUN66W5N0S6Prp4e05xoGcGePeJItJf0twViE2BPC7ORWeNRYMhU13iOxd5fM lVDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="E2/ctDfy"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1-v6si36834057pgf.80.2018.11.02.16.28.36; Fri, 02 Nov 2018 16:28:58 -0700 (PDT) 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=@google.com header.s=20161025 header.b="E2/ctDfy"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728483AbeKCIhM (ORCPT + 99 others); Sat, 3 Nov 2018 04:37:12 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:39805 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728434AbeKCIhM (ORCPT ); Sat, 3 Nov 2018 04:37:12 -0400 Received: by mail-oi1-f196.google.com with SMTP id 192-v6so2170944oii.6 for ; Fri, 02 Nov 2018 16:28:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=x1/cnYGOjjvtrAiM/pd5pG9QuDs8Ifd6xBYEVFwVp+4=; b=E2/ctDfyqAyKZZZGELrn70KQcFwECp/f1uGuNusSxj4SrZXLmKVF/PuTTnfZdI6/y9 de1M1Vt0fJ3X8B5Z0P4F98t9W5bobjGdtBJax8uvTIasm82pFhSmMSUr9eUNiTcz9xIp eJHnRrxypNCSY5uaD8McZ5peSB5dbEIxU6fiKXXNDOYO8gYQbiIAPyNffTV/Uq3vx3aj 6E/WvUq/gAe/nHwSShpi0JR/H43ecgiKz08JTVwd6mNQZcSt3Gn+egQ2xV2NItf3dQUQ GM8KCAbCg+qWk06wEpVxpPzVIqrZMcruK0jWclL8n5/TeIRE0uPWFwr+8RFBFrEWAHH4 Tqlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=x1/cnYGOjjvtrAiM/pd5pG9QuDs8Ifd6xBYEVFwVp+4=; b=jZnXbAm19mwjDGoCoS9SyvpUA6A4zfxPYZabXqbQwQ+tFmFyNnkfefrz98axjUgT88 g2eSHPiBAQR+MqtYe9mzcwilC1Gyd3ioU2BHaNGr13k1Dw0x3iX8YRIsdZBmtzc1bwpD rrK+49yUpK6dP2QEWteHbGqfRW0qL9H2BBhtlMUgPTR6gf1mTgPqsvVkLlpnpTdD2LGM ZLArI+lBTftaYdksmSlQwRjO0B0mTOrc5I2Bw0Eq60lNpVVzcl2vRDZ04tdt8HuDYZJ4 Jq4lheIY1ZTA+XQaahwwHpa+le/05aCIMzWx0SO7tcFQG/Tf/lXd2k4W5aRXKO6e02yl PL0Q== X-Gm-Message-State: AGRZ1gJKRHXlCJe4qQ/WrMq+6+6LKoXzH10gJLNxYP7mnp/dNEZ7Njhm oipMhNYrGeB1AU8Il9J+AsMfDIHJYlldVWQ2gFMz9A== X-Received: by 2002:aca:c4cf:: with SMTP id u198-v6mr7438789oif.209.1541201280962; Fri, 02 Nov 2018 16:28:00 -0700 (PDT) MIME-Version: 1.0 References: <20181102163034.GB7393@linux.intel.com> <7050972d-a874-dc08-3214-93e81181da60@intel.com> <20181102170627.GD7393@linux.intel.com> <20181102173350.GF7393@linux.intel.com> <20181102182712.GG7393@linux.intel.com> <20181102220437.GI7393@linux.intel.com> In-Reply-To: <20181102220437.GI7393@linux.intel.com> From: Jann Horn Date: Sat, 3 Nov 2018 00:27:34 +0100 Message-ID: Subject: Re: RFC: userspace exception fixups To: sean.j.christopherson@intel.com Cc: Andy Lutomirski , Dave Hansen , Linus Torvalds , dalias@libc.org, Dave Hansen , jethro@fortanix.com, jarkko.sakkinen@linux.intel.com, Florian Weimer , Linux API , "the arch/x86 maintainers" , linux-arch , kernel list , Peter Zijlstra , nhorman@redhat.com, npmccallum@redhat.com, serge.ayoun@intel.com, shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, andriy.shevchenko@linux.intel.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , carlos@redhat.com, adhemerval.zanella@linaro.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 2, 2018 at 11:04 PM Sean Christopherson wrote: > On Fri, Nov 02, 2018 at 08:02:23PM +0100, Jann Horn wrote: > > On Fri, Nov 2, 2018 at 7:27 PM Sean Christopherson > > wrote: > > > On Fri, Nov 02, 2018 at 10:48:38AM -0700, Andy Lutomirski wrote: > > > > This whole mechanism seems very complicated, and it's not clear > > > > exactly what behavior user code wants. > > > > > > No argument there. That's why I like the approach of dumping the > > > exception to userspace without trying to do anything intelligent in > > > the kernel. Userspace can then do whatever it wants AND we don't > > > have to worry about mucking with stacks. > > > > > > One of the hiccups with the VDSO approach is that the enclave may > > > want to use the untrusted stack, i.e. the stack that has the VDSO's > > > stack frame. For example, Intel's SDK uses the untrusted stack to > > > pass parameters for EEXIT, which means an AEX might occur with what > > > is effectively a bad stack from the VDSO's perspective. > > > > What exactly does "uses the untrusted stack to pass parameters for > > EEXIT" mean? I guess you're saying that the enclave is writing to > > RSP+[0...some_positive_offset], and the written data needs to be > > visible to the code outside the enclave afterwards? > > As is, they actually do it the other way around, i.e. negative offsets > relative to the untrusted %RSP. Going into the enclave there is no > reserved space on the stack. The SDK uses EEXIT like a function call, > i.e. pushing parameters on the stack and making an call outside of the > enclave, hence the name out-call. This allows the SDK to handle any > reasonable out-call without a priori knowledge of the application's > maximum out-call "size". But presumably this is bounded to be at most 128 bytes (the red zone size), right? Otherwise this would be incompatible with non-sigaltstack signal delivery.