Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp11616imd; Fri, 2 Nov 2018 16:39:40 -0700 (PDT) X-Google-Smtp-Source: AJdET5eBzUkPJzZX1jFnOVxRCzGDdtGMmhNVNv/njGpD0Fs0OaYzh0JQVC8mGjiwcpiiZ7zv9l3C X-Received: by 2002:a17:902:31a4:: with SMTP id x33-v6mr9396639plb.105.1541201980848; Fri, 02 Nov 2018 16:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541201980; cv=none; d=google.com; s=arc-20160816; b=VXIo12ud2eHCAXRAh5O1uh1ooy+B5Nl5Hw4wRyfHODSilio3TGVzQrasewwjUOr8H1 8uRw64hkXA+hxGHF9eb2DcvTLXHvc3BG6hkaRBA8AH+5HEpzOPr+XNgQq/n90nQ8R8k5 PAY+TWuZwRDt05bNrQ+j3X0JvDiuLmmnsZuW3tA2DXw0HP91N7deUhR07U4rgtNH0Hc7 bQFd7d6UvpYHMx+wLYqwiMGx+VQdu0uQ75E0gZ5KnQB4ox98dMvI4pqy4SSdhPlEJkbZ XyMPaMxu3vxKTBoaEPbVaEuJ1kii8XSrQW1uffse+gLr9mwnvPI1ibPvXbdgwq+fJtpF 8JNA== 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=/jfYvcq+Fk861HVzgrZI/Rl6MCadmc/WXcbYl1AODkY=; b=XHf4EKuWLTjCVpc4+RNQ4+CUyC028XCDZ+AkBTPiYbHMCDBAjILr+C/N1f1IgYB1NB CpgLZesUrtZCyhS5IttW4auex4ok22VRd2gN4ypj+N9eYNLhy89Vaeamiswmi39F0IM+ mdLVeEZeiR6z4DujKBtwOlqW+YcZHuuh8Q//x+iQOYlR7Xequf4aUfrkU4FF1bQWihQg M82RMNCtp9epx7GC1tEztMzSW4mTSTB2gyR3b+Nhw9ApaSF7pIxvGU5f+/3mVwxoKwFX xI+PhF+a9wrQirvPQjS6mjwcyDjSPm6KMJ1IWhxS/Epxi/OdOssA2C8lKGX2bEIJP+r7 IXnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=wD37VH3a; 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 o12-v6si33939335plk.360.2018.11.02.16.39.25; Fri, 02 Nov 2018 16:39:40 -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=wD37VH3a; 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 S1728544AbeKCIqR (ORCPT + 99 others); Sat, 3 Nov 2018 04:46:17 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:44394 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728504AbeKCIqR (ORCPT ); Sat, 3 Nov 2018 04:46:17 -0400 Received: by mail-oi1-f193.google.com with SMTP id k19-v6so2916036oic.11 for ; Fri, 02 Nov 2018 16:37:03 -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=/jfYvcq+Fk861HVzgrZI/Rl6MCadmc/WXcbYl1AODkY=; b=wD37VH3aZ1yqxWfmHtL2lxtgMfTbh/SVuukLl7ppDBpwVGPugJSO2A07VVghuijE4Q zo6Fr6NSUqGrkAuxhEWMNSn7+dvSnzjiP/A5l9aDdUEDAZSafCLZmZewZLO0ThfuIrFT MaV6nC+c50TQh+oJmGwOpRsootk2GPngD9wUq/hkw6vvvRAznQ4VZCoyGHKI2Nd21kEa Av1CmfMjXaNYoAZm0xnT1c5BGjn+EVJU0TO/4te2GuKcaHwoDgm3JBGfqwx43+RfTxFh mPQw4u7icrLDC7jkj4Rf3r0xRA+M5zQBEuwUdE8VBPeuL849aptz0+BPgKoCOKHnwwvS /Xrg== 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=/jfYvcq+Fk861HVzgrZI/Rl6MCadmc/WXcbYl1AODkY=; b=HAOHm8LUviipicfbnG57I0ELAlffnj8iUYCz2ITehYDTGM0Y0VP82lvB/wHJBJn1FV ebnk5x2uOmzK0sS2rB9Va9BRq6z/vUqwRKt4YozGwGl501/FmRWWreQOtafqfC0+TVIy XbdueyYg4aS7ECt2/mq6tFoeD/ppwo77mnN6IbTckeL1OEJbJSGn0lFxNeRMU5xCQSOj mYO6WT/KpWeOZ+vHKLgJDRhBZ4X81E1wMi1opnWSIm7/VhRRZzqAJAe7l4OCDtBjY1f0 9R/SaDaDz8975G/aXzcms7IyxHypD9yvbnJHCH6mJMOkQcolRUmMLIOLvIVNzS9EZTLc 8xSQ== X-Gm-Message-State: AGRZ1gLw4cSAofSlvbfVmmPCkZfHSjroRct1Agqwh7AJt1oL8e6UCewF hqdgpehl8oVr3uNi901eWPkQDiiJcKGIxjGuHeYVDQ== X-Received: by 2002:aca:efd6:: with SMTP id n205-v6mr7538990oih.3.1541201822909; Fri, 02 Nov 2018 16:37:02 -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: From: Jann Horn Date: Sat, 3 Nov 2018 00:36:36 +0100 Message-ID: Subject: Re: RFC: userspace exception fixups To: Andy Lutomirski Cc: sean.j.christopherson@intel.com, 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 Sat, Nov 3, 2018 at 12:32 AM Andy Lutomirski wrote: > On Fri, Nov 2, 2018 at 4:28 PM Jann Horn wrote: > > 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. > > > I think Sean is saying that the enclave also updates RSP. Ah, bleh, of course.